mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 21:10:59 +00:00
test(integration): keep two cases independent of file order and random ids
The backup schedule case assumed the shared database had no queue schema, but files that drive the queue create it and one leaves a finished backup run behind, so the case failed whenever it ran after them. It now clears that queue's history first. The delegate refusal case scanned the raw response for a digit run that the random request id can contain; the id is taken out before the scan.
This commit is contained in:
1 parent
b4618f2ec3
commit
23bc58660d
2 files changed
+19
-7
No files matched your search
@@ -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<Array<{ t: string | null }>>`
|
||||
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);
|
||||
});
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in new issue
Block a user