From 93c36c412ff1e7d0c3e0c954194533f6b9f31377 Mon Sep 17 00:00:00 2001 From: le king fu Date: Sun, 15 Nov 2026 12:47:02 -0500 Subject: [PATCH] test(web): the purge failure test no longer boots a second database (#203) The test started a second PGlite inside its body to get a real database error. Under load (every test file boots its own PGlite), that boot exceeded the 5 s test timeout: one run out of several failed on it. The real failure now comes from the database of the file, whose journal table is renamed for the time of one purge, with a control that the error does carry the text of the query that safePurge must not log. Co-Authored-By: Claude Fable 5.2 --- web/src/lib/agentJournal.test.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/web/src/lib/agentJournal.test.ts b/web/src/lib/agentJournal.test.ts index a03bef8..92ea9fe 100644 --- a/web/src/lib/agentJournal.test.ts +++ b/web/src/lib/agentJournal.test.ts @@ -358,9 +358,18 @@ describe('safePurge', () => { await expect(safePurge(() => Promise.reject('a string'), log)).resolves.toBeUndefined(); expect(lines).toEqual(['> Journal purge failed: QueryError', '> Journal purge failed: TypeError', '> Journal purge failed: Error']); - // A real failure: the table is not there. - const empty = drizzle(new PGlite()); - await expect(safePurge(() => purgeOldActions(empty, NOW), log)).resolves.toBeUndefined(); + // A real failure: the table is not there for the time of one purge. No + // second database is started for it: a PGlite that boots inside a test + // has exceeded the test timeout when the other files boot theirs. + await pg.exec('alter table sl_agent_actions rename to sl_agent_actions_away'); + try { + // Control: what safePurge has to hide. The query fails with its text. + const failure = await purgeOldActions(db, NOW).then(() => null, (error: Error) => error); + expect(failure?.message).toContain('sl_agent_actions'); + await expect(safePurge(() => purgeOldActions(db, NOW), log)).resolves.toBeUndefined(); + } finally { + await pg.exec('alter table sl_agent_actions_away rename to sl_agent_actions'); + } expect(lines).toHaveLength(4); expect(lines[3]).toMatch(/^> Journal purge failed: [A-Za-z]+$/); expect(lines.join('\n')).not.toMatch(/sl_agent_actions|delete|user-1|db-host/);