test(cypress): register intercept response rewrites as response events - #42327
wyattwalter wants to merge 1 commit into
Conversation
An intercept whose handler calls req.reply(callback) or
req.continue(callback) makes Cypress fail the running test or hook when
the browser aborts that request mid-response. cy.visit, cy.reload and
in-app navigation do that to any request still in flight, and
getConsolidatedDataApi registers such a handler on the consolidated-api
route for every test.
Register the rewrites with req.on("response") followed by req.continue()
through one helper. A completed response is rewritten exactly as before
and the most recent intercept on a route still wins; an aborted request
is dropped instead of failing a test that did not wait on it.
Covers the five response-callback intercepts in the shared support code:
four in FeatureFlags.ts and the product-alert intercept in commands.js.
https://linear.app/appsmith/issue/APP-16069
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: appsmithorg/appsmith/.coderabbit.yaml Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughCypress support code adds ChangesUpstream response rewriting
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to This test-support change preserves completed-response rewrites while allowing aborted requests to avoid failing unrelated tests. No actionable merge-blocking risk is established. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Requests travel upstream, then replies return. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Description
getConsolidatedDataApiregisters, for every test, acy.interceptonGET /api/v1/consolidated-api/*?*that rewrites the response throughreq.reply((res) => ...). Cypress treats a request with that kind of response callback as one the test is waiting on. When the browser aborts the request while its response is still arriving, which is whatcy.visit,cy.reloadand in-app navigation do to any request in flight, Cypress fails the running test or hook with a network error that names no spec code.This change registers the same rewrites with
req.on("response", ...)followed byreq.continue(), through one helper,rewriteUpstreamResponse. No error is filtered and no assertion changes:req.continue()still stops propagation, so the most recent intercept on a route still wins.Evidence, first-attempt logs of the scheduled release image test
Four retry events in 3 of the last 9 enterprise runs, none in 8 community runs. Each has a navigation command immediately before the error and recovers when the spec is repeated alone:
ME_CustomEnv_spec.ts,before allAudit_logs_EEAccess_spec.js, test 2cy.reload()thency.visit()FrameworkFunctions_NavigateToFunctions_spec.ts, test 3navigateToAudit_logs_EEAccess_spec.js, test 2cy.reload()thency.visit()Mechanism, read from the Cypress 13.13.0 driver
req.reply(callback)andreq.continue(callback)subscribe the callback asresponse:callback.req.on("response", callback)subscribes it asresponse. Both run through the same response handler, sores.send(...)behaves the same in either.response:callbacksubscription and no response has been handed to it yet.Cypress.on("uncaught:exception", () => false)insupport/e2e.jsdoes not apply: Cypress consults those listeners only for errors raised in the application frame, and this one is raised in the spec frame.Reproduced outside the suite
A standalone spec on Cypress 13.13.0 against a local HTTP server whose endpoint sends headers and part of the body, then stalls. The test starts a
fetch, then navigates withcy.visit.req.reply(callback), navigation mid-responseuncaught:exceptionhandler returningfalsereq.on("response", callback)+req.continue(), same navigationreq.on("response", callback)+req.continue(), completed responsecy.wait("@alias")yields the rewritten bodyA request aborted before any response byte arrives does not trigger the error in either form, which is why the failure is intermittent in the suite.
Repro spec and server
What the CI run on this PR can and cannot show
Every test in the suite goes through the consolidated-api rewrite, so a green
@tag.Allrun shows the rewrites still apply everywhere. It cannot show that the retries are gone, because the abort depends on request timing. That is read from the scheduled runs after merge: the error should stop appearing in first-attempt logs.One path is new: a test that calls
cy.wait("@getConsolidatedData")after its own navigation aborted a consolidated-api request can now be handed that aborted request by the wait. Before this change the same test had already failed at the abort.Call sites checked
Every
cy.intercepthandler underapp/client/cypressthat passes a callback toreq.replyorreq.continue:FeatureFlags.ts,getConsolidatedDataApiconsolidated-apifeatureFlagInterceptFeatureFlags.ts,featureFlagInterceptwithpreserveOtherFlagsusers/featuresFeatureFlags.ts,featureFlagInterceptForLicenseFlags(2)users/features,consolidated-apicommands.js,startServerAndRoutesproduct-alert/alertLicenseCommands.js(2)consolidated-apiprettierandeslint(thecypress/.eslintrc.jsonconfig) are clean on both files, and the helper type-checks against the Cypress 13.13.0 typings.Fixes https://linear.app/appsmith/issue/APP-16069
Automation
/ok-to-test tags="@tag.All"
🤖 Generated with Claude Code
Tip
🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/36982861836
Commit: 375a9cc
Cypress dashboard.
Tags:
@tag.AllSpec:
Fri, 02 Oct 2026 08:57:20 UTC
Summary by CodeRabbit