browser audio detection phase 3
This commit is contained in:
@@ -12,7 +12,7 @@ test("disabled beta returns the original file without loading policy", async ()
|
||||
const processor = new BrowserSubmissionProcessor({ browserProcessingBeta: false });
|
||||
assert.equal(processor.isEnabled(), false);
|
||||
assert.equal(processor.canProcess(file), false);
|
||||
assert.deepEqual(await processor.prepare(file), { file, metadata: null });
|
||||
assert.deepEqual(await processor.prepare(file), { file, metadata: null, gate: "unavailable" });
|
||||
} finally {
|
||||
globalThis.fetch = originalFetch;
|
||||
}
|
||||
@@ -37,9 +37,9 @@ test("admin-disabled policy and fetch failure both fall back to the original fil
|
||||
const processor = new BrowserSubmissionProcessor({ browserProcessingBeta: true, policyUrl: "/browser-policy/", policyVersion: 1 });
|
||||
try {
|
||||
globalThis.fetch = async () => ({ ok: true, json: async () => ({ browser_processing_beta_enabled: false, version: 1 }) });
|
||||
assert.deepEqual(await processor.prepare(file), { file, metadata: null });
|
||||
assert.deepEqual(await processor.prepare(file), { file, metadata: null, gate: "unavailable" });
|
||||
globalThis.fetch = async () => { throw new Error("offline"); };
|
||||
assert.deepEqual(await processor.prepare(file), { file, metadata: null });
|
||||
assert.deepEqual(await processor.prepare(file), { file, metadata: null, gate: "unavailable" });
|
||||
} finally {
|
||||
globalThis.fetch = originalFetch;
|
||||
}
|
||||
@@ -53,6 +53,7 @@ test("video routing is gated and audio never invokes FFmpeg", async () => {
|
||||
const processor = new BrowserSubmissionProcessor(
|
||||
{ browserProcessingBeta: true, policyUrl: "/browser-policy/", policyVersion: 1 },
|
||||
async () => { calls += 1; return new File(["wav"], "clip.wav", { type: "audio/wav" }); },
|
||||
{ prepareAudio: async () => new Float32Array(16000), classify: async () => [{ class: "Fireworks", score: .9 }] },
|
||||
);
|
||||
await processor.prepare(file);
|
||||
assert.equal(calls, 0);
|
||||
@@ -62,7 +63,7 @@ test("video routing is gated and audio never invokes FFmpeg", async () => {
|
||||
assert.equal(result.file.type, "audio/wav");
|
||||
assert.equal(result.metadata.browser_processing_used, true);
|
||||
const disabled = new BrowserSubmissionProcessor({ browserProcessingBeta: false }, async () => { throw new Error("must not run"); });
|
||||
assert.deepEqual(await disabled.prepare(video), { file: video, metadata: null });
|
||||
assert.deepEqual(await disabled.prepare(video), { file: video, metadata: null, gate: "unavailable" });
|
||||
} finally {
|
||||
globalThis.fetch = originalFetch;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user