RuneStone 1.0.0
This commit is contained in:
@@ -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 });
|
||||
Reference in New Issue
Block a user