-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix(driver): dynamic intercept aliases shown with name instead of no alias #28326
fix(driver): dynamic intercept aliases shown with name instead of no alias #28326
Conversation
|
How to test
|
a175f67
to
cc49197
Compare
@@ -0,0 +1,15 @@ | |||
import { loadSpec } from './support/spec-loader' | |||
|
|||
describe('Aliases', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is pretty heavy when we could be validating log attributes within a driver test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not super familiar with the driver but the way I understand it, the run time aliases that are set in the callback of intercept can't be triggered via a command? Am I missing something @emilyrohrbough ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can pull it from the log list and execute the renderProps function to pull the value. Intercepts is a tricker command, I was playing with it and noticed we already have a test for dynamic aliases here, and we can add this to verify the alias renders correctly:
it('can dynamically alias the request', function () {
const url = uniqueRoute('/foo')
cy.intercept(`${url}*`, (req) => {
req.alias = 'fromInterceptor'
})
.then(() => {
$.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')
+ })
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Just pushed a change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test should be in the driver package
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Additional details
Previously, dynamic aliases added using
cy.intercept
(documentation) would not show up in the app.cy.wait
would still work for them, but the aliases incorrectly renamed to "no alias" in the output confused users. See #24653.Sample spec for reproduction:
Steps to test
@jordanpowell88 provided testing through a fixture in dynamic-route-aliases.runner.cy.js that uses a dynamic alias and verifying the behavior in the test aliases.cy.ts. Thanks!
How has the user experience changed?
Sample spec output before and after changes:
![after](https://private-user-images.githubusercontent.com/49129166/282556222-1a37aa80-0620-4530-a4ba-b34b857a7014.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyODYxMTEsIm5iZiI6MTczOTI4NTgxMSwicGF0aCI6Ii80OTEyOTE2Ni8yODI1NTYyMjItMWEzN2FhODAtMDYyMC00NTMwLWE0YmEtYjM0Yjg1N2E3MDE0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDE0NTY1MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI3Mzk5MzMzYWI2Nzc4ZWExMTg1MDIxNjA2YzJkNzNiMDBjYzczM2Y2ZTQwYzhlZjQwZjk3NzE0OTQ4MjA2M2MmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.X27bTTEya3QdEjy09WbaRxMYpGsSdhv9Q6X_AWXt6t0)
PR Tasks
cypress-documentation
?type definitions
?