From 1e705b1107408d75d8e83dddd6c8fd5e8aec58fb Mon Sep 17 00:00:00 2001 From: Vance Ingalls Date: Sun, 7 Jun 2026 19:23:27 -0700 Subject: [PATCH] test(core,studio): add T3+T7 hfId targeting stubs (spec for R1) (#1267) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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. * test(core): add T6a GSAP parser golden baselines (Recast/Babel snapshot) 6 toMatchFileSnapshot tests across 3 representative scripts (minimal, moderate, complex). Captures parseGsapScript + serializeGsapAnimations output before the Recast → Meriyah swap so any parser change is detected as a golden diff rather than a silent behavioral regression. Goldens live in src/parsers/__goldens__/ and are checked in. Add __goldens__/** to fallow ignorePatterns (data files, not modules) and to .prettierignore so oxfmt does not reformat vitest-written snapshot files. * test(core,studio): add T3+T7 hfId targeting stubs (spec for R1) T3 (sourcePatcher.test.ts): 5 it.todo stubs for PatchTarget.hfId targeting — style, text, attribute patches plus preservation and fallthrough cases. T7 (sourceMutation.test.ts): 2 it.todo stubs for SourceMutationTarget.hfId — basic patch and data-hf-id survival after patch. Neither interface has hfId yet. R1 adds the field + [data-hf-id="…"] branch in findTagByTarget / findTargetElement, then converts these to real assertions. --- .../src/studio-api/helpers/sourceMutation.test.ts | 9 +++++++++ packages/studio/src/utils/sourcePatcher.test.ts | 15 +++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/packages/core/src/studio-api/helpers/sourceMutation.test.ts b/packages/core/src/studio-api/helpers/sourceMutation.test.ts index 8774fffcd..0b4d998d8 100644 --- a/packages/core/src/studio-api/helpers/sourceMutation.test.ts +++ b/packages/core/src/studio-api/helpers/sourceMutation.test.ts @@ -361,3 +361,12 @@ describe("probeElementInSource", () => { expect(probeElementInSource(sourceHtml, { id: "canvas" })).toBe(true); }); }); + +// T7 — data-hf-id targeting (spec for R1). +// R1 adds `hfId?: string` to SourceMutationTarget and a `[data-hf-id="…"]` branch +// in findTargetElement (sourceMutation.ts:34). Convert from it.todo in the R1 PR. +describe("T7 — data-hf-id targeting (spec for R1)", () => { + it.todo("patches element by data-hf-id when no HTML id attribute is present"); + + it.todo("data-hf-id attribute survives the patch (can be targeted again)"); +}); diff --git a/packages/studio/src/utils/sourcePatcher.test.ts b/packages/studio/src/utils/sourcePatcher.test.ts index 8bc64e1b8..7697d24e6 100644 --- a/packages/studio/src/utils/sourcePatcher.test.ts +++ b/packages/studio/src/utils/sourcePatcher.test.ts @@ -516,3 +516,18 @@ describe("motion attribute round-trip via sourcePatcher", () => { expect(JSON.parse(readBack!)).toEqual(motion); }); }); + +// T3 — id-based targeting (spec for R1). +// R1 adds `hfId?: string` to PatchTarget and a `[data-hf-id="…"]` lookup branch +// in findTagByTarget. Convert from it.todo to real assertions in the R1 PR. +describe("T3 — hfId targeting (spec for R1)", () => { + it.todo("updates inline style by data-hf-id"); + + it.todo("updates text content by data-hf-id"); + + it.todo("updates attribute by data-hf-id"); + + it.todo("data-hf-id attribute is preserved after a style patch"); + + it.todo("hfId lookup falls through to selector when hfId not found"); +});