test(core): add T10 PreviewAdapter contract stubs (spec for R7) (#1262)

* test(studio): add T5b rotation+motion build-patches characterization

Extends manualEditsDomPatches.test.ts with rotation and motion pairs.
Same 4-pattern structure: populated, empty, clear restores originals,
build/clear symmetry. Merges duplicate manualEditsTypes import block.

* test(studio): add T5c review-fix gaps in manualEditsDomPatches characterization

Fixes four gaps identified in max-setting code review:
- Box-size clear: replace arrayContaining with full ordered toEqual (30 ops)
- Box-size / pathOffset / rotation clear: add empty-string coercion tests
  (origVal||null must produce null, not set property to "")
- Rotation clear: add test for absent STUDIO_ORIGINAL_ROTATION_TRANSFORM_ORIGIN_ATTR
- Motion clear: prove input-independence by calling with both empty and populated
  element and asserting identical output

* refactor(core): extract maxEndTime+serialize to parsers/test-utils.ts (TU)

Deduplicate helpers shared by T1 (htmlParser.roundtrip.test.ts) and T2
(stableIds.test.ts). Both files inline identical implementations; extract
to test-utils.ts so future parser tests (T6a…) import one copy.

Also fix lefthook fallow command to unset GIT_DIR+GIT_INDEX_FILE before
running — those vars are set by git in worktree hook context and block
fallow’s internal temp-worktree creation.

* test(core): add T10 PreviewAdapter contract stubs (spec for R7)

All 14 tests are it.todo, following the T4 pattern. The stubs define the
full createPreviewAdapter interface — elementAtPoint (root exclusion,
hf-id ancestor walk, opacity filter), applyDraft/revertDraft (draft
marker lifecycle), commitPreview (patch derivation), and getElementTimings
(data-start/data-end reader).

createPreviewAdapter does not exist yet; R7 implements it and converts
these stubs to real assertions.
This commit is contained in:
Vance Ingalls
2026-06-07 19:22:34 -07:00
committed by GitHub
parent ffc54c7867
commit 1fdce71c8b
@@ -0,0 +1,51 @@
/**
* T10 — PreviewAdapter contract (spec for R7).
*
* `createPreviewAdapter` does not exist yet. These stubs define the expected
* interface so R7 has a concrete target. Convert from it.todo to real
* assertions in the R7 PR.
*
* Hit-testing (elementAtPoint) in both linkedom and jsdom returns null for
* all geometry calls — the real tests must inject a position-resolver stub
* or mock elementFromPoint. The contract tested is filtering logic (root
* exclusion, data-hf-id ancestor walk, opacity-at-playhead), not geometry.
*/
import { describe, it } from "vitest";
describe("T10 — PreviewAdapter contract (spec for R7)", () => {
describe("elementAtPoint", () => {
it.todo("returns null for the stage root (data-hf-root)");
it.todo("returns the nearest ancestor with data-hf-id");
it.todo("returns null when the hit element has no data-hf-id ancestor");
it.todo("skips elements whose computed opacity is 0 at the given playhead time");
});
describe("applyDraft / revertDraft", () => {
it.todo("applyDraft writes --hf-studio-* CSS props and sets the gesture marker");
it.todo("applyDraft accepts both move (dx/dy) and resize (w/h) payloads");
it.todo("revertDraft removes draft props and clears the gesture marker");
it.todo("revertDraft restores original translate when an original was recorded");
});
describe("commitPreview", () => {
it.todo("returns null when no gesture marker is present");
it.todo("derives a moveElement patch from draft markers on commit");
it.todo("derives a resize patch from draft markers on commit");
it.todo("clears the gesture marker after commit");
});
describe("getElementTimings", () => {
it.todo("reads authored absolute times from data-start / data-end");
it.todo("ignores elements without data-hf-id");
});
});