Update Healer Man server

This commit is contained in:
phenom committed 2026-10-04 13:13:35 -04:00
1 parent 39458d5de6
commit 6cc1b9217f
203 files changed
+133929 -31271

No files matched your search

+62
View File
@@ -57,6 +57,68 @@ afterEach(() => {
});
describe("combat audio output policy", () => {
it("bounds decoded audio memory, refreshes recent cues, and preserves active playback", async () => {
vi.resetModules();
const audio = await import("./combatAudio");
const sources: { stop: ReturnType<typeof vi.fn>; buffer: unknown }[] = [];
const buffer = { duration: 1, length: 1024 * 1024, numberOfChannels: 2 };
vi.stubGlobal("window", { AudioContext: function () {
return {
currentTime: 0, state: "running", destination: {},
createGain: () => ({ connect: vi.fn(), disconnect: vi.fn(), gain: { setTargetAtTime: vi.fn(), value: 1 } }),
createBufferSource: () => {
const source = { connect: vi.fn(), disconnect: vi.fn(), start: vi.fn(), stop: vi.fn(), buffer: null, onended: null };
sources.push(source);
return source;
},
decodeAudioData: async () => buffer,
resume: async () => undefined,
};
} });
combatMedia.ready = true;
combatMedia.fetch.mockImplementation(async () => new Response(new Uint8Array([1])));
audio.configureCombatAudio(DEFAULT_COMBAT_PRESENTATION_SETTINGS, 0.6);
for (const cue of [1, 2, 3, 4, 1, 5]) await audio.playMasterAudioCue(`/cue-${cue}.wav`);
expect(combatMedia.fetch).toHaveBeenCalledTimes(5);
await audio.playMasterAudioCue("/cue-1.wav");
expect(combatMedia.fetch).toHaveBeenCalledTimes(5);
await audio.playMasterAudioCue("/cue-2.wav");
expect(combatMedia.fetch).toHaveBeenCalledTimes(6);
expect(sources[1].buffer).toBe(buffer);
expect(sources.every((source) => source.stop.mock.calls.length === 0)).toBe(true);
audio.resetCombatAudio();
});
it("bounds the number of cached cues, shares pending decodes, and retries failed audio", async () => {
vi.resetModules();
const audio = await import("./combatAudio");
vi.stubGlobal("window", { AudioContext: function () {
return {
currentTime: 0, state: "running", destination: {},
createGain: () => ({ connect: vi.fn(), disconnect: vi.fn(), gain: { setTargetAtTime: vi.fn(), value: 1 } }),
createBufferSource: () => ({ connect: vi.fn(), disconnect: vi.fn(), start: vi.fn(), stop: vi.fn(), buffer: null, onended: null }),
decodeAudioData: async () => ({ duration: 0.1, length: 100, numberOfChannels: 1 }),
resume: async () => undefined,
};
} });
combatMedia.ready = true;
combatMedia.fetch.mockImplementation(async () => new Response(new Uint8Array([1])));
audio.configureCombatAudio(DEFAULT_COMBAT_PRESENTATION_SETTINGS, 0.6);
const stops = await Promise.all([audio.playMasterAudioCue("/shared.wav"), audio.playMasterAudioCue("/shared.wav")]);
stops.forEach((stop) => stop?.());
expect(combatMedia.fetch).toHaveBeenCalledTimes(1);
for (let index = 0; index < 65; index += 1) (await audio.playMasterAudioCue(`/small-${index}.wav`))?.();
const calls = combatMedia.fetch.mock.calls.length;
(await audio.playMasterAudioCue("/small-64.wav"))?.();
expect(combatMedia.fetch).toHaveBeenCalledTimes(calls);
(await audio.playMasterAudioCue("/shared.wav"))?.();
expect(combatMedia.fetch).toHaveBeenCalledTimes(calls + 1);
combatMedia.fetch.mockResolvedValueOnce(new Response(null, { status: 404 }));
expect(await audio.playMasterAudioCue("/retry.wav")).toBeNull();
expect(await audio.playMasterAudioCue("/retry.wav")).toBeTypeOf("function");
audio.resetCombatAudio();
});
it("plays source cues only on their mapped phase, with instant-cast release support", () => {
const cast = { url: "/cast.mp3", phase: "cast-start" as const };
const impact = { url: "/impact.mp3", phase: "impact" as const };