Skip to content

Commit bd3190f

Browse files
committed
test(webapp): let the chat-ordering test load where the route reaches ClickHouse
The chat route now pulls in the watch services, and through them a ClickHouse client built at import time from an unset env var.
1 parent e110e90 commit bd3190f

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

apps/webapp/test/dashboardAgentCreateChatOrdering.test.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,27 @@ vi.mock("~/models/runtimeEnvironment.server", () => ({
2929
}));
3030
vi.mock("~/services/dashboardAgent.server", () => ({
3131
dashboardAgentApiOrigin: () => "https://api.trigger.dev",
32+
dashboardAgentWakeFeedCounter: { inc: vi.fn() },
3233
isDashboardAgentConfigured: () => true,
3334
mintDashboardAgentToken: async () => "pat_public",
3435
mintDashboardAgentUserActorToken: mocks.mintUserActorToken,
3536
resolveDashboardAgentRepoSnapshot: async () => null,
3637
startDashboardAgentSession: async () => {},
3738
}));
39+
// The chat route reaches the ClickHouse factory through the watch services, and the factory
40+
// builds its client at import time from an env var no test sets.
41+
vi.mock("~/services/clickhouse/clickhouseFactoryInstance.server", () => ({
42+
clickhouseFactory: { getClickhouseForOrganization: async () => ({}) },
43+
}));
3844
vi.mock("~/services/dashboardAgentHeadStart.server", () => ({
3945
startDashboardAgentHeadStart: mocks.headStart,
4046
}));
4147
vi.mock("~/services/dashboardAgentDb.server", () => ({ dashboardAgentDb: {} }));
4248
vi.mock("~/services/resolveTriggerUri.server", () => ({ resolveTriggerUri: () => null }));
43-
vi.mock("@internal/dashboard-agent-db", () => ({
44-
chatExists: vi.fn(),
45-
countUserMessages: vi.fn(),
49+
// Spread the real module so this doesn't have to track every query the route imports.
50+
vi.mock("@internal/dashboard-agent-db", async (importOriginal) => ({
51+
...((await importOriginal()) as Record<string, unknown>),
4652
createChat: mocks.createChat,
47-
getChatMessages: vi.fn(),
48-
getSession: vi.fn(),
49-
listChatIdsWithOpenInvestigations: vi.fn(),
50-
listChats: vi.fn(),
51-
renameChat: vi.fn(),
52-
setChatPinned: vi.fn(),
53-
softDeleteChat: vi.fn(),
5453
}));
5554
vi.mock("~/services/logger.server", () => ({
5655
logger: { debug: vi.fn(), error: vi.fn(), warn: vi.fn(), info: vi.fn() },

0 commit comments

Comments
 (0)