From a60125952fcfffd9252ce753882beb947d499575 Mon Sep 17 00:00:00 2001 From: James Date: Sat, 13 Jun 2026 01:50:43 +0000 Subject: [PATCH] test(core): fix contradictory composition-discovery file-tree test (#1385) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #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) --- .../src/studio-api/routes/projects.test.ts | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/core/src/studio-api/routes/projects.test.ts b/packages/core/src/studio-api/routes/projects.test.ts index f726a4dcf..5e84a693d 100644 --- a/packages/core/src/studio-api/routes/projects.test.ts +++ b/packages/core/src/studio-api/routes/projects.test.ts @@ -17,14 +17,22 @@ afterEach(() => { const COMPOSITION_HTML = '
'; // Project layout for #1384: real compositions at the root and under -// compositions/, plus vendored example HTML inside dot-directories that -// must not surface as compositions. +// compositions/, plus two kinds of dot-directory content that exercise +// 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 { const projectDir = mkdtempSync(join(tmpdir(), "hf-projects-test-")); tempDirs.push(projectDir); writeFileSync(join(projectDir, "index.html"), COMPOSITION_HTML); mkdirSync(join(projectDir, "compositions")); 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 }); writeFileSync(join(projectDir, ".hyperframes", "examples", "preset.html"), COMPOSITION_HTML); return projectDir; @@ -59,10 +67,11 @@ describe("registerProjectRoutes — composition discovery (#1384)", () => { expect(response.status).toBe(200); expect(payload.compositions).toContain("index.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"); }); - 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 app = new Hono(); registerProjectRoutes(app, createAdapter(projectDir)); @@ -70,6 +79,9 @@ describe("registerProjectRoutes — composition discovery (#1384)", () => { const response = await app.request("http://localhost/projects/demo"); 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"); }); });