feat: support navigate requests - #2721
Merged
Merged
Conversation
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
commit: |
This was referenced Apr 17, 2026
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@test/browser/rest-api/navigate.mocks.ts`:
- Around line 4-14: The test setup calls setupWorker() and invokes
worker.start() without awaiting it, causing races where the Service Worker may
not be active when tests run; change the module to await worker.start() before
attaching msw to window so interception is guaranteed — specifically, ensure the
code that calls worker.start() (the worker.start() invocation created from
setupWorker()) is awaited and only after that call completes perform
Object.assign(window, { msw: { worker, http, HttpResponse } }); keep the same
symbols (setupWorker, worker, worker.start, Object.assign(window, ...)) so the
change is localized.
In `@test/browser/rest-api/navigate.test.ts`:
- Line 52: Replace the placeholder test.fixme for the test titled "bypasses an
unhandled form submission request" with a real test that ensures an unhandled
navigation/form submission is passed through to the network: create a form in
the test page (method POST or GET, with an action that points to your test
server endpoint), do a programmatic submit or user-like click to trigger
navigation, do NOT register any route/handler that matches that navigation, then
assert the test server received the form request (inspect method, body or query)
and that the page navigated to the server response (status/response body or URL)
— implement these checks in the test replacing test.fixme so the pass-through
path is covered.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: d59b62b7-027f-4726-9344-b0378790b5f4
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (7)
package.jsonsrc/browser/utils/deserializeRequest.tssrc/browser/utils/pruneGetRequestBody.test.tssrc/browser/utils/pruneGetRequestBody.tssrc/mockServiceWorker.jstest/browser/rest-api/navigate.mocks.tstest/browser/rest-api/navigate.test.ts
💤 Files with no reviewable changes (3)
- src/browser/utils/pruneGetRequestBody.test.ts
- src/browser/utils/pruneGetRequestBody.ts
- src/mockServiceWorker.js
kettanaito
marked this pull request as ready for review
April 20, 2026 11:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warning
Technically, a breaking change since this changes the worker script.
navigaterequests #1594Changes
Supports intercepting
mode: 'navigate'requests, which includes:Important
Service Workers cannot intercept cross-origin requests, which includes form submissions. If your form's
actionpoints to a different host, that submission will not be visible to the worker.Todos
FetchRequestto@mswjs/interceptors(fix: addFetchRequestutility interceptors#773).requestshape test case (exposes correct request method/URL andmode).