-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature-multidomain' into update_switch_to_domain_signa…
…ture
- Loading branch information
Showing
7 changed files
with
107 additions
and
31 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
packages/driver/cypress/integration/e2e/multi-domain/commands/multi_domain_log.spec.ts
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,70 @@ | ||
import { assertLogLength } from '../../../../support/utils' | ||
|
||
// @ts-ignore / session support is needed for visiting about:blank between tests | ||
context('log', { experimentalSessionSupport: true }, () => { | ||
let logs: any = [] | ||
let lastTestLogId = '' | ||
|
||
beforeEach(() => { | ||
logs = [] | ||
|
||
cy.on('log:added', (attrs, log) => { | ||
logs.push(log) | ||
}) | ||
|
||
cy.visit('/fixtures/multi-domain.html') | ||
cy.get('a[data-cy="dom-link"]').click() | ||
}) | ||
|
||
it('logs in primary and secondary domains', () => { | ||
cy.switchToDomain('http://foobar.com:3500', () => { | ||
const afterLogAdded = new Promise<void>((resolve) => { | ||
const listener = (attrs) => { | ||
if (attrs.message === 'test log in multi-domain') { | ||
expect(attrs.message).to.eq('test log in multi-domain') | ||
cy.removeListener('log:added', listener) | ||
resolve(attrs.id) | ||
} | ||
} | ||
|
||
cy.on('log:added', listener) | ||
}) | ||
|
||
cy.log('test log in multi-domain') | ||
cy.wrap(afterLogAdded) | ||
}).then((id) => { | ||
lastTestLogId = id | ||
// Verify the log is also fired in the primary domain. | ||
expect(logs[6].get('message')).to.eq('test log in multi-domain') | ||
// Verify the log has the same ID as was generated in the cross-origin | ||
expect(logs[6].get('id')).to.equal(id) | ||
assertLogLength(logs, 11) | ||
}) | ||
}) | ||
|
||
it('has a different id in a second test', () => { | ||
cy.switchToDomain('http://foobar.com:3500', () => { | ||
const afterLogAdded = new Promise<void>((resolve) => { | ||
const listener = (attrs) => { | ||
if (attrs.message === 'test log in multi-domain') { | ||
expect(attrs.message).to.eq('test log in multi-domain') | ||
cy.removeListener('log:added', listener) | ||
resolve(attrs.id) | ||
} | ||
} | ||
|
||
cy.on('log:added', listener) | ||
}) | ||
|
||
cy.log('test log in multi-domain') | ||
cy.wrap(afterLogAdded) | ||
}).then((id) => { | ||
// Verify the log is also fired in the primary domain. | ||
expect(logs[6].get('message')).to.eq('test log in multi-domain') | ||
// Verify the log has the same ID as was generated in the cross-origin | ||
expect(logs[6].get('id')).to.equal(id) | ||
expect(logs[6].get('id')).to.not.equal(lastTestLogId) | ||
assertLogLength(logs, 12) | ||
}) | ||
}) | ||
}) |
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
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
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