Files
RuneStone/tests/smoke/tree/renameSelection.smoke.mjs
T
Knotty Wyvern 69f90df571 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.
2026-10-27 20:58:55 -07:00

45 lines
2.2 KiB
JavaScript

// 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 });
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");
}
});