Skip to content

Commit d3d5654

Browse files
authored
chore(e2e-tests): Wait for route change on back/forward (gatsbyjs#37033)
1 parent 19e6c63 commit d3d5654

4 files changed

Lines changed: 30 additions & 20 deletions

File tree

‎e2e-tests/development-runtime/cypress/integration/gatsby-script/gatsby-script-inline-scripts.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ for (const { descriptor, inlineScriptType } of typesOfInlineScripts) {
135135
cy.visit(page.navigation).waitForRouteChange()
136136
cy.get(`a[href="${page.target}"][id=anchor-link]`).click()
137137
cy.get(`table[id=script-mark-records] tbody`) // Make sure history has time to change
138-
cy.go(`back`)
139-
cy.go(`forward`)
138+
cy.go(`back`).waitForRouteChange()
139+
cy.go(`forward`).waitForRouteChange()
140140

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

180180
cy.get(`table[id=script-mark-records] tbody`)
181181
.children()

‎e2e-tests/development-runtime/cypress/integration/gatsby-script/gatsby-script-scripts-with-sources.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ describe(`scripts with sources`, () => {
119119
it(`should load only once if the page is revisited via browser back/forward buttons after anchor link navigation`, () => {
120120
cy.visit(page.navigation).waitForRouteChange()
121121
cy.get(`a[href="${page.target}"][id=anchor-link]`).click()
122-
cy.go(`back`)
123-
cy.go(`forward`)
122+
cy.go(`back`).waitForRouteChange()
123+
cy.go(`forward`).waitForRouteChange()
124124

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

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

‎e2e-tests/production-runtime/cypress/integration/gatsby-script-inline-scripts.js‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ const typesOfInlineScripts = [
1717
},
1818
]
1919

20-
Cypress.on('uncaught:exception', (err) => {
21-
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`)) {
20+
Cypress.on(`uncaught:exception`, err => {
21+
if (
22+
(err.message.includes(`Minified React error #418`) ||
23+
err.message.includes(`Minified React error #423`) ||
24+
err.message.includes(`Minified React error #425`)) &&
25+
Cypress.env(`TEST_PLUGIN_OFFLINE`)
26+
) {
2227
return false
2328
}
2429
})
@@ -141,8 +146,8 @@ for (const { descriptor, inlineScriptType } of typesOfInlineScripts) {
141146
cy.visit(page.navigation).waitForRouteChange()
142147
cy.get(`a[href="${page.target}"][id=anchor-link]`).click()
143148
cy.get(`table[id=script-mark-records] tbody`) // Make sure history has time to change
144-
cy.go(`back`)
145-
cy.go(`forward`)
149+
cy.go(`back`).waitForRouteChange()
150+
cy.go(`forward`).waitForRouteChange()
146151

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

186191
cy.get(`table[id=script-mark-records] tbody`)
187192
.children()

‎e2e-tests/production-runtime/cypress/integration/gatsby-script-scripts-with-sources.js‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@ const page = {
88
navigation: `/gatsby-script-navigation/`,
99
}
1010

11-
Cypress.on('uncaught:exception', (err) => {
12-
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`)) {
11+
Cypress.on(`uncaught:exception`, err => {
12+
if (
13+
(err.message.includes(`Minified React error #418`) ||
14+
err.message.includes(`Minified React error #423`) ||
15+
err.message.includes(`Minified React error #425`)) &&
16+
Cypress.env(`TEST_PLUGIN_OFFLINE`)
17+
) {
1318
return false
1419
}
1520
})
@@ -131,8 +136,8 @@ describe(`scripts with sources`, () => {
131136
it(`should load only once if the page is revisited via browser back/forward buttons after anchor link navigation`, () => {
132137
cy.visit(page.navigation).waitForRouteChange()
133138
cy.get(`a[href="${page.target}"][id=anchor-link]`).click()
134-
cy.go(`back`)
135-
cy.go(`forward`)
139+
cy.go(`back`).waitForRouteChange()
140+
cy.go(`forward`).waitForRouteChange()
136141

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

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

0 commit comments

Comments
 (0)