Skip to content

Commit 63fd322

Browse files
authored
test(core): address review feedback on T6a / T10 / T7 stubs (heygen-com#1268)
T6a (heygen-com#1263): add fromTo corpus script (third parser method) with negative position values to exercise UnaryExpression arm; drop unused breatheRepeats from COMPLEX_SCRIPT; generate fromto.parsed.json + fromto.serialized.js goldens. T10 (heygen-com#1262): split applyDraft move/resize into two stubs; add applyDraft edge- case describe block (concurrent gestures, idempotent revert, playhead-change stability, nested sub-composition root); add getElementTimings stub for absent data-start/end on a data-hf-id element. T7 (heygen-com#1267): expand to full parity with T3 — add text-content, attribute, and fallthrough stubs (Core sourceMutation supports all patch types via patchElementInHtml).
1 parent 1e705b1 commit 63fd322

5 files changed

Lines changed: 104 additions & 3 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"animations": [
3+
{
4+
"targetSelector": "#hero",
5+
"method": "fromTo",
6+
"position": 0.1,
7+
"properties": {
8+
"x": 0,
9+
"opacity": 1
10+
},
11+
"fromProperties": {
12+
"x": -200,
13+
"opacity": 0
14+
},
15+
"duration": 0.6,
16+
"ease": "power3.out",
17+
"id": "#hero-fromTo-100"
18+
},
19+
{
20+
"targetSelector": "#caption",
21+
"method": "fromTo",
22+
"position": 0.5,
23+
"properties": {
24+
"y": 0,
25+
"opacity": 1
26+
},
27+
"fromProperties": {
28+
"y": -30,
29+
"opacity": 0
30+
},
31+
"duration": 0.45,
32+
"id": "#caption-fromTo-500"
33+
}
34+
],
35+
"timelineVar": "tl",
36+
"preamble": "var tl = gsap.timeline({ paused: true });",
37+
"postamble": "window.__timelines[\"hero-reveal\"] = tl;"
38+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
var tl = gsap.timeline({ paused: true });
3+
tl.fromTo("#hero", { x: -200, opacity: 0 }, { x: 0, opacity: 1, duration: 0.6, ease: "power3.out" }, 0.1);
4+
tl.fromTo("#caption", { y: -30, opacity: 0 }, { y: 0, opacity: 1, duration: 0.45 }, 0.5);
5+
window.__timelines["hero-reveal"] = tl;
6+

packages/core/src/parsers/gsapParser.golden.test.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,22 @@ const COMPLEX_SCRIPT = `\
5151
window.__timelines = window.__timelines || {};
5252
gsap.defaults({ force3D: true });
5353
const tl = gsap.timeline({ paused: true, defaults: { duration: 0.45, ease: "power3.out" } });
54-
const breatheRepeats = Math.ceil(7 / 2.4) - 1;
5554
tl.from(".headline span", { y: 46, opacity: 0, stagger: 0.055, duration: 0.38, ease: "back.out(1.35)" }, 0.05)
5655
.from(".headline .sub", { y: 20, opacity: 0, duration: 0.28 }, 0.2)
5756
.from(".ambient-word", { scale: 0.92, opacity: 0, duration: 0.5 }, 0.08)
5857
.from(".ambient-line", { scaleX: 0, opacity: 0, stagger: 0.08, duration: 0.42 }, 0.16);
5958
window.__timelines["vpn-youtube-spot"] = tl;`;
6059

60+
// fromTo: exercises the three-argument (fromArg, toArg, position) AST path and
61+
// negative numeric literals (UnaryExpression arm in resolveNode).
62+
const FROMTO_SCRIPT = `\
63+
var tl = gsap.timeline({ paused: true });
64+
var hero = document.getElementById("hero");
65+
var caption = document.getElementById("caption");
66+
tl.fromTo(hero, { x: -200, opacity: 0 }, { x: 0, opacity: 1, duration: 0.6, ease: "power3.out" }, 0.1);
67+
tl.fromTo(caption, { y: -30, opacity: 0 }, { y: 0, opacity: 1, duration: 0.45 }, 0.5);
68+
window.__timelines["hero-reveal"] = tl;`;
69+
6170
// ---------------------------------------------------------------------------
6271
// Helpers
6372
// ---------------------------------------------------------------------------
@@ -123,4 +132,20 @@ describe("T6a — GSAP parser golden tests (Recast/Babel baseline)", () => {
123132
await expect(serialized).toMatchFileSnapshot(g("complex.serialized.js"));
124133
});
125134
});
135+
136+
describe("fromTo — two tl.fromTo calls with negative positions (hero-reveal)", () => {
137+
let parsed: string;
138+
let serialized: string;
139+
beforeAll(() => {
140+
({ parsed, serialized } = parseAndSerialize(FROMTO_SCRIPT));
141+
});
142+
143+
it("parseGsapScript output matches golden", async () => {
144+
await expect(parsed).toMatchFileSnapshot(g("fromto.parsed.json"));
145+
});
146+
147+
it("serializeGsapAnimations output matches golden", async () => {
148+
await expect(serialized).toMatchFileSnapshot(g("fromto.serialized.js"));
149+
});
150+
});
126151
});

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,33 @@ describe("T10 — PreviewAdapter contract (spec for R7)", () => {
2626
describe("applyDraft / revertDraft", () => {
2727
it.todo("applyDraft writes --hf-studio-* CSS props and sets the gesture marker");
2828

29-
it.todo("applyDraft accepts both move (dx/dy) and resize (w/h) payloads");
29+
it.todo("applyDraft accepts a move payload (dx/dy) and writes the translate draft");
30+
31+
it.todo("applyDraft accepts a resize payload (w/h) and writes the size draft");
3032

3133
it.todo("revertDraft removes draft props and clears the gesture marker");
3234

3335
it.todo("revertDraft restores original translate when an original was recorded");
3436
});
3537

38+
describe("applyDraft edge cases (R7 implementation contract)", () => {
39+
it.todo(
40+
"second applyDraft before revert/commit overwrites first draft — does not accumulate (dx/dy)",
41+
);
42+
43+
it.todo(
44+
"revertDraft is safe to call when no gesture is in progress (idempotent / no-op on empty marker)",
45+
);
46+
47+
it.todo(
48+
"elementAtPoint filtering is stable when playhead changes mid-drag — opacity re-evaluated per call",
49+
);
50+
51+
it.todo(
52+
"stage-root exclusion applies only to the outermost data-hf-root; nested sub-composition roots count as targets",
53+
);
54+
});
55+
3656
describe("commitPreview", () => {
3757
it.todo("returns null when no gesture marker is present");
3858

@@ -47,5 +67,9 @@ describe("T10 — PreviewAdapter contract (spec for R7)", () => {
4767
it.todo("reads authored absolute times from data-start / data-end");
4868

4969
it.todo("ignores elements without data-hf-id");
70+
71+
it.todo(
72+
"returns a defined timing entry when data-hf-id is present but data-start / data-end are missing",
73+
);
5074
});
5175
});

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,16 @@ describe("probeElementInSource", () => {
365365
// T7 — data-hf-id targeting (spec for R1).
366366
// R1 adds `hfId?: string` to SourceMutationTarget and a `[data-hf-id="…"]` branch
367367
// in findTargetElement (sourceMutation.ts:34). Convert from it.todo in the R1 PR.
368+
// Covers the same surface as T3 (Studio sourcePatcher) — Core sourceMutation supports
369+
// all patch types (inline-style, attribute, text-content) via patchElementInHtml.
368370
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");
371+
it.todo("updates inline style by data-hf-id when no HTML id attribute is present");
372+
373+
it.todo("updates text content by data-hf-id");
374+
375+
it.todo("updates attribute by data-hf-id");
370376

371377
it.todo("data-hf-id attribute survives the patch (can be targeted again)");
378+
379+
it.todo("hfId lookup falls through to selector when hfId is not found in the document");
372380
});

0 commit comments

Comments
 (0)