Deflake the collab restore-listener DB test (poll for the PRE_RESTORE row)
All checks were successful
CD / Build and push images (push) Successful in 1m49s
CD / Deploy to Test (push) Successful in 9s
CD / Smoke tests against Test (push) Successful in 1m10s
CD / Promote to Int (push) Successful in 10s
CI / Lint, typecheck, test (push) Successful in 3m52s
CI / Build container images (push) Has been skipped
CI / Auth e2e pack (push) Successful in 5m32s
CI / Import/export fidelity gate (push) Successful in 47s

The client converges on the restored content via the broadcast INSIDE the
document transact — before the listener commits the PRE_RESTORE version
row. Asserting the row immediately after convergence is a race that CI
lost on the #104 run; poll for it instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EwZ4jR4KFAPvpjWevfUGX1
This commit is contained in:
Claude Fable 5 2026-07-12 11:23:18 +02:00
parent 0c85293830
commit 52975bad0a

View File

@ -141,12 +141,21 @@ describe.skipIf(!url)('restore listener (DB-backed, issue #42)', () => {
expect(textOf(doc)).not.toContain('current text'); expect(textOf(doc)).not.toContain('current text');
// A pre-restore snapshot was appended; history is append-only (the original // A pre-restore snapshot was appended; history is append-only (the original
// manual version is still present too). // manual version is still present too). Poll: the broadcast the client
const versions = await pool.query<{ trigger: string }>( // converged on happens inside the transact, BEFORE the listener commits
'SELECT trigger FROM page_versions WHERE page_id = $1', // the PRE_RESTORE row — asserting immediately is a race.
[pageId], const triggersNow = async (): Promise<string[]> => {
); const versions = await pool.query<{ trigger: string }>(
const triggers = versions.rows.map((r) => r.trigger); 'SELECT trigger FROM page_versions WHERE page_id = $1',
[pageId],
);
return versions.rows.map((r) => r.trigger);
};
let triggers: string[] = [];
await waitFor(() => {
void triggersNow().then((rows) => (triggers = rows));
return triggers.includes('PRE_RESTORE');
});
expect(triggers).toContain('PRE_RESTORE'); expect(triggers).toContain('PRE_RESTORE');
expect(triggers).toContain('MANUAL'); expect(triggers).toContain('MANUAL');