Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: (origin) handle waiting for aliased intercepts #21579

Merged
merged 8 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/driver/cypress/integration/commands/waiting_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('src/cy/commands/waiting', () => {

return null
})
.wait('@fetch').then((xhr) => {
.wait('@fetch.response').then((xhr) => {
mschile marked this conversation as resolved.
Show resolved Hide resolved
expect(xhr.responseBody).to.deep.eq(response)
})
})
Expand Down Expand Up @@ -302,7 +302,7 @@ describe('src/cy/commands/waiting', () => {
.wait('getAny').then(() => {})
})

it('throws when 2nd alias doesnt match any registered alias', (done) => {
it('throws when 2nd alias doesn\'t match any registered alias', (done) => {
cy.on('fail', (err) => {
expect(err.message).to.eq('`cy.wait()` could not find a registered alias for: `@bar`.\nAvailable aliases are: `foo`.')

Expand Down Expand Up @@ -339,7 +339,7 @@ describe('src/cy/commands/waiting', () => {
.wait(['@foo', 'bar'])
})

it('throws when 2nd alias isnt a route alias', (done) => {
it('throws when 2nd alias isn\'t a route alias', (done) => {
cy.on('fail', (err) => {
expect(err.message).to.include('`cy.wait()` only accepts aliases for routes.\nThe alias: `bar` did not match a route.')
expect(err.docsUrl).to.eq('https://on.cypress.io/wait')
Expand Down Expand Up @@ -448,7 +448,7 @@ describe('src/cy/commands/waiting', () => {
.wait(['@foo', 'bar'])
})

it('does not throw again when 2nd alias doesnt reference a route', {
it('does not throw again when 2nd alias doesn\'t reference a route', {
requestTimeout: 100,
}, (done) => {
Promise.onPossiblyUnhandledRejection(done)
Expand Down Expand Up @@ -1132,7 +1132,7 @@ describe('src/cy/commands/waiting', () => {
expect(this.lastLog.invoke('consoleProps')).to.deep.eq({
Command: 'wait',
'Waited For': 'getFoo, getBar',
Yielded: [xhrs[0], xhrs[1]], // explictly create the array here
Yielded: [xhrs[0], xhrs[1]], // explicitly create the array here
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,29 @@ import { findCrossOriginLogs } from '../../../../support/utils'
context('cy.origin aliasing', () => {
beforeEach(() => {
cy.visit('/fixtures/primary-origin.html')
cy.get('a[data-cy="dom-link"]').click()
})

it('.as()', () => {
cy.origin('http://foobar.com:3500', () => {
cy.get(':checkbox[name="colors"][value="blue"]').as('checkbox')
cy.get('@checkbox').click().should('be.checked')
context('.as()', () => {
it('supports dom elements inside origin', () => {
cy.get('a[data-cy="dom-link"]').click()

cy.origin('http://foobar.com:3500', () => {
cy.get(':checkbox[name="colors"][value="blue"]').as('checkbox')
cy.get('@checkbox').click().should('be.checked')
})
})

it('fails for dom elements outside origin', (done) => {
cy.on('fail', (err) => {
expect(err.message).to.equal('`cy.get()` could not find a registered alias for: `@welcome_button`.\nYou have not aliased anything yet.')
done()
})

cy.get('[data-cy="welcome"]').as('welcome_button')

cy.origin('http://foobar.com:3500', () => {
cy.get('@welcome_button').click()
})
})
})

Expand All @@ -25,6 +41,8 @@ context('cy.origin aliasing', () => {
})

it('.as()', () => {
cy.get('a[data-cy="dom-link"]').click()

cy.origin('http://foobar.com:3500', () => {
cy.get('#button').as('buttonAlias')
})
Expand Down
Loading