Skip to content

Commit 722299e

Browse files
mjhenkesAtofStrykerchrisbreiding
authored andcommitted
chore: [Multi-domain] Improve timeout error message. (#20671)
* Better timeout error handling * quick fix, should re-visit * cancel dangling timeouts * re-broadcast the window load event. * clean up code and comment more * ignore better * PR updates * oops, didn't mean to enable this * Apply suggestions from code review Co-authored-by: Bill Glesias <bglesias@gmail.com> * moar pr updates * Apply suggestions from code review Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com> Co-authored-by: Bill Glesias <bglesias@gmail.com> * Fix test * message changes * message update Co-authored-by: Bill Glesias <bglesias@gmail.com> Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
1 parent 087fcb2 commit 722299e

File tree

10 files changed

+352
-210
lines changed

10 files changed

+352
-210
lines changed

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

Lines changed: 0 additions & 198 deletions
Original file line numberDiff line numberDiff line change
@@ -265,201 +265,3 @@ describe('Multi-step Auth', { experimentalSessionSupport: true }, () => {
265265
.should('equal', 'Welcome MarkyMark')
266266
})
267267
})
268-
269-
describe('errors', { experimentalSessionSupport: true }, () => {
270-
it('reset top', () => {
271-
cy.visit('http://www.foobar.com:3500/fixtures/auth/index.html')
272-
})
273-
274-
// This test will fail primary domain not established
275-
it('logs in with no primary - fail', { baseUrl: undefined, pageLoadTimeout: 5000 }, (done) => {
276-
cy.on('fail', (err) => {
277-
expect(err.message).to.include(`Timed out after waiting \`5000ms\` for your remote page to load.`)
278-
done()
279-
})
280-
281-
cy.switchToDomain('http://idp.com:3500', () => { // Implicitly primary domain is foobar since the previous test set it to foobar. This command times out because we return to localhost, not foobar.
282-
cy.visit('http://www.idp.com:3500/fixtures/auth/idp.html')
283-
cy.get('[data-cy="username"]').type('FJohnson')
284-
cy.get('[data-cy="login"]').click() // Redirects to localhost
285-
})
286-
287-
cy.get('[data-cy="welcome"]') // Timeout on command, cannot find element (sorry, your element is in another domain)
288-
.invoke('text')
289-
.should('equal', 'Welcome FJohnson')
290-
})
291-
292-
it('never redirects to the subdomain', { defaultCommandTimeout: 50 }, (done) => {
293-
cy.on('fail', (err) => {
294-
expect(err.message).to.include(`Timed out retrying after 50ms: Expected to find element: \`[data-cy="username"]\`, but never found it`)
295-
// make sure that the secondary domain failures do NOT show up as spec failures or AUT failures
296-
expect(err.message).not.to.include(`The following error originated from your test code, not from Cypress`)
297-
expect(err.message).not.to.include(`The following error originated from your application code, not from Cypress`)
298-
done()
299-
})
300-
301-
cy.visit('/fixtures/auth/index.html')
302-
cy.get('[data-cy="login-idp"]')
303-
cy.switchToDomain('http://idp.com:3500', () => {
304-
cy.get('[data-cy="username"]').type('BJohnson') // Timeout here on command, cannot find element
305-
cy.get('[data-cy="login"]').click()
306-
})
307-
308-
cy.get('[data-cy="welcome"]')
309-
.invoke('text')
310-
.should('equal', 'Welcome BJohnson')
311-
})
312-
313-
it('redirects to the wrong subdomain', { pageLoadTimeout: 5000 }, (done) => {
314-
cy.on('fail', (err) => {
315-
expect(err.message).to.include(`Timed out after waiting \`5000ms\` for your remote page to load.`)
316-
done()
317-
})
318-
319-
cy.visit('/fixtures/auth/index.html')
320-
cy.get('[data-cy="login-foobar"]').click() // Timeout on page load here, we never reach the expected domain
321-
cy.switchToDomain('http://idp.com:3500', () => {
322-
cy.get('[data-cy="username"]').type('BJohnson')
323-
cy.get('[data-cy="login"]').click()
324-
})
325-
326-
// Verify that the user has logged in on localhost
327-
cy.get('[data-cy="welcome"]')
328-
.invoke('text')
329-
.should('equal', 'Welcome BJohnson')
330-
})
331-
332-
it('never returns to the primary domain', { defaultCommandTimeout: 50 }, (done) => {
333-
cy.on('fail', (err) => {
334-
expect(err.message).to.include(`Timed out retrying after 50ms: Expected to find element: \`[data-cy="welcome"]\`, but never found it`)
335-
// make sure that the secondary domain failures do NOT show up as spec failures or AUT failures
336-
expect(err.message).not.to.include(`The following error originated from your test code, not from Cypress`)
337-
expect(err.message).not.to.include(`The following error originated from your application code, not from Cypress`)
338-
done()
339-
})
340-
341-
cy.visit('/fixtures/auth/index.html')
342-
cy.get('[data-cy="login-idp"]').click()
343-
cy.switchToDomain('http://idp.com:3500', () => {
344-
cy.get('[data-cy="username"]').type('BJohnson')
345-
}) // switchToDomain is stable so the command exits
346-
347-
// Verify that the user has logged in on localhost
348-
cy.get('[data-cy="welcome"]') // Timeout here on command, cannot find element
349-
.invoke('text')
350-
.should('equal', 'Welcome BJohnson')
351-
})
352-
353-
it('redirects to an unexpected subdomain', { pageLoadTimeout: 5000 }, (done) => {
354-
cy.on('fail', (err) => {
355-
expect(err.message).to.include(`Timed out after waiting \`5000ms\` for your remote page to load.`)
356-
done()
357-
})
358-
359-
cy.visit('/fixtures/auth/index.html')
360-
cy.get('[data-cy="login-idp"]').click()
361-
cy.switchToDomain('http://idp.com:3500', () => {
362-
cy.get('[data-cy="username"]').type('BJohnson')
363-
cy.window().then((win) => {
364-
win.location.href = 'http://www.foobar.com:3500/fixtures/auth/index.html'
365-
})
366-
})
367-
368-
// Verify that the user has logged in on localhost
369-
cy.get('[data-cy="welcome"]') // Timeout here on command, cannot find element
370-
.invoke('text')
371-
.should('equal', 'Welcome BJohnson')
372-
})
373-
374-
// TODO: run in firefox too after we fix error serialization for firefox.
375-
it.skip('fails in switchToDomain when a command is run after we return to localhost', { browser: '!firefox', defaultCommandTimeout: 50 }, (done) => {
376-
cy.on('fail', (err) => {
377-
expect(err.message).to.include(`Timed out retrying after 50ms: Expected to find element: \`[data-cy="cannot_find"]\`, but never found it`)
378-
// make sure that the secondary domain failures do NOT show up as spec failures or AUT failures
379-
expect(err.message).not.to.include(`The following error originated from your test code, not from Cypress`)
380-
expect(err.message).not.to.include(`The following error originated from your application code, not from Cypress`)
381-
done()
382-
})
383-
384-
cy.visit('/fixtures/auth/index.html') // Establishes Primary Domain
385-
cy.get('[data-cy="login-idp"]').click() // Takes you to idp.com
386-
cy.switchToDomain('http://idp.com:3500', () => {
387-
cy.get('[data-cy="username"]').type('BJohnson')
388-
cy.get('[data-cy="login"]').click()
389-
cy.get('[data-cy="cannot_find"]') // Timeout here on command stability achieved by primary domain, this command times out.
390-
})
391-
392-
// Verify that the user has logged in on localhost
393-
cy.get('[data-cy="welcome"]') // Stability is false, this command is prevented from running until stability is achieved.
394-
.invoke('text')
395-
.should('equal', 'Welcome BJohnson')
396-
})
397-
398-
describe('Pre established spec bridge', () => {
399-
// These next three tests test and edge case where we want to prevent a load event from an established spec bridge that is not part of the test.
400-
// This test removes the foobar spec bridge, navigates to idp, then navigates to foobar and attempts to access selectors on localhost.
401-
it('times out in switchToDomain with foobar spec bridge undefined', { pageLoadTimeout: 5000 }, (done) => {
402-
cy.on('fail', (err) => {
403-
expect(err.message).to.include(`Timed out after waiting \`5000ms\` for your remote page to load.`)
404-
done()
405-
})
406-
407-
cy.visit('/fixtures/auth/index.html') // Establishes Primary Domain
408-
cy.window().then(() => {
409-
// Force remove the spec bridge
410-
window?.top?.document.getElementById('Spec Bridge: foobar.com')?.remove()
411-
})
412-
413-
cy.get('[data-cy="login-idp"]').click() // Takes you to idp.com
414-
cy.switchToDomain('http://idp.com:3500', () => {
415-
cy.get('[data-cy="username"]').type('BJohnson')
416-
cy.window().then((win) => {
417-
win.location.href = 'http://www.foobar.com:3500/fixtures/auth/index.html'
418-
})//
419-
})
420-
421-
// Verify that the user has logged in on localhost
422-
cy.get('[data-cy="welcome"]') // Stability is false, this command is prevented from running until stability is achieved.
423-
.invoke('text')
424-
.should('equal', 'Welcome BJohnson')
425-
})
426-
427-
// this test just needs to establish the foobar spec bridge.
428-
it('establishes foobar spec bridge', () => {
429-
cy.visit('/fixtures/auth/index.html') // Establishes Primary Domain
430-
cy.get('[data-cy="login-foobar"]').click() // Takes you to idp.com
431-
cy.switchToDomain('http://foobar.com:3500', () => {
432-
cy.get('[data-cy="username"]').type('BJohnson')
433-
cy.get('[data-cy="login"]').click()
434-
})
435-
436-
// Verify that the user has logged in on localhost
437-
cy.get('[data-cy="welcome"]')
438-
.invoke('text')
439-
.should('equal', 'Welcome BJohnson')
440-
})
441-
442-
// This test is the same as the first test but the foobar spec bridge has been established and we expect it to behave the same as the first test.
443-
// The primary domain should ignore the load event from the foobar spec bridge and load should timeout in the idp switchToDomain command..
444-
it('times out in switchToDomain with foobar spec bridge defined', { pageLoadTimeout: 5000 }, (done) => {
445-
cy.on('fail', (err) => {
446-
expect(err.message).to.include(`Timed out after waiting \`5000ms\` for your remote page to load.`)
447-
done()
448-
})
449-
450-
cy.visit('/fixtures/auth/index.html') // Establishes Primary Domain
451-
cy.get('[data-cy="login-idp"]').click() // Takes you to idp.com
452-
cy.switchToDomain('http://idp.com:3500', () => {
453-
cy.get('[data-cy="username"]').type('BJohnson')
454-
cy.window().then((win) => {
455-
win.location.href = 'http://www.foobar.com:3500/fixtures/auth/index.html'
456-
})
457-
})
458-
459-
// Verify that the user has logged in on localhost
460-
cy.get('[data-cy="welcome"]') // Stability is false, this command is prevented from running until stability is achieved.
461-
.invoke('text')
462-
.should('equal', 'Welcome BJohnson')
463-
})
464-
})
465-
})

0 commit comments

Comments
 (0)