Skip to content

test: add unit tests, the coverage gate and a render smoke test - #9

Merged
umiyosh merged 1 commit into
masterfrom
feat/tests-coverage
Oct 11, 2026
Merged

umiyosh merged 1 commit into
masterfrom
feat/tests-coverage

Conversation

@umiyosh

@umiyosh umiyosh commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Closes #5. Part of #2. Stacked on #8 (base feat/quality-gates-ci); retarget to master after #8 merges.

Why

The CLI had no tests. This adds unit tests for the logic that decides what a video sounds and looks like, a render smoke test in headless Chromium, and kotobae's 80% coverage gate, all run in CI without a GEMINI_API_KEY.

What changed

  • Vitest 3.2.7 with @vitest/coverage-v8, vitest.config.ts with 80% thresholds (lines, branches, functions, statements). make test, make test-coverage, and make check now includes the coverage gate.
  • Small refactor so the logic is testable, no behavior change:
    • prepare moved from cli.ts to store.ts and throws instead of exiting.
    • placeOnFilm (narration placement on the film timeline) moved to work.ts and reports long narration through a callback.
    • The MP4 encode arguments moved to encodeArgs in audio.ts.
    • cli.ts is left as command wiring and is excluded from coverage; the smoke test runs it as a real process.
  • Unit tests (48 in total):
    • script.json validation: defaults and every rejection message.
    • Scene timing: lengths from narration, speed, lead, tail and the final hold; timing.json parsing.
    • Narration placement on the film's actual scene starts, the overrun warning, unknown scene ids.
    • Gemini / Lyria requests with fetch mocked: URL, API key header, voice, the BGM prompt length, raw PCM to WAV, skipping unchanged scenes, three retries with the API's error message, missing key.
    • ffmpeg argument building with spawn mocked: narration delays, tempo, BGM loop, volume and fades in the filter graph, and the encode arguments.
    • prepare from a fixture store.
  • Render smoke tests against tests/fixtures/player, a small stand-in for the Motion player with the same window.__animation hook. The real player is Anthropic's Motion code and is not committed. The tests check:
    • the scene layout and that frames differ between scenes;
    • that the film cannot reach the network (the stub tries fetch("https://example.com/") and must see it blocked);
    • the load-error path;
    • motion-render prepare + stills as a subprocess.
  • CI:
    • installs Chromium with system dependencies;
    • lifts Ubuntu 24.04's AppArmor restriction on unprivileged user namespaces, because motion-render keeps Chromium's own sandbox on;
    • runs make test-coverage.
  • README (EN / JA) Development and Layout sections and SKILL.md's file list are updated.

Verification

  • make check locally: lint, format, typecheck, 48 tests pass, coverage lines 91.45% / branches 91.8% / functions 97.43% / statements 91.45%, quality gate tests, baseline unchanged
  • CI passes on this pull request, including Chromium with its own sandbox on the Ubuntu runner

Not verified

Base automatically changed from feat/quality-gates-ci to master October 11, 2026 13:21
@umiyosh
umiyosh merged commit 82d87d8 into master Oct 11, 2026
1 check passed
@umiyosh
umiyosh deleted the feat/tests-coverage branch October 11, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit tests, the coverage gate and a render smoke test

1 participant