Testy e2e: resetDb czysci seed, test-all w Justfile; db.json 56 rezerwacji na 2 tygodnie

This commit is contained in:
Krzysztof Cieślik
2026-06-21 07:22:38 +02:00
parent 7eb11de84e
commit f1eb1a7b20
4 changed files with 499 additions and 4 deletions

View File

@@ -29,6 +29,16 @@ async function resetDb() {
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
});
// Delete any reservations created by previous test runs (not part of seed r1r56).
const seedIds = new Set(Array.from({ length: 56 }, (_, i) => `r${i + 1}`));
const all = await fetch(`${api}/reservations`).then((r) => r.json()).catch(() => []);
await Promise.all(
all
.filter((r) => !seedIds.has(r.id))
.map((r) => fetch(`${api}/reservations/${r.id}`, { method: 'DELETE' }))
);
// Ensure r1 and r2 are pending so admin-confirm test always finds a button.
await patch('r1', { status: 'pending' });
await patch('r2', { status: 'pending' });