Step 26.7 follow-up: fix an intermittent fleet-sleep test
CI / check (push) Has been cancelled Details

The test used a random world; with events, some worlds had no trip in
flight at the sleep time. It now uses a fixed world seed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
fireshaper 2026-10-17 01:06:24 -04:00
parent 9b2fa19767
commit 0c52a1b532
2 changed files with 10 additions and 1 deletions

View File

@ -1956,3 +1956,5 @@ Implementation decisions not spelled out in `memory-bank/implementation-plan.md`
- **The short list shows a trip's event next to the trip**, without it counting as one of the 3 events: a delivery with a detour still reads as a quick check-in.
- **The hull bar colours** follow the rules: amber below 50% (no Dangerous cargo), red below 25% (Needs repair).
- **Developer tools: Damage hull** sets a ship to 20%, to try the warning and repairs (the CR's manual check).
- **A sleep test's world is fixed now** (`fleet-sleep.test.ts`, "trips in flight still pay"): each test company gets a random world, and with events shifting trip times, a world sometimes had no trip in the air at the sleep time, failing the check that one lands after it. Seen as an intermittent failure after Step 26.7's commit; fixed in a follow-up commit.

View File

@ -115,6 +115,11 @@ describe("fleet sleep in catch-up (Step 24.3, decision 0.5.137)", () => {
it("starts no Independent trips after 24 hours without orders; trips in flight still pay", async () => {
const test = newTestApp();
const decided = await sleepyFleet(test);
// A fixed world, so a trip is in the air when the fleet goes quiet (with random worlds
// and events, none sometimes is).
await edit(test.app, (save) => {
save.player.worldSeed = 12_345;
});
const sleep = decided + 24 * HOUR;
test.clock.now = decided + 7 * DAY;
const state = await test.app.call("getPlayerState", {});
@ -124,9 +129,11 @@ describe("fleet sleep in catch-up (Step 24.3, decision 0.5.137)", () => {
expect(Math.max(...trips.map((d) => d.record.departureAt))).toBeLessThan(sleep);
const flying = trips.filter((d) => d.record.departureAt < sleep && d.arrivalAt > sleep);
expect(flying.length).toBeGreaterThan(0);
// They land and resolve as normal: a contract pays its XP (and its pay, unless an
// event took it, CR-026), a deadhead home earns nothing.
for (const d of flying) {
expect(d.status).toBe("resolved");
expect(d.resolution!.credits).toBeGreaterThan(0);
if (d.record.contract) expect(d.resolution!.pilotXp).toBeGreaterThan(0);
}
expect(state.fleetSleep).toEqual({ afterHours: 24, sleepsAt: sleep, asleep: true });
});