test(planning): hold the worker until the preparation cancel arrives
CI / policy (push) Successful in 16s
CI / validate (push) Successful in 29s
CI / build (push) Successful in 20s
CI / benchmark (push) Successful in 1m27s
CI / security (push) Successful in 1m0s
CI / test (push) Successful in 1m57s
CI / images (push) Successful in 1m20s
CI / required (push) Successful in 1s
CI / policy (pull_request) Successful in 8s
CI / validate (pull_request) Successful in 23s
CI / test (pull_request) Successful in 1m51s
CI / build (pull_request) Successful in 38s
CI / security (pull_request) Successful in 1m1s
CI / benchmark (pull_request) Successful in 46s
CI / images (pull_request) Successful in 51s
CI / required (pull_request) Successful in 2s

The worker reads its queue only between event-loop turns, so the
calendar preparation could finish before the cancel sent on its second
progress update arrived, and the test received a complete plan. Use the
real-worker harness hold already applied to the checkpoint cancellation
test, and cancel on the first preparation update so the hold is released.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
nessarandClaude Sonnet 5.5 committed 2026-10-19 09:52:15 +02:00
1 parent f458a83599
commit af20c96f01
1 file changed
+3 -3
@@ -587,8 +587,8 @@ parentPort.on('message', (data) => globalThis.self.onmessage({ data }));
);
it('stops during calendar preparation without a plan or an obligation conflict', async () => {
holdForCancelAtStage = 'preparation';
const stages: string[] = [];
let preparationUpdates = 0;
const calculation = createPlanningCalculation({
horizon: { start: '2024-01-01', end: '2027-01-01' },
balances: [],
@@ -596,7 +596,7 @@ parentPort.on('message', (data) => globalThis.self.onmessage({ data }));
declaredDays: [{ date: '2024-01-02', type: 'other' }],
progress: (stage) => {
stages.push(stage);
if (stage === 'preparation' && ++preparationUpdates === 2) calculation.cancel();
if (stage === 'preparation') calculation.cancel();
},
});
const outcome = await calculation.outcome;
@@ -606,7 +606,7 @@ parentPort.on('message', (data) => globalThis.self.onmessage({ data }));
});
if (outcome.kind !== 'PlanningIncomplete') return;
expect(outcome.incumbent).toBeUndefined();
expect(preparationUpdates).toBeGreaterThanOrEqual(2);
expect(stages).toContain('preparation');
expect(stages).not.toContain('obligations');
expect(await calculation.explanationError).toBeUndefined();
expect(heartbeats).toBeGreaterThan(0);