AI media harness for planning, generating, and editing locally
TypeScript
Pin fixture line endings, parse Rust wire output in the frontend suite
Bitti423e86972f01
diff --git a/.gitattributes b/.gitattributesnew file mode 100644index 0000000..6a826d1--- /dev/null+++ b/.gitattributes@@ -0,0 +1,7 @@+# fixtures/rust-serialized-*.json are rewritten by `cargo test` (which always+# writes LF) and read back by the frontend test suite. The repo has+# core.autocrlf=true, so without this a fresh checkout would hand those files+# CRLF working copies until the next cargo run. Pin them to LF so the generated+# bytes are the same everywhere and a dirty `git status` after a test run means+# the wire format genuinely changed.+fixtures/*.json text eol=lfdiff --git a/src/lib/project.test.ts b/src/lib/project.test.tsindex 7532335..9138160 100644--- a/src/lib/project.test.ts+++ b/src/lib/project.test.ts@@ -1,6 +1,10 @@import { describe, expect, it } from "vitest";import completeFixture from "../../fixtures/project-v1-complete.json";import createdFixture from "../../fixtures/project-v1-created.json";+import wireCreated from "../../fixtures/rust-serialized-created.json";+import wireComplete from "../../fixtures/rust-serialized-complete.json";+import initialReferenceWire from "../../fixtures/rust-serialized-initial-reference.json";+import {compileMiniMaxH3Prompt,createProjectConfig,@@ -15,6 +19,8 @@ import {usableImageReferences,type ProjectReference,} from "./project";+/** Regenerated by `cargo test` from the Rust validator's real output. */+const wireFixtures = { created: wireCreated, complete: wireComplete, initialReference: initialReferenceWire };/** Body of one compiled section, for both prompt shapes: T2VA writes* `name: value` on one line, full-reference mode writes `name:\nvalue`, and in@@ -250,6 +256,42 @@ describe("project schema", () => {.toContain("The target video is in a 2D-animated style.");});+ it("accepts the real bytes the Rust validator writes, for every generated wire fixture", () => {+ // The other half of a contract that used to be checked by remembering: a+ // Rust test regenerates these three files from validate_and_normalize_config+ // on every `cargo test`, and this parses them with the real zod schema. A+ // field added on one side with the wrong optionality now fails here instead+ // of waiting to be noticed — which is how the last blocking bug survived+ // nine rounds. A diff in `git status` after cargo test means the wire+ // format moved and this test is the frontend's verdict on it.+ for (const [name, wire] of Object.entries(wireFixtures)) {+ const parsed = parseProjectConfig(wire);+ expect(parsed.schemaVersion, name).toBe(1);+ // No `null` may reach a field zod spells `.optional()` without `.nullable()`.+ expect(JSON.stringify(wire), name).not.toMatch(/"(clipId|durationMs|width|height|color)":\s*null/);+ }+ });++ it("compiles a clean prompt from a reference the Rust import path really produced", () => {+ // Built by create_project_in_with_references against a real file on disk —+ // not a hand-written reference with a tidy name and description. Every+ // compiler test used to supply both by hand, which is exactly why an+ // imported image shipped its filename and a filing note to the model.+ const config = parseProjectConfig(initialReferenceWire);+ const imported = config.references.find((reference) => reference.kind === "image");+ expect(imported, "the Rust fixture must contain an imported image").toBeTruthy();+ expect(imported!.description).toBe("");++ const compiled = compileMiniMaxH3Prompt("a cat walking across a sunny kitchen floor", [imported!]);+ expect(compiled).toContain("<Subject 1> is the content shown in <Picture 1>.");+ expect(compiled).toContain("fully_preserved - the referenced characteristics are retained.");+ // The library label is the source file's stem. It is not a description and+ // must appear nowhere in the text sent to the model.+ expect(imported!.name.length).toBeGreaterThan(0);+ expect(compiled).not.toContain(imported!.name);+ expect(compiled).not.toContain("Visual reference");+ });+it("accepts a freshly created project exactly as createProjectConfig writes it", () => {// This fixture is the byte-exact output of createProjectConfig. Its first// job has NO clipId key at all, which is what every real project looks like.