test: add testcase for tags

This commit is contained in:
plumrx 2020-10-27 00:19:58 +08:00
parent 774b0a1eab
commit dd15e2f1bd
1 changed files with 16 additions and 2 deletions

View File

@ -2,10 +2,10 @@ describe('View the homepage by guest', () => {
beforeEach(() => {
cy.server()
cy.route2('GET', /articles/, { fixture: 'articles.json' }).as('getArticles')
cy.route2('GET', /tags/, { fixture: 'tags.json' })
cy.route2('GET', /tags/, { fixture: 'tags.json' }).as('getTags')
cy.visit('/')
cy.wait('@getArticles')
})
it('should can access home page', () => {
@ -20,8 +20,22 @@ describe('View the homepage by guest', () => {
})
it('should display article when page loaded', () => {
cy.wait('@getArticles')
cy.get('.article-preview:first')
.find('h1')
.should('contain.text', 'abc123')
})
it.only('it should display correct tags when page loaded',()=>{
cy.wait('@getTags')
cy.get('div.tag-list')
.find('a.tag-pill.tag-default')
.should('have.length',8)
cy.get('div.tag-list')
.find('a.tag-pill.tag-default:nth-child(3)')
.should('contain.text','HITLER')
})
})