Add configurable manifest-driven race audio system
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
announcePassingHelper,
|
||||
announceRaceStartedHelper,
|
||||
getSessionAnnouncementText,
|
||||
handleSessionTimerTickHelper,
|
||||
selectSpeechVoice,
|
||||
} from "../src/runtime_services.js";
|
||||
|
||||
@@ -62,3 +63,28 @@ test("race start creates an overlay event and plays enabled start cues", async (
|
||||
await new Promise((resolve) => setTimeout(resolve, 700));
|
||||
assert.deepEqual(calls[2], ["speech", "timing.race_started_voice", { interrupt: true }]);
|
||||
});
|
||||
|
||||
test("session timer emits each race-audio clock marker once without changing finish rules", () => {
|
||||
const active = { id: "s1", eventId: "e1", type: "final", status: "running", followUpSec: 30, audioAnnouncements: [] };
|
||||
const announced = [];
|
||||
let remainingMs = 59_000;
|
||||
let saves = 0;
|
||||
const run = () => handleSessionTimerTickHelper({
|
||||
getActiveSession: () => active,
|
||||
isUntimedSession: () => false,
|
||||
getSessionTiming: () => ({ remainingMs, followUpRemainingMs: 30_000 }),
|
||||
saveState: () => { saves += 1; },
|
||||
getLastFinishAnnouncementSessionId: () => null,
|
||||
setLastFinishAnnouncementSessionId: () => {},
|
||||
announceRaceFinished: () => announced.push("race_finished"),
|
||||
announceRaceClockEvent: (key) => announced.push(key),
|
||||
});
|
||||
run(); run();
|
||||
remainingMs = 29_000; run();
|
||||
remainingMs = 9_000; run();
|
||||
remainingMs = 0; run();
|
||||
assert.deepEqual(announced, ["one_minute_remaining", "thirty_seconds_remaining", "ten_seconds_remaining", "time_expired", "final_lap"]);
|
||||
assert.equal(active.status, "running");
|
||||
assert.ok(active.followUpStartedAt);
|
||||
assert.ok(saves >= 4);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user