fix: avoid Cypress socket errors in layout intercepts#4318
Conversation
📝 WalkthroughWalkthroughThe ChangesinterceptLayout Response Handling
Estimated code review effort: 1 (Trivial) | ~5 minutes Related issues: None found in the provided context. Related PRs: None found in the provided context. Suggested labels: test, e2e Suggested reviewers: None specified. 🐰 A tiny hop, a small rewrite, 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/e2e/support/custom.ts (1)
525-525: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
setis implicitly typedany.
res.bodyis typedanyby Cypress'sCyHttpMessages.BaseMessage, soset(and downstream usages likeObject.values(set)) carry no type safety. This predates this change (same gap existed withreq.reply), but since the line is being touched, consider specifying the response generic (e.g.req.on<Record<string, ILayoutFile>>('before:response', ...)if supported by the Cypress version, or an explicit local type annotation) to avoidanypropagating through the mutation logic.As per coding guidelines, "Avoid using
anyor type casting (as type) in TypeScript; instead, improve typing by removing such casts andanys to maintain proper type safety."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/e2e/support/custom.ts` at line 525, The touched response parsing in custom.ts currently lets `set` inherit `any` from `res.body`, so the mutation logic loses type safety. Update the `before:response` handling around `req.on`/`req.reply` to use a concrete response type or an explicit local annotation for the parsed body (for example, a record of layout files) so `set` and downstream `Object.values(set)` remain strongly typed without `any` propagation.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@test/e2e/support/custom.ts`:
- Line 525: The touched response parsing in custom.ts currently lets `set`
inherit `any` from `res.body`, so the mutation logic loses type safety. Update
the `before:response` handling around `req.on`/`req.reply` to use a concrete
response type or an explicit local annotation for the parsed body (for example,
a record of layout files) so `set` and downstream `Object.values(set)` remain
strongly typed without `any` propagation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0c4f42cf-b65b-457b-943b-cd25f067e9af
📒 Files selected for processing (1)
test/e2e/support/custom.ts
Description
Updates the Cypress layout intercept helper used by several frontend tests so it mutates backend layout responses in the
before:responsehook instead of replying with a rewritten response.This is intended to reduce sporadic PDF test failures where Cypress reports
Socket closed before finished writing responsefor cancelled or abandoned intercepted requests. The error matches an open upstream Cypress issue: cypress-io/cypress#26248.The recurring failure has been observed in
test/e2e/integration/frontend-test/pdf.ts, specifically the"should generate PDF for changename step"test. The failure has been seen repeatedly in tt02 runs forGET **/api/layouts/changename, while the other PDF tests have not shown the same pattern.No application functionality is changed.
Related Issue(s)
None.
Verification/QA
kind/*andbackport*label to this PR for proper release notes groupingSummary by CodeRabbit