Skip to content

Commit

Permalink
feat: (origin) handle waiting for aliased intercepts (#21579)
Browse files Browse the repository at this point in the history
  • Loading branch information
mschile authored May 24, 2022
1 parent d681fd9 commit 53030b7
Show file tree
Hide file tree
Showing 7 changed files with 456 additions and 35 deletions.
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) => {
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

3 comments on commit 53030b7

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 53030b7 May 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.8.0/linux-x64/develop-53030b79f64e47c2d7348b8cb82b3b825ac9575e/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 53030b7 May 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.8.0/win32-x64/develop-53030b79f64e47c2d7348b8cb82b3b825ac9575e/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 53030b7 May 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.8.0/darwin-x64/develop-53030b79f64e47c2d7348b8cb82b3b825ac9575e/cypress.tgz

Please sign in to comment.