From 4e351bde9f891c2afbc45d888c08063745d5c323 Mon Sep 17 00:00:00 2001 From: Emma Mulitz Date: Wed, 29 Apr 2026 19:12:33 -0400 Subject: [PATCH] =?UTF-8?q?fix(test):=20add=20importOriginal=20to=20stripe?= =?UTF-8?q?-client=20vi.mock=20=E2=80=94=20restores=20integration=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #3548. Two integration tests vi.mock src/billing/stripe-client.js but the mock factories did not export listCustomersWithOrgIds. Server startup calls OrganizationDatabase.syncStripeCustomers which uses that method, threw at HTTPServer.start, broke every integration test that booted through these mocks. Fix: switch the mock factories to vitest's importOriginal pattern so partial mocks inherit real exports. listCustomersWithOrgIds (and any future stripe-client method) flow through automatically. Files: - server/tests/integration/content-my-content.test.ts - server/tests/integration/admin-endpoints.test.ts This unblocks the integration-tests CI job on #3540 and any future PR that adds tests booting the server through these mocks. --- .changeset/fix-stripe-mock-listcustomers.md | 4 ++++ server/tests/integration/admin-endpoints.test.ts | 8 ++++++-- server/tests/integration/content-my-content.test.ts | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 .changeset/fix-stripe-mock-listcustomers.md diff --git a/.changeset/fix-stripe-mock-listcustomers.md b/.changeset/fix-stripe-mock-listcustomers.md new file mode 100644 index 0000000000..9364a359ee --- /dev/null +++ b/.changeset/fix-stripe-mock-listcustomers.md @@ -0,0 +1,4 @@ +--- +--- + +Switch the `stripe-client` `vi.mock` factories in `content-my-content.test.ts` and `admin-endpoints.test.ts` to vitest's `importOriginal` pattern so unmocked exports (e.g. `listCustomersWithOrgIds` called from `OrganizationDatabase.syncStripeCustomers` during `HTTPServer.start`) flow through automatically and stop breaking integration tests. diff --git a/server/tests/integration/admin-endpoints.test.ts b/server/tests/integration/admin-endpoints.test.ts index 057d4c9344..9bbb89ac61 100644 --- a/server/tests/integration/admin-endpoints.test.ts +++ b/server/tests/integration/admin-endpoints.test.ts @@ -24,8 +24,12 @@ vi.mock('../../src/middleware/csrf.js', () => ({ csrfProtection: (_req: any, _res: any, next: any) => next(), })); -// Mock Stripe client to control subscription checks -vi.mock('../../src/billing/stripe-client.js', () => ({ +// Mock Stripe client to control subscription checks. Use importOriginal so +// any unmocked exports (e.g. listCustomersWithOrgIds called from +// OrganizationDatabase.syncStripeCustomers during HTTPServer.start) flow +// through to the real implementation instead of throwing. +vi.mock('../../src/billing/stripe-client.js', async (importOriginal) => ({ + ...(await importOriginal()), stripe: null, getSubscriptionInfo: vi.fn().mockResolvedValue(null), createStripeCustomer: vi.fn().mockResolvedValue(null), diff --git a/server/tests/integration/content-my-content.test.ts b/server/tests/integration/content-my-content.test.ts index 83d4799342..871107dbb8 100644 --- a/server/tests/integration/content-my-content.test.ts +++ b/server/tests/integration/content-my-content.test.ts @@ -66,7 +66,11 @@ vi.mock('../../src/addie/mcp/admin-tools.js', async (importOriginal) => { }; }); -vi.mock('../../src/billing/stripe-client.js', () => ({ +// Use importOriginal so any unmocked exports (e.g. listCustomersWithOrgIds +// called from OrganizationDatabase.syncStripeCustomers during HTTPServer.start) +// flow through to the real implementation instead of throwing. +vi.mock('../../src/billing/stripe-client.js', async (importOriginal) => ({ + ...(await importOriginal()), stripe: null, getSubscriptionInfo: vi.fn().mockResolvedValue(null), createStripeCustomer: vi.fn().mockResolvedValue(null),