Move the smoke tests onto the shared harness

Each smoke test now uses tests/smoke/_harness/ for Playwright, the Tauri
IPC mock, the in-memory workspace, and output folders, instead of its
own copy. The tests keep their interactions and assertions. Mock
handlers that the app never calls are gone.

- Split the four mixed regression scripts into 18 feature tests.
- Update tests that broke when the app changed on purpose. Each update
  cites the app source that shows the new behavior.
- Mark two real app defects with @known-issue: the settings window
  controls are 1px shorter than the main window controls, and plugin
  tabs cannot be reordered by dragging without a workspace.
- Merge three palette unit tests into one table-driven test.
- The native tests load Playwright through the harness and read
  NATIVE_CDP_URL, with their old variable names as fallbacks.
- A failed smoke test saves a screenshot and prints the console errors.
- The runner runs failed tests once more, alone, and reports a test
  that then passes as flaky.

Result: 89 passed, 1 flaky, 2 known issues, 0 failed. Before, 45 of 78
passed.
This commit is contained in:
Knotty Wyvern
2026-10-27 20:58:55 -07:00
parent c66ea1ce83
commit 69f90df571
109 changed files with 5920 additions and 7915 deletions
@@ -0,0 +1,80 @@
// Note templates from the file pane menu: New note from a template, and the template manager's rename, name conflict, edit, new, delete, and long list.
import assert from "node:assert/strict";
import path from "node:path";
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
const name = "workspace/manageTemplates";
await runSmoke(name, async ({ page }) => {
const output = await outputDir(name);
await mockTauri(page, {
commands: test => {
const workspace = test.workspace({ root: "C:\\manage-templates", files: { "a.md": "# Note\n\nOriginal text.", ".runestone/templates/Daily.md": "# Daily\n\n## Tasks" } });
test.files = workspace.files;
return {
...workspace,
workspace_list: args => workspace.workspace_list(args).filter(entry => args.rel || entry.rel_path !== ".runestone"),
"plugin:dialog|message": () => "Ok",
plugins_snapshot: () => ({ root: "C:/plugins", plugins: [] }),
spelling_menu_install: () => null,
};
},
});
const row = path => page.locator(`[data-tree-rel="${path}"]`);
const item = name => page.getByRole("menuitem", { name, exact: true });
const button = name => page.getByRole("button", { name, exact: true });
const templateName = () => page.getByRole("textbox", { name: "Template name", exact: true });
const file = path => page.evaluate(path => window.__TEST__.files.get(path), path);
async function openManager() {
await page.getByRole("navigation", { name: "Workspace files" }).click({ button: "right", position: { x: 90, y: 360 } });
await item("New note").hover();
await item("Manage templates…").click();
}
await page.goto(smokeUrl);
await row("a.md").waitFor();
await page.getByRole("navigation", { name: "Workspace files" }).click({ button: "right", position: { x: 90, y: 360 } });
await item("New note").hover();
await item("Daily").click();
await row("Daily.md").waitFor();
assert.equal(await file("Daily.md"), "# Daily\n\n## Tasks");
console.log("PASS: New note from a template");
await openManager();
await button("Rename Daily").click();
await templateName().fill("Weekly");
await button("Continue").click();
await button("Edit Weekly").waitFor();
await page.evaluate(() => window.__TEST__.files.set(".runestone/templates/Existing.md", "# Keep this template"));
await button("Rename Weekly").click();
await templateName().fill("Existing");
await button("Continue").click();
await page.getByRole("alert").filter({ hasText: "Destination exists" }).waitFor();
assert.equal(await file(".runestone/templates/Existing.md"), "# Keep this template");
for (const mode of ["light", "dark"]) {
await page.evaluate(async mode => { const { saveAppearance } = await import("/src/lib/theme/appearance.ts"); saveAppearance({ theme: "default", mode }); }, mode);
await page.screenshot({ path: path.join(output, `templates-${mode}.png`) });
}
await button("Edit Weekly").click();
await page.getByRole("tab", { name: "Weekly.md", exact: true }).waitFor();
console.log("PASS: rename, rename conflict, and edit a template");
await openManager();
await button("New template").click();
await templateName().fill("Meeting");
await button("Continue").click();
await page.getByRole("tab", { name: "Meeting.md", exact: true }).waitFor();
assert.equal(await file(".runestone/templates/Meeting.md"), "");
await openManager();
await button("Delete Weekly").click();
await button("Edit Weekly").waitFor({ state: "detached" });
assert.equal(await file("Daily.md"), "# Daily\n\n## Tasks", "Deleting template preserves notes");
await button("Close templates").click();
console.log("PASS: create and delete a template");
await page.evaluate(() => { for (let i = 0; i < 40; i++) window.__TEST__.files.set(`.runestone/templates/Long template name ${i}.md`, "# Template"); });
await page.setViewportSize({ width: 600, height: 600 });
await openManager();
assert.ok(await page.locator("dialog .list").evaluate(node => node.scrollHeight > node.clientHeight), "Long template list scrolls");
await page.screenshot({ path: path.join(output, "templates-narrow-long.png") });
await button("Close templates").click();
console.log("PASS: a long template list scrolls in a narrow window");
}, { viewport: { width: 1200, height: 850 } });