test(integration): un-skip 11 of 13 stale integration files (#3289)#3313
Merged
Conversation
The integration suite landed in #3292 with 13 files dark behind describe.skip / --exclude, surfacing as #3289. This walks through every umbrella item: * auth-mock cluster (8 files) — vi.mock factory was returning a partial auth.js shape, so HTTPServer setup tripped on the missing optionalAuth import. Switched to importOriginal + override; spread the real exports so future auth additions don't re-break tests. Added matching csrfProtection mocks so POST/PUT/DELETE no longer 403 on missing X-CSRF-Token. * admin-sync-revenue-backfill, self-service-delete — were excluded from the script because vi.mock factories referenced top-level vars that aren't live until after factory hoisting. Moved shared state into vi.hoisted blocks; rewrote the WorkOS class mock so every `new WorkOS()` returns the same shared instance methods, so per-test mockImplementation overrides actually retarget the right spy. Removed --exclude flags from test:server-integration. * health.test.ts — dropped the stale (server as any).registry.initialize() beforeAll (HTTPServer no longer exposes registry) and the two database-init tests that exercised it; kept the GET /health checks that still match the live response shape. * mcp-protocol — bearer-auth gate cleared via MCP_AUTH_DISABLED at module-load time; the file now stays describe.skip pending an SSE- format response-parser update (the only remaining blocker is the StreamableHTTP transport returning text/event-stream by default). * schema-routing — replaced localeCompare(numeric: true) with semver.rcompare so the test's idea of "latest in 3.x" matches the alias-rewrite middleware (which prefers stable over prerelease at the same X.Y.Z). * digest-email-recipients — counts were hardcoded to a track-B size of 3; the cert curriculum grew to 4. Read the live count out of certification_modules so the test tracks curriculum changes. * member-db — logo_url / brand_color / etc. aren't part of CreateMemberProfileInput anymore; the create handler doesn't persist them. Test reduced to the documented input contract. * agent-visibility-e2e — fixed `src/db/migrations/...` path to `server/src/db/migrations/...` so the legacy-shape test reads the migration file CI ships. * WORKOS_COOKIE_PASSWORD added to revenue-tracking-env.ts setup so AUTH_ENABLED resolves true in tests where production code reaches for `workos!.userManagement` and would otherwise hit a null deref. Result: 46 / 50 integration files green (was 35), 596 tests pass (was 465), 71 still skipped (was 139), 0 failures. Remaining file-level skips and per-test skips have richer comments pointing to #3289 with concrete next-step descriptions. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| }; | ||
| }); | ||
|
|
||
| const { FAKE_INVOICE, mockInvoicesList, mockCustomersRetrieve, mockProductsRetrieve } = mocks; |
| }; | ||
| }); | ||
|
|
||
| const { FAKE_INVOICE, mockInvoicesList, mockCustomersRetrieve, mockProductsRetrieve } = mocks; |
This was referenced Apr 26, 2026
bokelley
added a commit
that referenced
this pull request
Apr 27, 2026
…mock (#3327) * test(integration): un-skip revenue-tracking via fuller stripe-client mock Adds vi.hoisted + vi.mock for stripe-client following the pattern from admin-sync-revenue-backfill.test.ts (#3313). The webhook route guard requires both stripe and STRIPE_WEBHOOK_SECRET to be non-null; the mock satisfies both. products.retrieve rejects so the handler exercises its description-fallback path. Removes the stale dead-code block in beforeAll that attempted to patch the live stripe object at runtime — this was a no-op since stripe was null, and became a mock-overwrite bug after the vi.mock was added. Refs #3318. Part of #3289 integration-test restoration. https://claude.ai/code/session_01DZZ43na714gw4EYgJ5dJUQ * test(integration): align revenue-tracking stats assertions with current behavior formatCurrency in server/src/routes/admin/stats.ts rounds to whole dollars for dashboard display (10998¢ → \$110, 5998¢ → \$60). Test was asserting cent-precision strings ('\$109.98', '\$59.98') which no longer match. Update expectations. MRR test: live MRR query reads from revenue_events (DISTINCT ON stripe_subscription_id, period_end > NOW(), revenue_type IN subscription_initial/recurring), not from columns on the organizations table. Replace the UPDATE with a properly-shaped revenue_event INSERT. Refunds + product-breakdown tests also pick up the formatter rounding. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
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.
Summary
Walks through the umbrella in #3289 and un-skips everything that doesn't need a deeper architectural shift. +11 files un-skipped, +131 tests now run in CI, 0 failures.
--exclude)* Plus
user-context(file-skip) andimpersonation-audit(only the chat-driven describe is skipped — the schema describe runs).What's in this PR
Auth-mock cluster (8 files). Old pattern:
…silently dropped every other auth.js export. HTTPServer setup imports
optionalAuthand crashes during route registration → all 28 tests in admin-endpoints (etc.) get reported asskippedunder afailedsuite. Switched to:Future auth additions don't re-break tests. CSRF middleware also gets a passthrough mock so POST/PUT/DELETE stop hitting
403 forbiddenon the missingX-CSRF-Tokencookie.vi.hoistedfor the excluded files.admin-sync-revenue-backfillandself-service-deleteerrored at module-eval time becausevi.mockfactories referenced top-level vars that aren't live until after factory hoisting. Shared mock state moves intovi.hoisted({...}). The WorkOS class mock now wires everynew WorkOS()to the same shared instance methods, so per-testmockImplementationoverrides retarget the right spy.--excludeflags are removed fromtest:server-integration.health.test.ts. Dropped the stale(server as any).registry.initialize()beforeAll—HTTPServerno longer exposes.registry. The two failing-init tests went with it; the GET /health checks still match the live response shape.mcp-protocol.test.ts. Bearer-auth gate cleared viaMCP_AUTH_DISABLED=trueat module-load. Staysdescribe.skippending an SSE-format response-parser update — only blocker now isContent-Type: text/event-streamon the StreamableHTTP transport.schema-routing.test.ts. ReplacedlocaleCompare(numeric: true)withsemver.rcompareso the test's "latest in 3.x" matches the alias-rewrite middleware (which prefers stable over prerelease at the same X.Y.Z).digest-email-recipients.test.ts. Track-B counts were hardcoded to 3; the cert curriculum grew to 4. Reads the live count out ofcertification_modulesso the test tracks curriculum changes instead of breaking on them.member-db.test.ts.logo_url/brand_coloretc. aren't part ofCreateMemberProfileInputanymore and the create handler doesn't persist them. Test reduced to the documented input contract.agent-visibility-e2e.test.ts. Fixedsrc/db/migrations/...path →server/src/db/migrations/....Test env.
WORKOS_COOKIE_PASSWORDset inrevenue-tracking-env.tssetup soAUTH_ENABLEDresolves true andworkos!.userManagementis non-null in tests that reach for it.Remaining (still tracked in #3289)
mcp-protocol.test.ts— needs SSE-format parserrevenue-tracking.test.ts— needs fuller stripe-client mock (webhooks.constructEvent+ invoice/customer fixtures)user-context.test.ts(WorkOS-path tests) — needs richer WorkOS user-lookup mockimpersonation-audit.test.ts(chat-driven describe) — needs working AddieClaudeClient init or refactor to unit-level coverage of audit-log helpersjoin-request-approvalandpersonal-workspace-restrictions— 9 individualit.skiptests that need a per-file@workos-inc/nodeclass mock so handlers' directworkos!.userManagement.*calls don't 401 against real WorkOSPer-test skips now have inline comments describing exactly what blocks them, so the next person picking up #3289 can jump straight in.
Test plan
Server integration testsjob goes green on this PR.npm run test:server-integrationagainst a local Postgres reproduces 596 passed / 71 skipped.🤖 Generated with Claude Code