joplin-plugin-gtd-calendar/src/tests/Gtd/webviewInteraction.test.ts

40 lines
1.7 KiB
TypeScript

import { readFileSync } from "fs";
import { resolve } from "path";
const webview = readFileSync(
resolve(process.cwd(), "src/gtd-calendar-webview.js"),
"utf8"
);
const css = readFileSync(resolve(process.cwd(), "src/event-calendar.css"), "utf8");
describe("Slice 14a compact move-menu rendering contract", () => {
test("removes the permanent select and renders a disclosure-controlled menu", () => {
expect(webview).not.toContain("gtd-kanban-move-select");
expect(webview).toContain("gtd-kanban-move-disclosure");
expect(webview).toContain('setAttribute("aria-expanded", "false")');
expect(webview).toContain('setAttribute("aria-controls", menuId)');
expect(webview).toContain('setAttribute("aria-haspopup", "menu")');
expect(webview).toContain('setAttribute("role", "menu")');
expect(webview).toContain('setAttribute("role", "menuitem")');
});
test("retains fixed destinations, current-state disabling, and keyboard dismissal", () => {
for (const destination of ["backlog", "inProgress", "done"]) {
expect(webview).toContain(`["${destination}",`);
}
expect(webview).toContain('item.disabled = entry[0] === source');
expect(webview).toContain('event.key === "Escape"');
expect(webview).toContain('event.key === "ArrowDown"');
expect(webview).toContain('event.key === "ArrowUp"');
expect(webview).toContain("outsidePointer");
});
test("uses a compact overlay menu beneath the control stack", () => {
expect(css).toContain(".gtd-kanban-card-controls");
expect(css).toContain(".gtd-kanban-move-menu");
expect(css).toContain("position: absolute");
expect(css).toContain("top: calc(100% + 0.2em)");
expect(css).not.toContain(".gtd-kanban-move-select");
});
});