RuneStone 1.0.0
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
// Rename fields select the file stem, the folder name, or the tab dialog name, in dark/wide and light/narrow layouts.
|
||||
import assert from "node:assert/strict";
|
||||
import path from "node:path";
|
||||
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
await runSmoke("tree/renameSelection", async ({ page }) => {
|
||||
await mockTauri(page, {
|
||||
commands: test => test.workspace({
|
||||
root: "C:\\tree-actions-test",
|
||||
files: { "notes/a.md": "# A", "notes/nested/b.md": "# B", "target/a.md": "# Existing", "a.md": "# A", "b.md": "# B", "c.md": "# C" },
|
||||
}),
|
||||
});
|
||||
const output = await outputDir("tree/renameSelection");
|
||||
const row = rel => page.locator(`[data-tree-rel="${rel}"]`);
|
||||
const selection = input => input.evaluate(node => [node.selectionStart, node.selectionEnd, node.value]);
|
||||
await page.goto(smokeUrl);
|
||||
await row("notes").waitFor();
|
||||
for (const [theme, width] of [["dark", 1440], ["light", 620]]) {
|
||||
await page.setViewportSize({ width, height: 850 });
|
||||
// The side pane gives way below 800 pixels. The test opens it again.
|
||||
if (width < 800) { await page.locator("aside.left").waitFor({ state: "detached" }); await page.keyboard.press("Control+Backslash"); await row("a.md").waitFor(); }
|
||||
await page.evaluate(theme => { document.documentElement.dataset.theme = theme; document.documentElement.dataset.palette = "default"; }, theme);
|
||||
await row("a.md").click();
|
||||
await row("a.md").focus();
|
||||
await page.keyboard.press("F2");
|
||||
const input = row("a.md").locator("input");
|
||||
await input.waitFor();
|
||||
assert.deepEqual(await selection(input), [0, 1, "a.md"]);
|
||||
await page.screenshot({ path: path.join(output, `rename-selection-${theme}.png`) });
|
||||
await input.press("Escape");
|
||||
await row("notes").click();
|
||||
await row("notes").focus();
|
||||
await page.keyboard.press("F2");
|
||||
const folder = row("notes").locator("input");
|
||||
await folder.waitFor();
|
||||
assert.deepEqual(await selection(folder), [0, 5, "notes"]);
|
||||
await folder.press("Escape");
|
||||
await page.getByRole("tab", { name: "a.md", exact: true }).click();
|
||||
await page.getByRole("tab", { name: "a.md", exact: true }).click({ button: "right" });
|
||||
await page.getByRole("menuitem", { name: "Rename…", exact: true }).click();
|
||||
const dialogInput = page.locator("#text-request");
|
||||
await dialogInput.waitFor();
|
||||
assert.deepEqual(await selection(dialogInput), [0, 1, "a.md"]);
|
||||
await dialogInput.press("Escape");
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user