summaryrefslogtreecommitdiff
path: root/apps/web/src/voiceover/__tests__/devices.test.ts
diff options
context:
space:
mode:
authorcashmere <cashmere@autistici.org>2026-08-16 06:16:56 +0200
committercashmere <cashmere@autistici.org>2026-08-16 06:16:56 +0200
commitf1043734438c8518a302f698d9ae6583a75f0c14 (patch)
treed3e636a96e6349c1ad17afa7b28c9ffe5c882e37 /apps/web/src/voiceover/__tests__/devices.test.ts
parent37d22b1e390bd6cea04bf8e15069281ee125cf10 (diff)
downloadopencut-f1043734438c8518a302f698d9ae6583a75f0c14.tar.gz
feat: add transitions, track mixing, and voiceover controls
Diffstat (limited to 'apps/web/src/voiceover/__tests__/devices.test.ts')
-rw-r--r--apps/web/src/voiceover/__tests__/devices.test.ts72
1 files changed, 72 insertions, 0 deletions
diff --git a/apps/web/src/voiceover/__tests__/devices.test.ts b/apps/web/src/voiceover/__tests__/devices.test.ts
new file mode 100644
index 00000000..524e8c3f
--- /dev/null
+++ b/apps/web/src/voiceover/__tests__/devices.test.ts
@@ -0,0 +1,72 @@
+import { describe, expect, test } from "bun:test";
+import {
+ DEFAULT_AUDIO_INPUT_DEVICE_ID,
+ buildVoiceOverAudioConstraints,
+ normalizeSelectedDeviceId,
+ type VoiceOverInputDevice,
+} from "@/voiceover/devices";
+
+const devices: VoiceOverInputDevice[] = [
+ {
+ deviceId: DEFAULT_AUDIO_INPUT_DEVICE_ID,
+ label: "System default microphone",
+ isDefault: true,
+ },
+ {
+ deviceId: "blue-yeti-snowball",
+ label: "Blue Snowball",
+ isDefault: false,
+ },
+];
+
+describe("buildVoiceOverAudioConstraints", () => {
+ test("uses default processing constraints without an exact device", () => {
+ const constraints = buildVoiceOverAudioConstraints({ deviceId: null });
+ expect(constraints.audio).toEqual({
+ echoCancellation: true,
+ noiseSuppression: true,
+ autoGainControl: true,
+ });
+ });
+
+ test("adds an exact device constraint for a selected microphone", () => {
+ const constraints = buildVoiceOverAudioConstraints({
+ deviceId: "blue-yeti-snowball",
+ });
+ expect(constraints.audio).toEqual({
+ deviceId: { exact: "blue-yeti-snowball" },
+ echoCancellation: true,
+ noiseSuppression: true,
+ autoGainControl: true,
+ });
+ });
+});
+
+describe("normalizeSelectedDeviceId", () => {
+ test("keeps the selected device when it is still present", () => {
+ expect(
+ normalizeSelectedDeviceId({
+ deviceId: "blue-yeti-snowball",
+ devices,
+ }),
+ ).toBe("blue-yeti-snowball");
+ });
+
+ test("clears a selected device when it is no longer present", () => {
+ expect(
+ normalizeSelectedDeviceId({
+ deviceId: "missing",
+ devices,
+ }),
+ ).toBeNull();
+ });
+
+ test("keeps the browser default device id", () => {
+ expect(
+ normalizeSelectedDeviceId({
+ deviceId: DEFAULT_AUDIO_INPUT_DEVICE_ID,
+ devices: [],
+ }),
+ ).toBe(DEFAULT_AUDIO_INPUT_DEVICE_ID);
+ });
+});