mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 20:45:33 -08:00
Show a spec's Pathfinder Map and Plan draft as read-only tabs on the dashboard until it has an overview, so an undocumented spec's main files can be read like a documented one's Overview
AI Assisted
This commit is contained in:
1 parent
0d569954c4
commit
46f1f17261
16 files changed
+210
-50
No files matched your search
@@ -229,6 +229,51 @@ test("picking Start from scratch instead of a spec grays Document, and a launch
|
||||
assert.ok(!launch.spec, `a launch from scratch names no spec: ${JSON.stringify(launch)}`);
|
||||
});
|
||||
|
||||
// What a person would see break: a spec not documented yet offers nothing to
|
||||
// read, or its Map and Plan draft tabs stay up for a spec that has an
|
||||
// overview (or for no spec at all).
|
||||
test("a spec not documented yet shows its Map and Plan draft as tabs, and a documented one shows only Overview", async (t) => {
|
||||
const project = tempProject({
|
||||
...DRAFT_PROJECT,
|
||||
"specs/demo/pathfinder/map.md": "# Map: demo\n\n**Status:** Cleared\n\nWho votes for lunch.\n",
|
||||
"specs/done/overview.md": "# Overview: done\n\nAll written up.\n",
|
||||
"specs/done/phase-1.md": "- [ ] **Task 1.1:** x\n",
|
||||
});
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "dashboard", payload: MENU, project });
|
||||
const main = await toTheMenu(s);
|
||||
const tab = (name) => s.page.locator("#views .view-tab", { hasText: new RegExp(`^${name}$`) });
|
||||
|
||||
await chipFor(main, "demo").click();
|
||||
await pickedChip(main, "demo").waitFor();
|
||||
await tab("Map").waitFor();
|
||||
await tab("Plan draft").waitFor();
|
||||
assert.equal(await tab("Overview").count(), 0, "no overview.md, no Overview tab");
|
||||
|
||||
await tab("Plan draft").click();
|
||||
await main.getByRole("heading", { name: "Plan draft", exact: true }).waitFor();
|
||||
assert.match(await textOf(main), /specs\/demo\/PLAN-DRAFT-20261017\.md · read-only/);
|
||||
assert.match(await textOf(main), /A lunch vote for the team\./);
|
||||
await tab("Map").click();
|
||||
await main.getByRole("heading", { name: "Map", exact: true }).waitFor();
|
||||
assert.match(await textOf(main), /specs\/demo\/pathfinder\/map\.md · read-only/);
|
||||
assert.match(await textOf(main), /Who votes for lunch\./);
|
||||
|
||||
// The documented spec trades both for its Overview, and the open Map tab,
|
||||
// gone with them, sends the person home.
|
||||
await tab("Dashboard").click();
|
||||
await chipFor(main, "done").click();
|
||||
await pickedChip(main, "done").waitFor();
|
||||
await tab("Overview").waitFor();
|
||||
assert.ok(
|
||||
await until(async () => (await tab("Map").count()) === 0 && (await tab("Plan draft").count()) === 0),
|
||||
"the Map and Plan draft tabs go"
|
||||
);
|
||||
|
||||
await chipFor(main, "Start from scratch").click();
|
||||
await pickedChip(main, "Start from scratch").waitFor();
|
||||
assert.ok(await until(async () => (await tab("Overview").count()) === 0), "no spec, no spec tabs");
|
||||
});
|
||||
|
||||
// What a person would see break: the intro cannot be skipped, or it replays
|
||||
// on every reload of the same tab.
|
||||
test("Skip the intro ends the first-open wake-up at once, and a reload of the tab does not play it again", async (t) => {
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
handOff,
|
||||
PROTECTED_CONSOLE_FILES,
|
||||
readOverview,
|
||||
readSpecFile,
|
||||
removeCleanup,
|
||||
removeScratch,
|
||||
removeSessions,
|
||||
@@ -562,6 +563,12 @@ function overviewProject() {
|
||||
fs.writeFileSync(path.join(root, "specs", "a", "overview.md"), "# Overview A\n");
|
||||
fs.writeFileSync(path.join(root, "specs", "a", "phase-1.md"), "- [ ] **Task 1.1:** x\n");
|
||||
fs.writeFileSync(path.join(root, "specs", "b", "notes.md"), "notes\n");
|
||||
// Planned, not documented: a Pathfinder map and a live draft beside the
|
||||
// copy Revise plan keeps of the last one.
|
||||
fs.mkdirSync(path.join(root, "specs", "c", "pathfinder"), { recursive: true });
|
||||
fs.writeFileSync(path.join(root, "specs", "c", "pathfinder", "map.md"), "# Map C\n");
|
||||
fs.writeFileSync(path.join(root, "specs", "c", "PLAN-DRAFT-20261020.md"), "# Draft C\n");
|
||||
fs.writeFileSync(path.join(root, "specs", "c", "PLAN-DRAFT-20261020-prev.md"), "# Old draft C\n");
|
||||
fs.mkdirSync(path.join(base, "outside"));
|
||||
fs.writeFileSync(path.join(base, "outside", "overview.md"), "# SECRET\n");
|
||||
return { base, root };
|
||||
@@ -598,6 +605,22 @@ test("readOverview reads a spec's overview and nothing outside the root", async
|
||||
}
|
||||
});
|
||||
|
||||
test("readSpecFile reads a spec's map and live plan draft, and names the file", async () => {
|
||||
const { base, root } = overviewProject();
|
||||
try {
|
||||
assert.deepEqual(await readSpecFile(root, "specs/c", "map"), { file: "pathfinder/map.md", text: "# Map C\n" });
|
||||
assert.deepEqual(await readSpecFile(root, "specs/c", "draft"), { file: "PLAN-DRAFT-20261020.md", text: "# Draft C\n" });
|
||||
assert.deepEqual(await readSpecFile(root, "specs/a", "overview"), { file: "overview.md", text: "# Overview A\n" });
|
||||
assert.equal(await readSpecFile(root, "specs/c", "overview"), null);
|
||||
assert.equal(await readSpecFile(root, "specs/a", "map"), null);
|
||||
assert.equal(await readSpecFile(root, "specs/a", "draft"), null);
|
||||
assert.equal(await readSpecFile(root, "specs/c", "phase-1.md"), null, "only the known kinds");
|
||||
assert.equal(await readSpecFile(root, "../outside", "draft"), null);
|
||||
} finally {
|
||||
fs.rmSync(base, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("GET /overview serves the session's spec, and on the dashboard only a scanned one", async () => {
|
||||
const { base, root } = overviewProject();
|
||||
const sids = [];
|
||||
@@ -628,6 +651,16 @@ test("GET /overview serves the session's spec, and on the dashboard only a scann
|
||||
assert.equal((await get(d, "?spec=specs/b")).status, 204);
|
||||
assert.equal((await get(d, "?spec=specs/../..")).status, 204);
|
||||
assert.equal((await get(d, "?spec=specs/not-scanned")).status, 204);
|
||||
// ?file= picks the map or the live draft, and names it for the page.
|
||||
const map = await get(d, "?spec=specs/c&file=map");
|
||||
assert.equal(map.status, 200);
|
||||
assert.equal(map.headers.get("x-spec-file"), encodeURIComponent("pathfinder/map.md"));
|
||||
assert.equal(await map.text(), "# Map C\n");
|
||||
const draft = await get(d, "?spec=specs/c&file=draft");
|
||||
assert.equal(draft.headers.get("x-spec-file"), "PLAN-DRAFT-20261020.md");
|
||||
assert.equal(await draft.text(), "# Draft C\n");
|
||||
assert.equal((await get(d, "?spec=specs/c")).status, 204, "no overview.md yet");
|
||||
assert.equal((await get(d, "?spec=specs/c&file=nope")).status, 204);
|
||||
} finally {
|
||||
for (const s of sids) cliIn(root, ["stop", "--session", s]);
|
||||
fs.rmSync(base, { recursive: true, force: true });
|
||||
|
||||
@@ -734,6 +734,8 @@ test("help: helpTabFor opens on the tab for where the person is", () => {
|
||||
[{ dashboard: true, meterRed: true, view: "ask" }, "ask"],
|
||||
[{ meterRed: true }, "about"],
|
||||
[{ view: "overview" }, "docs"],
|
||||
[{ view: "map" }, "docs"],
|
||||
[{ view: "draft" }, "docs"],
|
||||
[{ view: "doc:plan" }, "docs"],
|
||||
[{ view: "doc:plan", workflow: "implement" }, "docs"],
|
||||
[{ workflow: "implement" }, "build"],
|
||||
|
||||
@@ -45,7 +45,7 @@ test("state: the rest of the shared state starts as app.js always started it", (
|
||||
updateFrame: null,
|
||||
inApp: false,
|
||||
subagentsFrame: null,
|
||||
overview: { key: null, text: null },
|
||||
overview: { key: null, files: {} },
|
||||
wake: null,
|
||||
dashPick: null,
|
||||
mentionPop: null,
|
||||
|
||||
Reference in new issue
Block a user