Initialize delayed cutscenes before evaluating result audio

This commit is contained in:
2026-10-15 00:16:48 +09:00
parent a533d6e221
commit 6a3a0ad4b9
2 changed files with 20 additions and 1 deletions
+19
View File
@@ -363,6 +363,25 @@ test('result sound waits for all three cutscene stages', t => {
} finally { view.destroy(); }
});
test('a delayed finishing snapshot plays the remaining cutscene before result audio', t => {
const { container, state } = domHarness(t, false);
const started = state.clockNow, cues: string[] = [];
t.mock.timers.enable({ apis: ['Date', 'setTimeout', 'setInterval'], now: started });
t.mock.method(performance, 'now', () => Date.now() - started);
t.mock.method(sound, 'play', (id: string) => { if (!cues.includes(id)) cues.push(id); });
state.matchId = 'audio-delayed-snapshot'; state.phase = 'finished';
state.reveal = { matchId: state.matchId, turnId: 1, actions: ['blast', 'charge'], energyBefore: [1, 1], energy: [0, 1], hitIndex: 1, winnerIndex: 0,
revealedAt: started - 1500, revealEndsAt: started - 300 };
state.finished = { matchId: state.matchId, winnerIndex: 0, reason: 'hit', stats: emptyPlayerStats(), revealEndsAt: started - 300, saved: true };
const view = createMatchView(container as unknown as HTMLElement, async () => true, () => {}, () => {});
try {
view.update(state);
assert.deepEqual(cues, ['cutscene2']);
t.mock.timers.tick(900); t.mock.timers.tick(1200);
assert.deepEqual(cues, ['cutscene2', 'cutscene3', 'win']);
} finally { view.destroy(); }
});
for (const reducedMotion of [false, true]) test(`cutscene timer automatically opens results once (reduced motion: ${reducedMotion})`, t => {
const { state } = domHarness(t, reducedMotion);
t.mock.timers.enable({ apis: ['setTimeout'] });