Files
RuneStone/tests/smoke/tree/renameMarks.smoke.mjs
T
2026-11-16 04:21:21 -07:00

44 lines
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Tree rename keeps pins and bookmarks: the file menu offers Copy path › System path, and Undo rename, Ctrl+Z, and Ctrl+Y restore the marks.
import assert from "node:assert/strict";
import { mockTauri, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("tree/renameMarks", async ({ page }) => {
await mockTauri(page, {
commands: test => {
const workspace = test.workspace({
root: "C:\\rename-marks",
files: { "a.md": "# Note\n\nOriginal text.", ".runestone/marks.json": JSON.stringify({ pins: ["a.md"], bookmarks: ["a.md"], order: { "": ["a.md"] } }) },
});
test.files = workspace.files;
return {
...workspace,
workspace_list: args => workspace.workspace_list(args).filter(entry => args.rel || entry.rel_path !== ".runestone"),
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 });
await page.goto(smokeUrl);
await row("a.md").click({ button: "right" });
// The file menu copies paths through the Copy path submenu, as the tab menu does.
await item("Copy path").hover();
assert.equal(await item("System path").count(), 1);
await item("Rename").click();
await page.locator(".tree input").fill("renamed.md");
await page.locator(".tree input").press("Enter");
await row("renamed.md").waitFor();
await row("renamed.md").click({ button: "right" });
assert.equal(await item("Undo rename").count(), 1);
await page.keyboard.press("Escape");
await row("renamed.md").focus();
await page.keyboard.press("Control+z");
await row("a.md").waitFor();
assert.deepEqual(await page.evaluate(() => JSON.parse(window.__TEST__.files.get(".runestone/marks.json")).pins), ["a.md"]);
await row("a.md").focus();
await page.keyboard.press("Control+y");
await row("renamed.md").waitFor();
console.log("PASS: Copy path › System path, rename, Undo rename, and Ctrl+Z and Ctrl+Y with marks");
}, { viewport: { width: 1200, height: 850 } });