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(ci): vider l'arriéré de types des tests et fermer le cliquet
Etienne Lescot2200c7c04c82
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 45e3d9508..d228826d9 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -34,39 +34,24 @@ jobs:typecheck-tests:name: Typecheck (tests)runs-on: ubuntu-latest- # A RATCHET, not a gate. tsconfig.json includes only src + electron and- # excludes **/*.test.ts, so no test file has ever been typechecked, and- # vitest transpiles without checking — fixture types have drifted from the- # schemas they claim to build for years. Failing on the whole backlog would- # put a red X on every PR that nobody can fix, and a check everyone ignores- # is worse than no check. So: fail only if the count GROWS. Lower BASELINE- # whenever you fix some; delete this job's baseline logic at zero.+ # A GATE now, and the baseline logic is gone — as its own comment instructed+ # ("delete this job's baseline logic at zero"). The history: tsconfig.json+ # includes only src + electron and excludes **/*.test.ts, and vitest+ # transpiles without checking, so no test file had ever been typechecked and+ # fixture types had drifted from the schemas they claim to build for years.+ # Failing on that whole backlog at once would have put a red X on every PR+ # that nobody could fix, so the job shipped as a ratchet (fail only if the+ # count GROWS), walked down 80 -> 74 -> 71 -> 66. The backlog is now cleared:+ # every fixture carries the fields its schema actually requires, which is+ # the point — a fixture missing `cameraTrack` or `reason` was not testing+ # the shape it claimed to. Keep it at zero. If a genuine error is not worth+ # fixing on the spot, fix the fixture anyway: re-introducing a baseline+ # re-opens the drift this closed.steps:- uses: actions/checkout@v4- uses: ./.github/actions/setup- - name: Typecheck tests against a baseline- shell: bash- env:- BASELINE: 66- run: |- set -uo pipefail- COUNT=$(npx tsc -p tsconfig.test.json --noEmit 2>&1 | grep -c 'error TS' || true)- {- echo "## Test-file typecheck"- echo ""- echo "| | |"- echo "|---|---|"- echo "| Errors now | ${COUNT} |"- echo "| Baseline | ${BASELINE} |"- } >> "$GITHUB_STEP_SUMMARY"- if [ "${COUNT}" -gt "${BASELINE}" ]; then- echo "::error::Test-file type errors went ${BASELINE} -> ${COUNT}. Fix the new ones, or raise BASELINE in ci.yml with a reason."- npx tsc -p tsconfig.test.json --noEmit 2>&1 | grep 'error TS' || true- exit 1- fi- if [ "${COUNT}" -lt "${BASELINE}" ]; then- echo "::notice::Test-file type errors down to ${COUNT} (baseline ${BASELINE}). Lower BASELINE in ci.yml to lock the win in."- fi+ - name: Typecheck tests+ run: npx tsc -p tsconfig.test.json --noEmitdocs:name: Docsdiff --git a/electron/ai-edition/chat-service.test.ts b/electron/ai-edition/chat-service.test.tsindex c1e6f1fe6..1f78e0dcc 100644--- a/electron/ai-edition/chat-service.test.ts+++ b/electron/ai-edition/chat-service.test.ts@@ -1,3 +1,5 @@+import { tmpdir } from "node:os";+import path from "node:path";import { beforeEach, describe, expect, it } from "vitest";import { type AxcutDocument, createEmptyDocument } from "../../src/lib/ai-edition/schema";import {@@ -8,6 +10,7 @@ import {runTimelineOperation,selectSession,} from "./chat-service";+import { DocumentService } from "./document-service";import type { LlmConfigStore } from "./llm-config-store";describe("chat-service sessions", () => {@@ -126,6 +129,8 @@ describe("runTimelineOperation", () => {label: "Rec",originalPath: "/tmp/r.mp4",durationSec: 60,+ // Screen-only recording: no webcam track attached.+ cameraTrack: null,},],timeline: {@@ -147,20 +152,42 @@ describe("runTimelineOperation", () => {};}+ // runTimelineOperation takes the concrete DocumentService, which owns private+ // state (projectsRoot, the per-project write queue), so no object literal can+ // stand in for it. Subclassing keeps the stub a real DocumentService while+ // replacing the only two methods runTimelineOperation calls with in-memory+ // versions — nothing here touches the filesystem, so projectsRoot is never+ // read and no directory is created.+ class StubDocumentService extends DocumentService {+ constructor(readonly file: { stored: AxcutDocument | undefined }) {+ super(path.join(tmpdir(), "openscreen-chat-service-test-unused"));+ }++ override async getProject(): Promise<AxcutDocument> {+ if (!this.file.stored) throw new Error("no document");+ return this.file.stored;+ }++ override async saveProject(doc: AxcutDocument): Promise<AxcutDocument> {+ this.file.stored = doc;+ return doc;+ }+ }++ // Same stub, but both disk-facing methods fail — the "disk is dead" path.+ class BrokenDocumentService extends StubDocumentService {+ override async getProject(): Promise<AxcutDocument> {+ throw new Error("disk is dead");+ }++ override async saveProject(): Promise<AxcutDocument> {+ throw new Error("disk is dead");+ }+ }+function makeDocumentsStub() {- const initial = makeDocument();- const file: { stored: AxcutDocument | undefined } = { stored: initial };- const documents = {- async getProject(_id: string): Promise<AxcutDocument> {- if (!file.stored) throw new Error("no document");- return file.stored;- },- async saveProject(doc: AxcutDocument): Promise<AxcutDocument> {- file.stored = doc;- return doc;- },- };- return { documents, file };+ const file: { stored: AxcutDocument | undefined } = { stored: makeDocument() };+ return { documents: new StubDocumentService(file), file };}it("applies the op, persists, and records an assistant summary", async () => {@@ -185,14 +212,7 @@ describe("runTimelineOperation", () => {});it("returns success:false on getProject failure", async () => {- const documents = {- async getProject() {- throw new Error("disk is dead");- },- async saveProject() {- throw new Error("disk is dead");- },- };+ const documents = new BrokenDocumentService({ stored: makeDocument() });const s = createSession("proj_run_err");const result = await runTimelineOperation("proj_run_err",diff --git a/electron/ai-edition/deep-agent/service.test.ts b/electron/ai-edition/deep-agent/service.test.tsindex 5753e0e8a..ec7770ac7 100644--- a/electron/ai-edition/deep-agent/service.test.ts+++ b/electron/ai-edition/deep-agent/service.test.ts@@ -15,6 +15,7 @@// and read tools were announced only by the lying emission.import { ChatAnthropic } from "@langchain/anthropic";+import type { StructuredToolInterface } from "@langchain/core/tools";import { ChatOpenAI } from "@langchain/openai";import { describe, expect, it } from "vitest";import {@@ -169,10 +170,20 @@ function recordingSink(): { sink: OpenScreenAgentSink; events: SinkEvent[] } {};}+/** `buildTools` returns a tuple with a DISTINCT type per tool, one per zod+ * schema, so `tools.find(...)` is a 19-way union — and `.invoke` is generic, a+ * shape TypeScript will not call through a union (TS2349). Widening to the+ * interface every one of them implements is what the model is handed anyway:+ * `createAgent` takes them as `ClientTool`, i.e. exactly this. Nothing the+ * tests read is lost — `name`, `description`, `schema` and `invoke` all live on+ * the interface. */+type BuiltTool = StructuredToolInterface;+function toolsFor(document: AxcutDocument) {const { sink, events } = recordingSink();const holder = { current: document };- return { tools: buildTools(holder, sink), events, holder };+ const tools: BuiltTool[] = buildTools(holder, sink);+ return { tools, events, holder };}describe("the tool surface handed to the model", () => {@@ -242,7 +253,7 @@ describe("the sink announces each call exactly once, with the real verdict", ()const { tools, events } = toolsFor(document);const tool = tools.find((t) => t.name === name);if (!tool) throw new Error(`${name} is not built`);- await tool.invoke(args as never);+ await tool.invoke(args);expect(events.map((e) => e.kind)).toEqual(["toolStart", "toolEnd"]);expect(events[0].name).toBe(name);@@ -270,7 +281,7 @@ describe("the sink announces each call exactly once, with the real verdict", ()const { tools, events } = toolsFor(document);const tool = tools.find((t) => t.name === "getTranscript");if (!tool) throw new Error("getTranscript is not built");- const result = await tool.invoke({} as never);+ const result = await tool.invoke({});expect(String(result)).toContain("No transcript");expect(events).toHaveLength(2);@@ -283,12 +294,12 @@ describe("the sink announces each call exactly once, with the real verdict", ()const refused = tools.find((t) => t.name === "setZoom");if (!refused) throw new Error("setZoom is not built");- await refused.invoke({ zoomId: "zoom_nope" } as never);+ await refused.invoke({ zoomId: "zoom_nope" });expect(holder.current).toBe(before);const write = tools.find((t) => t.name === "addTrim");if (!write) throw new Error("addTrim is not built");- await write.invoke({ startSec: 1, endSec: 2 } as never);+ await write.invoke({ startSec: 1, endSec: 2 });expect(holder.current).not.toBe(before);expect(holder.current.timeline.trimRanges).toHaveLength(2);});@@ -389,20 +400,20 @@ describe("the prompt when the user has turned project edits off", () => {describe("the tools when the user has turned project edits off", () => {it("still builds all 18 — the model has to be able to NAME the edit", () => {const { sink } = recordingSink();- const tools = buildTools({ current: fixtureDocument() }, sink, false);+ const tools: BuiltTool[] = buildTools({ current: fixtureDocument() }, sink, false);expect(tools.map((t) => t.name)).toEqual(OPENSCREEN_TOOLS);});it("refuses every write through the tool, and the sink says so", async () => {const holder = { current: fixtureDocument() };const { sink, events } = recordingSink();- const tools = buildTools(holder, sink, false);+ const tools: BuiltTool[] = buildTools(holder, sink, false);const before = holder.current;for (const name of OPENSCREEN_TOOLS.filter((n) => isMutatingTool(n))) {const tool = tools.find((t) => t.name === name);if (!tool) throw new Error(`${name} is not built`);- const result = await tool.invoke((ARGS[name] ?? {}) as never);+ const result = await tool.invoke(ARGS[name] ?? {});expect(JSON.parse(String(result)).code, name).toBe("consent_required");}// Not one of them advanced the document.@@ -413,10 +424,14 @@ describe("the tools when the user has turned project edits off", () => {});it("leaves the reads working", async () => {- const tools = buildTools({ current: fixtureDocument() }, recordingSink().sink, false);+ const tools: BuiltTool[] = buildTools(+ { current: fixtureDocument() },+ recordingSink().sink,+ false,+ );const read = tools.find((t) => t.name === "getCurrentDocument");if (!read) throw new Error("getCurrentDocument is not built");- expect(JSON.parse(String(await read.invoke({} as never))).primaryAssetId).toBe("asset_1");+ expect(JSON.parse(String(await read.invoke({}))).primaryAssetId).toBe("asset_1");});});@@ -451,10 +466,10 @@ const SAMPLES = (() => {async function invokeCursorTool(runtime: Parameters<typeof buildTools>[3]) {const { sink, events } = recordingSink();- const tools = buildTools({ current: fixtureDocument() }, sink, true, runtime);+ const tools: BuiltTool[] = buildTools({ current: fixtureDocument() }, sink, true, runtime);const tool = tools.find((t) => t.name === "getCursorTrack");if (!tool) throw new Error("getCursorTrack is not built");- const result = await tool.invoke({} as never);+ const result = await tool.invoke({});return { payload: JSON.parse(String(result)), events };}@@ -518,12 +533,12 @@ describe("cursor telemetry reaches the model", () => {},};const { sink } = recordingSink();- const tools = buildTools({ current: fixtureDocument() }, sink, true, runtime);+ const tools: BuiltTool[] = buildTools({ current: fixtureDocument() }, sink, true, runtime);const tool = tools.find((t) => t.name === "getCursorTrack");if (!tool) throw new Error("getCursorTrack is not built");- await tool.invoke({} as never);- await tool.invoke({ assetId: "asset_1" } as never);+ await tool.invoke({});+ await tool.invoke({ assetId: "asset_1" });// Both resolve to the primary asset — the wrapper and the executor must// agree on which asset is being reported, or the answer describes one and@@ -544,11 +559,13 @@ describe("cursor telemetry reaches the model", () => {},};const { sink } = recordingSink();- const tools = buildTools({ current: fixtureDocument() }, sink, true, runtime);+ const tools: BuiltTool[] = buildTools({ current: fixtureDocument() }, sink, true, runtime);const tool = tools.find((t) => t.name === "getCursorTrack");if (!tool) throw new Error("getCursorTrack is not built");- await tool.invoke({ assetId: "asset_1", path: "/etc/passwd" } as never);+ // The extra `path` is the point of the test: the model is allowed to ask+ // for anything, and the tool must ignore what it did not declare.+ await tool.invoke({ assetId: "asset_1", path: "/etc/passwd" });expect(seen).toEqual([{ originalPath: fixtureDocument().assets[0].originalPath }]);});diff --git a/electron/ai-edition/document-service.test.ts b/electron/ai-edition/document-service.test.tsindex bd3495e2b..ecc988a07 100644--- a/electron/ai-edition/document-service.test.ts+++ b/electron/ai-edition/document-service.test.ts@@ -3,6 +3,7 @@ import os from "node:os";import path from "node:path";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import type { AxcutDocument } from "../../src/lib/ai-edition/schema";+import { axcutSchemaVersion } from "../../src/lib/ai-edition/schema";import { DocumentNotFoundError, DocumentService, ProjectFileError } from "./document-service";async function makeTempDir(): Promise<string> {@@ -34,7 +35,7 @@ describe("DocumentService", () => {const filePath = path.join(tempDir, `${doc.project.id}.openscreen`);const raw = await fs.readFile(filePath, "utf8");expect(JSON.parse(raw)).toMatchObject({- schemaVersion: 7,+ schemaVersion: axcutSchemaVersion,project: { title: "Demo Project" },});});@@ -142,7 +143,7 @@ describe("DocumentService", () => {it("removes the asset and cascades clips + trimRanges", async () => {const doc = await service.createProject("P");const withAsset = await service.addAsset(doc.project.id, { path: "/tmp/a.mp4" });- const assetId = withAsset.assets[0]?.id;+ const assetId = withAsset.assets[0]?.id ?? "";expect(assetId).toBeTruthy();// Manually add a clip + trimRange so we can verify cascade@@ -159,6 +160,7 @@ describe("DocumentService", () => {timelineEndSec: 1,wordRefs: [],origin: "system",+ reason: "",},],trimRanges: [@@ -168,12 +170,13 @@ describe("DocumentService", () => {startSec: 0,endSec: 1,origin: "user",+ reason: "",},],},});- const after = await service.removeAsset(docWithTimeline.project.id, assetId ?? "");+ const after = await service.removeAsset(docWithTimeline.project.id, assetId);expect(after.assets).toHaveLength(0);expect(after.timeline.clips).toHaveLength(0);expect(after.timeline.trimRanges).toHaveLength(0);diff --git a/electron/native-bridge/services/compositorViewService.test.ts b/electron/native-bridge/services/compositorViewService.test.tsindex 0c04e7bc1..1569816af 100644--- a/electron/native-bridge/services/compositorViewService.test.ts+++ b/electron/native-bridge/services/compositorViewService.test.ts@@ -281,7 +281,10 @@ describe("resolveSceneAssetPaths", () => {Object.defineProperty(process, "resourcesPath", originalResourcesPath);}if (originalVitePublic === undefined) {- delete process.env.VITE_PUBLIC;+ // `NodeJS.ProcessEnv.VITE_PUBLIC` is declared non-optional (electron-env.d.ts),+ // so `delete` is rejected outright even though main.ts only assigns it at+ // startup and it really is absent under vitest. Reflect deletes the same key.+ Reflect.deleteProperty(process.env, "VITE_PUBLIC");} else {process.env.VITE_PUBLIC = originalVitePublic;}@@ -292,6 +295,10 @@ describe("resolveSceneAssetPaths", () => {return JSON.parse(resolveSceneAssetPaths(JSON.stringify(scene)));}+ /** What `resolveSceneAssetPaths` writes into `cursor.cursorSprites` — same shape the+ * service declares for the sprite map it builds. */+ type ResolvedSprite = { path: string; hotspotX: number; hotspotY: number };+it("resolves a bundled wallpaper to the extraResources copy, not the unreadable asar path", () => {const out = resolved({ background: { kind: "image", path: "/wallpapers/wallpaper1.jpg" } });@@ -324,7 +331,7 @@ describe("resolveSceneAssetPaths", () => {// The whole point of the fraction: it survives the size slider. A hotspot in source// pixels would have to be rescaled at draw time, and drifted when it wasn't.- for (const [type, sprite] of Object.entries(sprites)) {+ for (const [type, sprite] of Object.entries<ResolvedSprite>(sprites)) {expect(sprite.hotspotX, type).toBeGreaterThanOrEqual(0);expect(sprite.hotspotX, type).toBeLessThanOrEqual(1);expect(sprite.hotspotY, type).toBeGreaterThanOrEqual(0);diff --git a/electron/recording/webm-duration.test.ts b/electron/recording/webm-duration.test.tsindex d796bb36b..9c742a9b2 100644--- a/electron/recording/webm-duration.test.ts+++ b/electron/recording/webm-duration.test.ts@@ -1,7 +1,7 @@import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";import { tmpdir } from "node:os";import path from "node:path";-import { WebmBase, WebmContainer, WebmFile, WebmString, WebmUint } from "@fix-webm-duration/parser";+import { WebmContainer, WebmFile, WebmString, WebmUint } from "@fix-webm-duration/parser";import { afterEach, beforeEach, describe, expect, it } from "vitest";import { patchWebmDurationOnDisk } from "./webm-duration";@@ -10,6 +10,17 @@ interface WebmElementMock {getValue: () => number;}+// EBML element length encoded as a 4-byte VINT: 0x10 marker in the leading byte+// plus 28 bits of length, which covers both fixture sizes below.+function ebmlLength4(length: number): Buffer {+ return Buffer.from([+ 0x10 | ((length >>> 24) & 0x0f),+ (length >>> 16) & 0xff,+ (length >>> 8) & 0xff,+ length & 0xff,+ ]);+}+describe("webm-duration patching", () => {let dir: string;const pathFor = (name: string) => path.join(dir, name);@@ -42,26 +53,35 @@ describe("webm-duration patching", () => {info.updateByData();segment.data.push({ id: 0x549a966, idHex: "549a966", data: info });+ segment.updateByData();+if (includeCluster) {- const cluster = new WebmBase("Cluster");- // A valid EBML element for Cluster: ID 0x1f43b675 (stripped as 0xf43b675)- // Followed by a VINT for length (e.g. clusterSize bytes)- const header = Buffer.from([0x1f, 0x43, 0xb6, 0x75, 0x01, 0x00]); // 6 bytes header (id + length)- const body = Buffer.alloc(clusterSize, 0x42); // cluster data filled with 0x42- const clusterBytes = Buffer.concat([header, body]);-- cluster.setSource(new Uint8Array(clusterBytes));- segment.data.push({ id: 0xf43b675, idHex: "f43b675", data: cluster });+ // The Cluster is appended as raw bytes rather than as a `WebmContainerItem`:+ // the parser's `sections` map has no entry for Cluster (0x1f43b675), so its+ // id is not a `SectionKey`, and `WebmBase`'s constructor is protected.+ // Bytes are all that matters here anyway — patchWebmDurationOnDisk re-parses+ // the fixture from disk, so appending the element to the Segment payload is+ // equivalent to registering it as a child.+ // A valid EBML element for Cluster: ID 0x1f43b675, a VINT length, then the+ // cluster data filled with 0x42.+ const body = Buffer.alloc(clusterSize, 0x42);+ const clusterBytes = Buffer.concat([+ Buffer.from([0x1f, 0x43, 0xb6, 0x75]),+ ebmlLength4(body.length),+ body,+ ]);+ const segmentPayload = segment.source;+ if (!segmentPayload) throw new Error("fixture: Segment has no source after updateByData");+ segment.source = Buffer.concat([Buffer.from(segmentPayload), clusterBytes]);}- segment.updateByData();-const file = new WebmContainer("File");file.data = [];file.data.push({ id: 0xa45dfa3, idHex: "a45dfa3", data: ebml });file.data.push({ id: 0x8538067, idHex: "8538067", data: segment });file.updateByData();+ if (!file.source) throw new Error("fixture: File has no source after updateByData");return file.source;}diff --git a/electron/stt/modelManager.test.ts b/electron/stt/modelManager.test.tsindex 192cefe2f..92145dc7a 100644--- a/electron/stt/modelManager.test.ts+++ b/electron/stt/modelManager.test.ts@@ -72,8 +72,11 @@ describe("modelManager", () => {}> = [];let fetches = 0;- const fetcher: typeof fetch = async (url: string) => {+ const fetcher: typeof fetch = async (input) => {fetches++;+ // ensureModels passes a plain string URL, but a `typeof fetch` stub has to+ // honour the whole signature (string | URL | Request).+ const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;const content = Buffer.from(`content-for-${url.split("/").pop()}`);return new Response(content, { status: 200 });};diff --git a/electron/stt/whisperServer.test.ts b/electron/stt/whisperServer.test.tsindex 35d789586..2ee9bdfdc 100644--- a/electron/stt/whisperServer.test.ts+++ b/electron/stt/whisperServer.test.ts@@ -6,7 +6,14 @@ import { writeSamplesAsWav } from "./wav";import { WhisperServerManager } from "./whisperServer";vi.mock("node:child_process", async (importOriginal) => {- const actual = await importOriginal<typeof import("node:child_process")>();+ // `node:child_process` is CJS, so the ESM namespace also carries a `default`+ // holding the same exports — undeclared in @types/node. The mock has to keep it+ // so `import cp from "node:child_process"` consumers still see the stub.+ const actual = await importOriginal<+ typeof import("node:child_process") & {+ default?: Partial<typeof import("node:child_process")>;+ }+ >();const spawn = vi.fn();return { ...actual, spawn, default: { ...(actual.default ?? {}), spawn } };});diff --git a/src/components/ai-edition/EditorEmptyState.test.tsx b/src/components/ai-edition/EditorEmptyState.test.tsxindex 0ed9d5381..e6ae69246 100644--- a/src/components/ai-edition/EditorEmptyState.test.tsx+++ b/src/components/ai-edition/EditorEmptyState.test.tsx@@ -3,6 +3,7 @@ import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-libraimport type { ReactElement } from "react";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { I18nProvider } from "@/contexts/I18nContext";+import type { AxcutDocument } from "@/lib/ai-edition/schema";import { useProjectStore } from "@/lib/ai-edition/store/projectStore";import { EditorEmptyState } from "./EditorEmptyState";@@ -20,33 +21,40 @@ const bridgeMocks = vi.hoisted(() => ({openVideoFilePicker: vi.fn(),}));-const sampleDoc = vi.hoisted(() => ({- // ponytail: the bridge contract after the migration hoist is v6 — every- // load site (DocumentService, browserShim) runs `migrateRawDocumentToCurrent`- // before returning, and the renderer's `parseDocument` is a pure v6- // validator. Test fixtures model the post-hoist contract.- schemaVersion: 7,- project: {- id: "proj_test",- title: "Test",- createdAt: "2026-06-25T10:00:00.000Z",- updatedAt: "2026-06-25T10:00:00.000Z",- },- assets: [],- transcript: null,- transcripts: [],- timeline: {- clips: [],- gaps: [],- trimRanges: [],- muteRanges: [],- speedRegions: [],- captionRanges: [],- },- annotations: [],- zoomRanges: [],- legacyEditor: null,-}));+const sampleDoc = vi.hoisted(+ (): AxcutDocument => ({+ // ponytail: the bridge contract after the migration hoist is the CURRENT version —+ // every load site (DocumentService, browserShim) runs `migrateRawDocumentToCurrent`+ // before returning, and the renderer's `parseDocument` is a pure current-version+ // validator. Test fixtures model the post-hoist contract, so they read the version+ // off `axcutSchemaVersion` instead of restating it.+ // A literal, not `axcutSchemaVersion`: `vi.hoisted` runs before the module's+ // imports are initialised, so reading the constant here throws+ // "Cannot access ... before initialization". The typecheck gate catches it+ // if it ever falls behind the schema.+ schemaVersion: 7,+ project: {+ id: "proj_test",+ title: "Test",+ createdAt: "2026-06-25T10:00:00.000Z",+ updatedAt: "2026-06-25T10:00:00.000Z",+ },+ assets: [],+ transcript: null,+ transcripts: [],+ timeline: {+ clips: [],+ gaps: [],+ trimRanges: [],+ muteRanges: [],+ speedRanges: [],+ captionRanges: [],+ },+ annotations: [],+ zoomRanges: [],+ legacyEditor: null,+ }),+);function setupElectronApi() {Object.assign(window, {diff --git a/src/components/ai-edition/ExportDialog.test.ts b/src/components/ai-edition/ExportDialog.test.tsindex 560440033..3aa8d85b5 100644--- a/src/components/ai-edition/ExportDialog.test.ts+++ b/src/components/ai-edition/ExportDialog.test.ts@@ -4,7 +4,12 @@ import {collectUsedAssetDims,pickExtremeDims,} from "@/lib/ai-edition/document/outputFormat";-import type { AxcutAsset, AxcutClip, AxcutDocument } from "@/lib/ai-edition/schema";+import {+ type AxcutAsset,+ type AxcutClip,+ type AxcutDocument,+ axcutSchemaVersion,+} from "@/lib/ai-edition/schema";function asset(p: Partial<AxcutAsset> & Pick<AxcutAsset, "id">): AxcutAsset {return {@@ -31,7 +36,7 @@ function clip(p: Partial<AxcutClip> & Pick<AxcutClip, "id" | "assetId">): AxcutCfunction doc(assets: AxcutAsset[], clips: AxcutClip[]): AxcutDocument {return {- schemaVersion: 3,+ schemaVersion: axcutSchemaVersion,project: {id: "proj_1",title: "Test",diff --git a/src/components/ai-edition/WebcamOverlay.test.tsx b/src/components/ai-edition/WebcamOverlay.test.tsxindex 5fbfc9a04..9c49ec6f5 100644--- a/src/components/ai-edition/WebcamOverlay.test.tsx+++ b/src/components/ai-edition/WebcamOverlay.test.tsx@@ -2,6 +2,7 @@ import "@testing-library/jest-dom";import { cleanup, render } from "@testing-library/react";import { afterEach, describe, expect, it } from "vitest";import type { AxcutClip, AxcutDocument } from "@/lib/ai-edition/schema";+import { axcutSchemaVersion } from "@/lib/ai-edition/schema";import { useProjectStore } from "@/lib/ai-edition/store/projectStore";import { WebcamOverlay } from "./WebcamOverlay";@@ -36,7 +37,7 @@ const CLIP_WITHOUT_CAMERA: AxcutClip = {function makeDocument(): AxcutDocument {return {- schemaVersion: 7,+ schemaVersion: axcutSchemaVersion,project: {id: "proj_test",title: "Test",diff --git a/src/components/video-editor/projectPersistence.test.ts b/src/components/video-editor/projectPersistence.test.tsindex 0671b3fae..1ba5192c7 100644--- a/src/components/video-editor/projectPersistence.test.ts+++ b/src/components/video-editor/projectPersistence.test.ts@@ -1,4 +1,5 @@import { describe, expect, it } from "vitest";+import { DEFAULT_CURSOR_THEME_ID } from "@/lib/cursor/cursorThemes";import {createProjectData,createProjectSnapshot,@@ -38,6 +39,9 @@ describe("projectPersistence media compatibility", () => {padding: 50,cropRegion: { x: 0, y: 0, width: 1, height: 1 },zoomRegions: [],+ cameraFullscreenRegions: [],+ autoZoomEnabled: true,+ autoFocusAll: false,trimRegions: [],speedRegions: [],annotationRegions: [],@@ -45,6 +49,7 @@ describe("projectPersistence media compatibility", () => {webcamLayoutPreset: "picture-in-picture",webcamMaskShape: "circle",webcamMirrored: true,+ webcamReactiveZoom: false,webcamSizePreset: 25,webcamPosition: null,exportQuality: "good",@@ -52,6 +57,7 @@ describe("projectPersistence media compatibility", () => {gifFrameRate: 15,gifLoop: true,gifSizePreset: "medium",+ cursorTheme: DEFAULT_CURSOR_THEME_ID,},);diff --git a/src/lib/ai-edition/document/migrate.test.ts b/src/lib/ai-edition/document/migrate.test.tsindex 8dc4342f5..49308129d 100644--- a/src/lib/ai-edition/document/migrate.test.ts+++ b/src/lib/ai-edition/document/migrate.test.ts@@ -21,6 +21,7 @@ function makeV2Project(overrides: Partial<EditorProjectData> = {}): EditorProjecpadding: 50,cropRegion: { x: 0, y: 0, width: 1, height: 1 },zoomRegions: [],+ cameraFullscreenRegions: [],autoZoomEnabled: false,autoFocusAll: false,trimRegions: [],@@ -45,7 +46,7 @@ function makeV2Project(overrides: Partial<EditorProjectData> = {}): EditorProjec}describe("migrateProjectDataToAxcutDocument", () => {- it("produces a v3 document with one asset and one clip from a v2 single-recording project", () => {+ it("produces a current-schema document with one asset and one clip from a v2 single-recording project", () => {const doc = migrateProjectDataToAxcutDocument(makeV2Project());expect(doc.schemaVersion).toBe(7);diff --git a/src/lib/ai-edition/document/operations.test.ts b/src/lib/ai-edition/document/operations.test.tsindex 6fba75312..a4f58128a 100644--- a/src/lib/ai-edition/document/operations.test.ts+++ b/src/lib/ai-edition/document/operations.test.ts@@ -5,9 +5,19 @@// `electron/ai-edition/chat-service.test.ts`.import { describe, expect, it } from "vitest";-import { type AxcutDocument, createEmptyDocument } from "../schema";+import { type AxcutClip, type AxcutDocument, createEmptyDocument } from "../schema";import { applyTimelineOperation } from "./operations";+// `sourceEndSec` is optional in the schema (a clip migrated before its asset was+// probed has no known end). Every clip these operations build does have one, so+// assert that rather than folding a missing end into a zero-length clip.+function sourceLength(clip: AxcutClip): number {+ if (clip.sourceEndSec === undefined) {+ throw new Error(`clip ${clip.id} has no sourceEndSec`);+ }+ return clip.sourceEndSec - clip.sourceStartSec;+}+function makeDoc(): AxcutDocument {const base = createEmptyDocument({ title: "Test", projectId: "proj_ops" });const asset = {@@ -16,6 +26,7 @@ function makeDoc(): AxcutDocument {label: "Recording",originalPath: "C:/videos/rec.mp4",durationSec: 60,+ cameraTrack: null,};return {...base,@@ -77,6 +88,7 @@ describe("applyTimelineOperation.add_trim_range", () => {label: "Recording 2",originalPath: "C:/videos/rec2.mp4",durationSec: 30,+ cameraTrack: null,};const docWithTwoAssets: AxcutDocument = {...doc,@@ -254,7 +266,7 @@ describe("applyTimelineOperation.drop_range", () => {expect(asset).toBeDefined();const totalKeep = next.timeline.clips.filter((c) => c.assetId === "asset_1")- .reduce((sum, c) => sum + (c.sourceEndSec - c.sourceStartSec), 0);+ .reduce((sum, c) => sum + sourceLength(c), 0);expect(totalKeep).toBe(50);});@@ -297,7 +309,7 @@ describe("applyTimelineOperation.replace_timeline", () => {expect(result.summary).toMatch(/rebuilt timeline .2 interval/);const clips = result.document.timeline.clips.filter((c) => c.assetId === "asset_1");expect(clips).toHaveLength(2);- const totalClip = clips.reduce((s, c) => s + (c.sourceEndSec - c.sourceStartSec), 0);+ const totalClip = clips.reduce((s, c) => s + sourceLength(c), 0);expect(totalClip).toBe(25);});});@@ -315,7 +327,7 @@ describe("applyTimelineOperation.restore_full_timeline", () => {expect(asset).toBeDefined();const totalClip = restored.document.timeline.clips.filter((c) => c.assetId === "asset_1")- .reduce((s, c) => s + (c.sourceEndSec - c.sourceStartSec), 0);+ .reduce((s, c) => s + sourceLength(c), 0);expect(totalClip).toBe(60);expect(restored.document.timeline.trimRanges).toHaveLength(0);});diff --git a/src/lib/ai-edition/document/outputFormat.test.ts b/src/lib/ai-edition/document/outputFormat.test.tsindex 9c16552c6..4ceac442f 100644--- a/src/lib/ai-edition/document/outputFormat.test.ts+++ b/src/lib/ai-edition/document/outputFormat.test.ts@@ -1,5 +1,10 @@import { describe, expect, it } from "vitest";-import type { AxcutAsset, AxcutClip, AxcutDocument } from "@/lib/ai-edition/schema";+import {+ type AxcutAsset,+ type AxcutClip,+ type AxcutDocument,+ axcutSchemaVersion,+} from "@/lib/ai-edition/schema";import {ASPECT_RATIO_PRESETS,type AspectRatio,@@ -41,7 +46,7 @@ function clip(id: string, assetId: string, cropRegion?: AxcutClip["cropRegion"])function doc(assets: AxcutAsset[], clips: AxcutClip[]): AxcutDocument {return {- schemaVersion: 3,+ schemaVersion: axcutSchemaVersion,project: {id: "proj_1",title: "Test",@@ -63,7 +68,7 @@ function doc(assets: AxcutAsset[], clips: AxcutClip[]): AxcutDocument {annotations: [],zoomRanges: [],legacyEditor: null,- } as AxcutDocument;+ };}describe("collectNativeFormats", () => {diff --git a/src/lib/ai-edition/document/timeline.test.ts b/src/lib/ai-edition/document/timeline.test.tsindex ccfafd90d..19f90a8ca 100644--- a/src/lib/ai-edition/document/timeline.test.ts+++ b/src/lib/ai-edition/document/timeline.test.ts@@ -1,5 +1,10 @@import { describe, expect, it } from "vitest";-import type { AxcutClip, AxcutDocument, AxcutTrimRange } from "../schema";+import {+ type AxcutClip,+ type AxcutDocument,+ type AxcutTrimRange,+ axcutSchemaVersion,+} from "../schema";import {buildTimelineFromIntervals,duplicateClip,@@ -22,7 +27,7 @@ import {function makeDoc(overrides: Partial<AxcutDocument> = {}): AxcutDocument {return {- schemaVersion: 3,+ schemaVersion: axcutSchemaVersion,project: {id: "proj_1",title: "Test",@@ -37,6 +42,7 @@ function makeDoc(overrides: Partial<AxcutDocument> = {}): AxcutDocument {label: "screen.mp4",originalPath: "/tmp/screen.mp4",durationSec: 60,+ cameraTrack: null,},],transcript: null,@@ -951,7 +957,6 @@ describe("duplicateClip / moveClip", () => {zoomRanges: [{id: "z1",- groupId: "z1",clipId: "clip_b",sourceStartSec: 22,sourceEndSec: 24,diff --git a/src/lib/ai-edition/document/transcribe.test.ts b/src/lib/ai-edition/document/transcribe.test.tsindex b943839eb..72dc8d00b 100644--- a/src/lib/ai-edition/document/transcribe.test.ts+++ b/src/lib/ai-edition/document/transcribe.test.ts@@ -1,5 +1,5 @@import { describe, expect, it, vi } from "vitest";-import type { AxcutDocument, AxcutTranscript } from "../schema";+import { type AxcutDocument, type AxcutTranscript, axcutSchemaVersion } from "../schema";import { toAxcutTranscriptDsl, transcribeAsset } from "./transcribe";vi.mock("@/components/video-editor/projectPersistence", () => ({@@ -19,7 +19,7 @@ const transcribeMock = vi.mocked(transcribeMono16kToSegments);function makeDoc(): AxcutDocument {return {- schemaVersion: 3,+ schemaVersion: axcutSchemaVersion,project: {id: "proj_1",title: "Test",@@ -34,15 +34,18 @@ function makeDoc(): AxcutDocument {label: "demo.mp4",originalPath: "/tmp/demo.mp4",durationSec: 60,+ cameraTrack: null,},],transcript: null,transcripts: [],timeline: {- id: "tl_1",clips: [],gaps: [],- operations: [],+ trimRanges: [],+ muteRanges: [],+ speedRanges: [],+ captionRanges: [],},annotations: [],zoomRanges: [],diff --git a/src/lib/ai-edition/store/editorSettings.test.ts b/src/lib/ai-edition/store/editorSettings.test.tsindex f7af90df9..aed3e43f5 100644--- a/src/lib/ai-edition/store/editorSettings.test.ts+++ b/src/lib/ai-edition/store/editorSettings.test.ts@@ -6,18 +6,31 @@ import {DEFAULT_WEBCAM_MASK_SHAPE,} from "@/components/video-editor/types";import type { AxcutDocument } from "../schema";+import { axcutSchemaVersion } from "../schema";import { DEFAULT_EDITOR_SETTINGS, getEditorSettings, patchEditorSettings } from "./editorSettings";const baseDoc: AxcutDocument = {- schemaVersion: 3,- project: { id: "p1", title: "Test", primaryAssetId: "a1" },- assets: [{ id: "a1", kind: "video", label: "clip", originalPath: "/x.mp4" }],- timeline: { clips: [], trimRanges: [] },+ schemaVersion: axcutSchemaVersion,+ project: {+ id: "p1",+ title: "Test",+ createdAt: "2026-06-25T10:00:00.000Z",+ updatedAt: "2026-06-25T10:00:00.000Z",+ primaryAssetId: "a1",+ },+ assets: [{ id: "a1", kind: "video", label: "clip", originalPath: "/x.mp4", cameraTrack: null }],+ timeline: {+ clips: [],+ gaps: [],+ trimRanges: [],+ muteRanges: [],+ speedRanges: [],+ captionRanges: [],+ },annotations: [],zoomRanges: [],transcripts: [],transcript: null,- preview: { revision: 0 },legacyEditor: null,};diff --git a/src/lib/ai-edition/store/useTimeline.test.ts b/src/lib/ai-edition/store/useTimeline.test.tsindex ebeeacc37..74ad15de8 100644--- a/src/lib/ai-edition/store/useTimeline.test.ts+++ b/src/lib/ai-edition/store/useTimeline.test.ts@@ -2,6 +2,7 @@ import { act, renderHook, waitFor } from "@testing-library/react";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { I18nProvider } from "@/contexts/I18nContext";import type { AxcutDocument } from "../schema";+import { axcutSchemaVersion } from "../schema";import { useProjectStore } from "./projectStore";import { useTimeline } from "./useTimeline";@@ -48,12 +49,18 @@ vi.mock("@/native/client", () => ({},}));-const sampleDoc = {- // ponytail: the bridge contract after the migration hoist is v6 — every- // load site (DocumentService, browserShim) runs `migrateRawDocumentToCurrent`- // before returning, and the renderer's `parseDocument` is a pure v6- // validator. Test fixtures model the post-hoist contract.- schemaVersion: 7,+const sampleDoc: AxcutDocument = {+ // ponytail: the bridge contract after the migration hoist is the CURRENT version —+ // every load site (DocumentService, browserShim) runs `migrateRawDocumentToCurrent`+ // before returning, and the renderer's `parseDocument` is a pure current-version+ // validator. Test fixtures model the post-hoist contract, so they read the version+ // off `axcutSchemaVersion` instead of restating it.+ // Annotated `AxcutDocument` rather than left to inference: the document type+ // pins `schemaVersion` to the LITERAL 7 and `kind` to `"video"`, both of which+ // an unannotated object literal widens — and the annotation makes every+ // required field (`cameraTrack`) a compile error when it is missing instead of+ // a fixture that silently drifts from the schema.+ schemaVersion: axcutSchemaVersion,project: {id: "proj_test",title: "Test",@@ -69,6 +76,8 @@ const sampleDoc = {originalPath: "/tmp/screen.webm",durationSec: 30,video: { codec: "unknown", width: 1920, height: 1080, fps: 0 },+ // No webcam was recorded alongside this screen capture.+ cameraTrack: null,},],transcript: null,@@ -120,6 +129,7 @@ describe("useTimeline.insertClipAt background duration probe", () => {originalPath: "/tmp/long.webm",durationSec: undefined,video: { codec: "unknown", width: 1920, height: 1080, fps: 0 },+ cameraTrack: null,},],},@@ -163,7 +173,7 @@ describe("useTimeline.insertClipAt background duration probe", () => {});describe("useTimeline.moveClip / duplicateClip (delegates to document/timeline.ts)", () => {- const twoClipDoc = {+ const twoClipDoc: AxcutDocument = {...sampleDoc,timeline: {...sampleDoc.timeline,@@ -350,9 +360,8 @@ describe("useTimeline.updateClipSourceRange (Edit-clip modal)", () => {projectId: "proj_test",document: {...sampleDoc,- schemaVersion: 7,zoomRanges: [anchoredZoom("z_keep", 2, 3), anchoredZoom("z_drop", 6, 8)],- } as unknown as typeof sampleDoc,+ },revision: 1,status: "ready",error: null,@@ -396,9 +405,8 @@ describe("useTimeline.updateClipSourceRange (Edit-clip modal)", () => {useProjectStore.setState({document: {...sampleDoc,- schemaVersion: 7,zoomRanges: [anchoredZoom("z_edge", 3, 7)],- } as unknown as typeof sampleDoc,+ },});const { result } = renderTimeline();await act(async () => {@@ -459,7 +467,7 @@ describe("useTimeline.addAnnotation", () => {});describe("useTimeline zoom modifiers (rotation + focus mode)", () => {- const docWithZoom = {+ const docWithZoom: AxcutDocument = {...sampleDoc,zoomRanges: [{@@ -468,9 +476,14 @@ describe("useTimeline zoom modifiers (rotation + focus mode)", () => {endMs: 3000,depth: 3,focus: { cx: 0.5, cy: 0.5 },- focusMode: "manual" as const,+ focusMode: "manual",+ // v5 clip anchor: clip_a draws source 0..10 at timeline 0..10, so the+ // 1000..3000ms ruler span is source 1..3 of that clip. `startMs`/`endMs`+ // stay as the derived cache. (The fixture used to carry a+ // `clipStartOffsetMs` that exists in no schema and no reader.)clipId: "clip_a",- clipStartOffsetMs: 1000,+ sourceStartSec: 1,+ sourceEndSec: 3,},],};@@ -550,10 +563,7 @@ describe("useTimeline is not re-rendered by playhead ticks", () => {}));useProjectStore.setState({projectId: "proj_test",- // The shared `sampleDoc` fixture predates a few schema fields (see the- // "Typecheck (tests)" ratchet in ci.yml); cast rather than add one more- // error to that backlog.- document: sampleDoc as unknown as AxcutDocument,+ document: sampleDoc,revision: 1,status: "ready",error: null,diff --git a/src/lib/ai-edition/timeline/aggregated-transcript.test.ts b/src/lib/ai-edition/timeline/aggregated-transcript.test.tsindex 61e8c359e..adc70b6cb 100644--- a/src/lib/ai-edition/timeline/aggregated-transcript.test.ts+++ b/src/lib/ai-edition/timeline/aggregated-transcript.test.ts@@ -30,6 +30,7 @@ function makeAsset(overrides: Partial<AxcutAsset> = {}): AxcutAsset {label: "demo.mp4",originalPath: "/tmp/demo.mp4",durationSec: 30,+ cameraTrack: null,...overrides,};}diff --git a/src/lib/ai-edition/timeline/duration.test.ts b/src/lib/ai-edition/timeline/duration.test.tsindex 091c59037..ba1dc3d11 100644--- a/src/lib/ai-edition/timeline/duration.test.ts+++ b/src/lib/ai-edition/timeline/duration.test.ts@@ -16,8 +16,12 @@ describe("probeVideoDuration", () => {vi.useFakeTimers();created = [];originalCreate = document.createElement;+ // `document.createElement` is overloaded, and Electron's typings append a+ // `"webview"`-only overload — the one `.call` resolves to, which then rejects a+ // generic string tag. Pin the plain `(tagName: string) => HTMLElement` overload.+ const createReal: (this: Document, tag: string) => HTMLElement = originalCreate;document.createElement = ((tag: string) => {- const node = originalCreate.call(document, tag);+ const node = createReal.call(document, tag);if (tag === "video") {const fake: FakeVideo = {duration: Number.NaN,diff --git a/src/lib/ai-edition/timeline/pointer-drag.test.tsx b/src/lib/ai-edition/timeline/pointer-drag.test.tsxindex 9468c063d..8ed7f5067 100644--- a/src/lib/ai-edition/timeline/pointer-drag.test.tsx+++ b/src/lib/ai-edition/timeline/pointer-drag.test.tsx@@ -2,11 +2,17 @@ import { fireEvent, render } from "@testing-library/react";import { beforeEach, describe, expect, it, vi } from "vitest";import { startGlobalPointerDrag } from "./pointer-drag";-interface ElementWithCapture extends Element {+// `Element` declares the three pointer-capture methods as always present, but jsdom+// may ship without them — hence Omit + optional redeclaration rather than `extends`,+// which cannot make an inherited required member optional.+type ElementWithCapture = Omit<+ Element,+ "hasPointerCapture" | "setPointerCapture" | "releasePointerCapture"+> & {hasPointerCapture?: (id: number) => boolean;setPointerCapture?: (id: number) => void;releasePointerCapture?: (id: number) => void;-}+};describe("startGlobalPointerDrag", () => {beforeEach(() => {@@ -97,7 +103,12 @@ describe("startGlobalPointerDrag", () => {it("cancel-returned function ends with pointercancel", () => {const onEnd = vi.fn();- let cancel: (() => void) | null = null;+ // Seeded with a no-op instead of null: the assignment happens inside the+ // pointerdown handler, which control-flow analysis cannot see, so a nullable+ // `cancel` narrows to `null` and stops being callable at the call site below.+ // If the handler never ran, calling the no-op leaves `onEnd` unfired and the+ // expectation still fails.+ let cancel: () => void = () => undefined;const { getByRole } = render(<buttontype="button"@@ -112,7 +123,7 @@ describe("startGlobalPointerDrag", () => {</button>,);fireEvent.pointerDown(getByRole("button"), { pointerId: 5, buttons: 1 });- cancel?.();+ cancel();expect(onEnd).toHaveBeenCalledWith("pointercancel", undefined);});});diff --git a/src/lib/ai-edition/timeline/timelineMap.test.ts b/src/lib/ai-edition/timeline/timelineMap.test.tsindex 4bbd8fe6d..bf2a0c128 100644--- a/src/lib/ai-edition/timeline/timelineMap.test.ts+++ b/src/lib/ai-edition/timeline/timelineMap.test.ts@@ -20,9 +20,9 @@ import {} from "./timelineMap";function clip(overrides: Partial<AxcutClip> & Pick<AxcutClip, "id" | "assetId">): AxcutClip {+ // `id`/`assetId` come from the spread below — `Pick` makes them required there,+ // so restating them above would just be overwritten.return {- id: overrides.id,- assetId: overrides.assetId,sourceStartSec: 0,sourceEndSec: 4,timelineStartSec: 0,diff --git a/src/lib/captioning/transcribe.test.ts b/src/lib/captioning/transcribe.test.tsindex d5026865d..18c6cfa79 100644--- a/src/lib/captioning/transcribe.test.ts+++ b/src/lib/captioning/transcribe.test.ts@@ -1,4 +1,4 @@-import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { afterEach, beforeEach, describe, expect, it, type Mock, vi } from "vitest";import { transcribeMono16kToSegments } from "./transcribe";@@ -40,12 +40,17 @@ type RendererSttApi = {onStatus?: (cb: Listener) => () => void;};-let mockApi: RendererSttApi;+/** Same shape as the real API, but with the mock control surface on `transcribe`. */+type MockedSttApi = RendererSttApi & {+ transcribe: Mock<RendererSttApi["transcribe"]>;+};++let mockApi: MockedSttApi;let lastStatusCb: Listener | null = null;const installMockApi = () => {mockApi = {- transcribe: vi.fn(),+ transcribe: vi.fn<RendererSttApi["transcribe"]>(),onStatus: vi.fn((cb: Listener) => {lastStatusCb = cb;return () => {diff --git a/src/lib/compositeLayout.test.ts b/src/lib/compositeLayout.test.tsindex 12b78f7e7..0a100a679 100644--- a/src/lib/compositeLayout.test.ts+++ b/src/lib/compositeLayout.test.ts@@ -111,8 +111,9 @@ describe("computeCompositeLayout", () => {webcamSize: { width: 960, height: 720 },webcamSizePreset: 34,});- expect(layout.webcamRect).not.toBeNull();- const widthFraction = layout.webcamRect!.width / 230;+ expect(layout).not.toBeNull();+ expect(layout!.webcamRect).not.toBeNull();+ const widthFraction = layout!.webcamRect!.width / 230;expect(widthFraction).toBeLessThan(0.4);});diff --git a/src/lib/exporter/localSourceFile.test.ts b/src/lib/exporter/localSourceFile.test.tsindex 7d4b14163..bd2d3b920 100644--- a/src/lib/exporter/localSourceFile.test.ts+++ b/src/lib/exporter/localSourceFile.test.ts@@ -83,7 +83,9 @@ describe("materializeLocalSourceFile (small file path)", () => {class FakeWritable {private parts: Uint8Array[] = [];- constructor(private readonly onClose: (bytes: Uint8Array) => void) {}+ // The merged buffer is freshly allocated, so it is ArrayBuffer-backed (not+ // SharedArrayBuffer) — say so, or it can't be handed to `new File([...])`.+ constructor(private readonly onClose: (bytes: Uint8Array<ArrayBuffer>) => void) {}async write(data: ArrayBuffer | Uint8Array) {this.parts.push(data instanceof Uint8Array ? new Uint8Array(data) : new Uint8Array(data));}@@ -152,6 +154,22 @@ function cacheDir(root: FakeDir): FakeDir | undefined {return root.subdirs.get("openscreen-source-cache");}+/**+ * The real `electronAPI.readFileChunk` contract (electron/electron-env.d.ts):+ * a read can fail, and then carries a message instead of data. Spelled out so+ * tests can substitute a failing implementation.+ */+type ReadFileChunk = (+ filePath: string,+ offset: number,+ length: number,+) => Promise<{+ success: boolean;+ data?: ArrayBuffer;+ bytesRead?: number;+ message?: string;+}>;+/** electronAPI whose readFileChunk serves slices of `source`. */function largeSourceApi(url: string, source: Uint8Array, mtimeMs = 1) {return {@@ -159,7 +177,7 @@ function largeSourceApi(url: string, source: Uint8Array, mtimeMs = 1) {.fn().mockResolvedValue({ success: true, size: source.byteLength, mtimeMs, path: url }),readBinaryFile: vi.fn(),- readFileChunk: vi.fn(async (_url: string, offset: number, length: number) => ({+ readFileChunk: vi.fn<ReadFileChunk>(async (_url: string, offset: number, length: number) => ({success: true,data: source.slice(offset, offset + length).buffer,bytesRead: Math.min(length, source.byteLength - offset),diff --git a/src/native/sceneDescription.test.ts b/src/native/sceneDescription.test.tsindex c2be81cff..e40ff73c0 100644--- a/src/native/sceneDescription.test.ts+++ b/src/native/sceneDescription.test.ts@@ -17,6 +17,7 @@ import type {AxcutDocument,AxcutZoomRegion,} from "@/lib/ai-edition/schema";+import { axcutSchemaVersion } from "@/lib/ai-edition/schema";import { getFocusBoundsForScale } from "@/lib/zoomMath/focusUtils";import { buildSceneDescription } from "./sceneDescription";@@ -57,14 +58,20 @@ function makeZoom(}function makeDoc(- overrides: Partial<AxcutDocument> & { assets?: AxcutAsset[]; clips?: AxcutClip[] } = {},+ overrides: Omit<Partial<AxcutDocument>, "timeline"> & {+ assets?: AxcutAsset[];+ clips?: AxcutClip[];+ // spread over the full default timeline below, so a fixture names only the+ // tracks it actually exercises instead of restating five empty arrays.+ timeline?: Partial<AxcutDocument["timeline"]>;+ } = {},): AxcutDocument {const assets = overrides.assets ?? [];const clips = overrides.clips ?? [];const createdAt = "2024-01-01T00:00:00.000Z";const baseProject = { id: "p1", title: "Test", createdAt, updatedAt: createdAt };return {- schemaVersion: 7,+ schemaVersion: axcutSchemaVersion,project: {...baseProject,...(overrides.project ?? {}),@@ -290,8 +297,10 @@ describe("buildSceneDescription.clips", () => {});it("emits empty webcamPath and 0 offset when no cameraTrack", () => {- const asset = makeAsset({ originalPath: "/screen.mp4", cameraTrack: null });+ const asset = makeAsset({ id: "a", originalPath: "/screen.mp4", cameraTrack: null });const clip = makeClip({+ id: "c1",+ assetId: "a",sourceStartSec: 0,sourceEndSec: 4,timelineStartSec: 0,@@ -1159,7 +1168,7 @@ describe("buildSceneDescription.layout.screenRect", () => {const asset = makeAsset({id: "a",originalPath: "/screen.mp4",- video: { width: 1920, height: 1080 },+ video: { codec: "h264", width: 1920, height: 1080, fps: 30 },});const clip = makeClip({id: "c1",@@ -1214,7 +1223,7 @@ describe("buildSceneDescription.layout.layoutByClip", () => {const asset = makeAsset({id: "a",originalPath: "/screen.mp4",- video: { width: 1920, height: 1080 },+ video: { codec: "h264", width: 1920, height: 1080, fps: 30 },});const plain = makeClip({id: "c1",