Skip to content

Commit

Permalink
fix(driver): dynamic intercept aliases shown with name instead of no …
Browse files Browse the repository at this point in the history
…alias (#28326)

Co-authored-by: jordanpowell88 <[email protected]>
  • Loading branch information
S-Tornqvist and jordanpowell88 authored Nov 20, 2023
1 parent 2eb8455 commit 2041c69
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ _Released 11/21/2023 (PENDING)_

**Bugfixes:**

- Fixed an issue where dynamic intercept aliases now show with alias name instead of "no alias" in driver. Addresses [#24653](https://github.com/cypress-io/cypress/issues/24653)
- Fixed an issue where [aliasing individual requests](https://docs.cypress.io/api/commands/intercept#Aliasing-individual-requests) with `cy.intercept()` led to an error when retrieving all of the aliases with `cy.get(@alias.all)` . Addresses [#25448](https://github.com/cypress-io/cypress/issues/25448)
- The URL of the application under test and command error "Learn more" links now open externally instead of in the Cypress-launched browser. Fixes [#24572](https://github.com/cypress-io/cypress/issues/24572).

Expand Down
25 changes: 25 additions & 0 deletions packages/driver/cypress/e2e/commands/net_stubbing.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3809,6 +3809,31 @@ describe('network stubbing', { retries: 15 }, function () {
$.get(url)
})
.wait('@fromInterceptor')
.then(() => {
const log = cy.queue.logs({
displayName: 'xhr',
})[0]

const renderProps = log.get('renderProps')()

expect(renderProps.interceptions).to.have.length(1)
expect(renderProps.interceptions[0]).to.have.property('alias')
expect(renderProps.interceptions[0].alias).to.eq('fromInterceptor')
})
})

it('can dynamically alias the request and get with @alias.all', function () {
const url = uniqueRoute('/foo')

cy.intercept(`${url}*`, (req) => {
req.alias = 'fromInterceptor'
})
.then(() => {
$.get(url)
$.get(url)
})
.wait('@fromInterceptor').wait('@fromInterceptor')
.get('@fromInterceptor.all').should('have.length', 2)
})

it('can time out on a dynamic alias', function (done) {
Expand Down
4 changes: 4 additions & 0 deletions packages/driver/src/cy/commands/waiting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ export default (Commands, Cypress, cy, state) => {
const req = waitForRoute(alias, state, type)

if (req) {
// Attach alias to request to ensure driver access to
// dynamic aliases. See #24653
req.request.alias = alias

return req
}

Expand Down

5 comments on commit 2041c69

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2041c69 Nov 20, 2023

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 arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.0/linux-arm64/develop-2041c696e9b8518dcad0afec392ec8a9537703c4/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2041c69 Nov 20, 2023

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 build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.0/linux-x64/develop-2041c696e9b8518dcad0afec392ec8a9537703c4/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2041c69 Nov 20, 2023

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 build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.0/darwin-x64/develop-2041c696e9b8518dcad0afec392ec8a9537703c4/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2041c69 Nov 20, 2023

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 arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.0/darwin-arm64/develop-2041c696e9b8518dcad0afec392ec8a9537703c4/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2041c69 Nov 20, 2023

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 build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.6.0/win32-x64/develop-2041c696e9b8518dcad0afec392ec8a9537703c4/cypress.tgz

Please sign in to comment.