Skip to content

support explicit event push and hybrid for more cases#894

Merged
kibertoad merged 2 commits intomainfrom
feat/expand-sse
Mar 19, 2026
Merged

support explicit event push and hybrid for more cases#894
kibertoad merged 2 commits intomainfrom
feat/expand-sse

Conversation

@kibertoad
Copy link
Copy Markdown
Collaborator

Changes

Support pushing events on demand and support hybrid mode for more use-cases

Checklist

  • Apply one of following labels; major, minor, patch or skip-release
  • I've updated the documentation, or no changes were necessary
  • I've updated the tests, or no changes were necessary

AI 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.

  • Yes, AI assisted with this PR
  • No, AI did not assist with this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 19, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: lokalise/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e2c7cde0-7545-470f-af7e-951ad75395ee

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR adds Server-Sent Events (SSE) mocking capabilities to the universal testing utilities library. A new mockSseStream API is introduced that returns an SseEventController for on-demand SSE event emission. The existing mockValidResponseWithImplementation method is extended to support dual-mode contracts that route requests based on the Accept header, serving either JSON responses via handleRequest or SSE streams. Documentation is updated to reflect these additions, and comprehensive test coverage is included for both new APIs and existing functionality under dual-mode scenarios.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main changes: adding support for on-demand event pushing (mockSseStream) and extending hybrid/dual-mode support to more cases (mockValidResponseWithImplementation for dual-mode).
Description check ✅ Passed The description includes all required template sections: Changes section describing the work, completed Checklist with release label and update confirmations, and AI Assistance Tracking with appropriate selection.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/expand-sse
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between d3fff12 and 625ea86.

📒 Files selected for processing (4)
  • packages/app/universal-testing-utils/README.md
  • packages/app/universal-testing-utils/src/MswHelper.spec.ts
  • packages/app/universal-testing-utils/src/MswHelper.ts
  • packages/app/universal-testing-utils/src/index.ts

Comment on lines +489 to +494
server.use(
http[method](resolvedPath, async (requestInfo) => {
return HttpResponse.json(await params.handleRequest(requestInfo), {
status: params.responseCode,
})
}),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
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.

@kibertoad kibertoad merged commit c11bdb7 into main Mar 19, 2026
6 checks passed
@kibertoad kibertoad deleted the feat/expand-sse branch March 19, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants