Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(test): type the deferred release so the tests typecheck
Etienne Lescot43c23e842eaa
diff --git a/.claude/launch.json b/.claude/launch.jsonindex 16c0d4afe..0cbf82932 100644--- a/.claude/launch.json+++ b/.claude/launch.json@@ -12,8 +12,7 @@"name": "desktop-dev","runtimeExecutable": "npm","runtimeArgs": ["run", "dev", "--", "--port", "5201", "--strictPort"],- "port": 5201,- "env": { "NO_ELECTRON": "1" }+ "port": 5201},{"name": "v4preview",diff --git a/AGENTS.md b/AGENTS.mdindex 1f1a63d40..8864fdf57 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -7,7 +7,7 @@ OpenScreen is a free, open-source screen recorder and video editor (Electron + R- Install deps: `npm install` (Node 22.22.1, npm 10.9.4 — see `package.json#engines`)- Start dev: `npm run dev` (Vite dev server; Electron window opens via `vite-plugin-electron`)- Build: `npm run build` (TypeScript check + Vite build + electron-builder)-- Typecheck: `npx tsc --noEmit` (CI runs this; no standalone script)+- Typecheck: `npx tsc --noEmit` — app code only. CI also runs `npx tsc -p tsconfig.test.json --noEmit` in a separate job ("Typecheck (tests)"), so **run both**: test files are invisible to the root config, and a type error in a `*.test.ts` fails CI while the root check stays green.- Test (unit): `npm run test` (Vitest, jsdom env)- Test (browser): `npm run test:browser` (Vitest + Playwright, requires `npm run test:browser:install` first)- Test (e2e): `npm run test:e2e` (Playwright)diff --git a/src/lib/ai-edition/store/transcriptionStore.test.ts b/src/lib/ai-edition/store/transcriptionStore.test.tsindex 25e2b2548..47786837a 100644--- a/src/lib/ai-edition/store/transcriptionStore.test.ts+++ b/src/lib/ai-edition/store/transcriptionStore.test.ts@@ -76,6 +76,15 @@ function transcriptFor(assetId: string): AxcutTranscript {};}+/** A promise plus a 0-arg release, so a mocked run can be held open mid-flight. */+function deferred(): { promise: Promise<void>; release: () => void } {+ let release: () => void = () => {};+ const promise = new Promise<void>((resolve) => {+ release = () => resolve();+ });+ return { promise, release: () => release() };+}+/** Loads a document into the project store the way `loadProject` would. */function loadDocument(document: AxcutDocument) {useProjectStore.setState({@@ -308,7 +317,7 @@ describe("useTranscriptionStore", () => {// asks for French from the media card. The outgoing run must neither win// the race nor delete the request that replaced it.const languages: string[] = [];- let releaseFirst: (() => void) | null = null;+ const firstRun = deferred();transcribeMocks.transcribeAsset.mockImplementation(async (_doc: AxcutDocument,@@ -317,9 +326,7 @@ describe("useTranscriptionStore", () => {) => {languages.push(options.language ?? "auto");if (languages.length === 1) {- await new Promise<void>((resolve) => {- releaseFirst = resolve;- });+ await firstRun.promise;throw new DOMException("Aborted", "AbortError");}return { ...transcriptFor(assetId), language: options.language ?? "auto" };@@ -332,7 +339,7 @@ describe("useTranscriptionStore", () => {const requested = useTranscriptionStore.getState().request("asset_1", "fr");expect(useTranscriptionStore.getState().jobs.asset_1?.status).toBe("queued");- releaseFirst?.();+ firstRun.release();await requested;await whenTranscriptionIdle();@@ -386,14 +393,10 @@ describe("useTranscriptionStore", () => {});it("waits for the background run instead of transcribing the same asset twice", async () => {- let releaseFirst: (() => void) | null = null;+ const firstRun = deferred();transcribeMocks.transcribeAsset.mockImplementation(async (_doc: AxcutDocument, assetId: string) => {- if (!releaseFirst) {- await new Promise<void>((resolve) => {- releaseFirst = resolve;- });- }+ await firstRun.promise;return transcriptFor(assetId);},);@@ -403,7 +406,7 @@ describe("useTranscriptionStore", () => {expect(useTranscriptionStore.getState().jobs.asset_1?.status).toBe("running");const requested = useTranscriptionStore.getState().requestTimelineTranscripts();- releaseFirst?.();+ firstRun.release();await requested;expect(transcribeMocks.transcribeAsset).toHaveBeenCalledTimes(1);