// The native Project Management feature: no module loads before the first use, the ribbon button opens All tasks, // the board scope opens a board in the same tab with the board name, a card moves to another list through the host menu, // and a card edit saves to the hidden card file. Settings → Project Management saves the priority levels and the default // board, and the ribbon button then opens that board. It also checks both themes and the shared tooltip of the ribbon button. import assert from "node:assert/strict"; import path from "node:path"; import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs"; const roadmap = "6f4c2a3e-6a0b-4d57-9a3e-1c2b3d4e5f60"; const bugs = "0c18bcdc-f41e-4a31-87f4-87c369f398c1"; const board = id => ({ schema: 1, kind: "board", id, lists: [ { id: "todo", name: "To do", status: "todo", collapsed: false }, { id: "doing", name: "In progress", status: "doing", collapsed: false }, { id: "done", name: "Done", status: "done", collapsed: false }, ], defaults: { todo: "todo", doing: "doing", done: "done" }, }); const cardPath = id => `.runestone/pm/cards/${Buffer.from(id).toString("hex")}.md`; const card = (id, title, boardId, order) => [cardPath(id), [ "---", "runestone_pm:", " schema: 1", ` id: ${id}`, " kind: task", ` title: ${title}`, " createdAt: 2026-10-01T00:00:00.000Z", ` order: "${order}"`, " status: todo", " tags: []", " sessions: []", " archived: false", " placements:", ` ${boardId}:`, " listId: todo", ` order: "${order}"`, "---", `Body of ${title}.`, "", ].join("\n")]; const files = Object.fromEntries([ ["note.md", "# Note\n"], [".runestone/pm/.gitignore", "# RuneStone Project Management local data\n*\n"], [".runestone/pm/cards/.gitignore", "*\n"], [".runestone/pm/workspace.json", JSON.stringify({ schema: 1, boards: [{ name: "Roadmap", value: board(roadmap) }, { name: "Bugs", value: board(bugs) }] }, null, 2) + "\n"], card("card-a", "Card A", roadmap, "a"), card("card-b", "Card B", roadmap, "b"), card("card-c", "Card C", bugs, "c"), ]); await runSmoke("features/pm", async ({ browser }) => { const output = await outputDir("features/pm"); const mock = { state: { files }, commands: test => { const workspace = test.workspace({ root: "C:\\pm-feature", files: test.state.files }); test.files = workspace.files; return { ...workspace, workspace_read: args => { if (!workspace.files.has(args.rel) && args.missingOk) return null; return workspace.workspace_read(args); }, workspace_create: ({ rel, kind, contents }) => { if (workspace.files.has(rel)) throw new Error("Destination exists"); if (kind === "file") workspace.files.set(rel, contents ?? ""); return null; }, plugins_snapshot: () => ({ root: "C:/plugins", plugins: [] }), spelling_menu_install: () => null, "plugin:window|is_maximized": () => false, }; }, }; // One context, so the settings window shares the settings file of the main window. const context = await browser.newContext({ viewport: { width: 1440, height: 1000 } }); await mockTauri(context, mock); const page = await openPage(context); await page.goto(smokeUrl); await page.locator('[data-tree-rel="note.md"]').waitFor(); const loaded = () => page.evaluate(() => performance.getEntriesByType("resource").some(entry => { const { pathname } = new URL(entry.name); return pathname.startsWith("/src/lib/features/pm/") || /\/deps\/yaml\b|\/node_modules\/yaml\//.test(pathname); })); const ribbon = page.locator(".plugin-ribbon").getByRole("button", { name: "Project Management", exact: true }); await ribbon.waitFor(); assert.equal(await loaded(), false, "No Project Management module and no YAML parser load before the first use"); assert.equal(await page.locator('[data-tree-rel="note.md"] .document-icon').count(), 0, "The file tree marks no Markdown file for Project Management"); await ribbon.hover(); await page.getByRole("tooltip").filter({ hasText: /^Project Management$/ }).waitFor(); // The ribbon button opens All tasks: no default board is set. await ribbon.click(); const pane = page.locator(".plugin-editor-pane:visible"); await pane.locator(".pm-board").waitFor(); await page.getByRole("tab", { name: "Project Management", exact: true }).waitFor(); await page.waitForFunction(() => document.querySelectorAll(".plugin-editor-pane .pm-card").length === 3); assert.equal(await loaded(), true, "The first use loads the feature"); assert.equal(await ribbon.getAttribute("aria-pressed"), "true", "The ribbon button shows the open view"); // The board scope opens a board in the same tab, with the board name as its title. await pane.getByRole("button", { name: /^Board scope:/ }).click(); await page.getByRole("menuitemradio", { name: "Roadmap", exact: true }).click(); await page.getByRole("tab", { name: "Roadmap", exact: true }).waitFor(); assert.equal(await page.getByRole("tab", { name: "Project Management", exact: true }).count(), 0, "The board replaces All tasks in its tab"); await page.waitForFunction(() => [...document.querySelectorAll(".plugin-editor-pane .pm-card")].filter(card => card.getClientRects().length).length === 2); for (const theme of ["dark", "light"]) { await page.evaluate(async mode => { const { saveAppearance } = await import("/src/lib/theme/appearance.ts"); saveAppearance({ theme: "default", mode }); }, theme); await page.waitForFunction(mode => document.documentElement.dataset.theme === mode, theme); await page.screenshot({ path: path.join(output, `board-${theme}.png`) }); } // Move a card to another list through the host action menu. The save writes only that card. await pane.getByRole("button", { name: "Actions for Card A", exact: true }).click(); await page.getByRole("menuitem", { name: "Move to list", exact: true }).click(); await page.getByRole("menuitemradio", { name: "In progress", exact: true }).click(); await page.waitForFunction(path => /listId: doing/.test(window.__TEST__.files.get(path)), cardPath("card-a")); const moved = await page.evaluate(path => window.__TEST__.files.get(path), cardPath("card-a")); assert.match(moved, /status: doing/, "The list status applies to the card"); await pane.locator(".pm-column", { hasText: "In progress" }).locator(".pm-card", { hasText: "Card A" }).waitFor(); // Edit a card in its details and save it. await pane.getByRole("button", { name: "Card B", exact: true }).click(); const editor = page.locator("dialog.pm-card-editor[open]"); await editor.waitFor(); await editor.getByRole("textbox", { name: "Title", exact: true }).fill("Card B edited"); await page.screenshot({ path: path.join(output, "card-editor-light.png") }); await editor.getByRole("button", { name: "Save card", exact: true }).click(); await editor.waitFor({ state: "detached" }); await page.waitForFunction(path => /title: Card B edited/.test(window.__TEST__.files.get(path)), cardPath("card-b")); await pane.locator(".pm-card", { hasText: "Card B edited" }).waitFor(); assert.equal(await page.evaluate(path => window.__TEST__.files.get(path), cardPath("card-c")), files[cardPath("card-c")], "Other cards stay unchanged"); await page.screenshot({ path: path.join(output, "board-after-edit-light.png") }); // The board menu shows the same settings component as Settings → Project Management. await pane.getByRole("button", { name: "More actions", exact: true }).click(); await page.getByRole("menuitem", { name: "Project Management settings", exact: true }).click(); const popup = page.getByRole("dialog", { name: "Project Management settings", exact: true }); await popup.getByRole("button", { name: "Priority levels", exact: true }).waitFor(); await popup.getByRole("button", { name: "Default board", exact: true }).waitFor(); await page.screenshot({ path: path.join(output, "board-settings-light.png") }); await page.keyboard.press("Escape"); await popup.waitFor({ state: "detached" }); // Settings → Project Management in the settings window. Each page of the mock has its own copy of the workspace files. const settings = await openPage(context); await settings.goto(`${smokeUrl}/?settingsWindow=true`); await settings.getByRole("button", { name: "Project Management", exact: true }).click(); await settings.getByRole("heading", { name: "Project Management", exact: true }).waitFor(); const levels = settings.getByRole("button", { name: "Priority levels", exact: true }); assert.equal(await levels.innerText(), "3 — High, Medium, and Low"); await levels.click(); await settings.getByRole("menuitemradio", { name: "5 — Highest through Lowest", exact: true }).click(); await settings.waitForFunction(() => window.__TEST__.settings("projectManagement")?.priorityLevels === 5); const defaultBoard = settings.getByRole("button", { name: "Default board", exact: true }); await settings.waitForFunction(() => !document.querySelector('[aria-label="Default board"]').disabled); assert.equal(await defaultBoard.innerText(), "All tasks"); await defaultBoard.click(); assert.deepEqual(await settings.getByRole("menuitemradio").allInnerTexts(), ["All tasks", "Roadmap", "Bugs"]); await settings.getByRole("menuitemradio", { name: "Roadmap", exact: true }).click(); await settings.waitForFunction(id => JSON.parse(window.__TEST__.files.get(".runestone/pm/workspace.json")).defaultBoardId === id, roadmap); await settings.screenshot({ path: path.join(output, "settings-light.png") }); await settings.close(); // With a default board, the ribbon button opens it. await page.evaluate(([board, catalog]) => { const value = JSON.parse(catalog); window.__TEST__.files.set(".runestone/pm/workspace.json", JSON.stringify({ ...value, defaultBoardId: board, defaultBoardPath: `pm-board:${board}` })); }, [bugs, files[".runestone/pm/workspace.json"]]); await ribbon.click(); await page.getByRole("tab", { name: "Bugs", exact: true }).waitFor(); await page.waitForFunction(() => [...document.querySelectorAll(".plugin-editor-pane .pm-card")].some(card => card.getClientRects().length && card.textContent.includes("Card C"))); assert.deepEqual([...page.errors, ...settings.errors], [], "No page errors"); await context.close(); });