- 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.
128 lines
7.7 KiB
JavaScript
128 lines
7.7 KiB
JavaScript
// 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 });
|