Skip to content

Commit 00c210b

Browse files
committed
Merge remote-tracking branch 'origin/feat/dashboard-agent-flows-watch' into feat/dashboard-agent-flows-watch
2 parents accc651 + bddae8c commit 00c210b

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

apps/webapp/test/dashboardAgentWatches.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ const ctx = vi.hoisted(() => ({
5151
agentDb: undefined as unknown as DashboardAgentDb,
5252
canAccess: true,
5353
actor: undefined as undefined | { userId: string; client?: string; environmentId?: string },
54+
/** Every task id the suite would have triggered for real. */
55+
triggered: [] as string[],
5456
}));
5557

5658
vi.mock("~/services/uatRoutePreamble.server", () => ({
@@ -84,6 +86,23 @@ vi.mock("~/v3/canAccessDashboardAgent.server", () => ({
8486
canAccessDashboardAgent: async () => ctx.canAccess,
8587
}));
8688

89+
// The routes drive the real service, which builds a TriggerClient from .env — so an unmocked
90+
// suite triggers actual runs against whatever origin .env names.
91+
vi.mock("@trigger.dev/sdk", async (importOriginal) => {
92+
const actual = await importOriginal<typeof import("@trigger.dev/sdk")>();
93+
return {
94+
...actual,
95+
TriggerClient: class {
96+
tasks = {
97+
trigger: async (taskId: string) => {
98+
ctx.triggered.push(taskId);
99+
return { id: "run_test" };
100+
},
101+
};
102+
},
103+
};
104+
});
105+
87106
const SESSION_SECRET = "test-session-secret-for-watch-tokens";
88107
process.env.SESSION_SECRET = SESSION_SECRET;
89108
// The agent's subscribe endpoint refuses without an email transport configured.
@@ -1594,6 +1613,9 @@ describe("the check endpoint", () => {
15941613
const body = await response.json();
15951614
expect(body.result).toBe("terminal_unsatisfied");
15961615

1616+
// Arming the chain goes through the stubbed client, never a real trigger.
1617+
expect(ctx.triggered).toContain("dashboard-agent-watch-batch");
1618+
15971619
const row = await getWatch(ctx.agentDb, { id: watch.watchId });
15981620
expect(row?.lastCheckedAt).not.toBeNull();
15991621
expect(row?.tickCount).toBe(0);

0 commit comments

Comments
 (0)