Skip to content

Commit e2cc134

Browse files
jrusso1020claude
andauthored
test(core): fix contradictory composition-discovery file-tree test (#1385) (#1399)
#1385 ("exclude dot-directories from composition discovery", b952dc9) 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>
1 parent 5f12e69 commit e2cc134

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

packages/core/src/studio-api/routes/projects.test.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,22 @@ afterEach(() => {
1717
const COMPOSITION_HTML = '<html><body><div data-composition-id="main"></div></body></html>';
1818

1919
// Project layout for #1384: real compositions at the root and under
20-
// compositions/, plus vendored example HTML inside dot-directories that
21-
// must not surface as compositions.
20+
// compositions/, plus two kinds of dot-directory content that exercise
21+
// discovery gating differently:
22+
// - .cache/ a vendored dot-directory. walkDir does NOT special-case it,
23+
// so its HTML stays listed in the file tree, but it must be
24+
// gated out of composition discovery by isInHiddenOrVendorDir.
25+
// - .hyperframes/ Studio's own internal directory (backups, etc.) — already in
26+
// walkDir's IGNORE_DIRS, so it is hidden from the file tree
27+
// entirely (and therefore from compositions too).
2228
function createProjectDir(): string {
2329
const projectDir = mkdtempSync(join(tmpdir(), "hf-projects-test-"));
2430
tempDirs.push(projectDir);
2531
writeFileSync(join(projectDir, "index.html"), COMPOSITION_HTML);
2632
mkdirSync(join(projectDir, "compositions"));
2733
writeFileSync(join(projectDir, "compositions", "scene.html"), COMPOSITION_HTML);
34+
mkdirSync(join(projectDir, ".cache", "examples"), { recursive: true });
35+
writeFileSync(join(projectDir, ".cache", "examples", "preset.html"), COMPOSITION_HTML);
2836
mkdirSync(join(projectDir, ".hyperframes", "examples"), { recursive: true });
2937
writeFileSync(join(projectDir, ".hyperframes", "examples", "preset.html"), COMPOSITION_HTML);
3038
return projectDir;
@@ -59,17 +67,21 @@ describe("registerProjectRoutes — composition discovery (#1384)", () => {
5967
expect(response.status).toBe(200);
6068
expect(payload.compositions).toContain("index.html");
6169
expect(payload.compositions).toContain("compositions/scene.html");
70+
expect(payload.compositions).not.toContain(".cache/examples/preset.html");
6271
expect(payload.compositions).not.toContain(".hyperframes/examples/preset.html");
6372
});
6473

65-
it("keeps dot-directory files visible in the file tree", async () => {
74+
it("lists vendored dot-directory files in the file tree but hides Studio-internal ones", async () => {
6675
const projectDir = createProjectDir();
6776
const app = new Hono();
6877
registerProjectRoutes(app, createAdapter(projectDir));
6978

7079
const response = await app.request("http://localhost/projects/demo");
7180
const payload = (await response.json()) as { files?: string[] };
7281

73-
expect(payload.files).toContain(".hyperframes/examples/preset.html");
82+
// Vendored dot-dirs stay browsable — discovery is gated, the file tree is not.
83+
expect(payload.files).toContain(".cache/examples/preset.html");
84+
// Studio's internal dir is hidden from the tree entirely (walkDir IGNORE_DIRS).
85+
expect(payload.files).not.toContain(".hyperframes/examples/preset.html");
7486
});
7587
});

0 commit comments

Comments
 (0)