Skip to content

Commit

Permalink
feat: (multi-domain) adding support for cy.visit in multi-domain (#20467
Browse files Browse the repository at this point in the history
)
  • Loading branch information
mschile authored Mar 8, 2022
1 parent 1eb5ab7 commit 74dea89
Show file tree
Hide file tree
Showing 22 changed files with 612 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ describe('src/cy/commands/navigation', () => {
onLoad,
})
.then((win) => {
expect(win.bar).to.not.exist
expect(win.foo).to.equal('bar')
expect(onLoad).not.to.have.been.called
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,6 @@ context('multi-domain misc', { experimentalSessionSupport: true }, () => {
cy.get('a[data-cy="dom-link"]').click()
})

it('verifies number of cy commands', () => {
// @ts-ignore
const actualCommands = Object.keys(cy.commandFns)
const expectedCommands = [
'check', 'uncheck', 'click', 'dblclick', 'rightclick', 'focus', 'blur', 'hover', 'scrollIntoView', 'scrollTo', 'select',
'selectFile', 'submit', 'type', 'clear', 'trigger', 'as', 'ng', 'should', 'and', 'clock', 'tick', 'spread', 'each', 'then',
'invoke', 'its', 'getCookie', 'getCookies', 'setCookie', 'clearCookie', 'clearCookies', 'pause', 'debug', 'exec', 'readFile',
'writeFile', 'fixture', 'clearLocalStorage', 'url', 'hash', 'location', 'end', 'noop', 'log', 'wrap', 'reload', 'go', 'visit',
'focused', 'get', 'contains', 'root', 'shadow', 'within', 'request', 'session', 'screenshot', 'task', 'find', 'filter', 'not',
'children', 'eq', 'closest', 'first', 'last', 'next', 'nextAll', 'nextUntil', 'parent', 'parents', 'parentsUntil', 'prev',
'prevAll', 'prevUntil', 'siblings', 'wait', 'title', 'window', 'document', 'viewport', 'server', 'route', 'intercept', 'switchToDomain',
]
const addedCommands = Cypress._.difference(actualCommands, expectedCommands)
const removedCommands = Cypress._.difference(expectedCommands, actualCommands)

if (addedCommands.length && removedCommands.length) {
throw new Error(`Commands have been added to and removed from Cypress.
The following command(s) were added: ${addedCommands.join(', ')}
The following command(s) were removed: ${removedCommands.join(', ')}
Update this test accordingly.`)
}

if (addedCommands.length) {
throw new Error(`The following command(s) have been added to Cypress: ${addedCommands.join(', ')}. Please add the command(s) to this test.`)
}

if (removedCommands.length) {
throw new Error(`The following command(s) have been removed from Cypress: ${removedCommands.join(', ')}. Please remove the command(s) from this test.`)
}
})

it('.end()', () => {
cy.switchToDomain('foobar.com', () => {
cy.get('#button').end().should('be.null')
Expand Down Expand Up @@ -104,3 +71,37 @@ context('multi-domain misc', { experimentalSessionSupport: true }, () => {
})
})
})

it('verifies number of cy commands', () => {
// @ts-ignore
// remove 'getAll' command since it's a custom command we add for our own testing and not an actual cy command
const actualCommands = Cypress._.reject(Object.keys(cy.commandFns), (command) => command === 'getAll')
const expectedCommands = [
'check', 'uncheck', 'click', 'dblclick', 'rightclick', 'focus', 'blur', 'hover', 'scrollIntoView', 'scrollTo', 'select',
'selectFile', 'submit', 'type', 'clear', 'trigger', 'as', 'ng', 'should', 'and', 'clock', 'tick', 'spread', 'each', 'then',
'invoke', 'its', 'getCookie', 'getCookies', 'setCookie', 'clearCookie', 'clearCookies', 'pause', 'debug', 'exec', 'readFile',
'writeFile', 'fixture', 'clearLocalStorage', 'url', 'hash', 'location', 'end', 'noop', 'log', 'wrap', 'reload', 'go', 'visit',
'focused', 'get', 'contains', 'root', 'shadow', 'within', 'request', 'session', 'screenshot', 'task', 'find', 'filter', 'not',
'children', 'eq', 'closest', 'first', 'last', 'next', 'nextAll', 'nextUntil', 'parent', 'parents', 'parentsUntil', 'prev',
'prevAll', 'prevUntil', 'siblings', 'wait', 'title', 'window', 'document', 'viewport', 'server', 'route', 'intercept', 'switchToDomain',
]
const addedCommands = Cypress._.difference(actualCommands, expectedCommands)
const removedCommands = Cypress._.difference(expectedCommands, actualCommands)

if (addedCommands.length && removedCommands.length) {
throw new Error(`Commands have been added to and removed from Cypress.
The following command(s) were added: ${addedCommands.join(', ')}
The following command(s) were removed: ${removedCommands.join(', ')}
Update this test accordingly.`)
}

if (addedCommands.length) {
throw new Error(`The following command(s) have been added to Cypress: ${addedCommands.join(', ')}. Please add tests for the command(s) in multi-domain and add the command(s) to this test.`)
}

if (removedCommands.length) {
throw new Error(`The following command(s) have been removed from Cypress: ${removedCommands.join(', ')}. Please remove the command(s) from this test.`)
}
})
Loading

0 comments on commit 74dea89

Please sign in to comment.