-
Notifications
You must be signed in to change notification settings - Fork 922
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: reorganize hmr e2e tests and add retries config
- Loading branch information
Showing
6 changed files
with
140 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
if (Cypress.env('E2E_COMMAND') === 'dev') { | ||
const retries = 5 | ||
|
||
beforeEach(() => cy.task('hmr:restore')) | ||
after(() => cy.task('hmr:restore')) | ||
|
||
it('should update frontmatter correctly', { retries }, () => { | ||
cy.visit('/hmr/frontmatter.html') | ||
cy.get('.e2e-theme-content #rendered-foo + p').should( | ||
'have.text', | ||
'HMR foo', | ||
) | ||
|
||
cy.task('hmr:frontmatter').then(() => { | ||
cy.get('.e2e-theme-content #rendered-foo + p').should( | ||
'have.text', | ||
'Updated foo', | ||
) | ||
}) | ||
}) | ||
|
||
it('should update title correctly', { retries }, () => { | ||
cy.visit('/hmr/title.html') | ||
cy.title().should('include', 'HMR Title') | ||
cy.get('.e2e-theme-content #rendered-title + p').should( | ||
'have.text', | ||
'HMR Title', | ||
) | ||
|
||
cy.task('hmr:title').then(() => { | ||
cy.title().should('include', 'Updated Title') | ||
cy.get('.e2e-theme-content #rendered-title + p').should( | ||
'have.text', | ||
'Updated Title', | ||
) | ||
}) | ||
}) | ||
|
||
it( | ||
'should update title and frontmatter correctly after navigation', | ||
{ retries }, | ||
() => { | ||
cy.visit('/hmr/title.html') | ||
cy.title().should('include', 'HMR Title') | ||
cy.get('.e2e-theme-content #rendered-title + p').should( | ||
'have.text', | ||
'HMR Title', | ||
) | ||
|
||
// update title page | ||
cy.task('hmr:title') | ||
.then(() => { | ||
cy.title().should('include', 'Updated Title') | ||
cy.get('.e2e-theme-content #rendered-title + p').should( | ||
'have.text', | ||
'Updated Title', | ||
) | ||
}) | ||
// navigate to frontmatter page | ||
.then(() => { | ||
cy.get('.e2e-theme-content #link-to-frontmatter + p > a').click() | ||
cy.get('.e2e-theme-content #rendered-foo + p').should( | ||
'have.text', | ||
'HMR foo', | ||
) | ||
}) | ||
// update frontmatter page | ||
.then(() => cy.task('hmr:frontmatter')) | ||
.then(() => { | ||
cy.get('.e2e-theme-content #rendered-foo + p').should( | ||
'have.text', | ||
'Updated foo', | ||
) | ||
}) | ||
// navigate to title page | ||
.then(() => { | ||
cy.get('.e2e-theme-content #link-to-title + p > a').click() | ||
cy.get('.e2e-theme-content #rendered-title + p').should( | ||
'have.text', | ||
'Updated Title', | ||
) | ||
}) | ||
// navigate to frontmatter page | ||
.then(() => { | ||
cy.get('.e2e-theme-content #link-to-frontmatter + p > a').click() | ||
cy.get('.e2e-theme-content #rendered-foo + p').should( | ||
'have.text', | ||
'Updated foo', | ||
) | ||
}) | ||
}, | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,22 @@ | ||
it( | ||
'should render anchors and navigate correctly', | ||
// this test is randomly failing on CI, so we need to retry it | ||
{ retries: 3 }, | ||
() => { | ||
cy.visit('/markdown/anchors.html') | ||
const retries = 5 | ||
|
||
cy.get('.e2e-theme-content h1') | ||
.should('have.attr', 'id', 'title') | ||
.should('have.attr', 'tabindex', '-1') | ||
it('should render anchors and navigate correctly', { retries }, () => { | ||
cy.visit('/markdown/anchors.html') | ||
|
||
cy.get('.e2e-theme-content h1 > a') | ||
.should('have.attr', 'class', 'header-anchor') | ||
.should('have.attr', 'href', '#title') | ||
.click() | ||
cy.get('.e2e-theme-content h1') | ||
.should('have.attr', 'id', 'title') | ||
.should('have.attr', 'tabindex', '-1') | ||
|
||
cy.hash().should('eq', '#title') | ||
cy.get('.e2e-theme-content h1 > a') | ||
.should('have.attr', 'class', 'header-anchor') | ||
.should('have.attr', 'href', '#title') | ||
.click() | ||
|
||
cy.get('#anchor-1-1 > a') | ||
.should('have.attr', 'class', 'header-anchor') | ||
.click() | ||
cy.hash().should('eq', '#title') | ||
|
||
cy.hash().should('eq', '#anchor-1-1') | ||
}, | ||
) | ||
cy.get('#anchor-1-1 > a') | ||
.should('have.attr', 'class', 'header-anchor') | ||
.click() | ||
|
||
cy.hash().should('eq', '#anchor-1-1') | ||
}) |