|
1 | 1 | import { describe, expect, it } from "vitest"; |
2 | 2 | import { spawnSync } from "node:child_process"; |
3 | | -import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; |
| 3 | +import { |
| 4 | + copyFileSync, |
| 5 | + existsSync, |
| 6 | + mkdirSync, |
| 7 | + mkdtempSync, |
| 8 | + readFileSync, |
| 9 | + rmSync, |
| 10 | + writeFileSync, |
| 11 | +} from "node:fs"; |
4 | 12 | import { tmpdir } from "node:os"; |
5 | 13 | import { join, resolve } from "node:path"; |
6 | 14 | import { fileURLToPath } from "node:url"; |
@@ -192,20 +200,32 @@ describe("hyperframes init flag rename", () => { |
192 | 200 | expect(injected).not.toContain("setTimeout"); |
193 | 201 | }); |
194 | 202 |
|
195 | | - it("packs from-file and selects it when --video is set without --example", () => { |
| 203 | + it("packs from-file and wires --video into the composition", () => { |
196 | 204 | const copySource = readFileSync( |
197 | 205 | new URL("../../scripts/build-copy.mjs", import.meta.url), |
198 | 206 | "utf-8", |
199 | 207 | ); |
200 | | - expect(copySource).toContain('"from-file"'); |
201 | | - expect(copySource).not.toMatch(/for \(const tmpl of \[[^\]]*"[^"]*agent[^"]*"/); |
202 | | - expect(initSource).toMatch(/videoFlag \|\| audioFlag \? "from-file"/); |
203 | | - expect(initSource).toMatch( |
204 | | - /else if \(videoFlag \|\| audioFlag\) \{\s*templateId = "from-file"/, |
| 208 | + expect(copySource).toContain('for (const tmpl of ["blank", "from-file", "_shared"])'); |
| 209 | + const dir = mkdtempSync(join(tmpdir(), "hf-init-test-")); |
| 210 | + const target = join(dir, "proj"); |
| 211 | + const clip = join(dir, "clip.mp4"); |
| 212 | + copyFileSync( |
| 213 | + resolve( |
| 214 | + fileURLToPath(import.meta.url), |
| 215 | + "../../../../studio/tests/e2e/fixtures/design-panel-qa/assets/test.mp4", |
| 216 | + ), |
| 217 | + clip, |
205 | 218 | ); |
206 | | - expect( |
207 | | - existsSync(resolve(fileURLToPath(import.meta.url), "../../templates/from-file/index.html")), |
208 | | - ).toBe(true); |
| 219 | + try { |
| 220 | + const res = runInit([target, "--non-interactive", "--skip-transcribe", "--video", clip]); |
| 221 | + expect(res.status).toBe(0); |
| 222 | + const html = readFileSync(join(target, "index.html"), "utf-8"); |
| 223 | + expect(html).toContain('id="a-roll"'); |
| 224 | + expect(html).toContain('src="clip.mp4"'); |
| 225 | + expect(existsSync(join(target, "clip.mp4"))).toBe(true); |
| 226 | + } finally { |
| 227 | + rmSync(dir, { recursive: true, force: true }); |
| 228 | + } |
209 | 229 | }); |
210 | 230 |
|
211 | 231 | it("-v works as the short alias for --video", () => { |
|
0 commit comments