Milestone v1 (v2.0.0): Mokosh — Session Capture #1

Merged
strategy155 merged 297 commits from gsd/phase-04-harden-clean-up-optional into main 2026-05-31 15:34:17 +00:00
Showing only changes of commit d7840a811c - Show all commits

View File

@@ -0,0 +1,43 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
interface ChromeStub {
runtime: { sendMessage: ReturnType<typeof vi.fn> };
}
interface GlobalWithChrome {
chrome?: ChromeStub;
MediaRecorder?: { isTypeSupported: (mime: string) => boolean };
}
describe('codec strict mode', () => {
beforeEach(() => {
vi.resetModules();
(globalThis as unknown as GlobalWithChrome).chrome = {
runtime: { sendMessage: vi.fn() },
};
});
it('throws on unsupported vp9 and emits RECORDING_ERROR', async () => {
(globalThis as unknown as GlobalWithChrome).MediaRecorder = {
isTypeSupported: vi.fn().mockReturnValue(false),
};
const mod = await import('../../src/offscreen/recorder');
expect(() => mod.assertCodecSupported()).toThrow(/vp9 unsupported/);
const stub = (globalThis as unknown as GlobalWithChrome).chrome!;
expect(stub.runtime.sendMessage).toHaveBeenCalledWith(
expect.objectContaining({ type: 'RECORDING_ERROR' })
);
});
it('does not throw when vp9 IS supported', async () => {
(globalThis as unknown as GlobalWithChrome).MediaRecorder = {
isTypeSupported: vi.fn().mockReturnValue(true),
};
const mod = await import('../../src/offscreen/recorder');
expect(() => mod.assertCodecSupported()).not.toThrow();
const stub = (globalThis as unknown as GlobalWithChrome).chrome!;
expect(stub.runtime.sendMessage).not.toHaveBeenCalledWith(
expect.objectContaining({ type: 'RECORDING_ERROR' })
);
});
});