fix(e2e): task-10 review fixes — Nth tick, retry-safe preambles, queue-DTO shape (#44)
CI / build + unit + e2e (pull_request) Failing after 34m10s

This commit is contained in:
2026-10-03 00:35:10 +00:00
parent 1ddb8ad469
commit a0307e4ccd
3 changed files with 42 additions and 19 deletions
+15
View File
@@ -72,3 +72,18 @@ export async function jumpToFreshSystem(page: Page): Promise<WorldState> {
expect(after.systems.find((s) => s.current)?.id).toBe(target.id); // landed, not just queued
return after;
}
// Tick the save's task queue until it is empty (free skips are legal 200s; every tick decrements
// every ACTIVE row and PENDING rows auto-start, so a non-empty queue always shrinks — the bound
// only fails a pathological state). Every spec that queues actions starts from this on retry:
// the CI DB persists across attempts, and a failed one may have left a row behind — an in-transit
// JUMP would 409 every new queue (lib/game/tasks.ts's in-transit rule).
export async function drainQueue(page: Page): Promise<void> {
for (let ticks = 0; ; ticks++) {
const body = (await (await page.request.get('/api/crew')).json()) as { crew?: CrewDto[]; tasks?: { id: number }[] } | CrewDto[];
const tasks = Array.isArray(body) ? [] : (body.tasks ?? []);
if (tasks.length === 0) return;
expect(ticks).toBeLessThan(60);
expect((await page.request.post('/api/turn')).status()).toBe(200);
}
}