Skip to content

Commit 071db97

Browse files
authored
Merge branch 'feature-multidomain' into md-todos-fixmes
2 parents 5efae15 + a7caf8a commit 071db97

File tree

2 files changed

+37
-34
lines changed

2 files changed

+37
-34
lines changed

packages/driver/cypress/integration/e2e/multi-domain/navigation_spec.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ describe('event timing', () => {
209209
cy.log('inside cy.origin foobar')
210210
})
211211

212-
// This command is run from localhost against the cross origin aut. Updating href is one of the few allowed commands. See https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#location
212+
// This command is run from localhost against the cross-origin aut. Updating href is one of the few allowed commands. See https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#location
213213
cy.window().then((win) => {
214214
win.location.href = 'http://www.idp.com:3500/fixtures/multi-domain.html'
215215
})
@@ -265,11 +265,10 @@ describe('errors', () => {
265265
cy.on('fail', (err) => {
266266
expect(err.message).to.include(`Timed out after waiting \`5000ms\` for your remote page to load on origin(s):`)
267267
expect(err.message).to.include(`\n- \`http://localhost:3500\`\n`)
268-
expect(err.message).to.include(`Your page did not fire its \`load\` event within \`5000ms\`.`)
269-
expect(err.message).to.include(`A cross origin request for \`http://www.foobar.com:3500/fixtures/auth/idp.html?redirect=http%3A%2F%2Flocalhost%3A3500%2Ffixtures%2Fauth%2Findex.html\` was detected.`)
270-
expect(err.message).to.include(`A command that triggers cross origin navigation must be immediately followed by a \`cy.origin()\` command:`)
268+
expect(err.message).to.include(`A cross-origin request for \`http://www.foobar.com:3500/fixtures/auth/idp.html?redirect=http%3A%2F%2Flocalhost%3A3500%2Ffixtures%2Fauth%2Findex.html\` was detected.`)
269+
expect(err.message).to.include(`A command that triggers cross-origin navigation must be immediately followed by a \`cy.origin()\` command:`)
271270
expect(err.message).to.include(`\`\ncy.origin(\'http://foobar.com:3500\', () => {\n <commands targeting http://www.foobar.com:3500 go here>\n})\n\``)
272-
expect(err.message).to.include(`If the cross origin request was an intermediary state, you can try increasing the \`pageLoadTimeout\` value in \`cypress.json\` to wait longer`)
271+
expect(err.message).to.include(`If the cross-origin request was an intermediary state, you can try increasing the \`pageLoadTimeout\` value in \`cypress.json\` to wait longer`)
273272

274273
expect(err.message).not.to.include(`The following error originated from your test code, not from Cypress`)
275274
expect(err.message).not.to.include(`The following error originated from your application code, not from Cypress`)
@@ -281,10 +280,11 @@ describe('errors', () => {
281280
cy.get('[data-cy="login-foobar"]')
282281
})
283282

284-
it('never redirects to the cross origin', { defaultCommandTimeout: 50 }, (done) => {
283+
it('never redirects to the cross-origin', { defaultCommandTimeout: 50 }, (done) => {
285284
cy.on('fail', (err) => {
286285
expect(err.message).to.include(`Timed out retrying after 50ms: Expected to find element: \`[data-cy="username"]\`, but never found it`)
287-
expect(err.message).to.include(`The command was expected to run against origin: \`http://idp.com:3500\` but the application is at origin: \`http://localhost:3500\`.`)
286+
expect(err.message).to.include(`The command was expected to run against origin \`http://idp.com:3500\` but the application is at origin \`http://localhost:3500\`.`)
287+
expect(err.message).to.include(`This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.`)
288288
// make sure that the secondary origin failures do NOT show up as spec failures or AUT failures
289289
expect(err.message).not.to.include(`The following error originated from your test code, not from Cypress`)
290290
expect(err.message).not.to.include(`The following error originated from your application code, not from Cypress`)
@@ -303,11 +303,11 @@ describe('errors', () => {
303303
.should('equal', 'Welcome BJohnson')
304304
})
305305

306-
it('redirects to the wrong cross origin', { pageLoadTimeout: 5000 }, (done) => {
306+
it('redirects to the wrong cross-origin', { pageLoadTimeout: 5000 }, (done) => {
307307
cy.on('fail', (err) => {
308308
expect(err.message).to.include(`Timed out after waiting \`5000ms\` for your remote page to load on origin(s):`)
309309
expect(err.message).to.include(`\n- \`http://idp.com:3500\`\n`)
310-
expect(err.message).to.include(`A cross origin request for \`http://www.foobar.com:3500/fixtures/auth/idp.html?redirect=http%3A%2F%2Flocalhost%3A3500%2Ffixtures%2Fauth%2Findex.html\` was detected.`)
310+
expect(err.message).to.include(`A cross-origin request for \`http://www.foobar.com:3500/fixtures/auth/idp.html?redirect=http%3A%2F%2Flocalhost%3A3500%2Ffixtures%2Fauth%2Findex.html\` was detected.`)
311311
expect(err.message).to.include(`\`\ncy.origin(\'http://foobar.com:3500\', () => {\n <commands targeting http://www.foobar.com:3500 go here>\n})\n\``)
312312

313313
expect(err.message).not.to.include(`The following error originated from your test code, not from Cypress`)
@@ -331,7 +331,7 @@ describe('errors', () => {
331331
it('never returns to the primary origin', { defaultCommandTimeout: 50 }, (done) => {
332332
cy.on('fail', (err) => {
333333
expect(err.message).to.include(`Timed out retrying after 50ms: Expected to find element: \`[data-cy="welcome"]\`, but never found it`)
334-
expect(err.message).to.include(`The command was expected to run against origin: \`http://localhost:3500\` but the application is at origin: \`http://idp.com:3500\`.`)
334+
expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://idp.com:3500\`.`)
335335
// make sure that the secondary origin failures do NOT show up as spec failures or AUT failures
336336
expect(err.message).not.to.include(`The following error originated from your test code, not from Cypress`)
337337
expect(err.message).not.to.include(`The following error originated from your application code, not from Cypress`)
@@ -350,11 +350,11 @@ describe('errors', () => {
350350
.should('equal', 'Welcome BJohnson')
351351
})
352352

353-
it('redirects to an unexpected cross origin', { pageLoadTimeout: 5000 }, (done) => {
353+
it('redirects to an unexpected cross-origin', { pageLoadTimeout: 5000 }, (done) => {
354354
cy.on('fail', (err) => {
355355
expect(err.message).to.include(`Timed out after waiting \`5000ms\` for your remote page to load on origin(s):`)
356356
expect(err.message).to.include(`\n- \`http://localhost:3500\`\n`)
357-
expect(err.message).to.include(`A cross origin request for \`http://www.foobar.com:3500/fixtures/auth/index.html\` was detected.`)
357+
expect(err.message).to.include(`A cross-origin request for \`http://www.foobar.com:3500/fixtures/auth/index.html\` was detected.`)
358358
expect(err.message).to.include(`\`\ncy.origin(\'http://foobar.com:3500\', () => {\n <commands targeting http://www.foobar.com:3500 go here>\n})\n\``)
359359

360360
expect(err.message).not.to.include(`The following error originated from your test code, not from Cypress`)
@@ -377,11 +377,11 @@ describe('errors', () => {
377377
.should('equal', 'Welcome BJohnson')
378378
})
379379

380-
it('redirects to an unexpected cross origin and calls another command in the cy.origin command', { pageLoadTimeout: 5000 }, (done) => {
380+
it('redirects to an unexpected cross-origin and calls another command in the cy.origin command', { pageLoadTimeout: 5000 }, (done) => {
381381
cy.on('fail', (err) => {
382382
expect(err.message).to.include(`Timed out after waiting \`5000ms\` for your remote page to load on origin(s):`)
383383
expect(err.message).to.include(`\n- \`http://idp.com:3500\`\n`)
384-
expect(err.message).to.include(`A cross origin request for \`http://www.foobar.com:3500/fixtures/auth/index.html\` was detected.`)
384+
expect(err.message).to.include(`A cross-origin request for \`http://www.foobar.com:3500/fixtures/auth/index.html\` was detected.`)
385385
expect(err.message).to.include(`\`\ncy.origin(\'http://foobar.com:3500\', () => {\n <commands targeting http://www.foobar.com:3500 go here>\n})\n\``)
386386

387387
expect(err.message).not.to.include(`The following error originated from your test code, not from Cypress`)
@@ -409,7 +409,7 @@ describe('errors', () => {
409409
it('fails in cy.origin when a command is run after we return to localhost', { defaultCommandTimeout: 50 }, (done) => {
410410
cy.on('fail', (err) => {
411411
expect(err.message).to.include(`Timed out retrying after 50ms: Expected to find element: \`[data-cy="cannot_find"]\`, but never found it`)
412-
expect(err.message).to.include(`The command was expected to run against origin: \`http://idp.com:3500\` but the application is at origin: \`http://localhost:3500\`.`)
412+
expect(err.message).to.include(`The command was expected to run against origin \`http://idp.com:3500\` but the application is at origin \`http://localhost:3500\`.`)
413413
// make sure that the secondary origin failures do NOT show up as spec failures or AUT failures
414414
expect(err.message).not.to.include(`The following error originated from your test code, not from Cypress`)
415415
expect(err.message).not.to.include(`The following error originated from your application code, not from Cypress`)
@@ -454,7 +454,7 @@ describe('errors', () => {
454454
cy.on('fail', (err) => {
455455
expect(err.message).to.include(`Timed out after waiting \`5000ms\` for your remote page to load on origin(s):`)
456456
expect(err.message).to.include(`\n- \`http://localhost:3500\`\n`)
457-
expect(err.message).to.include(`A cross origin request for \`http://www.foobar.com:3500/fixtures/auth/index.html\` was detected.`)
457+
expect(err.message).to.include(`A cross-origin request for \`http://www.foobar.com:3500/fixtures/auth/index.html\` was detected.`)
458458
expect(err.message).to.include(`\`\ncy.origin(\'http://foobar.com:3500\', () => {\n <commands targeting http://www.foobar.com:3500 go here>\n})\n\``)
459459

460460
expect(err.message).not.to.include(`The following error originated from your test code, not from Cypress`)
@@ -503,7 +503,7 @@ describe('errors', () => {
503503
cy.on('fail', (err) => {
504504
expect(err.message).to.include(`Timed out after waiting \`5000ms\` for your remote page to load on origin(s):`)
505505
expect(err.message).to.include(`\n- \`http://localhost:3500\`\n`)
506-
expect(err.message).to.include(`A cross origin request for \`http://www.foobar.com:3500/fixtures/auth/index.html\` was detected.`)
506+
expect(err.message).to.include(`A cross-origin request for \`http://www.foobar.com:3500/fixtures/auth/index.html\` was detected.`)
507507
expect(err.message).to.include(`\`\ncy.origin(\'http://foobar.com:3500\', () => {\n <commands targeting http://www.foobar.com:3500 go here>\n})\n\``)
508508

509509
expect(err.message).not.to.include(`The following error originated from your test code, not from Cypress`)

packages/driver/src/cypress/error_messages.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,10 @@ export default {
895895
return `Timed out retrying after ${ms}ms: `
896896
},
897897
cross_origin_command ({ commandOrigin, autOrigin }) {
898-
return `The command was expected to run against origin: \`${commandOrigin }\` but the application is at origin: \`${autOrigin}\`.`
898+
return stripIndent`\
899+
The command was expected to run against origin \`${commandOrigin }\` but the application is at origin \`${autOrigin}\`.
900+
901+
This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.`
899902
},
900903
},
901904

@@ -989,29 +992,29 @@ export default {
989992
If so, increase \`redirectionLimit\` value in configuration.`
990993
},
991994
cross_origin_load_timed_out ({ ms, configFile, crossOriginUrl, originPolicies }) {
992-
return stripIndent`\
993-
994-
Timed out after waiting \`${ms}ms\` for your remote page to load on origin(s):
995-
996-
- ${originPolicies.map((originPolicy) => `\`${originPolicy}\``).join('\n -')}
995+
return {
996+
message: stripIndent`\
997+
Timed out after waiting \`${ms}ms\` for your remote page to load on origin(s):
997998
998-
Your page did not fire its \`load\` event within \`${ms}ms\`.
999+
- ${originPolicies.map((originPolicy) => `\`${originPolicy}\``).join('\n -')}
9991000
1000-
A cross origin request for \`${crossOriginUrl.href}\` was detected.
1001+
A cross-origin request for \`${crossOriginUrl.href}\` was detected.
10011002
1002-
A command that triggers cross origin navigation must be immediately followed by a ${cmd('origin')} command:
1003+
A command that triggers cross-origin navigation must be immediately followed by a ${cmd('origin')} command:
10031004
1004-
\`\`\`
1005-
cy.origin('${crossOriginUrl.originPolicy}', () => {
1006-
<commands targeting ${crossOriginUrl.origin} go here>
1007-
})
1008-
\`\`\`
1005+
\`\`\`
1006+
cy.origin('${crossOriginUrl.originPolicy}', () => {
1007+
<commands targeting ${crossOriginUrl.origin} go here>
1008+
})
1009+
\`\`\`
10091010
1010-
If the cross origin request was an intermediary state, you can try increasing the \`pageLoadTimeout\` value in ${formatConfigFile(configFile)} to wait longer.
1011+
If the cross-origin request was an intermediary state, you can try increasing the \`pageLoadTimeout\` value in ${formatConfigFile(configFile)} to wait longer.
10111012
1012-
Browsers will not fire the \`load\` event until all stylesheets and scripts are done downloading.
1013+
Browsers will not fire the \`load\` event until all stylesheets and scripts are done downloading.
10131014
1014-
When this \`load\` event occurs, Cypress will continue running commands.`
1015+
When this \`load\` event occurs, Cypress will continue running commands.`,
1016+
docsUrl: 'https://on.cypress.io/origin',
1017+
}
10151018
},
10161019
},
10171020

0 commit comments

Comments
 (0)