diff --git a/packages/cypress/cypress/integration/library/save-link.js b/packages/cypress/cypress/integration/library/save-link.js new file mode 100644 index 000000000..fa5aaa42a --- /dev/null +++ b/packages/cypress/cypress/integration/library/save-link.js @@ -0,0 +1,51 @@ +describe('save link', () => { + const title = 'Omnivore - Cypress Webpage Test' + const desc = 'OMNIvore' + + const TEST_LINK = 'https://blog.omnivore.app/p/getting-started-with-omnivore' + + const WEBPAGE_URL = 'https://sites.google.com/gitstart.dev/webpage/home' + + beforeEach(() => { + const email = 'tester@omnivore.app' + const password = 'testpassword' + + cy.login(email, password) + cy.visit('/home') + + //if for whatever reason, there are no already existing links, + //trying to get all links fails and throws an error + //so by adding a dummy link first, we circumvent this error + cy.addItem(TEST_LINK) + + //it takes quite a while for the added link to show up after adding. + cy.wait(5000) + + //by adding a link above, the query below cannot fail + // find and delete any already existing link. + cy.findAllByTestId('linkedItemCard').each(() => { + cy.get('body').type('j') + cy.get('body').type('r') + }) + }) + + it('should save a web page', () => { + //add the link + cy.addItem(WEBPAGE_URL) + + //wait for the link to be on the page + cy.wait(5000) + + //confirm that the title and description on the card is correct + cy.findAllByTestId('linkedItemCard').first().within(() => { + cy.findByTestId('listTitle').contains(title) + cy.findByTestId('listDesc').contains(desc) + }) + + //confirm that the title and description on the article page is correct + cy.findAllByTestId('linkedItemCard').first().click() + cy.wait(5000) + cy.findByTestId('article-headline').contains(title) + cy.findByTestId('article-inner').contains(desc) + }) +}) diff --git a/packages/cypress/cypress/support/commands.js b/packages/cypress/cypress/support/commands.js index 3e0d1e5e4..75636f3a8 100644 --- a/packages/cypress/cypress/support/commands.js +++ b/packages/cypress/cypress/support/commands.js @@ -13,4 +13,29 @@ Cypress.Commands.add('login', (email, password) => { cy.getCookie('auth').should('exist') cy.location('pathname').should('include', '/home') }) -}) \ No newline at end of file +}) + +Cypress.Commands.add('registerEmail', (email, username, password, fullName) => { + cy.visit('/email-registration') + + cy.get('input[name=email]').type(email) + cy.get('input[name=username]').type(username) + cy.get('input[name=password]').type(password) + cy.get('input[name=name]').type(fullName) + + cy.get('form').submit() + + // we should be redirected to /dashboard + cy.location('pathname').should('include', '/email-login') +}) + +Cypress.Commands.add('addItem', (link) => { + cy.get('body').type('a') + + cy.focused().type(`${link}{enter}`) + + // wait for the link to be added + cy.wait(2000) + + cy.reload() +}) diff --git a/packages/web/components/patterns/LibraryCards/GridLinkedItemCard.tsx b/packages/web/components/patterns/LibraryCards/GridLinkedItemCard.tsx index f01e7260c..c9278b0a7 100644 --- a/packages/web/components/patterns/LibraryCards/GridLinkedItemCard.tsx +++ b/packages/web/components/patterns/LibraryCards/GridLinkedItemCard.tsx @@ -138,6 +138,7 @@ export function GridLinkedItemCard(props: LinkedItemCardProps): JSX.Element { WebkitLineClamp: 5, WebkitBoxOrient: 'vertical', }} + data-testid="listDesc" > {props.item.description} @@ -171,6 +172,7 @@ function CardTitle(props: CardTitleProps): JSX.Element { return ( {props.item.title} diff --git a/packages/web/components/templates/article/Article.tsx b/packages/web/components/templates/article/Article.tsx index 9c6382857..b896d69e6 100644 --- a/packages/web/components/templates/article/Article.tsx +++ b/packages/web/components/templates/article/Article.tsx @@ -237,6 +237,7 @@ export function Article(props: ArticleProps): JSX.Element { maxWidth: '100%', }} className="article-inner-css" + data-testid="article-inner" dangerouslySetInnerHTML={{ __html: props.content, }} diff --git a/packages/web/components/templates/article/ArticleContainer.tsx b/packages/web/components/templates/article/ArticleContainer.tsx index 1ef48a9f7..0a537c36a 100644 --- a/packages/web/components/templates/article/ArticleContainer.tsx +++ b/packages/web/components/templates/article/ArticleContainer.tsx @@ -129,6 +129,7 @@ export function ArticleContainer(props: ArticleContainerProps): JSX.Element { {props.article.title} diff --git a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx index 916f02d05..ddd8e6bc2 100644 --- a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx +++ b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx @@ -385,6 +385,9 @@ export function HomeFeedContainer(props: HomeFeedContainerProps): JSX.Element { case 'archiveItem': handleCardAction('archive', activeItem) break + case 'removeItem': + handleCardAction('delete', activeItem) + break case 'markItemAsRead': handleCardAction('mark-read', activeItem) break @@ -687,6 +690,7 @@ function HomeFeedGrid(props: HomeFeedContentProps): JSX.Element { {props.items.map((linkedItem) => ( actionHandler('archiveItem'), }, + { + shortcutKeys: ['r'], + actionDescription: 'Remove item', + shortcutKeyDescription: 'r', + callback: () => actionHandler('removeItem'), + }, { shortcutKeys: ['l'], actionDescription: 'Edit item labels',