diff --git a/tests/integration/admin-backups-audit.test.ts b/tests/integration/admin-backups-audit.test.ts index 1417525e0..0a68fd32a 100644 --- a/tests/integration/admin-backups-audit.test.ts +++ b/tests/integration/admin-backups-audit.test.ts @@ -225,6 +225,16 @@ describe("GET /api/admin/backups — schedule health", () => { data: { userId: admin.id, type: "MANUAL_UPLOAD_1", data: blob }, }); + // Files that drive the queue create the `pgboss` schema in the shared + // database, and one of them leaves a finished backup run behind. Clear + // that queue's history so this case reads the same in every file order. + const [queueTable] = await prisma.$queryRaw>` + SELECT to_regclass('pgboss.job')::text AS t + `; + if (queueTable?.t) { + await prisma.$executeRaw`DELETE FROM pgboss.job WHERE name = 'data-backup'`; + } + // The listing handler declares no parameters; `apiHandler` reads the // request defensively out of its arguments, so calling it bare is what a // zero-argument handler supports. @@ -255,9 +265,9 @@ describe("GET /api/admin/backups — schedule health", () => { expect(body.data.schedule.lastSuccessAgeDays).toBe(46); expect(body.data.schedule.stale).toBe(true); - // No `pgboss` schema in the test database — the run reader fails soft to - // null rather than taking the whole page down, which is the arm a web-only - // deployment lives on permanently. + // No remembered run, or no `pgboss` schema at all — the run reader fails + // soft to null rather than taking the whole page down, which is the arm a + // web-only deployment lives on permanently. expect(body.data.schedule.lastRun).toBeNull(); expect(body.data.schedule.lastRunFailed).toBe(false); }); diff --git a/tests/integration/mood-context-linkage.test.ts b/tests/integration/mood-context-linkage.test.ts index 13db69e77..e3230ec3f 100644 --- a/tests/integration/mood-context-linkage.test.ts +++ b/tests/integration/mood-context-linkage.test.ts @@ -524,10 +524,12 @@ describe("mood context linkage (real Postgres)", () => { expect(res.status).toBe(403); const raw = await res.text(); // Asserted on the bytes, not on a parsed field: the point is that not one - // of the owner's figures reached the response. - expect(raw).not.toContain("7777"); - expect(raw).not.toContain("55"); - expect(raw).not.toContain("functionalImpact"); + // of the owner's figures reached the response. The request id is random + // and can contain any digit run, so it is taken out before the check. + const bytes = raw.replace(/"requestId":"[^"]*"/, ""); + expect(bytes).not.toContain("7777"); + expect(bytes).not.toContain("55"); + expect(bytes).not.toContain("functionalImpact"); }); it("refuses a malformed day", async () => {