Add unit tests for cartoon scene-plan validation and plan timing

Open Beginner friendly
#28 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
94/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
frontend, testing

Research direction

Start by reading frontend/src/engine/cartoon/scene-plan.ts, timing.ts, and the fixture functions in frontend/src/engine/cartoon/harness/reference-plan.ts. Create scene-plan.test.ts and timing.test.ts using the existing fixture to cover validation, canonical JSON, hashing, and frame timing. Done means both files pass with npx vitest run, and the test output is pasted in the PR.

Written by the indexing model from the issue text.

Description

engine good first issue testing
Context

The versioned scene plan is the single source of truth for cartoon renders (.claude/skills/scene-plan-schema). The determinism law L6 depends on canonicalJson producing the same output for any key order, and on computePlanTiming quantizing to whole frames. None of this is unit-tested, but a ready-made fixture already exists.

Where
  • frontend/src/engine/cartoon/scene-plan.ts:143-213: validateScenePlan; :230: canonicalJson; :245/:250: hashScenePlan / hashScene
  • frontend/src/engine/cartoon/timing.ts:15: takeKeyForLine; :58-139: computePlanTiming
  • Fixture: frontend/src/engine/cartoon/harness/reference-plan.ts: buildReferencePlan(), buildEditedReferencePlan() (type-only imports, safe in vitest)
What to do

Create src/engine/cartoon/scene-plan.test.ts and timing.test.ts:

  1. validateScenePlan(buildReferencePlan()) → {ok:true}. Then mutate one field at a time (wrong version, duplicate scene id, dialogue charId not in the scene, fps: 0) and assert the specific error string.
  2. canonicalJson: the same object with keys in a different order gives the same string, and undefined members are dropped. hashScenePlan is stable across calls (Node 18+ has crypto.subtle).
  3. computePlanTiming: build a takeDurations map from takeKeyForLine. Assert that every frameCount is an integer, that scenes are contiguous (startFrame = previous start + count), and that a missing take throws.
Acceptance criteria
  • Both test files pass under npx vitest run
  • Tests use the existing fixture, not a hand-written fake plan
  • Paste the test output in the PR
Getting started

Read CONTRIBUTING.md for dev setup and the quality bar (no facades, evidence before done). Comment here to claim the issue.

Dominant language
TypeScript
Stars
0
Forks
3
Avg merge
1d 4h
Merged PRs (30d)
5

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from BeyondITL/contentine-create

All issues in BeyondITL/contentine-create

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.