diff --git a/cypress/integration/home.spec.js b/cypress/integration/home.spec.js index 6926483..ba85b2e 100644 --- a/cypress/integration/home.spec.js +++ b/cypress/integration/home.spec.js @@ -30,4 +30,27 @@ describe('Home page', () => { cy.get(home.sidebarTags).should('be.visible') .and('have.length', 20) }) + + it('can see popular tags', () => { + const apiUrl = Cypress.env('apiUrl') + + // delay tag request so we can test "loading tags..." text + cy.intercept(`${apiUrl}/tags`, (req) => { + req.continue((res) => { + res.send({ + delay: 2000 + }) + }) + }).as('tagRequest') + + cy.visit('') + cy.get(home.sidebar).should('be.visible') + .and('contain', 'Popular Tags') + cy.get(home.loadingTagsText).should('be.visible') + .and('contain', 'Loading tags...') + cy.get(home.sidebarTags).should('not.exist') + cy.get(home.loadingTagsText).should('not.be.visible') + cy.get(home.sidebarTags).should('be.visible') + .and('have.length', 20) + }) }) diff --git a/cypress/selectors/home.sel.js b/cypress/selectors/home.sel.js index c8bb76d..0363620 100644 --- a/cypress/selectors/home.sel.js +++ b/cypress/selectors/home.sel.js @@ -4,6 +4,7 @@ module.exports = { articles: 'article-list [ng-repeat*="ctrl.list"] .article-preview', sidebar: '.sidebar', sidebarTags: '.sidebar .tag-default', + loadingTagsText: '.tag-list + div', firstFavoriteButton: 'article-list > article-preview:nth-child(1) button', readMoreLink: 'article-list > article-preview:nth-child(1) .preview-link' }