feat(play): debug retry step, folder hints, and e2e coverage

- Add buildFsAtSubStart so dev "Retry step" resets the current sub while keeping earlier subs complete; quiz screen clears the selected answer.

- Stop adding hinted files' parent folders to click hints (avoids wrongly highlighting Downloads when already inside it).

- Extend Playwright: localStorage reset, full playthrough through quiz, and a retry-step regression test. Add Vitest for buildFsAtSubStart.

Made-with: Cursor
This commit is contained in:
2026-04-11 19:26:39 +12:00
parent 1957e96363
commit 104d6a1d46
5 changed files with 404 additions and 146 deletions

View File

@@ -1,12 +1,14 @@
import { describe, expect, it } from "vitest";
import {
buildFsAtSubStart,
buildInitialFs,
isFsLevelComplete,
isQuizComplete,
isSubComplete,
QUIZ_CORRECT_ID,
} from "~/lib/folder-game/levels";
import { DESKTOP_ID } from "~/lib/folder-game/state";
describe("isFsLevelComplete", () => {
it("level 0 completes when Games and Documents were opened", () => {
@@ -50,3 +52,33 @@ describe("isQuizComplete", () => {
expect(isQuizComplete("opt-dl")).toBe(false);
});
});
describe("buildFsAtSubStart", () => {
it("matches full initial state for sub 0", () => {
expect(buildFsAtSubStart(1, 0)).toEqual(buildInitialFs(1));
});
it("level 1 sub 1 start keeps cat sorted and homework on desktop", () => {
const fs = buildFsAtSubStart(1, 1);
expect(isSubComplete(1, 0, fs)).toBe(true);
expect(isSubComplete(1, 1, fs)).toBe(false);
const nodes = fs.nodes;
const cat = nodes.find((n) => n.id === "file-cat");
const hw = nodes.find((n) => n.id === "file-hw");
expect(cat?.parentId).toBe("fld-pics");
expect(hw?.parentId).toBe(DESKTOP_ID);
});
it("level 2 sub 2 start has beach and budget sorted, installer in downloads", () => {
const fs = buildFsAtSubStart(2, 2);
const beach = fs.nodes.find((n) => n.id === "f-beach");
const budget = fs.nodes.find((n) => n.id === "f-budget");
const game = fs.nodes.find((n) => n.id === "f-game");
expect(beach?.parentId).toBe("fld-photos");
expect(budget?.parentId).toBe("fld-work");
expect(game?.parentId).toBe("fld-downloads");
expect(isSubComplete(2, 0, fs)).toBe(true);
expect(isSubComplete(2, 1, fs)).toBe(true);
expect(isSubComplete(2, 2, fs)).toBe(false);
});
});