Files
RuneStone/tests/smoke/tree/moveUndo.smoke.mjs
T
2026-11-03 00:23:07 -07:00

46 lines
1.9 KiB
JavaScript

// File moves in the tree: cut and paste, Undo and Redo file move from the folder menu, Ctrl+Z, and drag into a folder.
import { mockTauri, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("tree/moveUndo", async ({ page }) => {
await mockTauri(page, {
commands: test => {
const workspace = test.workspace({ root: "C:\\move-undo", files: { "a.md": "# Alpha\n", "b.md": "# Beta\n", "folder/keep.md": "# Keep\n" } });
test.files = workspace.files;
return {
...workspace,
plugins_snapshot: () => ({ plugins: [], issues: [] }),
spelling_menu_install: () => null,
};
},
});
const row = path => page.locator(`[data-tree-rel="${path}"]`);
const menu = label => page.getByRole("menuitem", { name: label, exact: true });
const has = path => page.waitForFunction(path => window.__TEST__.files.has(path), path);
await page.goto(smokeUrl);
await row("b.md").click({ button: "right" });
await menu("Cut").click();
await row("folder").click({ button: "right" });
await menu("Paste").click();
await has("folder/b.md");
await row("folder").click({ button: "right" });
await menu("Undo file move").click();
await has("b.md");
await row("folder").click({ button: "right" });
await menu("Redo file move").click();
await has("folder/b.md");
await row("folder").focus();
await page.keyboard.press("Control+z");
await has("b.md");
console.log("PASS: cut and paste, menu undo and redo, and Ctrl+Z");
const sourceBox = await row("b.md").boundingBox(), folderBox = await row("folder").boundingBox();
await page.mouse.move(sourceBox.x + 50, sourceBox.y + sourceBox.height / 2);
await page.mouse.down();
await page.mouse.move(folderBox.x + 70, folderBox.y + folderBox.height / 2, { steps: 12 });
await page.mouse.up();
await has("folder/b.md");
await page.keyboard.press("Control+z");
await has("b.md");
console.log("PASS: drag into a folder, and Ctrl+Z");
}, { timeout: 15000 });