Skip to content

Commit

Permalink
test(e2e): fix homepage test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Jan 26, 2024
1 parent 812afb8 commit d29c799
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
35 changes: 14 additions & 21 deletions e2e/tests/theme-default/home.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,23 @@ describe('homepage', () => {
const heroImage = 'https://v2.vuepress.vuejs.org/images/hero.png'

cy.visit('/')
cy.get('.hero').then((el) => {
cy.wrap(el)
.get('img')
.should('have.attr', 'src', heroImage)
.should('have.attr', 'alt', title)

cy.wrap(el).get('#main-title').should('have.text', title)
cy.get('.hero img')
.should('have.attr', 'src', heroImage)
.should('have.attr', 'alt', title)

cy.wrap(el).get('.description').should('have.text', description)
cy.get('#main-title').should('have.text', title)

cy.wrap(el)
.get('.actions')
.then((el) => {
cy.wrap(el)
.get('.action-button')
.should('have.length', 2)
.each((el, index) => {
cy.wrap(el)
.should('have.attr', 'href', `${BASE}action${index + 1}.html`)
.should('have.attr', 'aria-label', `Action${index + 1}`)
.contains(`Action${index + 1}`)
})
})
})
cy.get('.hero .description').should('have.text', description)

cy.get('.actions .action-button')
.should('have.length', 2)
.each((el, index) => {
cy.wrap(el)
.should('have.attr', 'href', `${BASE}action${index + 1}.html`)
.should('have.attr', 'aria-label', `Action${index + 1}`)
.contains(`Action${index + 1}`)
})

cy.get('.features .feature').then((el) => {
cy.wrap(el)
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"release:check": "pnpm lint && pnpm clean && pnpm build && pnpm test",
"release:publish": "lerna publish",
"test": "vitest run",
"test:cov": "vitest run --coverage"
"test:cov": "vitest run --coverage",
"test:e2e": "pnpm --dir e2e e2e:ci:build"
},
"lint-staged": {
"**/*": "prettier --write --ignore-unknown",
Expand Down

0 comments on commit d29c799

Please sign in to comment.