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

Add throttleKbps, delayMs with presets to StaticResponse objects #7661

Closed
flotwig opened this issue Jun 10, 2020 · 2 comments · Fixed by #8109
Closed

Add throttleKbps, delayMs with presets to StaticResponse objects #7661

flotwig opened this issue Jun 10, 2020 · 2 comments · Fixed by #8109
Assignees
Labels
pkg/driver This is due to an issue in the packages/driver directory topic: cy.intercept() type: enhancement Requested enhancement of existing feature

Comments

@flotwig
Copy link
Contributor

flotwig commented Jun 10, 2020

Current behavior:

Users have to invoke .delay() or .throttle() to delay/throttle the response, and they have to use plain numbers (ms and kbps, respectively) to set the throttle:

cy.route2('/timeout', (req) => {
req.reply((res) => {
this.start = Date.now()
res.throttle(kbps).delay(delayMs).send({
statusCode: 200,
body: payload,
})
})

Desired behavior:

Users should be able to statically define throttleKbps or delayMs, and should be able to use string presets. So the above code could be written as this:

cy.route2('/timeout', {
	statusCode: 200,
	body: payload,
	delayMs,
	throttle: '3g', 
})

For the list of throttle presets, we can probably use the same list that Chromium/WebKit use: https://source.chromium.org/chromium/chromium/src/+/master:chrome/test/chromedriver/chrome/network_list.cc;l=12;drc=23bc3b1c92fd920d4d359ba46d73054ff0f47d2c?originalUrl=https:%2F%2Fcs.chromium.org%2F

Depends on #687

@flotwig flotwig added type: enhancement Requested enhancement of existing feature pkg/driver This is due to an issue in the packages/driver directory topic: cy.intercept() labels Jun 10, 2020
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Jul 28, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 11, 2020

The code for this is done in cypress-io/cypress#8109, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Sep 11, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 15, 2020

Released in 5.2.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v5.2.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Sep 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg/driver This is due to an issue in the packages/driver directory topic: cy.intercept() type: enhancement Requested enhancement of existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants