fix: version neural audio requests for v0.1.1
This commit is contained in:
+53
-4
@@ -88,6 +88,54 @@ const flush = async () => {
|
||||
};
|
||||
|
||||
describe("오디오 재생 수명과 믹서", () => {
|
||||
it("intro와 목표 실제 fetch URL에 같은 명시적 cache-busting 버전을 붙인다", async () => {
|
||||
const f = fixture();
|
||||
const done = f.engine.play(question, true, vi.fn());
|
||||
await flush();
|
||||
f.sources.at(-1)!.onended?.();
|
||||
await done;
|
||||
expect(f.fetcher.mock.calls.map(([url]) => url)).toEqual([
|
||||
"/audio/intro.wav?v=0.1.1",
|
||||
`/audio/${question.id}.wav?v=0.1.1`,
|
||||
]);
|
||||
f.engine.dispose();
|
||||
});
|
||||
it.each(["intro", "target"])(
|
||||
"%s 404 후 intro·목표를 동일한 versioned URL로 다시 요청한다",
|
||||
async (failed) => {
|
||||
const f = fixture();
|
||||
let pendingFailure = true;
|
||||
f.fetcher.mockImplementation(async (input) => {
|
||||
const pathname = new URL(String(input), "http://localhost").pathname;
|
||||
if (
|
||||
pendingFailure &&
|
||||
pathname ===
|
||||
`/audio/${failed === "intro" ? "intro" : question.id}.wav`
|
||||
) {
|
||||
pendingFailure = false;
|
||||
return { ok: false, status: 404 } as Response;
|
||||
}
|
||||
return {
|
||||
ok: true,
|
||||
arrayBuffer: async () => new ArrayBuffer(8),
|
||||
} as Response;
|
||||
});
|
||||
await expect(f.engine.play(question, true, vi.fn())).rejects.toThrow(
|
||||
"음성 파일",
|
||||
);
|
||||
const done = f.engine.play(question, true, vi.fn());
|
||||
await flush();
|
||||
f.sources.at(-1)!.onended?.();
|
||||
await done;
|
||||
expect(f.fetcher.mock.calls.map(([url]) => url)).toEqual([
|
||||
"/audio/intro.wav?v=0.1.1",
|
||||
`/audio/${question.id}.wav?v=0.1.1`,
|
||||
"/audio/intro.wav?v=0.1.1",
|
||||
`/audio/${question.id}.wav?v=0.1.1`,
|
||||
]);
|
||||
f.engine.dispose();
|
||||
},
|
||||
);
|
||||
it("생성 시 무음이며 gesture의 play에서만 장치를 연다", async () => {
|
||||
const f = fixture();
|
||||
expect(f.factory).not.toHaveBeenCalled();
|
||||
@@ -98,10 +146,11 @@ describe("오디오 재생 수명과 믹서", () => {
|
||||
await flush();
|
||||
expect(started).toHaveBeenCalledOnce();
|
||||
expect(f.sources).toHaveLength(3);
|
||||
expect(f.fetcher.mock.calls.map((call) => call[0])).toEqual([
|
||||
"/audio/intro.wav",
|
||||
question.audioUrl,
|
||||
]);
|
||||
expect(
|
||||
f.fetcher.mock.calls.map(
|
||||
([url]) => new URL(String(url), "http://localhost").pathname,
|
||||
),
|
||||
).toEqual(["/audio/intro.wav", `/audio/${question.id}.wav`]);
|
||||
// master, 배경, 목표, 안내의 gain을 분리한다. 안내는 점차 소음에 묻힌다.
|
||||
expect(f.gains[1]!.gain.setValueAtTime).toHaveBeenCalledWith(
|
||||
1,
|
||||
|
||||
Reference in New Issue
Block a user