Queue consumed on dispatch; engine chain hardened; queued planes unsellable (ISS-088)
CI / build + unit + e2e (pull_request) Failing after 12m59s
CI / build + unit + e2e (pull_request) Failing after 12m59s
This commit is contained in:
@@ -82,3 +82,49 @@ test('state survives a container restart (sim clock + account persisted)', async
|
||||
expect(a.planes.map((p) => p.id).sort()).toEqual(before.planes.map((p) => p.id).sort());
|
||||
expect(a.packages.map((p) => p.id).sort()).toEqual(before.packages.map((p) => p.id).sort());
|
||||
});
|
||||
|
||||
test('queued legs survive a container restart (v0.46.0)', async ({ page }) => {
|
||||
test.setTimeout(180_000);
|
||||
|
||||
// Self-heal: the suite runs serially and every spec leaves plane-starter grounded, but an
|
||||
// interrupted run may not — wait it out before staging a queue (queueLeg works while flying too).
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const res = await page.request.get('/api/state');
|
||||
if (res.status() !== 200) return 'down';
|
||||
const body = (await res.json()) as StateBody;
|
||||
return String(body.planes.find((p) => p.id === 'plane-starter')?.status ?? 'missing');
|
||||
}, { timeout: 120_000, message: 'waiting for plane-starter to be grounded' })
|
||||
.toBe('available');
|
||||
|
||||
// Stage a two-leg queue on the starter…
|
||||
const q1 = await page.request.post('/api/planes/plane-starter/queue', { data: { destIcao: 'LEMD' } });
|
||||
expect(q1.status()).toBe(200);
|
||||
const q2 = await page.request.post('/api/planes/plane-starter/queue', { data: { destIcao: 'EHAM' } });
|
||||
expect(q2.status()).toBe(200);
|
||||
|
||||
execSync(`docker compose ${composeArgs} restart flight`, { cwd: repoRoot, stdio: 'pipe' });
|
||||
|
||||
// Wait for the app to come back, capturing the post-restart snapshot.
|
||||
let after: StateBody | undefined;
|
||||
await expect
|
||||
.poll(async () => {
|
||||
try {
|
||||
const res = await page.request.get('/api/state');
|
||||
if (res.status() === 200) after = (await res.json()) as StateBody;
|
||||
return !!after;
|
||||
} catch {
|
||||
return false; // connection refused / 502 while the container starts
|
||||
}
|
||||
}, { timeout: 120_000, message: 'waiting for /api/state after docker compose restart' })
|
||||
.toBe(true);
|
||||
|
||||
const p = after!.planes.find((x) => x.id === 'plane-starter')!;
|
||||
expect(p.queue).toEqual(['LEMD', 'EHAM']); // the queue persisted byte-identical, in order…
|
||||
|
||||
// Cleanup: cancel both legs so the starter is left with an empty queue.
|
||||
for (let i = 0; i < 2; i++) {
|
||||
const c = await page.request.post('/api/planes/plane-starter/queue/cancel', { data: { index: 0 } });
|
||||
expect(c.status()).toBe(200);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user