Skip to content

Commit 1e705b1

Browse files
authored
test(core,studio): add T3+T7 hfId targeting stubs (spec for R1) (heygen-com#1267)
* 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.
1 parent 184ef03 commit 1e705b1

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

packages/core/src/studio-api/helpers/sourceMutation.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,3 +361,12 @@ describe("probeElementInSource", () => {
361361
expect(probeElementInSource(sourceHtml, { id: "canvas" })).toBe(true);
362362
});
363363
});
364+
365+
// T7 — data-hf-id targeting (spec for R1).
366+
// R1 adds `hfId?: string` to SourceMutationTarget and a `[data-hf-id="…"]` branch
367+
// in findTargetElement (sourceMutation.ts:34). Convert from it.todo in the R1 PR.
368+
describe("T7 — data-hf-id targeting (spec for R1)", () => {
369+
it.todo("patches element by data-hf-id when no HTML id attribute is present");
370+
371+
it.todo("data-hf-id attribute survives the patch (can be targeted again)");
372+
});

packages/studio/src/utils/sourcePatcher.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,3 +516,18 @@ describe("motion attribute round-trip via sourcePatcher", () => {
516516
expect(JSON.parse(readBack!)).toEqual(motion);
517517
});
518518
});
519+
520+
// T3 — id-based targeting (spec for R1).
521+
// R1 adds `hfId?: string` to PatchTarget and a `[data-hf-id="…"]` lookup branch
522+
// in findTagByTarget. Convert from it.todo to real assertions in the R1 PR.
523+
describe("T3 — hfId targeting (spec for R1)", () => {
524+
it.todo("updates inline style by data-hf-id");
525+
526+
it.todo("updates text content by data-hf-id");
527+
528+
it.todo("updates attribute by data-hf-id");
529+
530+
it.todo("data-hf-id attribute is preserved after a style patch");
531+
532+
it.todo("hfId lookup falls through to selector when hfId not found");
533+
});

0 commit comments

Comments
 (0)