Skip to content

Commit

Permalink
test: update cypress location properties assertion usage
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorlxy committed Jan 2, 2024
1 parent 28f1dce commit 70d0c58
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
1 change: 0 additions & 1 deletion e2e/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { defineConfig } from 'cypress'

export default defineConfig({
defaultCommandTimeout: 10000,
e2e: {
baseUrl: 'http://localhost:9080',
specPattern: 'tests/**/*.cy.ts',
Expand Down
8 changes: 2 additions & 6 deletions e2e/tests/markdown/anchors.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ it('should render anchors and navigate correctly', () => {
.should('have.attr', 'href', '#title')
.click()

cy.location().should((location) => {
expect(location.hash).to.eq('#title')
})
cy.hash().should('eq', '#title')

cy.get('#anchor-1-1 > a')
.should('have.attr', 'class', 'header-anchor')
.click()

cy.location().should((location) => {
expect(location.hash).to.eq('#anchor-1-1')
})
cy.hash().should('eq', '#anchor-1-1')
})
12 changes: 3 additions & 9 deletions e2e/tests/markdown/links.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,21 @@ it('should render links and navigate between pages correctly', () => {
.should('have.text', 'bar')
.click()

cy.location().should((location) => {
expect(location.pathname).to.eq(`${E2E_BASE}markdown/links/bar.html`)
})
cy.location('pathname').should('eq', `${E2E_BASE}markdown/links/bar.html`)

cy.get('.e2e-theme-content ul li a')
.should('have.length', 2)
.last()
.should('have.text', 'baz')
.click()

cy.location().should((location) => {
expect(location.pathname).to.eq(`${E2E_BASE}markdown/links/baz.html`)
})
cy.location('pathname').should('eq', `${E2E_BASE}markdown/links/baz.html`)

cy.get('.e2e-theme-content ul li a')
.should('have.length', 2)
.first()
.should('have.text', 'foo')
.click()

cy.location().should((location) => {
expect(location.pathname).to.eq(`${E2E_BASE}markdown/links/foo.html`)
})
cy.location('pathname').should('eq', `${E2E_BASE}markdown/links/foo.html`)
})

0 comments on commit 70d0c58

Please sign in to comment.