- Move the storage and model of the plugin into src/lib/features/pm/ as pure TypeScript, so the skill can still bundle them. - Move the DOM interface onto the host menus, the shared tooltip, and the host icons. - A ribbon button opens Project Management. Board tabs keep the owner runestone.pm and the board-<hex> view IDs through view patterns. - Read only .runestone/pm/. Offer the plugin migration, with backups, for legacy notes. - A save, move, or delete reads only that card again. Watcher paths reach the feature. - Add Settings → Project Management and the projectManagement section. View states move to localStorage. - Background reads the boards from workspace.json. Remove api.backgrounds and the boards service. - Add yaml 2.9.1. Use the host markdown-it. - Move 18 plugin test files to tests/unit/features/pm/ and add native tests.
67 lines
4.1 KiB
TypeScript
67 lines
4.1 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { allTaskColumns, allTaskGroups } from "../../../../src/lib/features/pm/model/all-tasks.ts";
|
|
import { defaultBoard, type BoardDocument } from "../../../../src/lib/features/pm/storage/board.ts";
|
|
import { newTask, readTask } from "../../../../src/lib/features/pm/storage/notes.ts";
|
|
import type { TaskFields } from "../../../../src/lib/features/pm/model/model.ts";
|
|
const board = (id: string): BoardDocument => ({ id, path: `${id}.md`, name: id, source: "", value: defaultBoard(id) });
|
|
const task = (title: string, placements: TaskFields["placements"]) => {
|
|
const note = newTask(title, { status: "todo", archived: false, tags: [], sessions: [], placements });
|
|
return readTask(`${title}.md`, note.source)!;
|
|
};
|
|
|
|
test("All tasks merges list names, preserves custom lists, and includes every matching card once", () => {
|
|
const a = board("A"), b = board("B"), c = board("C");
|
|
a.value.lists.push({ id: "review", name: "Review", status: null, collapsed: true });
|
|
b.value.lists[0].name = " To Do ";
|
|
b.value.lists[0].id = "different-id";
|
|
c.value.lists[0].maxCards = 2;
|
|
const shared = task("Shared", { A: { listId: "todo" }, B: { listId: "different-id" } });
|
|
const other = task("Other", { C: { listId: "todo" } });
|
|
const review = task("Review", { A: { listId: "review" }, C: { listId: "todo" } });
|
|
const unlisted = task("Unlisted", { A: { listId: "removed" }, B: { listId: null } });
|
|
const orphan = task("Orphan", { deleted: { listId: "todo" } });
|
|
const original = JSON.stringify({ boards: [a, b, c], tasks: [shared, other, review, unlisted, orphan] });
|
|
const columns = allTaskColumns([a, b, c], [shared, other, review, unlisted, orphan]);
|
|
assert.equal(columns.length, 5);
|
|
assert.deepEqual(columns.find(c => c.list?.name === "To do")?.tasks, [shared, other, review, orphan]);
|
|
assert.deepEqual(columns.find(c => c.list?.name === "Review")?.tasks, [review]);
|
|
assert.deepEqual(columns.find(c => !c.list)?.tasks, [unlisted]);
|
|
assert.equal(columns.find(c => c.list?.name === "Review")?.list?.collapsed, false);
|
|
assert.equal(columns.find(c => c.list?.name === "To do")?.list?.maxCards, undefined);
|
|
assert.equal(columns.find(c => c.list?.name === "To do")?.allowCreate, false);
|
|
assert.equal(JSON.stringify({ boards: [a, b, c], tasks: [shared, other, review, unlisted, orphan] }), original);
|
|
});
|
|
|
|
test("matching list IDs with different names remain separate and empty lists stay visible", () => {
|
|
const a = board("A"), b = board("B");
|
|
b.value.lists[0].name = "Backlog";
|
|
const columns = allTaskColumns([a, b], []);
|
|
assert.deepEqual(columns.map(c => c.list?.name), ["To do", "In progress", "Done", "Backlog"]);
|
|
assert.equal(new Set(columns.map(c => c.list?.id)).size, 4);
|
|
});
|
|
|
|
test("cards on archived boards remain visible and empty workspaces retain default lists", () => {
|
|
const archived = { ...board("Archived"), archived: true };
|
|
const card = task("Archived board card", { Archived: { listId: "todo" } });
|
|
const columns = allTaskColumns([archived], [card]);
|
|
assert.deepEqual(columns[0].tasks, [card]);
|
|
assert.equal(columns.length, 3);
|
|
assert.equal(columns[0].allowCreate, true);
|
|
assert.equal(allTaskColumns([], []).length, 3);
|
|
});
|
|
|
|
test("board dividers name shared memberships once and separate cards without active boards", () => {
|
|
const a = board("A"), b = board("B");
|
|
a.value.lists.push({ id: "review", name: "Review", status: null, collapsed: false });
|
|
const shared = task("Shared", { A: { listId: "todo" }, B: { listId: "todo" } });
|
|
const separate = task("Separate", { A: { listId: "review" }, B: { listId: "todo" } });
|
|
const orphan = task("Orphan", { deleted: { listId: "todo" } });
|
|
const columns = allTaskColumns([a, b], [shared, separate, orphan]);
|
|
const todo = columns.find(column => column.list?.name === "To do")!;
|
|
assert.deepEqual(allTaskGroups([a, b], todo).map(group => [group.name, group.tasks.map(task => task.title)]), [
|
|
["A · B", ["Shared"]], ["B", ["Separate"]], ["No active board", ["Orphan"]],
|
|
]);
|
|
assert.deepEqual(allTaskGroups([a, b], columns.find(column => column.list?.name === "Review")!).map(group => group.name), ["A"]);
|
|
});
|