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),