fix(course-format): directories are not lesson files; a failing course never rejects loadAll

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas WintherandClaude Opus 5.5 committed 2026-10-30 02:54:23 +01:00
1 parent b8c65626f9
commit a82ab18bee
2 files changed
+59 -6

No files matched your search

+28
View File
@@ -80,6 +80,34 @@ describe("overlays and errors", () => {
expect(errs[2]!.message).toContain("Exercise 1");
});
test("lesson file that is a directory gives a diagnostic", async () => {
const d = await tmp();
await Bun.write(join(d, "adir/x.md"), "# X\n");
await Bun.write(join(d, "stcourse.yaml"), manifest("dirs", "", " - { id: as-file, title: L, type: text, file: adir }"));
const c = await loadCourse(join(d, "stcourse.yaml"));
expect(c.status).toBe("error");
const e = c.diagnostics.filter((x) => x.level === "error");
expect(e).toHaveLength(1);
expect(e[0]!.lessonId).toBe("as-file");
expect(e[0]!.path).toBe("adir");
});
test("one throwing course does not break loadAll", async () => {
const d = await tmp();
await Bun.write(join(d, "bad/adir/x.md"), "# X\n");
await Bun.write(join(d, "bad/a.md"), "# A\n## Sec\n");
await Bun.write(
join(d, "bad/stcourse.yaml"),
manifest("bad", "", " - { id: h, title: L, type: exercise, file: a.md, hints: { file: adir, match: 'E' } }"),
);
await Bun.write(join(d, "good/a.md"), "# A\n");
await Bun.write(join(d, "good/stcourse.yaml"), manifest("good", "", " - { id: l, title: L, type: text, file: a.md }"));
const all = await loadAll([d]);
expect(all.map((c) => c.id).sort()).toEqual(["bad", "good"]);
expect(all.find((c) => c.id === "bad")!.status).toBe("error");
expect(all.find((c) => c.id === "good")!.status).toBe("ok");
});
test("invalid manifest gives an error course and does not throw", async () => {
const d = await tmp();
await Bun.write(join(d, "stcourse.yaml"), "schema: 2\nid: x\n");