mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-05 05:37:09 +00:00
#1385 ("exclude dot-directories from composition discovery", b952dc9c)
merged with a failing test, leaving main red. Its commit message assumed
"walkDir only skipped three exact names (.thumbnails, node_modules, .git)",
but `.hyperframes` had already been added to walkDir's IGNORE_DIRS by the
backup feature (with its own passing "hides internal backup files" test).
So the new test "keeps dot-directory files visible in the file tree" used
`.hyperframes/examples/preset.html` — the one dot-dir that walkDir hides —
and asserted it appears in `files`, which can never hold: `files = walkDir(...)`
filters `.hyperframes`. The implementation is coherent; the test picked the
wrong fixture and never exercised the isInHiddenOrVendorDir gating it meant to.
Fix the fixtures (test-only, no production change):
- Add a genuinely-vendored dot-dir `.cache/examples/preset.html` — walkDir does
not special-case it, so it stays in the file tree but must be gated out of
composition discovery by isInHiddenOrVendorDir. This is what #1385 actually
targets, now properly exercised.
- Keep `.hyperframes/examples/preset.html` and assert it is hidden from the file
tree (IGNORE_DIRS) — documenting the deliberate divergence so the two features
(Studio-internal backups vs. browsable vendored dot-dirs) don't collide again.
Full non-producer suite green; the walkDir "hides backups" test is untouched.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
5f12e692d5
commit
e2cc134c77
@@ -17,14 +17,22 @@ afterEach(() => {
|
|||||||
const COMPOSITION_HTML = '<html><body><div data-composition-id="main"></div></body></html>';
|
const COMPOSITION_HTML = '<html><body><div data-composition-id="main"></div></body></html>';
|
||||||
|
|
||||||
// Project layout for #1384: real compositions at the root and under
|
// Project layout for #1384: real compositions at the root and under
|
||||||
// compositions/, plus vendored example HTML inside dot-directories that
|
// compositions/, plus two kinds of dot-directory content that exercise
|
||||||
// must not surface as compositions.
|
// discovery gating differently:
|
||||||
|
// - .cache/ a vendored dot-directory. walkDir does NOT special-case it,
|
||||||
|
// so its HTML stays listed in the file tree, but it must be
|
||||||
|
// gated out of composition discovery by isInHiddenOrVendorDir.
|
||||||
|
// - .hyperframes/ Studio's own internal directory (backups, etc.) — already in
|
||||||
|
// walkDir's IGNORE_DIRS, so it is hidden from the file tree
|
||||||
|
// entirely (and therefore from compositions too).
|
||||||
function createProjectDir(): string {
|
function createProjectDir(): string {
|
||||||
const projectDir = mkdtempSync(join(tmpdir(), "hf-projects-test-"));
|
const projectDir = mkdtempSync(join(tmpdir(), "hf-projects-test-"));
|
||||||
tempDirs.push(projectDir);
|
tempDirs.push(projectDir);
|
||||||
writeFileSync(join(projectDir, "index.html"), COMPOSITION_HTML);
|
writeFileSync(join(projectDir, "index.html"), COMPOSITION_HTML);
|
||||||
mkdirSync(join(projectDir, "compositions"));
|
mkdirSync(join(projectDir, "compositions"));
|
||||||
writeFileSync(join(projectDir, "compositions", "scene.html"), COMPOSITION_HTML);
|
writeFileSync(join(projectDir, "compositions", "scene.html"), COMPOSITION_HTML);
|
||||||
|
mkdirSync(join(projectDir, ".cache", "examples"), { recursive: true });
|
||||||
|
writeFileSync(join(projectDir, ".cache", "examples", "preset.html"), COMPOSITION_HTML);
|
||||||
mkdirSync(join(projectDir, ".hyperframes", "examples"), { recursive: true });
|
mkdirSync(join(projectDir, ".hyperframes", "examples"), { recursive: true });
|
||||||
writeFileSync(join(projectDir, ".hyperframes", "examples", "preset.html"), COMPOSITION_HTML);
|
writeFileSync(join(projectDir, ".hyperframes", "examples", "preset.html"), COMPOSITION_HTML);
|
||||||
return projectDir;
|
return projectDir;
|
||||||
@@ -59,10 +67,11 @@ describe("registerProjectRoutes — composition discovery (#1384)", () => {
|
|||||||
expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
expect(payload.compositions).toContain("index.html");
|
expect(payload.compositions).toContain("index.html");
|
||||||
expect(payload.compositions).toContain("compositions/scene.html");
|
expect(payload.compositions).toContain("compositions/scene.html");
|
||||||
|
expect(payload.compositions).not.toContain(".cache/examples/preset.html");
|
||||||
expect(payload.compositions).not.toContain(".hyperframes/examples/preset.html");
|
expect(payload.compositions).not.toContain(".hyperframes/examples/preset.html");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("keeps dot-directory files visible in the file tree", async () => {
|
it("lists vendored dot-directory files in the file tree but hides Studio-internal ones", async () => {
|
||||||
const projectDir = createProjectDir();
|
const projectDir = createProjectDir();
|
||||||
const app = new Hono();
|
const app = new Hono();
|
||||||
registerProjectRoutes(app, createAdapter(projectDir));
|
registerProjectRoutes(app, createAdapter(projectDir));
|
||||||
@@ -70,6 +79,9 @@ describe("registerProjectRoutes — composition discovery (#1384)", () => {
|
|||||||
const response = await app.request("http://localhost/projects/demo");
|
const response = await app.request("http://localhost/projects/demo");
|
||||||
const payload = (await response.json()) as { files?: string[] };
|
const payload = (await response.json()) as { files?: string[] };
|
||||||
|
|
||||||
expect(payload.files).toContain(".hyperframes/examples/preset.html");
|
// Vendored dot-dirs stay browsable — discovery is gated, the file tree is not.
|
||||||
|
expect(payload.files).toContain(".cache/examples/preset.html");
|
||||||
|
// Studio's internal dir is hidden from the tree entirely (walkDir IGNORE_DIRS).
|
||||||
|
expect(payload.files).not.toContain(".hyperframes/examples/preset.html");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user