Skip to content

Commit 8bb665e

Browse files
committed
test(webapp): close the watch tenancy suite's agent db pool
The file the review comment named was missed: it opened a pool per case and never closed one. Adds the sibling files' afterEach and their 30s case timeout.
1 parent bd3190f commit 8bb665e

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

apps/webapp/test/dashboardAgentWatchTenancy.test.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { postgresTest } from "@internal/testcontainers";
1818
import type { PrismaClient } from "@trigger.dev/database";
1919
import { readdirSync, readFileSync } from "node:fs";
2020
import path from "node:path";
21-
import { beforeEach, describe, expect, vi } from "vitest";
21+
import { afterEach, beforeEach, describe, expect, vi } from "vitest";
2222
import type { WatchCheckDeps, WatchRunRow } from "~/services/dashboardAgentWatchChecks";
2323

2424
const ctx = vi.hoisted(() => ({
@@ -105,6 +105,11 @@ beforeEach(() => {
105105
enqueue.mockClear();
106106
});
107107

108+
afterEach(async () => {
109+
await agentDbClient?.close();
110+
agentDbClient = undefined;
111+
});
112+
108113
function suffix() {
109114
return Math.random().toString(36).slice(2, 10);
110115
}
@@ -262,7 +267,8 @@ describe("the submission ledger's tenancy", () => {
262267
// Each chat belongs to exactly one organization, so neither is readable as the other.
263268
expect(await messagesIn(inSecond.chatId, first.organization.id, first.user.id)).toBeNull();
264269
expect(await messagesIn(inFirst.chatId, second.organization.id, second.user.id)).toBeNull();
265-
}
270+
},
271+
30_000
266272
);
267273

268274
postgresTest(
@@ -297,7 +303,8 @@ describe("the submission ledger's tenancy", () => {
297303
clientRequestId: "wreq_1",
298304
});
299305
expect(recorded).toMatchObject({ environmentId: seeded.environment.id });
300-
}
306+
},
307+
30_000
301308
);
302309

303310
postgresTest(
@@ -330,7 +337,8 @@ describe("the submission ledger's tenancy", () => {
330337
expect(
331338
await prisma.projectAlertChannel.count({ where: { projectId: seeded.project.id } })
332339
).toBe(0);
333-
}
340+
},
341+
30_000
334342
);
335343

336344
postgresTest(
@@ -376,7 +384,8 @@ describe("the submission ledger's tenancy", () => {
376384
if (!retry.ok) return;
377385
expect(retry.repaired).toBe(true);
378386
expect(JSON.stringify(retry.messages[1])).toContain(line);
379-
}
387+
},
388+
30_000
380389
);
381390
});
382391

@@ -431,7 +440,8 @@ describe("the fire callback", () => {
431440
(call) => (call[0] as { job: string }).job === "v3.deliverDashboardAgentWatchAlert"
432441
);
433442
expect(alerts).toHaveLength(1);
434-
}
443+
},
444+
30_000
435445
);
436446
});
437447

@@ -511,6 +521,7 @@ describe("the alert unsubscribe", () => {
511521
enabled: false,
512522
alertTypes: [],
513523
});
514-
}
524+
},
525+
30_000
515526
);
516527
});

0 commit comments

Comments
 (0)