OUT-3986: MSW harness + error-shape reproduction#120
Open
SandipBajracharya wants to merge 5 commits into
Open
Conversation
Mock Service Worker (2.x) fakes Dropbox + Copilot at the HTTP boundary for the integration test suite. Dev-only; no production dependency. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…dary Fake the Dropbox (rpc + content) and Copilot hosts with MSW so integration tests drive the real SDK clients without network access: - server + base handlers (ambient OAuth refresh, empty list_folder/listFiles) - per-test override helpers (mockDropboxRpc / mockDropboxContent / mockCopilot) - error-shape builders reproducing the errors production branches on (isCopilotApiError 400/404; DropboxResponseError 409 not_found) by returning HTTP responses the real SDKs turn into those errors - cursor / nextToken pagination helpers - a self-test driving the real clients to prove every shape reproduces Wire the MSW lifecycle into the integration setup (onUnhandledRequest: 'error'), point DROPBOX_API_URL at the content host, set COPILOT_ENV=local so the Copilot SDK trusts the placeholder apiKey, and inline copilot-node-sdk in Vitest to resolve its ESM directory import. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a scoped noRestrictedImports rule: files under src/ (excluding co-located tests) may not import the test harness or test files (test/**, **/__tests__/**, *.test.*). Keeps test-only code out of the production bundle. Test files are exempt and keep full import freedom. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR adds an MSW-based HTTP harness for Dropbox and Copilot integration tests. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (2): Last reviewed commit: "fix(OUT-3986): treat *.spec files as tes..." | Re-trigger Greptile |
A pageSize of 0 (or negative / non-integer) made slice return no entries, so nextOffset never advanced while has_more stayed true — a consumer following the cursor/nextToken would loop on the same page until timeout. Both paginators now fail fast with a clear error, and a guard test covers it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The unit config recognizes src/**/*.spec.ts as tests, but the noRestrictedImports override only exempted *.test.ts/tsx — so a co-located *.spec file importing a test/ helper was wrongly flagged as production. Exempt *.spec.ts/tsx on the importer side and add *.spec.* to the banned import targets, so .spec and .test are handled uniformly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator
Author
|
@greptileai review |
priosshrsth
approved these changes
Jul 21, 2026
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.
OUT-3986 — L0.2: MSW harness + error-shape reproduction
Fakes Dropbox (rpc + content) and Copilot (
api.copilot.app) at the HTTP boundary with MSW, so integration tests drive the real SDK clients — and their real error-construction paths — without touching the network.What's included
setupServerwithonUnhandledRequest: 'error', wired into the integration setup; per-test overrides reset between tests.list_folder/list_folder/continue, emptylistFiles.mockDropboxRpc/mockDropboxContent/mockCopilot(correctly host/method-scoped).isCopilotApiErrorat 400 (body.message === 'Folder already exists') and 404DropboxResponseErrorat 409 witherror.error.path['.tag'] === 'not_found'anderror_summarystartingpath_lookup/not_foundlist_folder) andnextToken(listFiles).test/msw/msw-harness.integration.test.ts) — drives the real clients over both transports (node-fetch + undici) to prove every shape reproduces.Supporting changes
DROPBOX_API_URL→ content host (keeps the two Dropbox hosts distinct);COPILOT_ENV=localso the Copilot SDK trusts the placeholder apiKey;copilot-node-sdkinlined in Vitest to resolve its ESM directory import.noRestrictedImportsrule forbids productionsrc/code from importing test files / the harness (test/**,**/__tests__/**,*.test.*). Test files are exempt.Scope
Mechanism only — typed data factories/seeders (L0.3), clock control (L0.4), and CI wiring (L0.5) are separate issues.
Verification
typecheckclean ·lintclean.🤖 Generated with Claude Code