Files
RuneStone/tests/smoke/workspace/session.smoke.mjs
T
Knotty Wyvern 9cf82503d0 Show one view control and name the file once
Phase 5-3.

- One radio group shows Write, Source, and Read at all times, with an
  icon and a name. Narrow panes show only the icons. The arrow keys
  move the choice, and the group has one Tab stop. The current choice
  gets the selection fill and an accent bar. Hover gets only a fill.
- A Split toggle shows Read beside Write or Source. Each document pane
  keeps a split flag beside its reading flag. Read ends Split.
- Ctrl+Shift+E switches between Read and the editor. Ctrl+E still
  switches between Write and Source.
- "IDE" becomes "Source" in the Chrome type, the tab menu (a View
  submenu), the status bar, the catalog, the tests, and the docs.
- Settings, General, File name title hides the title in Write and
  Read. It is on by default.
- The breadcrumb shows only the folder of the file. The status bar
  shows the view, not the path.
- ModeSwitcher.svelte and its hover test are gone. The new test
  layout/viewModes covers the control.
- The command palette from 5-2 gets its row in docs/menu-surfaces.json.
- The user guide Format table is whole again. The 5-2 edit had put
  the Paragraph and Insert rows under the shortcut table.
- 8 new catalog rows and 10 removed rows, in French, Japanese, and
  Simplified Chinese.
- Docs: UI-049, the user guide, ui-design.md, document-tools.md,
  development.md, and the README feature list.

Tests: the new layout/viewModes, new cases in documentPanes.spec.ts
and settings.spec.ts, and the chooseView harness helper. 21 smoke
tests use the new control. Tests that read the full path from the
breadcrumb now read its tooltip.
2026-10-28 19:45:08 -07:00

77 lines
4.3 KiB
JavaScript

// Workspace session: a title rename moves pins and bookmarks, marks from another window reach the panes, watcher paths update the tree and backlinks, and focus does not rescan the workspace.
import assert from "node:assert/strict";
import { mockTauri, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("workspace/session", async ({ page }) => {
await mockTauri(page, {
commands: test => {
const ws = test.workspace({
root: "C:\\smoke-workspace",
files: {
"notes/welcome.md": "# Welcome\n",
"notes/other.md": "# Other\n",
".runestone/marks.json": JSON.stringify({ pins: ["notes/welcome.md"], bookmarks: ["notes/welcome.md"], order: {} }, null, 2) + "\n",
},
});
const files = ws.files;
Object.assign(test, { files, root: ws.root });
return {
...ws,
workspace_rename: ({ from, to }) => {
if (!files.has(from)) throw new Error("File is missing");
files.set(to, files.get(from));
files.delete(from);
},
spelling_menu_install: () => null,
};
},
});
const marks = () => page.evaluate(() => JSON.parse(window.__TEST__.files.get(".runestone/marks.json")));
const emit = (kind, paths) => page.evaluate(([kind, paths]) => window.__TEST__.emit("workspace-event", { root: window.__TEST__.root, kind, paths }), [kind, paths]);
const tree = page.locator(".tree");
const backlinks = page.getByRole("region", { name: "Backlinks" });
await page.goto(smokeUrl);
await page.getByText("smoke-workspace", { exact: true }).waitFor();
await tree.getByText("notes", { exact: true }).click();
await tree.getByText("welcome", { exact: true }).dblclick();
const title = page.getByRole("button", { name: "Rename note", exact: true });
await title.click();
await page.getByRole("textbox", { name: "Note filename", exact: true }).fill("renamed");
await page.keyboard.press("Enter");
await page.waitForFunction(() => document.querySelector(".breadcrumb")?.title === "notes/renamed.md");
await page.waitForFunction(() => window.__TEST__.files.get(".runestone/marks.json").includes("notes/renamed.md"));
assert.deepEqual(await marks(), { pins: ["notes/renamed.md"], bookmarks: ["notes/renamed.md"], order: {} }, "A title rename moves the pin and the bookmark");
await tree.getByText("renamed", { exact: true }).waitFor();
await page.getByRole("button", { name: "Bookmarks", exact: true }).click();
const bookmarks = page.locator(".pane").filter({ hasText: "Bookmarks" });
await bookmarks.getByText("notes/renamed.md").waitFor();
// Another window bookmarks a second note. The watcher reports the marks file.
await page.evaluate(() => window.__TEST__.files.set(".runestone/marks.json", JSON.stringify({ pins: ["notes/renamed.md"], bookmarks: ["notes/renamed.md", "notes/other.md"], order: {} })));
await emit("modify", [".runestone/marks.json"]);
await bookmarks.getByText("notes/other.md").waitFor();
await page.getByRole("button", { name: "Files", exact: true }).click();
// A note that another program creates appears in the tree and in the backlinks, without a rescan.
const listCalls = () => page.evaluate(() => window.__TEST__.calls.filter(call => call.command === "workspace_list").length);
const before = await listCalls();
await page.evaluate(() => window.__TEST__.files.set("notes/linker.md", "See [[renamed]] for details.\n"));
await emit("create", ["notes/linker.md"]);
await tree.getByText("linker", { exact: true }).waitFor();
await backlinks.getByText("notes/linker.md").waitFor();
assert.ok(await listCalls() - before <= 3, "One change lists only the folders that it touches");
const afterChange = await listCalls();
await page.evaluate(() => window.dispatchEvent(new Event("focus")));
await page.waitForTimeout(400);
assert.equal(await listCalls(), afterChange, "Window focus does not rescan the workspace");
// A deleted note leaves the tree and the backlinks.
await page.evaluate(() => window.__TEST__.files.delete("notes/linker.md"));
await emit("remove", ["notes/linker.md"]);
await backlinks.getByText("No other notes link to this file.").waitFor();
assert.equal(await tree.getByText("linker", { exact: true }).count(), 0);
console.log("PASS: title rename moves marks, marks from another window, watcher paths update the tree and backlinks, no rescan on focus.");
});