Files
OwnCord/Client/tauri-client/tests/browser/smoke.test.ts
T
J3vbandClaude Fable 5 d880b64d64 test: audit 2026-08-19 — fix stale tests, close coverage gaps (#1397)
* test(server): admin/handlers/channels — test-audit 2026-08-19 fixes

* test(server): api/constants — test-audit 2026-08-19 fixes

* test(server): api/middleware — test-audit 2026-08-19 fixes

* test(server): api/waf — test-audit 2026-08-19 fixes

* test(server): auth/totp/encrypt — test-audit 2026-08-19 fixes

* test(server): db/session/expiry/test — test-audit 2026-08-19 fixes

* test(server): migrations/030/attachments/unlink/on/message/delete — test-audit 2026-08-19 fixes

* test(server): updater/download — test-audit 2026-08-19 fixes

* test(server): ws/handlers_command — test-audit 2026-08-19 fixes

* test(server): ws/hub/broadcast — test-audit 2026-08-19 fixes

* test(server): ws/hub/events — test-audit 2026-08-19 fixes

* test(server): ws/livekit/webhook — test-audit 2026-08-19 fixes

* test(server): ws/voice/controls — test-audit 2026-08-19 fixes

* test(server): ws/voice/join — test-audit 2026-08-19 fixes

* test(server): ws/voice/moderation — test-audit 2026-08-19 fixes

* test(rust): src-tauri/src/commands.rs — test-audit 2026-08-19 fixes

* test(rust): src-tauri/src/secret_store.rs — test-audit 2026-08-19 fixes

* test(rust): src-tauri/src/update_commands.rs — test-audit 2026-08-19 fixes

* test(client): src/components/ChannelSidebar.ts — test-audit 2026-08-19 fixes

* test(client): src/lib/ws.ts — test-audit 2026-08-19 fixes

* test(rust): src-tauri/src/credentials.rs — test-audit 2026-08-19 fixes

* test(rust): src-tauri/src/tofu.rs — test-audit 2026-08-19 fixes

* test(client): src/lib/hostValidation.ts — test-audit 2026-08-19 fixes

* test(client): src/lib/rate-limiter.ts — test-audit 2026-08-19 fixes

* test(client): src/pages/connect-page/LoginForm.ts — test-audit 2026-08-19 fixes

* test(client): src/pages/main-page/SidebarArea.ts — test-audit 2026-08-19 fixes

* test(client): src/stores/voice.store.ts — test-audit 2026-08-19 fixes

* test(client): tests/browser/smoke.test.ts — test-audit 2026-08-19 fixes

* test(client): tests/unit/media.test.ts — test-audit 2026-08-19 fixes

* test(client): tests/unit/renderers.test.ts — test-audit 2026-08-19 fixes

* test(client): src/components/UserProfilePopup.ts — test-audit 2026-08-19 fixes

* test(client): src/lib/e2eeCrypto.ts — test-audit 2026-08-19 fixes

* test(client): tests/unit/log-persistence.test.ts — test-audit 2026-08-19 fixes

* test(client): keep tests/browser out of the jsdom suite and run it in CI

* test(server): ws/hub_broadcast_test.go — bytes.Equal payload compare (gocritic)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* test(client): src/lib/credentials.ts — test-audit 2026-08-19 round 2 (Stryker)

* test(client): src/lib/dispatcher.ts — test-audit 2026-08-19 round 2 (Stryker)

* test(client): src/lib/permissions.ts — test-audit 2026-08-19 round 2 (Stryker)

* test(client): src/lib/rate-limiter.ts — test-audit 2026-08-19 round 2 (Stryker)

* test(client): src/lib/hostValidation.ts — test-audit 2026-08-19 round 2 (Stryker)

* test(client): src/stores/messages.store.ts — test-audit 2026-08-19 round 2 (Stryker)

* test(client): src/lib/e2eeCrypto.ts — test-audit 2026-08-19 round 2 (Stryker)

* test(client): src/lib/ws.ts — test-audit 2026-08-19 round 2 (Stryker)

* test(client): src/lib/identity.ts — test-audit 2026-08-19 round 2 (Stryker)

* test(client): src/lib/livekitE2EE.ts — test-audit 2026-08-19 round 2 (Stryker)

* test(client): src/stores/auth.store.ts — test-audit 2026-08-19 round 2 (Stryker)

* test(client): src/stores/voice.store.ts — test-audit 2026-08-19 round 2 (Stryker)

* docs: test audit 2026-08-19 — findings, fixes, measured baselines

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* chore(graph): refresh the knowledge graph after the 2026-08-19 test audit

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-20 19:29:31 +02:00

67 lines
2.4 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from "vitest";
import { Track } from "livekit-client";
import { createRNNoiseProcessor } from "../../src/lib/noise-suppression";
// Real-browser sanity checks: a real DOM is available (jsdom can fake this,
// but this suite runs in an actual Chromium instance via the vitest
// playwright provider).
describe("browser environment", () => {
it("provides real DOM globals", () => {
expect(typeof window).toBe("object");
expect(typeof document).toBe("object");
expect(typeof document.createElement).toBe("function");
});
it("real DOM APIs work", () => {
const div = document.createElement("div");
div.innerHTML = "<span>hello</span>";
document.body.appendChild(div);
const span = document.querySelector("span");
expect(span).not.toBeNull();
expect(span!.textContent).toBe("hello");
div.remove();
});
});
// src/lib/noise-suppression.ts needs a real AudioContext/AudioWorklet/WASM
// runtime that jsdom cannot provide (vitest.config.ts excludes it from
// coverage on that basis) — so it has to be exercised here, not in
// tests/unit. Every tests/unit reference to it is a vi.mock().
describe("noise-suppression (real AudioContext)", () => {
afterEach(() => {
vi.restoreAllMocks();
});
it("falls back to a ScriptProcessorNode pipeline when AudioWorklet is unsupported", async () => {
const originalAudioWorkletNode = window.AudioWorkletNode;
// @ts-expect-error -- deleting a required DOM global to force the
// module's supportsAudioWorklet() feature check to fail
delete window.AudioWorkletNode;
const audioContext = new AudioContext();
const scriptProcessorSpy = vi.spyOn(audioContext, "createScriptProcessor");
const inputTrack = audioContext.createMediaStreamDestination().stream.getAudioTracks()[0]!;
try {
const processor = createRNNoiseProcessor();
await processor.init({
kind: Track.Kind.Audio,
track: inputTrack,
audioContext,
});
// The fallback pipeline is the only thing that calls createScriptProcessor.
expect(scriptProcessorSpy).toHaveBeenCalledTimes(1);
expect(processor.processedTrack).toBeInstanceOf(MediaStreamTrack);
expect(processor.processedTrack!.kind).toBe("audio");
await processor.destroy();
} finally {
window.AudioWorkletNode = originalAudioWorkletNode;
await audioContext.close();
}
});
});