fix: v0.12.1 — ISS-001 time-scale slider no longer snaps back to the stale value on speed change (optimistic scale kept until a snapshot confirms it); sim-control commit machinery hardened (synchronous busy ref, in-flight queue flush loop, sent/queued/failed outcomes so queued commits never drop the display)
This commit is contained in:
+43
-2
@@ -44,11 +44,21 @@ test('left pane renders wallet, reputation and the starter fleet at Frankfurt',
|
||||
await expect(page.getByTestId('reputation')).toBeVisible();
|
||||
expect(Number((await page.getByTestId('reputation').textContent()) ?? 'NaN')).toBeGreaterThanOrEqual(0);
|
||||
|
||||
// Fleet: the starter ATR 72-600 at Frankfurt (EDDF).
|
||||
// Fleet: the starter ATR 72-600 — location asserted against /api/state truth, because a
|
||||
// human player (or an earlier spec) may have moved it anywhere by now.
|
||||
const row = page.getByTestId('fleet-list').locator('.plane-row').first();
|
||||
await expect(row, 'starter plane row appears once the first snapshot lands').toBeVisible({ timeout: 15_000 });
|
||||
await expect(row).toContainText('ATR 72-600');
|
||||
await expect(row).toContainText('Frankfurt');
|
||||
const truth = (await getState(page)).planes.find((p) => p.id === 'plane-starter') as unknown as {
|
||||
status: string;
|
||||
locationName: string;
|
||||
destName: string | null;
|
||||
};
|
||||
if (truth.status === 'flying' && truth.destName) {
|
||||
await expect(row).toContainText(`${truth.locationName} → ${truth.destName}`); // in-flight leg
|
||||
} else {
|
||||
await expect(row).toContainText(truth.locationName);
|
||||
}
|
||||
|
||||
// v0.12.0 loadout: "n/capacity pkgs" (capacity from the snapshot catalog — ATR 72-600 = 6).
|
||||
const loadout = page.getByTestId('plane-loadout-plane-starter');
|
||||
@@ -94,6 +104,37 @@ test('time controls: pause freezes the sim and the power-of-two slider sets time
|
||||
expect(after.simState.paused).toBe(false);
|
||||
});
|
||||
|
||||
test('slider commit keeps the chosen scale on screen until confirmed — no snap-back (ISS-001)', async ({ page }) => {
|
||||
test.setTimeout(60_000);
|
||||
await page.goto('/');
|
||||
const slider = page.getByTestId('time-scale-slider');
|
||||
await expect(slider).toBeVisible({ timeout: 15_000 });
|
||||
|
||||
// Commit to max via keyboard (input + change → immediate commitNow POST)…
|
||||
await slider.focus();
|
||||
await page.keyboard.press('End');
|
||||
|
||||
// …and sample the displayed value rapidly across the whole commit→confirm window. With the
|
||||
// ISS-001 fix the optimistic value stays until a snapshot confirms it, so EVERY sample must
|
||||
// be '64×' — never snapping back to the previous scale for one poll cycle (the old bug).
|
||||
const seen: string[] = [];
|
||||
for (let i = 0; i < 30; i++) {
|
||||
seen.push(((await page.getByTestId('time-scale-value').textContent()) ?? '').trim());
|
||||
await new Promise((r) => setTimeout(r, 25));
|
||||
}
|
||||
expect(
|
||||
seen.every((v) => v === '64×'),
|
||||
`displayed scale must stay 64× during the commit window (saw: ${[...new Set(seen)].join(', ')})`,
|
||||
).toBe(true);
|
||||
|
||||
// …and the server confirms it.
|
||||
await expect.poll(async () => (await getState(page)).simState.timeScale, { timeout: 10_000 }).toBe(64);
|
||||
|
||||
// Restore to min for later tests (afterEach restores scale anyway).
|
||||
await page.keyboard.press('Home');
|
||||
await expect.poll(async () => (await getState(page)).simState.timeScale, { timeout: 10_000 }).toBe(1);
|
||||
});
|
||||
|
||||
test('right pane placeholder exists with the Jobs & Market heading', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
const right = page.getByTestId('right-pane');
|
||||
|
||||
Reference in New Issue
Block a user