Play result audio after finishing cutscene ends

This commit is contained in:
2026-10-15 00:14:17 +09:00
parent 32d32a6ebc
commit 013807c873
3 changed files with 25 additions and 1 deletions
+23
View File
@@ -341,6 +341,28 @@ test('global cutscene speed scales stages and CSS timing while respecting result
}
});
test('result sound waits for all three cutscene stages', 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-stage-order'; 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, revealEndsAt: started + 1200 };
state.finished = { matchId: state.matchId, winnerIndex: 0, reason: 'hit', stats: emptyPlayerStats(), revealEndsAt: started + 1200, saved: true };
const view = createMatchView(container as unknown as HTMLElement, async () => true, () => {}, () => {});
try {
view.update(state);
t.mock.timers.tick(1100); t.mock.timers.tick(100);
assert.deepEqual(cues, ['cutscene1', 'cutscene2']);
t.mock.timers.tick(1200);
assert.deepEqual(cues, ['cutscene1', 'cutscene2', 'cutscene3']);
t.mock.timers.tick(1200);
assert.deepEqual(cues, ['cutscene1', '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'] });
@@ -404,3 +426,4 @@ test('a dismissed finisher stays closed when the opponent disconnects after the
assert.equal(dismissals, 1); assert.equal(appended.length, 1);
} finally { cutscene.destroy(); }
});
import { sound } from '../src/client/sound.js';