-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding specs for all cy commands in multi-domain
- Loading branch information
Showing
24 changed files
with
848 additions
and
5 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
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
142 changes: 142 additions & 0 deletions
142
packages/driver/cypress/integration/e2e/multi-domain/commands/multi_domain_actions.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,142 @@ | ||
// @ts-ignore / session support is needed for visiting about:blank between tests | ||
context('multi-domain actions', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => { | ||
beforeEach(() => { | ||
cy.visit('/fixtures/multi-domain.html') | ||
}) | ||
|
||
it('.type()', () => { | ||
cy.get('a[data-cy="dom-link"]').click() | ||
|
||
cy.switchToDomain('foobar.com', () => { | ||
cy.get('#input').type('foo').should('have.value', 'foo') | ||
}) | ||
}) | ||
|
||
it('.focus()', () => { | ||
cy.get('a[data-cy="dom-link"]').click() | ||
|
||
cy.switchToDomain('foobar.com', () => { | ||
cy.get('#input').focus() | ||
}) | ||
}) | ||
|
||
it('.blur()', () => { | ||
cy.get('a[data-cy="dom-link"]').click() | ||
|
||
cy.switchToDomain('foobar.com', () => { | ||
cy.get('#input').type('foo').blur() | ||
}) | ||
}) | ||
|
||
it('.clear()', () => { | ||
cy.get('a[data-cy="dom-link"]').click() | ||
|
||
cy.switchToDomain('foobar.com', () => { | ||
cy.get('#input') | ||
.type('foo').should('have.value', 'foo') | ||
.clear().should('have.value', '') | ||
}) | ||
}) | ||
|
||
it('.submit()', (done) => { | ||
cy.get('a[data-cy="dom-link"]').click() | ||
|
||
cy.switchToDomain('foobar.com', done, () => { | ||
Cypress.once('form:submitted', (e) => done()) | ||
cy.get('#input-type-submit').submit() | ||
}) | ||
}) | ||
|
||
it('.click()', (done) => { | ||
cy.get('a[data-cy="dom-link"]').click() | ||
|
||
cy.switchToDomain('foobar.com', done, () => { | ||
const $btn = cy.$$('#button') | ||
|
||
$btn.on('click', (e) => done()) | ||
cy.get('#button').click() | ||
}) | ||
}) | ||
|
||
it('.dblclick()', (done) => { | ||
cy.get('a[data-cy="dom-link"]').click() | ||
|
||
cy.switchToDomain('foobar.com', done, () => { | ||
const $btn = cy.$$('#button') | ||
|
||
$btn.on('dblclick', () => done()) | ||
cy.get('#button').dblclick() | ||
}) | ||
}) | ||
|
||
it('.rightclick()', (done) => { | ||
cy.get('a[data-cy="dom-link"]').click() | ||
|
||
cy.switchToDomain('foobar.com', done, () => { | ||
const el = cy.$$('#button') | ||
|
||
el.on('contextmenu', () => done()) | ||
|
||
cy.get('#button').rightclick() | ||
}) | ||
}) | ||
|
||
it('.check()', () => { | ||
cy.get('a[data-cy="dom-link"]').click() | ||
|
||
cy.switchToDomain('foobar.com', () => { | ||
cy.get(':checkbox[name="colors"][value="blue"]') | ||
.check().should('be.checked') | ||
}) | ||
}) | ||
|
||
it('.uncheck()', () => { | ||
cy.get('a[data-cy="dom-link"]').click() | ||
|
||
cy.switchToDomain('foobar.com', () => { | ||
cy.get(':checkbox[name="colors"][value="blue"]') | ||
.check().should('be.checked') | ||
.uncheck().should('not.be.checked') | ||
}) | ||
}) | ||
|
||
it('.select()', () => { | ||
cy.get('a[data-cy="dom-link"]').click() | ||
|
||
cy.switchToDomain('foobar.com', () => { | ||
cy.get('select[name="foods"]') | ||
.select('Japanese').should('have.value', 'Japanese') | ||
}) | ||
}) | ||
|
||
it('.scrollIntoView()', () => { | ||
cy.get('a[data-cy="scrolling-link"]').click() | ||
|
||
cy.switchToDomain('foobar.com', () => { | ||
cy.get('#scroll-into-view-vertical h5') | ||
.should('not.be.visible') | ||
.scrollIntoView().should('be.visible') | ||
}) | ||
}) | ||
|
||
it('.scrollTo()', () => { | ||
cy.get('a[data-cy="scrolling-link"]').click() | ||
|
||
cy.switchToDomain('foobar.com', () => { | ||
cy.get('#scroll-into-view-vertical h5').should('not.be.visible') | ||
cy.get('#scroll-into-view-vertical').scrollTo(0, 300) | ||
cy.get('#scroll-into-view-vertical h5').should('be.visible') | ||
}) | ||
}) | ||
|
||
it('.trigger()', (done) => { | ||
cy.get('a[data-cy="dom-link"]').click() | ||
|
||
cy.switchToDomain('foobar.com', done, () => { | ||
const $btn = cy.$$('#button') | ||
|
||
$btn.on('click', (e) => done()) | ||
cy.get('#button').trigger('click') | ||
}) | ||
}) | ||
}) |
14 changes: 14 additions & 0 deletions
14
packages/driver/cypress/integration/e2e/multi-domain/commands/multi_domain_aliasing.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,14 @@ | ||
// @ts-ignore / session support is needed for visiting about:blank between tests | ||
context('multi-domain aliasing', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => { | ||
beforeEach(() => { | ||
cy.visit('/fixtures/multi-domain.html') | ||
cy.get('a[data-cy="dom-link"]').click() | ||
}) | ||
|
||
it('.as()', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
cy.get(':checkbox[name="colors"][value="blue"]').as('checkbox') | ||
cy.get('@checkbox').click().should('be.checked') | ||
}) | ||
}) | ||
}) |
14 changes: 14 additions & 0 deletions
14
...ages/driver/cypress/integration/e2e/multi-domain/commands/multi_domain_assertions.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,14 @@ | ||
// @ts-ignore / session support is needed for visiting about:blank between tests | ||
context('multi-domain assertions', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => { | ||
beforeEach(() => { | ||
cy.visit('/fixtures/multi-domain.html') | ||
cy.get('a[data-cy="dom-link"]').click() | ||
}) | ||
|
||
it('.should() and .and()', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
cy.get(':checkbox[name="colors"][value="blue"]') | ||
.should('not.be.checked').and('not.be.disabled') | ||
}) | ||
}) | ||
}) |
47 changes: 47 additions & 0 deletions
47
...ages/driver/cypress/integration/e2e/multi-domain/commands/multi_domain_connectors.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,47 @@ | ||
// @ts-ignore / session support is needed for visiting about:blank between tests | ||
context('multi-domain connectors', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => { | ||
beforeEach(() => { | ||
cy.visit('/fixtures/multi-domain.html') | ||
cy.get('a[data-cy="dom-link"]').click() | ||
}) | ||
|
||
it('.each()', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
cy.get('#by-name>[name="colors"]').each(($element, index) => { | ||
expect($element.prop('type')).to.eq('checkbox') | ||
}) | ||
}) | ||
}) | ||
|
||
it('.its()', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
cy.get('#by-id>input').its('length').should('eq', 3) | ||
}) | ||
}) | ||
|
||
it('.invoke()', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
cy.get('#button').invoke('text').should('eq', 'button') | ||
}) | ||
}) | ||
|
||
it('.spread()', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
const arr = ['foo', 'bar', 'baz'] | ||
|
||
cy.wrap(arr).spread((foo, bar, baz) => { | ||
expect(foo).to.eq('foo') | ||
expect(bar).to.eq('bar') | ||
expect(baz).to.eq('baz') | ||
}) | ||
}) | ||
}) | ||
|
||
it('.then()', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
cy.get('#by-id>input').then(($list) => { | ||
expect($list).to.have.length(3) | ||
}) | ||
}) | ||
}) | ||
}) |
39 changes: 39 additions & 0 deletions
39
packages/driver/cypress/integration/e2e/multi-domain/commands/multi_domain_cookies.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,39 @@ | ||
// @ts-ignore / session support is needed for visiting about:blank between tests | ||
// FIXME: hangs | ||
context.skip('multi-domain cookies', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => { | ||
beforeEach(() => { | ||
cy.visit('/fixtures/multi-domain.html') | ||
cy.get('a[data-cy="multi-domain-secondary-link"]').click() | ||
}) | ||
|
||
it('.getCookie(), .getCookies(), and .setCookie()', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
cy.getCookies().should('be.empty') | ||
|
||
cy.setCookie('foo', 'bar') | ||
|
||
cy.getCookie('foo').should('have.property', 'value', 'bar') | ||
cy.getCookies().should('have.length', 1) | ||
}) | ||
}) | ||
|
||
it('.clearCookie()', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
cy.setCookie('foo', 'bar') | ||
cy.getCookie('foo').should('not.be.null') | ||
cy.clearCookie('foo') | ||
cy.getCookie('foo').should('be.null') | ||
}) | ||
}) | ||
|
||
it('.clearCookies()', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
cy.setCookie('foo', 'bar') | ||
cy.setCookie('faz', 'baz') | ||
|
||
cy.getCookies().should('have.length', 2) | ||
cy.clearCookies() | ||
cy.getCookies().should('be.empty') | ||
}) | ||
}) | ||
}) |
54 changes: 54 additions & 0 deletions
54
packages/driver/cypress/integration/e2e/multi-domain/commands/multi_domain_files.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,54 @@ | ||
// @ts-ignore / session support is needed for visiting about:blank between tests | ||
context('multi-domain files', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => { | ||
beforeEach(() => { | ||
cy.visit('/fixtures/multi-domain.html') | ||
cy.get('a[data-cy="multi-domain-secondary-link"]').click() | ||
cy.stub(Cypress, 'backend').callThrough() | ||
}) | ||
|
||
// FIXME: CypressError: `cy.fixture()` timed out waiting `undefinedms` to receive a fixture. No fixture was ever sent by the server. | ||
// at eval (webpack:///../driver/src/cy/commands/fixtures.ts?:89:85) | ||
it.skip('.fixture()', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
cy.fixture('example.json').then((json) => { | ||
expect(json).to.be.an('object') | ||
expect(json.example).to.be.true | ||
}) | ||
}) | ||
}) | ||
|
||
// FIXME: CypressError: `cy.readFile("cypress/fixtures/multi-domain.json")` timed out after waiting `undefinedms`. | ||
// at eval (webpack:///../driver/src/cy/commands/files.ts?:59:89) | ||
it.skip('.readFile()', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
cy.readFile('cypress/fixtures/example.json').then((json) => { | ||
expect(json).to.be.an('object') | ||
expect(json.example).to.be.true | ||
}) | ||
}) | ||
}) | ||
|
||
// FIXME: Cypress.backend.resolves is not a function | ||
// Works when not using switchToDomain | ||
it.skip('.writeFile()', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
// @ts-ignore | ||
Cypress.backend.resolves({ | ||
contents: JSON.stringify({ foo: 'bar' }), | ||
filePath: 'foo.json', | ||
}) | ||
|
||
cy.writeFile('foo.json', JSON.stringify({ foo: 'bar' })).then(() => { | ||
expect(Cypress.backend).to.be.calledWith( | ||
'write:file', | ||
'foo.json', | ||
JSON.stringify({ foo: 'bar' }), | ||
{ | ||
encoding: 'utf8', | ||
flag: 'w', | ||
}, | ||
) | ||
}) | ||
}) | ||
}) | ||
}) |
23 changes: 23 additions & 0 deletions
23
...s/driver/cypress/integration/e2e/multi-domain/commands/multi_domain_local_storage.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,23 @@ | ||
// @ts-ignore / session support is needed for visiting about:blank between tests | ||
context('multi-domain local storage', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => { | ||
beforeEach(() => { | ||
cy.visit('/fixtures/multi-domain.html') | ||
cy.get('a[data-cy="multi-domain-secondary-link"]').click() | ||
}) | ||
|
||
it('.clearLocalStorage()', () => { | ||
cy.switchToDomain('foobar.com', () => { | ||
cy.window().then((win) => { | ||
win.localStorage.setItem('foo', 'bar') | ||
expect(win.localStorage.getItem('foo')).to.eq('bar') | ||
}) | ||
|
||
cy.clearLocalStorage().should((localStorage) => { | ||
cy.window().then((win) => { | ||
expect(localStorage.length).to.eq(0) | ||
expect(win.localStorage.getItem('foo')).to.be.null | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.