Files
wekan/server/lib/tests/sweepUntil.js
T
Lauri Ojansivu 5b3669b00f Page retention sweeps in the full-app tests until their own record is compacted.
A retention sweep reads one page of 100 receipts, oldest first, and keeps its
place. The full-app test database outlives a run, so receipts left by other
suites and earlier runs came to fill the first page, and the webhook test's
single sweep compacted nothing. Production pages through every receipt over
successive sweeps; the tests now do the same through a shared sweepUntil
helper, and assert that their own plan was compacted.

Thanks to xet7 !
2026-09-30 12:17:20 +03:00

13 lines
537 B
JavaScript

// A retention sweep reads one page (100 receipts, oldest first) per call and
// keeps its place. The test database outlives a run, so older receipts from
// other suites and earlier runs can fill the first pages: page on until this
// test's own record is compacted, or the sweep has reached the end.
export async function sweepUntil(retention, done) {
for (let page = 0; page < 1000; page++) {
const result = await retention.sweep();
if (await done()) return true;
if (!result.next) return done();
}
return done();
}