support explicit event push and hybrid for more cases#894
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository: lokalise/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe PR adds Server-Sent Events (SSE) mocking capabilities to the universal testing utilities library. A new Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/app/universal-testing-utils/src/MswHelper.ts`:
- Around line 489-494: The REST branch handler registered with server.use using
http[method] passes params.responseCode directly to HttpResponse.json which can
be undefined; update that call in the http[method](...) handler to supply a
default (e.g. params.responseCode ?? 200) so the status is guaranteed, keeping
the same request handling via params.handleRequest and HttpResponse.json.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: lokalise/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d8afd6f5-6e25-4c94-8591-64ef57749af8
📒 Files selected for processing (4)
packages/app/universal-testing-utils/README.mdpackages/app/universal-testing-utils/src/MswHelper.spec.tspackages/app/universal-testing-utils/src/MswHelper.tspackages/app/universal-testing-utils/src/index.ts
| server.use( | ||
| http[method](resolvedPath, async (requestInfo) => { | ||
| return HttpResponse.json(await params.handleRequest(requestInfo), { | ||
| status: params.responseCode, | ||
| }) | ||
| }), |
There was a problem hiding this comment.
Missing default for responseCode in REST branch.
The dual-mode branch uses params.responseCode ?? 200, but the REST branch passes params.responseCode directly without a default. If responseCode is undefined, this passes undefined to HttpResponse.json, which may cause unexpected behavior.
🔧 Proposed fix
server.use(
http[method](resolvedPath, async (requestInfo) => {
return HttpResponse.json(await params.handleRequest(requestInfo), {
- status: params.responseCode,
+ status: params.responseCode ?? 200,
})
}),
)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| server.use( | |
| http[method](resolvedPath, async (requestInfo) => { | |
| return HttpResponse.json(await params.handleRequest(requestInfo), { | |
| status: params.responseCode, | |
| }) | |
| }), | |
| server.use( | |
| http[method](resolvedPath, async (requestInfo) => { | |
| return HttpResponse.json(await params.handleRequest(requestInfo), { | |
| status: params.responseCode ?? 200, | |
| }) | |
| }), |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/app/universal-testing-utils/src/MswHelper.ts` around lines 489 -
494, The REST branch handler registered with server.use using http[method]
passes params.responseCode directly to HttpResponse.json which can be undefined;
update that call in the http[method](...) handler to supply a default (e.g.
params.responseCode ?? 200) so the status is guaranteed, keeping the same
request handling via params.handleRequest and HttpResponse.json.
Changes
Support pushing events on demand and support hybrid mode for more use-cases
Checklist
major,minor,patchorskip-releaseAI Assistance Tracking
We're running a metric to understand where AI assists our engineering work. Please select exactly one of the options below:
Mark "Yes" if AI helped in any part of this work, for example: generating code, refactoring, debugging support,
explaining something, reviewing an idea, or suggesting an approach.