Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(e2e-tests): Wait for route change on back/forward #37033

Merged
merged 1 commit into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ for (const { descriptor, inlineScriptType } of typesOfInlineScripts) {
cy.visit(page.navigation).waitForRouteChange()
cy.get(`a[href="${page.target}"][id=anchor-link]`).click()
cy.get(`table[id=script-mark-records] tbody`) // Make sure history has time to change
cy.go(`back`)
cy.go(`forward`)
cy.go(`back`).waitForRouteChange()
cy.go(`forward`).waitForRouteChange()

cy.get(`table[id=script-mark-records] tbody`)
.children()
Expand Down Expand Up @@ -174,8 +174,8 @@ for (const { descriptor, inlineScriptType } of typesOfInlineScripts) {
it(`should load only once if the page is revisited via browser back/forward buttons after Gatsby link navigation`, () => {
cy.visit(page.navigation).waitForRouteChange()
cy.get(`a[href="${page.target}"][id=gatsby-link]`).click()
cy.go(`back`)
cy.go(`forward`)
cy.go(`back`).waitForRouteChange()
cy.go(`forward`).waitForRouteChange()

cy.get(`table[id=script-mark-records] tbody`)
.children()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ describe(`scripts with sources`, () => {
it(`should load only once if the page is revisited via browser back/forward buttons after anchor link navigation`, () => {
cy.visit(page.navigation).waitForRouteChange()
cy.get(`a[href="${page.target}"][id=anchor-link]`).click()
cy.go(`back`)
cy.go(`forward`)
cy.go(`back`).waitForRouteChange()
cy.go(`forward`).waitForRouteChange()

cy.get(`table[id=script-resource-records] tbody`)
.children()
Expand Down Expand Up @@ -150,8 +150,8 @@ describe(`scripts with sources`, () => {
it(`should load only once if the page is revisited via browser back/forward buttons after Gatsby link navigation`, () => {
cy.visit(page.navigation).waitForRouteChange()
cy.get(`a[href="${page.target}"][id=gatsby-link]`).click()
cy.go(`back`)
cy.go(`forward`)
cy.go(`back`).waitForRouteChange()
cy.go(`forward`).waitForRouteChange()

cy.get(`table[id=script-resource-records] tbody`)
.children()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ const typesOfInlineScripts = [
},
]

Cypress.on('uncaught:exception', (err) => {
if ((err.message.includes('Minified React error #418') || err.message.includes('Minified React error #423') || err.message.includes('Minified React error #425')) && Cypress.env(`TEST_PLUGIN_OFFLINE`)) {
Cypress.on(`uncaught:exception`, err => {
if (
(err.message.includes(`Minified React error #418`) ||
err.message.includes(`Minified React error #423`) ||
err.message.includes(`Minified React error #425`)) &&
Cypress.env(`TEST_PLUGIN_OFFLINE`)
) {
return false
}
})
Expand Down Expand Up @@ -141,8 +146,8 @@ for (const { descriptor, inlineScriptType } of typesOfInlineScripts) {
cy.visit(page.navigation).waitForRouteChange()
cy.get(`a[href="${page.target}"][id=anchor-link]`).click()
cy.get(`table[id=script-mark-records] tbody`) // Make sure history has time to change
cy.go(`back`)
cy.go(`forward`)
cy.go(`back`).waitForRouteChange()
cy.go(`forward`).waitForRouteChange()

cy.get(`table[id=script-mark-records] tbody`)
.children()
Expand Down Expand Up @@ -180,8 +185,8 @@ for (const { descriptor, inlineScriptType } of typesOfInlineScripts) {
it(`should load only once if the page is revisited via browser back/forward buttons after Gatsby link navigation`, () => {
cy.visit(page.navigation).waitForRouteChange()
cy.get(`a[href="${page.target}"][id=gatsby-link]`).click()
cy.go(`back`)
cy.go(`forward`)
cy.go(`back`).waitForRouteChange()
cy.go(`forward`).waitForRouteChange()

cy.get(`table[id=script-mark-records] tbody`)
.children()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ const page = {
navigation: `/gatsby-script-navigation/`,
}

Cypress.on('uncaught:exception', (err) => {
if ((err.message.includes('Minified React error #418') || err.message.includes('Minified React error #423') || err.message.includes('Minified React error #425')) && Cypress.env(`TEST_PLUGIN_OFFLINE`)) {
Cypress.on(`uncaught:exception`, err => {
if (
(err.message.includes(`Minified React error #418`) ||
err.message.includes(`Minified React error #423`) ||
err.message.includes(`Minified React error #425`)) &&
Cypress.env(`TEST_PLUGIN_OFFLINE`)
) {
return false
}
})
Expand Down Expand Up @@ -131,8 +136,8 @@ describe(`scripts with sources`, () => {
it(`should load only once if the page is revisited via browser back/forward buttons after anchor link navigation`, () => {
cy.visit(page.navigation).waitForRouteChange()
cy.get(`a[href="${page.target}"][id=anchor-link]`).click()
cy.go(`back`)
cy.go(`forward`)
cy.go(`back`).waitForRouteChange()
cy.go(`forward`).waitForRouteChange()

cy.get(`table[id=script-resource-records] tbody`)
.children()
Expand Down Expand Up @@ -162,8 +167,8 @@ describe(`scripts with sources`, () => {
it(`should load only once if the page is revisited via browser back/forward buttons after Gatsby link navigation`, () => {
cy.visit(page.navigation).waitForRouteChange()
cy.get(`a[href="${page.target}"][id=gatsby-link]`).click()
cy.go(`back`)
cy.go(`forward`)
cy.go(`back`).waitForRouteChange()
cy.go(`forward`).waitForRouteChange()

cy.get(`table[id=script-resource-records] tbody`)
.children()
Expand Down