Skip to content

Commit 299afbe

Browse files
Shawclaude
andcommitted
fix(cloud-shared): preserve real db/schemas exports in mock.module calls
Three service tests used mock.module("db/schemas", ...) with only a hand-picked subset of table refs. Because Bun's mock.module is process-global and keyed by absolute path, the partial mock leaked into later tests in the same test:cloud run. Downstream code that imported apps.ts (the repository) then crashed with: SyntaxError: Export named 'appAnalytics' not found in module '.../db/schemas/index.ts' Spread the real schemas module into each mock so every export remains defined; only the table refs the test specifically wants to stub are overridden. Fixes Cloud Tests CI failures in stripe-event-helpers, mcp-proxy-helpers, and a2a-agent-card. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5f51d82 commit 299afbe

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

packages/cloud-shared/src/lib/services/agent-gateway-router.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { beforeEach, describe, expect, mock, test } from "bun:test";
22

3+
import * as realDbSchemas from "../../db/schemas";
4+
35
const findByPhoneNumberWithOrganization = mock();
46
const listByOrganization = mock();
57
const findRunningSandbox = mock();
@@ -72,6 +74,7 @@ mock.module("../../db/repositories/agent-sandboxes", () => ({
7274
}));
7375

7476
mock.module("../../db/schemas", () => ({
77+
...realDbSchemas,
7578
anonymousSessions: {},
7679
agentPhoneContacts: {
7780
agent_id: "contact_agent_id",

packages/cloud-shared/src/lib/services/message-router/index.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { beforeEach, describe, expect, mock, test } from "bun:test";
22

3+
import * as realDbSchemas from "../../../db/schemas";
4+
35
const blooioApiRequest = mock();
46
const secretsGet = mock();
57
const insertValues = mock();
@@ -26,6 +28,7 @@ mock.module("../../../db/client", () => ({
2628
}));
2729

2830
mock.module("../../../db/schemas", () => ({
31+
...realDbSchemas,
2932
anonymousSessions: {},
3033
agentPhoneContacts: {
3134
provider: "provider",

packages/cloud-shared/src/lib/services/phone-gateway-devices.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { beforeEach, describe, expect, mock, test } from "bun:test";
22

3+
import * as realDbSchemas from "../../db/schemas";
4+
35
const values = mock();
46
const onConflictDoUpdate = mock();
57
const returning = mock();
@@ -26,6 +28,7 @@ mock.module("../../db/client", () => ({
2628
}));
2729

2830
mock.module("../../db/schemas", () => ({
31+
...realDbSchemas,
2932
anonymousSessions: {},
3033
agentPhoneContacts: {
3134
provider: "provider",

0 commit comments

Comments
 (0)