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.
68 lines
3.7 KiB
JavaScript
68 lines
3.7 KiB
JavaScript
// File tree selection: Ctrl and Shift ranges across expanded folders, F2 on multiple rows, and Collapse all.
|
|
import assert from "node:assert/strict";
|
|
import path from "node:path";
|
|
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
|
|
|
await runSmoke("tree/selection", async ({ page }) => {
|
|
page.on("console", message => { if (message.type() === "error" || message.type() === "warning") console.log(message.type(), message.text()); });
|
|
await mockTauri(page, {
|
|
commands: test => test.workspace({
|
|
root: "C:\\smoke-workspace",
|
|
files: {
|
|
"notes/welcome.md": "---\ntitle: Welcome\n---\n\n# Working notes\n\nFirst paragraph.\n\n- [ ] A task\n\n[[second]]\n",
|
|
"notes/second.md": "# Second note\n",
|
|
"src/hello.py": "print('hello')\n",
|
|
},
|
|
writeEvents: true,
|
|
}),
|
|
});
|
|
const output = await outputDir("tree/selection");
|
|
const row = rel => page.locator(`[data-tree-rel="${rel}"]`);
|
|
const selected = () => page.locator('[role="treeitem"][aria-selected="true"]').evaluateAll(rows => rows.map(row => row.dataset.treeRel));
|
|
await page.goto(smokeUrl);
|
|
await row("notes").waitFor();
|
|
await row("notes").click();
|
|
await row("notes/second.md").waitFor();
|
|
assert.deepEqual(await selected(), ["notes"]);
|
|
await row("notes/second.md").click({ modifiers: ["Control"] });
|
|
await row("src").click({ modifiers: ["Control"] });
|
|
assert.deepEqual(await selected(), ["notes", "notes/second.md", "src"]);
|
|
assert.equal(await row("src").getAttribute("aria-expanded"), "false");
|
|
assert.equal(await page.getByRole("tab").count(), 1);
|
|
assert.equal(await page.getByRole("tab", { name: "New tab", exact: true }).count(), 1);
|
|
await row("notes").click({ modifiers: ["Control"] });
|
|
assert.deepEqual(await selected(), ["notes/second.md", "src"]);
|
|
assert.equal(await row("notes").getAttribute("aria-expanded"), "true");
|
|
await row("notes/second.md").click({ modifiers: ["Shift"] });
|
|
assert.deepEqual(await selected(), ["notes", "notes/second.md"]);
|
|
await row("src").click({ modifiers: ["Shift"] });
|
|
assert.deepEqual(await selected(), ["notes", "notes/second.md", "notes/welcome.md", "src"]);
|
|
await page.keyboard.press("F2");
|
|
assert.equal(await page.locator(".tree .rename").count(), 0);
|
|
await row("notes/welcome.md").click({ modifiers: ["Shift"] });
|
|
assert.deepEqual(await selected(), ["notes", "notes/second.md", "notes/welcome.md"]);
|
|
await row("notes/second.md").click();
|
|
assert.deepEqual(await selected(), ["notes/second.md"]);
|
|
await page.getByRole("tab", { name: /second/ }).waitFor();
|
|
await row("notes/second.md").click({ modifiers: ["Control"] });
|
|
assert.deepEqual(await selected(), []);
|
|
await row("src").click({ modifiers: ["Control"] });
|
|
await row("notes").click({ modifiers: ["Control"] });
|
|
await row("notes").click({ modifiers: ["Control"] });
|
|
await page.keyboard.press("F2");
|
|
assert.equal(await page.locator(".tree .rename").inputValue(), "src");
|
|
await page.keyboard.press("Escape");
|
|
await row("notes/second.md").click({ modifiers: ["Shift"] });
|
|
assert.deepEqual(await selected(), ["notes/second.md", "notes/welcome.md", "src"]);
|
|
const colors = await page.locator(".tree .row.selected").evaluateAll(rows => rows.map(row => getComputedStyle(row).backgroundColor));
|
|
assert.equal(new Set(colors).size, 1);
|
|
await page.screenshot({ path: path.join(output, "tree-selection.png") });
|
|
await page.getByRole("button", { name: "Collapse all", exact: true }).click();
|
|
assert.deepEqual(await selected(), ["src"]);
|
|
await row("notes").click({ modifiers: ["Shift"] });
|
|
assert.deepEqual(await selected(), ["notes", "src"]);
|
|
await row("notes").click({ modifiers: ["Control"] });
|
|
await row("notes").click({ modifiers: ["Shift", "Control"] });
|
|
assert.deepEqual(await selected(), ["notes", "src"]);
|
|
});
|