Setting the file. One moment.
Pad Frame Duration Test · Product Launch Video · heygen-com/hyperframes · Skills Docs
ContentsBack to the top of the page (opens in a new tab)
scripts/lib/ pad-frame-duration.test.mjs
JavaScript · 76 lines · 3 KB
// Regression: an outgoing transition pads the index.html WRAPPER's
9 // data-duration to cover the transition tail, but the frame's own internal
10 // file kept its shorter content-only duration, so the render engine
11 // clip-gated the sub-composition's visible content at the shorter value —
12 // content vanished abruptly instead of fading through the wrapper's
13 // extended fade-out tween. A user diagnosed and verified this fix
14 // themselves: pad the frame's own #root/clip data-duration to match.
15 test ( "padFrameInternalDuration pads the matching frame's own data-duration" , () => {
16 const dir = mkdtempSync ( join ( tmpdir (), "transitions-pad-" ));
17 const framesDir = join (dir, "compositions" , "frames" );
18 mkdirSync (framesDir, { recursive: true });
19 const frameSrc = "compositions/frames/scene-1.html" ;
20 const framePath = join (dir, frameSrc);
21 writeFileSync (
22 framePath,
23 `<template>
24 <div
25 id="root"
26 data-composition-id="scene-1"
27 data-width="1920"
28 data-height="1080"
29 data-duration="4.2"
30 ></div>
31 </template>` ,
32 );
33
34 try {
35 padFrameInternalDuration (dir, frameSrc, "scene-1" , 4.7 );
36 const updated = readFileSync (framePath, "utf8" );
37 assert. match (updated, /data-duration="4 \. 7"/ );
38 assert. doesNotMatch (updated, /data-duration="4 \. 2"/ );
39 } finally {
40 rmSync (dir, { recursive: true , force: true });
41 }
42 });
43
44 test ( "padFrameInternalDuration only touches the tag matching the given frame id" , () => {
45 const dir = mkdtempSync ( join ( tmpdir (), "transitions-pad-scope-" ));
46 const framesDir = join (dir, "compositions" , "frames" );
47 mkdirSync (framesDir, { recursive: true });
48 const frameSrc = "compositions/frames/scene-2.html" ;
49 const framePath = join (dir, frameSrc);
50 const original = `<template>
51 <div id="root" data-composition-id="scene-2" data-duration="3.0">
52 <div data-composition-id="unrelated-child" data-duration="1.0"></div>
53 </div>
54 </template>` ;
55 writeFileSync (framePath, original);
56
57 try {
58 padFrameInternalDuration (dir, frameSrc, "scene-2" , 3.5 );
59 const updated = readFileSync (framePath, "utf8" );
60 assert. match (updated, /data-composition-id="scene-2" data-duration="3 \. 5"/ );
61 assert. match (updated, /data-composition-id="unrelated-child" data-duration="1 \. 0"/ );
62 } finally {
63 rmSync (dir, { recursive: true , force: true });
64 }
65 });
66
67 test ( "padFrameInternalDuration is a no-op when the frame file does not exist" , () => {
68 const dir = mkdtempSync ( join ( tmpdir (), "transitions-pad-missing-" ));
69 try {
70 assert. doesNotThrow (() =>
71 padFrameInternalDuration (dir, "compositions/frames/missing.html" , "missing" , 5 ),
72 );
73 } finally {
74 rmSync (dir, { recursive: true , force: true });
75 }
76 });