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 issue-20041-multi-domain-view…
…port
- Loading branch information
Showing
9 changed files
with
345 additions
and
14 deletions.
There are no files selected for viewing
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
29 changes: 29 additions & 0 deletions
29
...r/cypress/integration/e2e/multi-domain/commands/multi_domain_unsupported_commands.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,29 @@ | ||
// @ts-ignore / session support is needed for visiting about:blank between tests | ||
context('multi-domain unsupported commands', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => { | ||
beforeEach(() => { | ||
cy.visit('/fixtures/multi-domain.html') | ||
cy.get('a[data-cy="multi-domain-secondary-link"]').click() | ||
}) | ||
|
||
it('throws an error that the `cy.route()` method is deprecated and unsupported when attempted use is in multi-domain', (done) => { | ||
cy.on('fail', (err) => { | ||
expect(err.message).to.equal('`cy.route()` has been deprecated and use is not supported in `cy.switchToDomain()`. Consider using `cy.intercept()` instead.') | ||
done() | ||
}) | ||
|
||
cy.switchToDomain('foobar.com', () => { | ||
cy.route('api') | ||
}) | ||
}) | ||
|
||
it('throws an error that the `cy.server()` method is deprecated and unsupported when attempted use is in multi-domain', (done) => { | ||
cy.on('fail', (err) => { | ||
expect(err.message).to.equal('`cy.server()` has been deprecated and use is not supported in `cy.switchToDomain()`. Consider using `cy.intercept()` instead.') | ||
done() | ||
}) | ||
|
||
cy.switchToDomain('foobar.com', () => { | ||
cy.server() | ||
}) | ||
}) | ||
}) |
247 changes: 247 additions & 0 deletions
247
packages/driver/cypress/integration/e2e/multi-domain/multi_domain_cypress_api.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,247 @@ | ||
// @ts-ignore / session support is needed for visiting about:blank between tests+ | ||
describe('multi-domain Cypress API', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => { | ||
beforeEach(() => { | ||
cy.visit('/fixtures/multi-domain.html') | ||
cy.get('a[data-cy="multi-domain-secondary-link"]').click() | ||
}) | ||
|
||
// FIXME: Commands adding/overwriting should be condensed into one test with two switchToDomain tests | ||
// once multiple switchToDomain calls are supported | ||
context('Commands', () => { | ||
context('add', () => { | ||
it('adds a custom command', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
// @ts-ignore | ||
Cypress.Commands.add('foo', () => 'bar') | ||
|
||
// @ts-ignore | ||
cy.foo().should('equal', 'bar') | ||
}) | ||
}) | ||
|
||
it('persists defined commands through spec bridge', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
// @ts-ignore | ||
cy.foo().should('equal', 'bar') | ||
}) | ||
}) | ||
}) | ||
|
||
context('overwrite', () => { | ||
it('overwrites an existing command in the spec bridge', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
// @ts-ignore | ||
Cypress.Commands.overwrite('foo', () => 'baz') | ||
|
||
// @ts-ignore | ||
cy.foo().should('equal', 'baz') | ||
}) | ||
}) | ||
|
||
it('persists overwritten command through spec bridge', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
// @ts-ignore | ||
cy.foo().should('equal', 'baz') | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
context('Keyboard', () => { | ||
it('does NOT sync defaults', () => { | ||
const defaults = Cypress.Keyboard.defaults({ | ||
keystrokeDelay: 30, | ||
}) | ||
|
||
cy.switchToDomain('foobar.com', [defaults], ([primaryKeyboardDefaults]) => { | ||
const multiDomainKeyboardDefaults = Cypress.Keyboard.defaults({}) | ||
|
||
expect(multiDomainKeyboardDefaults).to.not.deep.equal(primaryKeyboardDefaults) | ||
}) | ||
}) | ||
|
||
// FIXME: Commands adding/overwriting should be condensed into one test with two switchToDomain tests | ||
// once multiple switchToDomain calls are supported | ||
it('allows a user to configure defaults', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
const multiDomainKeyboardDefaults = Cypress.Keyboard.defaults({ | ||
keystrokeDelay: 60, | ||
}) | ||
|
||
expect(multiDomainKeyboardDefaults).to.deep.include({ | ||
keystrokeDelay: 60, | ||
}) | ||
}) | ||
}) | ||
|
||
it('persists default configuration changes through spec bridge', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
const multiDomainKeyboardDefaults = Cypress.Keyboard.defaults({}) | ||
|
||
expect(multiDomainKeyboardDefaults).to.deep.include({ | ||
keystrokeDelay: 60, | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
context('Screenshot', () => { | ||
it('does NOT sync defaults', () => { | ||
Cypress.Screenshot.defaults({ | ||
blackout: ['foo'], | ||
overwrite: true, | ||
onBeforeScreenshot: () => undefined, | ||
onAfterScreenshot: () => undefined, | ||
}) | ||
|
||
cy.switchToDomain('foobar.com', () => { | ||
const multiDomainScreenshotDefaults = Cypress.Screenshot.defaults({}) | ||
|
||
expect(multiDomainScreenshotDefaults).to.not.deep.include({ | ||
blackout: ['foo'], | ||
overwrite: true, | ||
onBeforeScreenshot: () => undefined, | ||
onAfterScreenshot: () => undefined, | ||
}) | ||
}) | ||
}) | ||
|
||
// FIXME: Commands adding/overwriting should be condensed into one test with two switchToDomain tests | ||
// once multiple switchToDomain calls are supported | ||
it('allows a user to configure defaults', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
const multiDomainScreenshotDefaults = Cypress.Screenshot.defaults({ | ||
blackout: ['foo'], | ||
overwrite: true, | ||
}) | ||
|
||
expect(multiDomainScreenshotDefaults).to.deep.include({ | ||
blackout: ['foo'], | ||
overwrite: true, | ||
}) | ||
}) | ||
}) | ||
|
||
it('persists default configuration changes through spec bridge', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
const multiDomainScreenshotDefaults = Cypress.Screenshot.defaults({}) | ||
|
||
expect(multiDomainScreenshotDefaults).to.deep.include({ | ||
blackout: ['foo'], | ||
overwrite: true, | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
context('dom', () => { | ||
it('provides a sanity check that the dom API exists on Cypress.*', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
cy.get('[data-cy="dom-check"]').then(($el) => { | ||
expect(Cypress.dom.isAttached($el)).to.be.true | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
// TODO: Before implementing, understand how Cypress.session.* and cy.session() are supposed to function within the context of multi-domain | ||
context.skip('session', () => { | ||
it('clearAllSavedSessions() functions as expected', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
Cypress.session.clearAllSavedSessions() | ||
}) | ||
}) | ||
}) | ||
|
||
context('properties', () => { | ||
it('has arch property synced from primary', () => { | ||
cy.switchToDomain('foobar.com', [Cypress.arch], ([theArch]) => { | ||
expect(Cypress.arch).to.equal(theArch) | ||
}) | ||
}) | ||
|
||
it('has browser property synced from primary', () => { | ||
cy.switchToDomain('foobar.com', [Cypress.browser], ([theBrowser]) => { | ||
expect(Cypress.browser).to.deep.equal(theBrowser) | ||
}) | ||
}) | ||
|
||
it('has currentTest property synced from primary', () => { | ||
cy.switchToDomain('foobar.com', [Cypress.currentTest], ([theCurrentTest]) => { | ||
expect(Cypress.currentTest).to.deep.equal(theCurrentTest) | ||
}) | ||
}) | ||
|
||
it('has platform property synced from primary', () => { | ||
cy.switchToDomain('foobar.com', [Cypress.platform], ([thePlatform]) => { | ||
expect(Cypress.platform).to.equal(thePlatform) | ||
}) | ||
}) | ||
|
||
it('has testingType property synced from primary', () => { | ||
cy.switchToDomain('foobar.com', [Cypress.testingType], ([theTestingType]) => { | ||
expect(Cypress.testingType).to.deep.equal(theTestingType) | ||
}) | ||
}) | ||
|
||
it('has spec property synced from primary', () => { | ||
cy.switchToDomain('foobar.com', [Cypress.spec], ([theSpec]) => { | ||
expect(Cypress.spec).to.deep.equal(theSpec) | ||
}) | ||
}) | ||
}) | ||
|
||
context('methods', () => { | ||
it('isCy()', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
expect(Cypress.isCy(cy)).to.be.true | ||
}) | ||
}) | ||
|
||
it('isBrowser()', () => { | ||
cy.switchToDomain('foobar.com', [Cypress.browser], ([theBrowser]) => { | ||
expect(Cypress.isBrowser(theBrowser.name)).to.equal(true) | ||
}) | ||
}) | ||
|
||
it('log()', (done) => { | ||
cy.on('log:changed', (changedLog) => { | ||
if (changedLog?.message === 'test log' && changedLog.ended) { | ||
// just make sure Big Cypress logs make their way back to the primary | ||
done() | ||
} | ||
}) | ||
|
||
cy.switchToDomain('foobar.com', () => { | ||
Cypress.log({ | ||
message: 'test log', | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
context('not supported', () => { | ||
it('throws an error when a user attempts to configure Cypress.Server.defaults() inside of multi-domain', (done) => { | ||
cy.on('fail', (err) => { | ||
expect(err.message).to.equal('`Cypress.Server.*` has been deprecated and use is not supported in `cy.switchToDomain()`. Consider using `cy.intercept()` instead.') | ||
done() | ||
}) | ||
|
||
cy.switchToDomain('foobar.com', () => { | ||
Cypress.Server.defaults({}) | ||
}) | ||
}) | ||
|
||
it('throws an error when a user attempts to configure Cypress.Cookies.preserveOnce() inside of multi-domain', (done) => { | ||
cy.on('fail', (err) => { | ||
expect(err.message).to.equal('`Cypress.Cookies.preserveOnce` use is not supported in `cy.switchToDomain()`. Consider using `cy.session()` instead.') | ||
done() | ||
}) | ||
|
||
cy.switchToDomain('foobar.com', () => { | ||
// @ts-ignore | ||
Cypress.Cookies.preserveOnce({}) | ||
}) | ||
}) | ||
}) | ||
}) |
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
Oops, something went wrong.