Translate Project Management and add its tests and guide
- Every interface string of Project Management goes through the catalog: 539 new rows with fr, ja, and zh-CN. - Storage and model messages use a local message() marker and stay free of host imports. The interface translates them. - A board renders again when the language changes. Dates use the interface language. - Fix: the ribbon button waits for the feature switches at startup, and the settings code loads no feature module. - Add six smoke tests: board state, cards, menus, drag and drop, views, and language. - Add docs/guides/project-management.md and UI-060. Update the user, plugin, SDK, host, development, and interface docs and CLAUDE.md. - Name the fake board view of tree/renameUndo "Board fixture", because the native Project Management button is now in the ribbon.
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
// Shared setup of the Project Management smoke tests (tests/smoke/features/pm*.smoke.mjs): a workspace with two boards
|
||||
// and five cards in hidden storage, a mock that keeps the workspace files through a page reload, and small helpers.
|
||||
import { mockTauri, smokeUrl } from "./index.mjs";
|
||||
|
||||
export const roadmap = "6f4c2a3e-6a0b-4d57-9a3e-1c2b3d4e5f60";
|
||||
export const bugs = "0c18bcdc-f41e-4a31-87f4-87c369f398c1";
|
||||
export const catalogPath = ".runestone/pm/workspace.json";
|
||||
export const deletedPath = ".runestone/pm/deleted-cards.json";
|
||||
const hex = id => Buffer.from(id).toString("hex");
|
||||
export const cardPath = id => `.runestone/pm/cards/${hex(id)}.md`;
|
||||
export const draftPath = id => `.runestone/pm/drafts/${hex(id)}.json`;
|
||||
|
||||
/** The local date `offset` days from today, as YYYY-MM-DD. */
|
||||
export function localDay(offset = 0) {
|
||||
const date = new Date();
|
||||
date.setDate(date.getDate() + offset);
|
||||
return [date.getFullYear(), date.getMonth() + 1, date.getDate()].map(part => String(part).padStart(2, "0")).join("-");
|
||||
}
|
||||
|
||||
/** A board with the three default lists and one review list. `review` gives the ID, the name, and the limit of that list. */
|
||||
export function board(id, review = { id: "review", name: "Review" }) {
|
||||
return {
|
||||
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 },
|
||||
{ collapsed: false, status: null, ...review },
|
||||
],
|
||||
defaults: { todo: "todo", doing: "doing", done: "done" },
|
||||
};
|
||||
}
|
||||
|
||||
/** A card file. `placements` maps a board ID to a list ID. `extra` adds lines to the front matter. */
|
||||
export function card(id, title, { placements = {}, status = "todo", order = id.slice(-1), extra = [] } = {}) {
|
||||
const lines = ["---", "runestone_pm:", " schema: 1", ` id: ${id}`, " kind: task", ` title: ${title}`,
|
||||
' createdAt: "2026-10-01T08:30:00.000Z"', ` order: "${order}"`, ` status: ${status}`, " tags: []", " sessions: []", " archived: false", ...extra];
|
||||
if (Object.keys(placements).length) {
|
||||
lines.push(" placements:");
|
||||
for (const [boardId, listId] of Object.entries(placements)) lines.push(` ${boardId}:`, ` listId: ${listId}`, ` order: "${order}"`);
|
||||
}
|
||||
return [cardPath(id), [...lines, "---", `Body of ${title}.`, ""].join("\n")];
|
||||
}
|
||||
|
||||
/**
|
||||
* The workspace files. Roadmap: Card A and Card B in To do, Shared card in To do, and a limit of 2 on Review.
|
||||
* Bugs: Card C in its "review" list, Shared card in To do. Loose card has no board. Card B has planned dates and a deadline.
|
||||
*/
|
||||
export function pmFiles({ boards = true, defaultBoardId } = {}) {
|
||||
const catalog = { schema: 1, boards: [
|
||||
{ name: "Roadmap", value: board(roadmap, { id: "review", name: "Review", maxCards: 2 }) },
|
||||
{ name: "Bugs", value: board(bugs, { id: "qa", name: "review" }) },
|
||||
], ...(defaultBoardId ? { defaultBoardId, defaultBoardPath: `pm-board:${defaultBoardId}` } : {}) };
|
||||
return Object.fromEntries([
|
||||
["note.md", "# Note\n"],
|
||||
[".runestone/pm/.gitignore", "# RuneStone Project Management local data\n*\n"],
|
||||
[".runestone/pm/cards/.gitignore", "*\n"],
|
||||
...boards ? [[catalogPath, JSON.stringify(catalog, null, 2) + "\n"]] : [],
|
||||
card("card-a", "Card A", { placements: { [roadmap]: "todo" }, order: "a" }),
|
||||
card("card-b", "Card B", { placements: { [roadmap]: "todo" }, order: "b", extra: [
|
||||
" due:", ` date: "${localDay(2)}"`, " plan:", ` start: "${localDay(0)}"`, ` end: "${localDay(4)}"`] }),
|
||||
card("card-c", "Card C", { placements: { [bugs]: "qa" }, order: "c" }),
|
||||
card("card-d", "Shared card", { placements: { [roadmap]: "todo", [bugs]: "todo" }, order: "d" }),
|
||||
card("card-e", "Loose card", { order: "e" }),
|
||||
]);
|
||||
}
|
||||
|
||||
// This function runs in the page. Keep it self-contained. The files stay in localStorage, so a reload keeps them.
|
||||
function pmCommands(test) {
|
||||
const KEY = "runestone.smoke.pm-files";
|
||||
let saved = null;
|
||||
try { saved = JSON.parse(localStorage.getItem(KEY)); } catch { saved = null; }
|
||||
const workspace = test.workspace({ root: "C:\\pm-smoke", files: new Map(saved ?? Object.entries(test.state.files)) });
|
||||
test.files = workspace.files;
|
||||
const keep = () => localStorage.setItem(KEY, JSON.stringify([...workspace.files]));
|
||||
const kept = handler => args => { const result = handler(args); keep(); return result; };
|
||||
return {
|
||||
...workspace,
|
||||
workspace_read: args => {
|
||||
if (!workspace.files.has(args.rel) && args.missingOk) return null;
|
||||
return workspace.workspace_read(args);
|
||||
},
|
||||
workspace_write: kept(workspace.workspace_write),
|
||||
workspace_delete: kept(workspace.workspace_delete),
|
||||
workspace_create: kept(({ rel, kind, contents }) => {
|
||||
if (workspace.files.has(rel)) throw new Error("Destination exists");
|
||||
if (kind === "file") workspace.files.set(rel, contents ?? "");
|
||||
else workspace.folders.add(rel);
|
||||
return null;
|
||||
}),
|
||||
plugins_snapshot: () => ({ root: "C:/plugins", plugins: [] }),
|
||||
spelling_menu_install: () => null,
|
||||
"plugin:window|is_maximized": () => false,
|
||||
};
|
||||
}
|
||||
|
||||
/** Mock the host with the files of `pmFiles()`, load the app, and wait for the file tree. */
|
||||
export async function loadWorkspace(page, files = pmFiles()) {
|
||||
await mockTauri(page, { state: { files }, commands: pmCommands });
|
||||
await page.goto(smokeUrl);
|
||||
await page.locator('[data-tree-rel="note.md"]').waitFor();
|
||||
}
|
||||
|
||||
/** The Project Management ribbon button. */
|
||||
export const ribbon = page => page.locator(".plugin-ribbon").getByRole("button", { name: "Project Management", exact: true });
|
||||
/** The visible Project Management view. */
|
||||
export const pane = page => page.locator(".plugin-editor-pane:visible .rs-pm");
|
||||
/** A Kanban column by its accessible name. */
|
||||
export const column = (page, name) => pane(page).locator(`section.pm-column[aria-label="${name}"]`);
|
||||
|
||||
/** Open All tasks with the ribbon button, then open a board through the board scope menu when `name` is given. */
|
||||
export async function openBoard(page, name) {
|
||||
if (!await pane(page).count()) {
|
||||
await ribbon(page).click();
|
||||
await pane(page).locator(".pm-board").waitFor();
|
||||
}
|
||||
if (!name) return;
|
||||
await pane(page).locator(".pm-scope").click();
|
||||
await page.getByRole("menuitemradio", { name, exact: true }).click();
|
||||
await page.getByRole("tab", { name, exact: true }).waitFor();
|
||||
await pane(page).locator(".pm-scope-label", { hasText: new RegExp(`^${name}$`) }).waitFor();
|
||||
await pane(page).locator(".pm-column").first().waitFor();
|
||||
}
|
||||
|
||||
/** Use the dark or the light mode of the default theme. */
|
||||
export async function setTheme(page, mode) {
|
||||
await page.evaluate(async value => {
|
||||
const { saveAppearance } = await import("/src/lib/theme/appearance.ts");
|
||||
saveAppearance({ theme: "default", mode: value });
|
||||
}, mode);
|
||||
await page.waitForFunction(value => document.documentElement.dataset.theme === value, mode);
|
||||
}
|
||||
|
||||
/** The text of a workspace file, or undefined. */
|
||||
export const fileText = (page, path) => page.evaluate(rel => window.__TEST__.files.get(rel), path);
|
||||
/** Wait until a workspace file matches `pattern`. */
|
||||
export const waitForFile = (page, path, pattern) =>
|
||||
page.waitForFunction(([rel, source, flags]) => new RegExp(source, flags).test(window.__TEST__.files.get(rel) ?? ""), [path, pattern.source, pattern.flags]);
|
||||
/** The saved boards of the catalog. */
|
||||
export const savedBoards = async page => JSON.parse(await fileText(page, catalogPath)).boards;
|
||||
/** The element that has focus, as its accessible name or text. */
|
||||
export const focusedName = page => page.evaluate(() => document.activeElement?.getAttribute("aria-label") ?? document.activeElement?.textContent?.trim());
|
||||
@@ -0,0 +1,165 @@
|
||||
// Project Management board state: list capacity and its warning (UI-033), compact list collapse (UI-036), the separate
|
||||
// collapse state of All tasks, new cards from the list composer, a page reload that keeps the state, the fixed default
|
||||
// board of the workspace (UI-038), and the first board of a workspace without boards.
|
||||
// Ports list-limits.spec.ts, list-collapse-create.spec.ts, kanban-cards.spec.ts, board-view-state.spec.ts,
|
||||
// october-cards.spec.ts (default board and onboarding), and host-board-state.smoke.mjs of RuneStone_Project_Management.
|
||||
import assert from "node:assert/strict";
|
||||
import path from "node:path";
|
||||
import { openPage, outputDir, runSmoke } from "../_harness/index.mjs";
|
||||
import { bugs, catalogPath, column, fileText, loadWorkspace, openBoard, pane, pmFiles, ribbon, roadmap, savedBoards, setTheme, waitForFile } from "../_harness/pmFixture.mjs";
|
||||
|
||||
const listOf = async (page, id, listId) => (await savedBoards(page)).find(item => item.value.id === id).value.lists.find(list => list.id === listId);
|
||||
const width = async locator => (await locator.boundingBox()).width;
|
||||
|
||||
await runSmoke("features/pmBoard", async ({ browser, page }) => {
|
||||
const output = await outputDir("features/pmBoard");
|
||||
await loadWorkspace(page);
|
||||
const catalog = await fileText(page, catalogPath);
|
||||
|
||||
// All tasks keeps its collapsed lists in the view state of the tab. The board files stay unchanged.
|
||||
await openBoard(page);
|
||||
const allTodo = column(page, "To do");
|
||||
await allTodo.getByRole("button", { name: "Collapse To do", exact: true }).click();
|
||||
await allTodo.getByRole("button", { name: "Expand To do", exact: true }).waitFor();
|
||||
assert.equal(await focusedLabel(page), "Expand To do", "Focus stays on the collapse control");
|
||||
assert(await width(allTodo) < 60, "A collapsed list is a narrow strip");
|
||||
assert.equal(await allTodo.locator(".pm-card").count(), 0, "A collapsed list hides its cards");
|
||||
assert.equal(await allTodo.locator(".pm-count").innerText(), "4", "The strip keeps the card count");
|
||||
await page.waitForFunction(() => JSON.parse(localStorage.getItem("runestone.pm.viewStates") ?? "{}").planning?.collapsedLists?.includes("list:to do"));
|
||||
assert.equal(await fileText(page, catalogPath), catalog, "A collapse in All tasks does not write the boards");
|
||||
// UI-033: All tasks has no list actions and no capacity of a merged list.
|
||||
assert.equal(await pane(page).locator(".pm-list-actions, .pm-list-limit").count(), 0, "All tasks has no list actions and no list limits");
|
||||
|
||||
// A board list starts expanded: the board has its own collapse state.
|
||||
await openBoard(page, "Roadmap");
|
||||
const todo = column(page, "To do");
|
||||
assert.equal(await todo.locator(".pm-card").count(), 3);
|
||||
// UI-033: a limit below the maximum shows the plain indicator.
|
||||
const review = column(page, "Review");
|
||||
assert.equal(await review.locator(".pm-count").innerText(), "0/2");
|
||||
assert.equal(await review.locator(".pm-list-limit").count(), 1);
|
||||
assert.equal(await review.locator(".pm-list-limit-reached").count(), 0);
|
||||
|
||||
// Set a limit through the list menu. At the maximum, the list shows the warning.
|
||||
await todo.getByRole("button", { name: "List actions for To do", exact: true }).click();
|
||||
await page.getByRole("menu", { name: "List actions", exact: true }).getByRole("menuitem", { name: "Set list limit", exact: true }).click();
|
||||
const limitForm = page.getByRole("dialog", { name: "Set list limit", exact: true });
|
||||
await limitForm.getByLabel("Maximum cards", { exact: true }).fill("3");
|
||||
await limitForm.getByRole("button", { name: "Save limit", exact: true }).click();
|
||||
await limitForm.waitFor({ state: "detached" });
|
||||
await waitForFile(page, catalogPath, /"maxCards": 3/);
|
||||
assert.equal(await todo.locator(".pm-count").innerText(), "3/3");
|
||||
const warning = todo.locator(".pm-list-limit-reached");
|
||||
assert.match(await warning.getAttribute("aria-label"), /^Active cards in To do: 3\. The maximum is 3\. The list is at the limit\.$/);
|
||||
|
||||
// The limit warns but does not block: the composer adds a fourth card.
|
||||
await todo.getByRole("button", { name: "Add a card", exact: true }).click();
|
||||
const composer = todo.getByRole("textbox", { name: "Card title", exact: true });
|
||||
await composer.fill("Composer card");
|
||||
await composer.press("Enter");
|
||||
await todo.getByRole("button", { name: "Composer card", exact: true }).waitFor();
|
||||
await page.waitForFunction(() => [...window.__TEST__.files.values()].some(text => /title: Composer card/.test(text)));
|
||||
await page.waitForFunction(() => document.querySelector('.plugin-editor-pane .pm-column[aria-label="To do"] .pm-count')?.textContent === "4/3");
|
||||
assert.match(await warning.getAttribute("aria-label"), /The list is over the limit\.$/);
|
||||
for (const theme of ["dark", "light"]) {
|
||||
await setTheme(page, theme);
|
||||
await warning.focus();
|
||||
await page.getByRole("tooltip").filter({ hasText: /over the limit/ }).waitFor();
|
||||
await page.screenshot({ path: path.join(output, `limit-warning-${theme}.png`) });
|
||||
}
|
||||
|
||||
// UI-036: a keyboard collapse saves the board file, keeps the count, and keeps focus on the control.
|
||||
await todo.getByRole("button", { name: "Collapse To do", exact: true }).focus();
|
||||
await page.keyboard.press("Enter");
|
||||
await todo.getByRole("button", { name: "Expand To do", exact: true }).waitFor();
|
||||
assert.equal(await focusedLabel(page), "Expand To do");
|
||||
await waitForList(page, roadmap, "todo", list => list.collapsed === true);
|
||||
assert(await width(todo) < 60);
|
||||
assert.equal(await todo.locator(".pm-count").innerText(), "4/3", "The strip keeps the count and the limit");
|
||||
assert.equal(await todo.locator(".pm-list-limit-reached").count(), 1, "The strip keeps the warning");
|
||||
await column(page, "Done").getByRole("button", { name: "Collapse Done", exact: true }).click();
|
||||
await waitForList(page, roadmap, "done", list => list.collapsed === true);
|
||||
for (const theme of ["dark", "light"]) {
|
||||
await setTheme(page, theme);
|
||||
await page.screenshot({ path: path.join(output, `collapsed-board-${theme}.png`) });
|
||||
}
|
||||
|
||||
// A reload keeps the board state, the limits, and the collapsed lists of All tasks.
|
||||
await page.reload();
|
||||
await page.locator('[data-tree-rel="note.md"]').waitFor();
|
||||
await openBoard(page, "Roadmap");
|
||||
await column(page, "To do").getByRole("button", { name: "Expand To do", exact: true }).waitFor();
|
||||
assert.equal(await column(page, "To do").locator(".pm-count").innerText(), "4/3");
|
||||
await column(page, "Done").getByRole("button", { name: "Expand Done", exact: true }).waitFor();
|
||||
assert.equal(await column(page, "In progress").getByRole("button", { name: "Collapse In progress", exact: true }).count(), 1);
|
||||
await column(page, "To do").getByRole("button", { name: "Expand To do", exact: true }).click();
|
||||
await waitForList(page, roadmap, "todo", list => list.collapsed === false);
|
||||
await column(page, "To do").getByRole("button", { name: "Composer card", exact: true }).waitFor();
|
||||
|
||||
// The limit indicator opens the limit form. An empty field removes the limit.
|
||||
await column(page, "To do").locator(".pm-list-limit").click();
|
||||
await limitForm.getByLabel("Maximum cards", { exact: true }).fill("");
|
||||
await limitForm.getByRole("button", { name: "Save limit", exact: true }).click();
|
||||
await waitForList(page, roadmap, "todo", list => list.maxCards === undefined);
|
||||
assert.equal(await column(page, "To do").locator(".pm-list-limit").count(), 0);
|
||||
assert.equal(await column(page, "To do").locator(".pm-count").innerText(), "4");
|
||||
|
||||
await pane(page).locator(".pm-scope").click();
|
||||
await page.getByRole("menuitemradio", { name: "All tasks", exact: true }).click();
|
||||
await column(page, "To do").getByRole("button", { name: "Expand To do", exact: true }).waitFor();
|
||||
|
||||
// UI-038: the settings save a default board. The ribbon button then opens it.
|
||||
await pane(page).getByRole("button", { name: "More actions", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "Project Management settings", exact: true }).click();
|
||||
const settings = page.getByRole("dialog", { name: "Project Management settings", exact: true });
|
||||
const defaultBoard = settings.getByRole("button", { name: "Default board", exact: true });
|
||||
await page.waitForFunction(() => document.querySelector('.pm-settings-popup [aria-label="Default board"]')?.disabled === false);
|
||||
assert.equal(await defaultBoard.innerText(), "All tasks");
|
||||
await defaultBoard.click();
|
||||
await page.getByRole("menuitemradio", { name: "Bugs", exact: true }).click();
|
||||
await waitForFile(page, catalogPath, new RegExp(`"defaultBoardId": "${bugs}"`));
|
||||
await page.keyboard.press("Escape");
|
||||
await settings.waitFor({ state: "detached" });
|
||||
await ribbon(page).click();
|
||||
await page.getByRole("tab", { name: "Bugs", exact: true, selected: true }).waitFor();
|
||||
await pane(page).locator(".pm-card", { hasText: "Card C" }).waitFor();
|
||||
|
||||
// An unavailable default opens All tasks.
|
||||
await page.evaluate(rel => {
|
||||
const value = JSON.parse(window.__TEST__.files.get(rel));
|
||||
window.__TEST__.files.set(rel, JSON.stringify({ ...value, defaultBoardId: "missing-board", defaultBoardPath: "pm-board:missing-board" }));
|
||||
}, catalogPath);
|
||||
await ribbon(page).click();
|
||||
await page.getByRole("tab", { name: "Project Management", exact: true, selected: true }).waitFor();
|
||||
await pane(page).locator(".pm-scope-label", { hasText: /^All tasks$/ }).waitFor();
|
||||
console.log("PASS: list limits, collapse, reload, and the default board");
|
||||
|
||||
// UI-038: a workspace without boards shows a visible action that creates the first board.
|
||||
const context = await browser.newContext({ viewport: { width: 1280, height: 860 } });
|
||||
const empty = await openPage(context);
|
||||
await loadWorkspace(empty, pmFiles({ boards: false }));
|
||||
await openBoard(empty);
|
||||
const welcome = empty.getByRole("region", { name: "Create your first board", exact: true });
|
||||
await welcome.waitFor();
|
||||
await welcome.getByRole("button", { name: "Create your first board", exact: true }).click();
|
||||
await empty.getByRole("textbox", { name: "Board name", exact: true }).fill("First board");
|
||||
await empty.getByRole("dialog", { name: "Create board", exact: true }).getByRole("button", { name: "Create board", exact: true }).click();
|
||||
await empty.getByRole("tab", { name: "First board", exact: true, selected: true }).waitFor();
|
||||
await waitForFile(empty, catalogPath, /"name": "First board"/);
|
||||
await empty.screenshot({ path: path.join(output, "first-board-light.png") });
|
||||
assert.deepEqual(empty.errors, [], "No page errors in the workspace without boards");
|
||||
await context.close();
|
||||
}, { timeout: 15000 });
|
||||
|
||||
function focusedLabel(page) {
|
||||
return page.evaluate(() => document.activeElement?.getAttribute("aria-label"));
|
||||
}
|
||||
|
||||
/** Wait until a list of a saved board matches `test`. */
|
||||
async function waitForList(page, boardId, listId, test) {
|
||||
for (let attempt = 0; attempt < 50; attempt++) {
|
||||
if (test(await listOf(page, boardId, listId))) return;
|
||||
await page.waitForTimeout(100);
|
||||
}
|
||||
throw new Error(`The list ${listId} of ${boardId} did not change`);
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
// Project Management cards: open and edit a card, description drafts with Save, Cancel, and the unsaved marker (UI-037),
|
||||
// a list choice that saves at once, the creation time, labels, priority, and delete with a confirmation, in both themes.
|
||||
// Ports october-cards.spec.ts, description-indicator.spec.ts, card-details.spec.ts, labels.spec.ts, delete-card.spec.ts,
|
||||
// and kanban-editing.spec.ts of RuneStone_Project_Management.
|
||||
import assert from "node:assert/strict";
|
||||
import path from "node:path";
|
||||
import { outputDir, runSmoke } from "../_harness/index.mjs";
|
||||
import { cardPath, column, deletedPath, draftPath, fileText, focusedName, loadWorkspace, openBoard, pane, setTheme, waitForFile } from "../_harness/pmFixture.mjs";
|
||||
|
||||
const draft = async (page, id) => JSON.parse(await fileText(page, draftPath(id)) ?? "null")?.body;
|
||||
|
||||
await runSmoke("features/pmCards", async ({ page }) => {
|
||||
const output = await outputDir("features/pmCards");
|
||||
await loadWorkspace(page);
|
||||
await openBoard(page, "Roadmap");
|
||||
const editor = page.locator("dialog.pm-card-editor[open]");
|
||||
// The source field is hidden outside edit mode, so select it by its label attribute.
|
||||
const description = editor.locator('textarea[aria-label="Details (Markdown)"]');
|
||||
const unsaved = editor.locator(".pm-description-unsaved");
|
||||
const descriptionAction = name => editor.locator(".pm-description-actions").getByRole("button", { name, exact: true });
|
||||
const openCard = async title => {
|
||||
await pane(page).locator(".pm-card-title", { hasText: new RegExp(`^${title}$`) }).click();
|
||||
await editor.waitFor();
|
||||
};
|
||||
const closeCard = async () => {
|
||||
await editor.getByRole("button", { name: "Close card", exact: true }).click();
|
||||
await editor.waitFor({ state: "detached" });
|
||||
};
|
||||
|
||||
// The details show the saved creation time.
|
||||
await openCard("Card A");
|
||||
const created = editor.locator(".pm-created-at");
|
||||
assert.match(await created.innerText(), /^Created: (?!Unknown)/);
|
||||
assert.equal(await created.getAttribute("title"), "2026-10-01T08:30:00.000Z");
|
||||
assert.equal(await editor.getByRole("textbox", { name: "Title", exact: true }).inputValue(), "Card A");
|
||||
|
||||
// UI-037: a description edit stays a draft when the card closes. The saved description does not change.
|
||||
await editor.getByRole("button", { name: "Edit", exact: true }).click();
|
||||
await description.fill("Draft text");
|
||||
await unsaved.waitFor();
|
||||
assert.equal(await unsaved.innerText(), "Unsaved changes");
|
||||
await closeCard();
|
||||
await page.waitForFunction(rel => /"body":"Draft text"/.test(window.__TEST__.files.get(rel) ?? ""), draftPath("card-a"));
|
||||
assert.match(await fileText(page, cardPath("card-a")), /\nBody of Card A\.\n$/, "Close keeps the saved description");
|
||||
const marker = pane(page).locator('.pm-card[data-task-id="card-a"] .pm-card-unsaved');
|
||||
await marker.waitFor();
|
||||
assert.equal(await marker.innerText(), "Unsaved description");
|
||||
|
||||
// The card opens with the saved description and the marker. Edit shows the draft. Cancel restores the saved text.
|
||||
await openCard("Card A");
|
||||
await unsaved.waitFor();
|
||||
assert.equal(await editor.getByRole("region", { name: "Description preview", exact: true }).innerText(), "Body of Card A.");
|
||||
await editor.getByRole("button", { name: "Edit", exact: true }).click();
|
||||
assert.equal(await description.inputValue(), "Draft text");
|
||||
await descriptionAction("Cancel").click();
|
||||
await unsaved.waitFor({ state: "hidden" });
|
||||
assert.equal((await description.inputValue()).trim(), "Body of Card A.");
|
||||
assert.equal(await draft(page, "card-a"), null, "Cancel removes the draft");
|
||||
|
||||
// Save commits the description at once. The creation time does not change.
|
||||
await editor.getByRole("button", { name: "Edit", exact: true }).click();
|
||||
await description.fill("Saved description");
|
||||
await descriptionAction("Save").click();
|
||||
await waitForFile(page, cardPath("card-a"), /\nSaved description\n?$/);
|
||||
await unsaved.waitFor({ state: "hidden" });
|
||||
assert.match(await fileText(page, cardPath("card-a")), /createdAt: "?2026-10-01T08:30:00.000Z"?/);
|
||||
assert.equal(await draft(page, "card-a"), null);
|
||||
await closeCard();
|
||||
await marker.waitFor({ state: "hidden" });
|
||||
|
||||
// UI-037: a list choice in the details saves at once, before Save card.
|
||||
await openCard("Shared card");
|
||||
await editor.getByRole("button", { name: "List", exact: true }).click();
|
||||
await page.getByRole("menu", { name: "List", exact: true }).getByRole("menuitemradio", { name: "Done", exact: true }).click();
|
||||
await waitForFile(page, cardPath("card-d"), /listId: done/);
|
||||
assert.match(await fileText(page, cardPath("card-d")), /status: done/, "The list status applies at once");
|
||||
await closeCard();
|
||||
await column(page, "Done").locator(".pm-card-title", { hasText: "Shared card" }).waitFor();
|
||||
|
||||
// Title, labels, and priority save with Save card.
|
||||
await openCard("Card B");
|
||||
await editor.getByRole("textbox", { name: "Title", exact: true }).fill("Card B edited");
|
||||
const details = editor.getByRole("group", { name: "Card details", exact: true });
|
||||
await details.getByRole("button", { name: "Labels", exact: true }).click();
|
||||
const labels = page.getByRole("dialog", { name: "Choose labels", exact: true });
|
||||
await labels.getByRole("button", { name: "Add label Bug", exact: true }).click();
|
||||
await editor.getByRole("button", { name: "Remove label Bug", exact: true }).waitFor({ state: "attached" });
|
||||
await page.keyboard.press("Escape");
|
||||
await labels.waitFor({ state: "hidden" });
|
||||
assert.equal(await editor.count(), 1, "Escape closes only the label choices");
|
||||
const priority = details.getByRole("button", { name: "Priority", exact: true });
|
||||
await priority.click();
|
||||
await page.getByRole("menu", { name: "Choose priority", exact: true }).getByRole("menuitemradio", { name: "High priority", exact: true }).click();
|
||||
await details.getByRole("button", { name: "High priority", exact: true }).waitFor();
|
||||
for (const theme of ["dark", "light"]) {
|
||||
await setTheme(page, theme);
|
||||
await page.screenshot({ path: path.join(output, `card-details-${theme}.png`) });
|
||||
}
|
||||
await editor.getByRole("button", { name: "Save card", exact: true }).click();
|
||||
await editor.waitFor({ state: "detached" });
|
||||
await waitForFile(page, cardPath("card-b"), /title: Card B edited/);
|
||||
const saved = await fileText(page, cardPath("card-b"));
|
||||
assert.match(saved, /priority: high/);
|
||||
assert.match(saved, /labels:\n\s+- bug/);
|
||||
const edited = pane(page).locator('.pm-card[data-task-id="card-b"]');
|
||||
assert.equal(await edited.locator(".pm-priority").innerText(), "High priority");
|
||||
assert.equal(await edited.locator(".pm-label-badge").innerText(), "Bug");
|
||||
assert.match(await fileText(page, cardPath("card-c")), /title: Card C/, "Other cards stay unchanged");
|
||||
|
||||
// Delete asks for a confirmation. Cancel keeps the card and returns focus to the card menu.
|
||||
const actions = pane(page).getByRole("button", { name: "Actions for Card A", exact: true });
|
||||
const confirm = page.getByRole("dialog", { name: "Delete card", exact: true });
|
||||
await actions.click();
|
||||
await page.getByRole("menu", { name: "Card actions", exact: true }).getByRole("menuitem", { name: "Delete card", exact: true }).click();
|
||||
await confirm.getByRole("heading", { name: "Delete “Card A”?", exact: true }).waitFor();
|
||||
assert.equal(await focusedName(page), "Cancel", "The safe choice has focus");
|
||||
for (const theme of ["dark", "light"]) {
|
||||
await setTheme(page, theme);
|
||||
await page.screenshot({ path: path.join(output, `delete-card-${theme}.png`) });
|
||||
}
|
||||
await confirm.getByRole("button", { name: "Cancel", exact: true }).click();
|
||||
await confirm.waitFor({ state: "detached" });
|
||||
assert.equal(await focusedName(page), "Actions for Card A");
|
||||
assert.equal(await fileText(page, deletedPath), undefined, "Cancel deletes nothing");
|
||||
|
||||
await actions.click();
|
||||
await page.getByRole("menu", { name: "Card actions", exact: true }).getByRole("menuitem", { name: "Delete card", exact: true }).click();
|
||||
await confirm.getByRole("button", { name: "Delete card", exact: true }).click();
|
||||
await confirm.waitFor({ state: "detached" });
|
||||
await waitForFile(page, deletedPath, /"card-a"/);
|
||||
await pane(page).locator('.pm-card[data-task-id="card-a"]').waitFor({ state: "detached" });
|
||||
assert.equal(await focusedName(page), "More actions", "Focus moves to the board menu after the card is gone");
|
||||
assert.equal(await column(page, "To do").locator(".pm-card").count(), 1);
|
||||
console.log("PASS: card details, description drafts, labels, priority, and delete");
|
||||
}, { timeout: 15000 });
|
||||
@@ -0,0 +1,70 @@
|
||||
// Project Management drag and drop: a card to another list, a card to a new place in its list, and a list to a new
|
||||
// place on the board. Each drop saves the files. All tasks has no drag and drop (UI-033).
|
||||
// Ports card-placement.spec.ts, card-transfer.spec.ts (drag part), lists.spec.ts, and kanban-cards.spec.ts
|
||||
// of RuneStone_Project_Management.
|
||||
import assert from "node:assert/strict";
|
||||
import path from "node:path";
|
||||
import { outputDir, runSmoke } from "../_harness/index.mjs";
|
||||
import { cardPath, column, fileText, loadWorkspace, openBoard, pane, roadmap, savedBoards, setTheme, waitForFile } from "../_harness/pmFixture.mjs";
|
||||
|
||||
const titles = locator => locator.locator(".pm-card-title").allInnerTexts();
|
||||
const columnIds = page => pane(page).locator("section.pm-column").evaluateAll(nodes => nodes.map(node => node.dataset.listId));
|
||||
|
||||
await runSmoke("features/pmDrag", async ({ page }) => {
|
||||
const output = await outputDir("features/pmDrag");
|
||||
await loadWorkspace(page);
|
||||
await openBoard(page, "Roadmap");
|
||||
|
||||
/** Drag `source` to a point of `target` with the mouse, and take a screenshot before the drop. */
|
||||
async function drag(source, target, { x = 0.5, y = 0.5, shot }) {
|
||||
const from = await source.boundingBox(), to = await target.boundingBox();
|
||||
await page.mouse.move(from.x + from.width / 2, from.y + Math.min(12, from.height / 2));
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(from.x + from.width / 2 + 20, from.y + 20, { steps: 4 });
|
||||
await page.mouse.move(to.x + to.width * x, to.y + to.height * y, { steps: 8 });
|
||||
if (shot) {
|
||||
await pane(page).locator(".pm-drag-preview").waitFor();
|
||||
await page.screenshot({ path: path.join(output, shot) });
|
||||
}
|
||||
await page.mouse.up();
|
||||
}
|
||||
|
||||
// A card goes to another list. The list status applies, and only that card file changes.
|
||||
await setTheme(page, "dark");
|
||||
const cardC = await fileText(page, cardPath("card-c"));
|
||||
await drag(pane(page).locator('.pm-card[data-task-id="card-a"]'), column(page, "In progress"), { y: 0.3, shot: "card-drag-dark.png" });
|
||||
await waitForFile(page, cardPath("card-a"), /listId: doing/);
|
||||
assert.match(await fileText(page, cardPath("card-a")), /status: doing/);
|
||||
assert.deepEqual(await titles(column(page, "In progress")), ["Card A"]);
|
||||
assert.deepEqual(await titles(column(page, "To do")), ["Card B", "Shared card"]);
|
||||
assert.equal(await fileText(page, cardPath("card-c")), cardC, "Other cards stay unchanged");
|
||||
assert.equal(await pane(page).locator(".pm-drag-preview, .pm-drop-target").count(), 0, "The drop removes the drag preview");
|
||||
|
||||
// A card goes above another card of the same list.
|
||||
await drag(pane(page).locator('.pm-card[data-task-id="card-d"]'), pane(page).locator('.pm-card[data-task-id="card-b"]'), { y: 0.2 });
|
||||
await page.waitForFunction(() => [...document.querySelectorAll('.plugin-editor-pane .pm-column[aria-label="To do"] .pm-card-title')].map(node => node.textContent).join() === "Shared card,Card B");
|
||||
const order = async id => /\n {6}order: "([^"]+)"/.exec(await fileText(page, cardPath(id)))[1];
|
||||
assert(await order("card-d") < await order("card-b"), "The saved order puts Shared card first");
|
||||
|
||||
// A list goes to a new place: the grip of Done goes to the left half of To do.
|
||||
await setTheme(page, "light");
|
||||
const grip = column(page, "Done").getByRole("button", { name: "Move list Done", exact: true });
|
||||
await drag(grip, column(page, "To do"), { x: 0.2, y: 0.2, shot: "list-drag-light.png" });
|
||||
await page.waitForFunction(() => [...document.querySelectorAll(".plugin-editor-pane .pm-column")].map(node => node.dataset.listId).join() === "done,todo,doing,review");
|
||||
assert.deepEqual((await savedBoards(page)).find(item => item.value.id === roadmap).value.lists.map(list => list.id), ["done", "todo", "doing", "review"]);
|
||||
assert.deepEqual(await columnIds(page), ["done", "todo", "doing", "review"]);
|
||||
await page.screenshot({ path: path.join(output, "after-drops-light.png") });
|
||||
|
||||
// UI-033: All tasks has no drag and drop. Its cards and lists cannot move.
|
||||
await pane(page).locator(".pm-scope").click();
|
||||
await page.getByRole("menuitemradio", { name: "All tasks", exact: true }).click();
|
||||
await pane(page).locator(".pm-scope-label", { hasText: /^All tasks$/ }).waitFor();
|
||||
await pane(page).locator(".pm-card").first().waitFor();
|
||||
assert.deepEqual([...new Set(await pane(page).locator(".pm-card").evaluateAll(nodes => nodes.map(node => node.draggable)))], [false]);
|
||||
assert.equal(await pane(page).locator(".pm-list-grip").count(), 0);
|
||||
const before = await fileText(page, cardPath("card-b"));
|
||||
await drag(pane(page).locator('.pm-card[data-task-id="card-b"]'), column(page, "Done"), {});
|
||||
await page.waitForTimeout(300);
|
||||
assert.equal(await fileText(page, cardPath("card-b")), before, "A drag in All tasks changes nothing");
|
||||
console.log("PASS: card and list drag and drop, and no drag in All tasks");
|
||||
}, { timeout: 15000 });
|
||||
@@ -0,0 +1,88 @@
|
||||
// Project Management in French: a language change in the settings shows an open board again in the new language and
|
||||
// closes its open menu. The controls, menus, card details, and All tasks show French text from the catalog
|
||||
// (src/lib/i18n/messages.ts). Board names, list names, and card titles stay as the user typed them.
|
||||
// A change back to English shows English again. New in RuneStone: the plugin had no translations.
|
||||
import assert from "node:assert/strict";
|
||||
import path from "node:path";
|
||||
import { outputDir, runSmoke } from "../_harness/index.mjs";
|
||||
import { column, loadWorkspace, openBoard, pane, setTheme } from "../_harness/pmFixture.mjs";
|
||||
|
||||
await runSmoke("features/pmLanguage", async ({ page }) => {
|
||||
const output = await outputDir("features/pmLanguage");
|
||||
await loadWorkspace(page);
|
||||
await openBoard(page, "Roadmap");
|
||||
const catalog = await page.evaluate(async () => (await import("/src/lib/i18n/messages.ts")).catalogs.fr);
|
||||
/** The French text of a catalog key, with its values. */
|
||||
const fr = (key, values = {}) => {
|
||||
assert(Object.hasOwn(catalog, key), `The catalog has "${key}"`);
|
||||
return catalog[key].replace(/\{(\w+)\}/g, (_, name) => values[name]);
|
||||
};
|
||||
const button = name => pane(page).getByRole("button", { name, exact: true });
|
||||
const setLanguage = async language => {
|
||||
await page.evaluate(value => window.__TEST__.writeSettings("language", value), language);
|
||||
await page.waitForFunction(value => document.documentElement.lang === value, language);
|
||||
};
|
||||
|
||||
// An open menu closes when the language changes. The board shows again in French.
|
||||
await button("List actions for To do").click();
|
||||
await page.getByRole("menu", { name: "List actions", exact: true }).waitFor();
|
||||
await setLanguage("fr");
|
||||
await page.locator(".rs-menu").waitFor({ state: "detached" });
|
||||
await button(fr("More actions")).waitFor();
|
||||
assert.equal(fr("More actions"), "Plus d’actions");
|
||||
assert.equal(fr("Calendar"), "Calendrier");
|
||||
const views = pane(page).getByRole("navigation", { name: fr("Project Management views"), exact: true });
|
||||
assert.deepEqual(await views.getByRole("button").evaluateAll(nodes => nodes.map(node => node.getAttribute("aria-label"))), [fr("Kanban"), fr("Gantt"), fr("Calendar")]);
|
||||
for (const name of [fr("Search tasks"), fr("Manage labels"), fr("Add a list"), fr("Board scope: {name}", { name: "Roadmap" }),
|
||||
fr("List actions for {name}", { name: "To do" }), fr("Collapse {name}", { name: "To do" }), fr("Actions for {name}", { name: "Card A" })]) {
|
||||
assert.equal(await button(name).count() > 0, true, `The board has the control "${name}"`);
|
||||
}
|
||||
assert.equal(await column(page, "To do").getByRole("button", { name: fr("Add a card"), exact: true }).count(), 1);
|
||||
assert.equal(await button("More actions").count(), 0, "No English control name stays");
|
||||
|
||||
// The text that the user typed stays unchanged.
|
||||
assert.equal(await pane(page).locator(".pm-scope-label").innerText(), "Roadmap");
|
||||
await page.getByRole("tab", { name: "Roadmap", exact: true }).waitFor();
|
||||
assert.deepEqual(await column(page, "To do").locator(".pm-card-title").allInnerTexts(), ["Card A", "Card B", "Shared card"]);
|
||||
assert.deepEqual(await pane(page).locator(".pm-column-heading h2").allInnerTexts(), ["To do", "In progress", "Done", "Review"]);
|
||||
|
||||
// The shared menus show French items.
|
||||
await button(fr("List actions for {name}", { name: "To do" })).focus();
|
||||
await page.keyboard.press("Enter");
|
||||
const listMenu = page.getByRole("menu", { name: fr("List actions"), exact: true });
|
||||
await listMenu.waitFor();
|
||||
assert.deepEqual((await listMenu.getByRole("menuitem").allInnerTexts()).slice(0, 2), [fr("Edit list"), fr("Set list limit")]);
|
||||
for (const theme of ["dark", "light"]) {
|
||||
await setTheme(page, theme);
|
||||
await page.screenshot({ path: path.join(output, `board-menu-fr-${theme}.png`) });
|
||||
}
|
||||
await page.keyboard.press("Escape");
|
||||
await listMenu.waitFor({ state: "detached" });
|
||||
|
||||
// The card details are in French. The card title stays.
|
||||
await pane(page).locator(".pm-card-title", { hasText: /^Card A$/ }).click();
|
||||
const editor = page.locator("dialog.pm-card-editor[open]");
|
||||
await editor.waitFor();
|
||||
assert.equal(await editor.getByRole("textbox", { name: fr("Title"), exact: true }).inputValue(), "Card A");
|
||||
assert.ok((await editor.locator(".pm-created-at").innerText()).startsWith(fr("Created: {date}", { date: "" })));
|
||||
await editor.getByRole("button", { name: fr("Save card"), exact: true }).waitFor();
|
||||
await page.screenshot({ path: path.join(output, "card-fr-light.png") });
|
||||
await editor.getByRole("button", { name: fr("Close card"), exact: true }).click();
|
||||
await editor.waitFor({ state: "detached" });
|
||||
|
||||
// All tasks: the catalog name of a group without a board translates. Board names stay.
|
||||
await pane(page).locator(".pm-scope").click();
|
||||
await page.getByRole("menu", { name: fr("Board scope"), exact: true }).getByRole("menuitemradio", { name: fr("All tasks"), exact: true }).click();
|
||||
await pane(page).locator(".pm-scope-label", { hasText: fr("All tasks") }).waitFor();
|
||||
await page.getByRole("tab", { name: "Project Management", exact: true }).waitFor();
|
||||
assert.deepEqual(await column(page, "To do").locator(".pm-board-group-heading").allInnerTexts(), ["Bugs · Roadmap", "Roadmap", fr("No active board")]);
|
||||
await page.screenshot({ path: path.join(output, "all-tasks-fr-light.png") });
|
||||
|
||||
// A change back to English shows the open view in English at once.
|
||||
await setLanguage("en");
|
||||
await button("More actions").waitFor();
|
||||
assert.equal(await pane(page).locator(".pm-scope-label").innerText(), "All tasks");
|
||||
assert.deepEqual(await column(page, "To do").locator(".pm-board-group-heading").allInnerTexts(), ["Bugs · Roadmap", "Roadmap", "No active board"]);
|
||||
assert.equal(await button(fr("More actions")).count(), 0);
|
||||
console.log("PASS: French controls, menus, and card details, with the typed names unchanged");
|
||||
}, { timeout: 15000 });
|
||||
@@ -0,0 +1,127 @@
|
||||
// Project Management menus: the list actions, the card actions with the Move to list submenu, the board scope, and
|
||||
// More actions. All use the shared host menu. Each opens with the keyboard, in the dark and the light theme, at a wide
|
||||
// and a narrow width. The arrow keys move the focus, Enter runs an item, and Escape closes the menu and returns focus.
|
||||
// Ports menu-audit.spec.ts, shared-menu.spec.ts, board-menu-api.spec.ts, and relations-menu.spec.ts (keyboard part)
|
||||
// of RuneStone_Project_Management.
|
||||
import assert from "node:assert/strict";
|
||||
import path from "node:path";
|
||||
import { outputDir, runSmoke, settle } from "../_harness/index.mjs";
|
||||
import { cardPath, column, focusedName, loadWorkspace, openBoard, pane, roadmap, savedBoards, setTheme, waitForFile } from "../_harness/pmFixture.mjs";
|
||||
|
||||
await runSmoke("features/pmMenus", async ({ page }) => {
|
||||
const output = await outputDir("features/pmMenus");
|
||||
await loadWorkspace(page);
|
||||
await openBoard(page, "Roadmap");
|
||||
const listTrigger = column(page, "To do").getByRole("button", { name: "List actions for To do", exact: true });
|
||||
const cardTrigger = pane(page).getByRole("button", { name: "Actions for Card A", exact: true });
|
||||
const scope = pane(page).getByRole("button", { name: "Board scope: Roadmap", exact: true });
|
||||
const moreTrigger = pane(page).getByRole("button", { name: "More actions", exact: true });
|
||||
const menu = name => page.getByRole("menu", { name, exact: true });
|
||||
const items = async name => menu(name).locator(":scope > button").evaluateAll(rows => rows.map(row => `${row.textContent.trim()}${row.disabled ? " (disabled)" : ""}`));
|
||||
|
||||
/** Open a menu with `key` on its focused trigger, and return the menu after its checks. */
|
||||
async function open(trigger, key, name) {
|
||||
await trigger.focus();
|
||||
await page.keyboard.press(key);
|
||||
const panel = menu(name);
|
||||
await panel.waitFor();
|
||||
assert.equal(await panel.evaluate(node => node.classList.contains("rs-menu")), true, `${name} uses the shared menu`);
|
||||
const box = await panel.boundingBox(), viewport = page.viewportSize();
|
||||
assert(box.x >= 0 && box.y >= 0 && box.x + box.width <= viewport.width + 1 && box.y + box.height <= viewport.height + 1, `${name} stays inside the window`);
|
||||
return panel;
|
||||
}
|
||||
/** Press Escape, and make sure that the menu closes and the trigger has focus again. */
|
||||
async function dismiss(name, trigger) {
|
||||
await page.keyboard.press("Escape");
|
||||
await menu(name).waitFor({ state: "detached" });
|
||||
assert.equal(await focusedName(page), trigger, `Escape returns focus to ${trigger}`);
|
||||
}
|
||||
|
||||
for (const theme of ["dark", "light"]) {
|
||||
await setTheme(page, theme);
|
||||
for (const width of [1440, 760]) {
|
||||
await page.setViewportSize({ width, height: width === 1440 ? 1000 : 700 });
|
||||
// A window resize closes an open menu. Let the resize event pass first.
|
||||
await settle(page);
|
||||
const shot = name => page.screenshot({ path: path.join(output, `${name}-${theme}-${width}.png`) });
|
||||
|
||||
// List actions: Enter opens the menu on the first item. The arrow keys skip a disabled item.
|
||||
await column(page, "To do").scrollIntoViewIfNeeded();
|
||||
await open(listTrigger, "Enter", "List actions");
|
||||
assert.deepEqual(await items("List actions"), ["Edit list", "Set list limit", "Move left (disabled)", "Move right", "Archive all cards", "Delete list"]);
|
||||
assert.equal(await focusedName(page), "Edit list");
|
||||
await page.keyboard.press("ArrowDown");
|
||||
assert.equal(await focusedName(page), "Set list limit");
|
||||
await page.keyboard.press("ArrowDown");
|
||||
assert.equal(await focusedName(page), "Move right", "ArrowDown skips the disabled item");
|
||||
await shot("list-actions");
|
||||
await dismiss("List actions", "List actions for To do");
|
||||
|
||||
// Card actions: ArrowDown on the card menu button opens the menu. ArrowRight opens the list submenu.
|
||||
await open(cardTrigger, "ArrowDown", "Card actions");
|
||||
assert.deepEqual(await items("Card actions"), ["Edit card", "Move to list", "Move to board", "Move up (disabled)", "Move down", "Remove from board", "Archive", "Delete card"]);
|
||||
assert.equal(await focusedName(page), "Edit card");
|
||||
await page.keyboard.press("ArrowDown");
|
||||
assert.equal(await focusedName(page), "Move to list");
|
||||
await page.keyboard.press("ArrowRight");
|
||||
const submenu = menu("Move to list");
|
||||
await submenu.waitFor();
|
||||
assert.equal(await submenu.getByRole("menuitemradio", { name: "To do", exact: true }).getAttribute("aria-checked"), "true");
|
||||
assert.equal(await focusedName(page), "Unlisted");
|
||||
await shot("card-actions");
|
||||
await page.keyboard.press("ArrowLeft");
|
||||
assert.equal(await focusedName(page), "Move to list", "ArrowLeft returns to the parent item");
|
||||
await dismiss("Card actions", "Actions for Card A");
|
||||
|
||||
// Board scope: the boards are in name order, and the focus starts on the checked board.
|
||||
await open(scope, "ArrowDown", "Board scope");
|
||||
assert.deepEqual(await menu("Board scope").getByRole("menuitemradio").allInnerTexts(), ["All tasks", "Bugs", "Roadmap"]);
|
||||
assert.equal(await focusedName(page), "Roadmap");
|
||||
await page.keyboard.press("ArrowUp");
|
||||
assert.equal(await focusedName(page), "Bugs");
|
||||
await shot("board-scope");
|
||||
await dismiss("Board scope", "Board scope: Roadmap");
|
||||
|
||||
// More actions: the board commands.
|
||||
await open(moreTrigger, "Enter", "More actions");
|
||||
assert.deepEqual(await items("More actions"), ["New board", "Archive board", "Delete board", "Rename board", "New card", "Add existing note", "Show archived", "Refresh", "Customize background", "Project Management settings"]);
|
||||
assert.equal(await focusedName(page), "New board");
|
||||
await page.keyboard.press("End");
|
||||
assert.equal(await focusedName(page), "Project Management settings");
|
||||
await shot("more-actions");
|
||||
await dismiss("More actions", "More actions");
|
||||
}
|
||||
}
|
||||
await page.setViewportSize({ width: 1440, height: 1000 });
|
||||
await settle(page);
|
||||
|
||||
// Enter runs the focused item. Move right changes the list order.
|
||||
await open(listTrigger, "Enter", "List actions");
|
||||
await page.keyboard.press("ArrowDown");
|
||||
await page.keyboard.press("ArrowDown");
|
||||
await page.keyboard.press("Enter");
|
||||
await menu("List actions").waitFor({ state: "detached" });
|
||||
await page.waitForFunction(() => [...document.querySelectorAll(".plugin-editor-pane .pm-column")].map(node => node.dataset.listId).join() === "doing,todo,done,review");
|
||||
assert.deepEqual((await savedBoards(page)).find(item => item.value.id === roadmap).value.lists.map(list => list.id), ["doing", "todo", "done", "review"]);
|
||||
|
||||
// Enter on a submenu item moves the card to that list.
|
||||
await open(cardTrigger, "ArrowDown", "Card actions");
|
||||
await page.keyboard.press("ArrowDown");
|
||||
await page.keyboard.press("ArrowRight");
|
||||
await menu("Move to list").waitFor();
|
||||
// The submenu follows the new list order: Unlisted, In progress, To do, Done, Review.
|
||||
await page.keyboard.press("ArrowDown");
|
||||
assert.equal(await focusedName(page), "In progress");
|
||||
await page.keyboard.press("Enter");
|
||||
await waitForFile(page, cardPath("card-a"), /listId: doing/);
|
||||
await column(page, "In progress").locator(".pm-card-title", { hasText: "Card A" }).waitFor();
|
||||
|
||||
// Enter on a board opens it in the same tab.
|
||||
await open(scope, "ArrowDown", "Board scope");
|
||||
await page.keyboard.press("ArrowUp");
|
||||
await page.keyboard.press("Enter");
|
||||
await page.getByRole("tab", { name: "Bugs", exact: true, selected: true }).waitFor();
|
||||
await pane(page).getByRole("button", { name: "Board scope: Bugs", exact: true }).waitFor();
|
||||
assert.equal(await page.getByRole("tab", { name: "Roadmap", exact: true }).count(), 0);
|
||||
console.log("PASS: list, card, board scope, and board menus with the keyboard in both themes");
|
||||
}, { timeout: 15000 });
|
||||
@@ -0,0 +1,92 @@
|
||||
// Project Management views: All tasks with merged list columns and board dividers (UI-034, UI-035), then Gantt,
|
||||
// Calendar (month, week, and day), and Kanban, in both themes. Each view keeps its own view state.
|
||||
// Ports all-tasks.spec.ts, board-scope-alignment.spec.ts, board-view-state.spec.ts, and the Gantt and Calendar parts of
|
||||
// workflow.spec.ts of RuneStone_Project_Management.
|
||||
import assert from "node:assert/strict";
|
||||
import path from "node:path";
|
||||
import { outputDir, runSmoke } from "../_harness/index.mjs";
|
||||
import { card, column, loadWorkspace, openBoard, pane, pmFiles, roadmap, setTheme } from "../_harness/pmFixture.mjs";
|
||||
|
||||
await runSmoke("features/pmViews", async ({ page }) => {
|
||||
const output = await outputDir("features/pmViews");
|
||||
// One more card on the Review list of Roadmap, so that the merged review column has two boards.
|
||||
await loadWorkspace(page, Object.fromEntries([...Object.entries(pmFiles()), card("card-f", "Review card", { placements: { [roadmap]: "review" }, order: "f" })]));
|
||||
await openBoard(page);
|
||||
const view = name => pane(page).getByRole("navigation", { name: "Project Management views", exact: true }).getByRole("button", { name, exact: true });
|
||||
const shots = async name => {
|
||||
for (const theme of ["dark", "light"]) {
|
||||
await setTheme(page, theme);
|
||||
await page.screenshot({ path: path.join(output, `${name}-${theme}.png`) });
|
||||
}
|
||||
};
|
||||
|
||||
// UI-034: equal list names share one column. Case and outer spaces do not matter ("Review" and "review").
|
||||
await pane(page).locator(".pm-card").first().waitFor();
|
||||
assert.equal(await view("Kanban").getAttribute("aria-pressed"), "true");
|
||||
const labels = await pane(page).locator("section.pm-column").evaluateAll(nodes => nodes.map(node => node.getAttribute("aria-label")));
|
||||
assert.deepEqual(labels.map(label => label.toLowerCase()), ["to do", "in progress", "done", "review"]);
|
||||
|
||||
// UI-035: each column groups its cards under board names. A shared card shows once, under the names of its boards.
|
||||
const todo = column(page, "To do");
|
||||
const headings = locator => locator.locator(".pm-board-group-heading").allInnerTexts();
|
||||
assert.deepEqual(await headings(todo), ["Bugs · Roadmap", "Roadmap", "No active board"]);
|
||||
assert.equal(await todo.locator(".pm-card-title", { hasText: /^Shared card$/ }).count(), 1, "A shared card shows once");
|
||||
assert.deepEqual(await todo.getByRole("region", { name: "Roadmap", exact: true }).locator(".pm-card-title").allInnerTexts(), ["Card A", "Card B"]);
|
||||
assert.deepEqual(await todo.getByRole("region", { name: "No active board", exact: true }).locator(".pm-card-title").allInnerTexts(), ["Loose card"]);
|
||||
const review = pane(page).locator('section.pm-column[data-list-id="list:review"]');
|
||||
assert.deepEqual(await headings(review), ["Bugs", "Roadmap"]);
|
||||
// A merged column has no board limit. The board keeps its limit (checked below).
|
||||
assert.equal(await review.locator(".pm-list-limit").count(), 0);
|
||||
assert.equal(await review.locator(".pm-count").innerText(), "2");
|
||||
assert.equal(await pane(page).locator(".pm-board-group-heading").evaluateAll(nodes => nodes.every(node => getComputedStyle(node).opacity === "1")), true, "Board names are opaque");
|
||||
await shots("all-tasks");
|
||||
|
||||
// Gantt: a row for each card, a bar for the planned dates, and a deadline marker.
|
||||
await view("Gantt").click();
|
||||
assert.equal(await view("Gantt").getAttribute("aria-pressed"), "true");
|
||||
const timeline = pane(page).getByRole("table", { name: "Task timeline", exact: true });
|
||||
await timeline.waitFor();
|
||||
assert.equal(await timeline.locator(".pm-gantt-row").count(), 7, "A heading row and six cards");
|
||||
const bar = timeline.locator(".pm-gantt-bar", { hasText: "Card B" });
|
||||
assert.match(await bar.getAttribute("title"), /^Card B: .+ to .+$/);
|
||||
assert.equal(await timeline.locator(".pm-deadline").count(), 1);
|
||||
assert.match(await timeline.locator(".pm-deadline").getAttribute("aria-label"), /^Card B, deadline /);
|
||||
assert.equal(await timeline.getByRole("button", { name: /^Card A/ }).locator("small").innerText(), "Unscheduled");
|
||||
await pane(page).getByRole("button", { name: "Next", exact: true }).click();
|
||||
await pane(page).getByRole("button", { name: "Today", exact: true }).click();
|
||||
await timeline.locator(".pm-gantt-bar").waitFor();
|
||||
await shots("gantt");
|
||||
|
||||
// Calendar: the month shows the deadline. Week and Day show the hours.
|
||||
await view("Calendar").click();
|
||||
const period = name => pane(page).locator(".pm-date-nav").getByRole("button", { name, exact: true });
|
||||
assert.equal(await period("Month").getAttribute("aria-pressed"), "true");
|
||||
await pane(page).locator(".pm-month").waitFor();
|
||||
assert.equal(await pane(page).locator(".pm-day-heading").count(), 7);
|
||||
assert.equal(await pane(page).locator(".pm-month-day").count(), 42);
|
||||
await pane(page).getByRole("button", { name: "◆ Due: Card B", exact: true }).waitFor();
|
||||
await shots("calendar-month");
|
||||
await period("Week").click();
|
||||
assert.equal(await pane(page).locator(".pm-hour-day").count(), 7);
|
||||
assert.equal(await period("Week").getAttribute("aria-pressed"), "true");
|
||||
await shots("calendar-week");
|
||||
await period("Day").click();
|
||||
assert.equal(await pane(page).locator(".pm-hour-day").count(), 1);
|
||||
assert.equal(await pane(page).locator(".pm-hour-day .pm-hour-slot").count(), 24);
|
||||
await page.waitForFunction(() => {
|
||||
const state = JSON.parse(localStorage.getItem("runestone.pm.viewStates") ?? "{}").planning;
|
||||
return state?.view === "calendar" && state?.period === "day";
|
||||
});
|
||||
|
||||
// Kanban again. A board in the same tab has its own view state and shows its limit.
|
||||
await view("Kanban").click();
|
||||
await pane(page).locator(".pm-board").waitFor();
|
||||
await openBoard(page, "Roadmap");
|
||||
assert.equal(await view("Kanban").getAttribute("aria-pressed"), "true", "A board starts in Kanban");
|
||||
assert.equal(await column(page, "Review").locator(".pm-count").innerText(), "1/2");
|
||||
assert.equal(await column(page, "Review").locator(".pm-list-limit").count(), 1);
|
||||
await view("Calendar").click();
|
||||
await pane(page).locator(".pm-month").waitFor();
|
||||
await shots("board-calendar");
|
||||
console.log("PASS: All tasks columns and dividers, Gantt, Calendar, and Kanban");
|
||||
}, { timeout: 15000 });
|
||||
@@ -116,8 +116,8 @@ await runSmoke('tree/renameUndo', async ({ browser }) => {
|
||||
await page.keyboard.press('Escape');
|
||||
await page.evaluate(async () => {
|
||||
const external = await import(performance.getEntriesByType('resource').find(entry => new URL(entry.name).pathname === '/src/lib/plugins/external.ts').name);
|
||||
external.pluginNavigation.set([{ owner: 'pm-test', id: 'pm', title: 'Project Management', icon: 'kanban', placement: 'editor', toolbar: true }, { owner: 'git-test', id: 'source', title: 'Source control', icon: 'git', placement: 'sidebar', toolbar: true }]);
|
||||
external.pluginTools.set([{ owner: 'pm-test', id: 'pm', title: 'Project Management', kind: 'view', surface: 'open' }, { owner: 'git-test', id: 'graph', title: 'Graph view', kind: 'command', surface: 'open', icon: 'git' }]);
|
||||
external.pluginNavigation.set([{ owner: 'pm-test', id: 'pm', title: 'Board fixture', icon: 'kanban', placement: 'editor', toolbar: true }, { owner: 'git-test', id: 'source', title: 'Source control', icon: 'git', placement: 'sidebar', toolbar: true }]);
|
||||
external.pluginTools.set([{ owner: 'pm-test', id: 'pm', title: 'Board fixture', kind: 'view', surface: 'open' }, { owner: 'git-test', id: 'graph', title: 'Graph view', kind: 'command', surface: 'open', icon: 'git' }]);
|
||||
external.pluginTools.update(items => [...items, { owner: 'runestone.browser', id: 'new-tab', title: 'New browser tab', kind: 'command', surface: 'open' }]);
|
||||
const registry = await import(performance.getEntriesByType('resource').find(entry => new URL(entry.name).pathname === '/src/lib/plugins/registry.ts').name);
|
||||
registry.pluginHost.get('browser').newTab = async () => { window.__TEST__.browserOpened = true; };
|
||||
@@ -125,11 +125,11 @@ await runSmoke('tree/renameUndo', async ({ browser }) => {
|
||||
// The app tools are in the left ribbon. Plugin view shortcuts stay out of it in this test (src/lib/layout/PluginRibbon.svelte).
|
||||
await page.locator('.plugin-ribbon').getByRole('button', { name: 'New browser tab', exact: true }).click();
|
||||
assert.equal(await page.evaluate(() => window.__TEST__.browserOpened), true);
|
||||
assert.equal(await page.locator('.plugin-ribbon .ribbon-tools').getByRole('button', { name: 'Project Management', exact: true }).count(), 0);
|
||||
assert.equal(await page.locator('.plugin-ribbon .ribbon-tools').getByRole('button', { name: 'Board fixture', exact: true }).count(), 0);
|
||||
assert.equal(await page.locator('.header-left').getByRole('button', { name: 'Source control', exact: true }).count(), 1);
|
||||
assert.equal(await page.locator('.plugin-ribbon .ribbon-tools').getByRole('button', { name: 'Source control', exact: true }).count(), 0);
|
||||
await page.getByRole('button', { name: 'Plug-in views', exact: true }).click();
|
||||
assert.equal(await page.getByRole('menuitem', { name: /Project Management/ }).count(), 1);
|
||||
assert.equal(await page.getByRole('menuitem', { name: /Board fixture/ }).count(), 1);
|
||||
assert.equal(await page.getByRole('menuitem', { name: /New browser tab/ }).count(), 0);
|
||||
await page.getByRole('menuitem', { name: /Graph view/ }).waitFor(); await page.keyboard.press('Escape');
|
||||
for (const mode of ['light', 'dark']) {
|
||||
|
||||
Reference in New Issue
Block a user