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.
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
// Git plugin sidebar toolbar: the Graph control is icon-only, keeps its accessible name, shows hover and focus tooltips in both themes, and opens Graph.
|
||||
// @requires repo:RuneStone_Git/src
|
||||
// The source loads from the sibling RuneStone_Git checkout (RUNESTONE_PLUGIN_REPOS) without building a plugin ZIP.
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { mockTauri, outputDir, pluginRepo, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
const name = "plugins/gitToolbar";
|
||||
await runSmoke(name, async ({ page }) => {
|
||||
const output = await outputDir(name);
|
||||
const source = pluginRepo("RuneStone_Git");
|
||||
const files = new Map(await Promise.all(["view.js", "model.js"].map(async file => [file, await readFile(path.join(source, "src", file), "utf8")])));
|
||||
const css = await readFile(path.join(source, "src", "style.css"), "utf8");
|
||||
await page.route("**/__git_source/*", route => route.fulfill({ contentType: "text/javascript", body: files.get(new URL(route.request().url()).pathname.split("/").pop()) || "" }));
|
||||
await mockTauri(page, {
|
||||
commands: test => ({
|
||||
...test.workspace({ root: "C:\\git-toolbar", files: { "notes/draft.md": "Before.\n" } }),
|
||||
plugins_snapshot: () => ({ plugins: [], issues: [] }),
|
||||
spelling_menu_install: () => null,
|
||||
}),
|
||||
});
|
||||
await page.goto(smokeUrl);
|
||||
await page.locator('[data-tree-rel="notes"]').waitFor();
|
||||
await page.evaluate(async css => {
|
||||
const { mountSidebar } = await import("/__git_source/view.js");
|
||||
const container = document.createElement("div");
|
||||
container.id = "git-smoke";
|
||||
container.style.cssText = "position:fixed;inset:45px 0 0 0;z-index:1000;background:var(--rs-bg)";
|
||||
document.body.append(container);
|
||||
window.gitGraphOpens = 0;
|
||||
window.disposeGitSmoke = mountSidebar(container, {
|
||||
workspace: {},
|
||||
git: { status: async () => ({ available: true, repository: true, branch: "main", changes: [] }), pull: async () => {}, push: async () => {} },
|
||||
openView: () => window.gitGraphOpens++,
|
||||
}, css, () => {});
|
||||
}, css);
|
||||
const graph = page.locator("#git-smoke").getByRole("button", { name: "Graph", exact: true });
|
||||
// The plugin shows the shared host tooltip (a `.rs-tooltip` popover from `data-tooltip`) instead of a title and its own tooltip span.
|
||||
// RuneStone_Git/src/view.js: button() sets data-tooltip and aria-label; tooltipScope() shows the popover on hover and focus.
|
||||
const tooltip = page.locator(".rs-tooltip:popover-open");
|
||||
for (const theme of ["dark", "light"]) {
|
||||
await page.evaluate(async mode => { const { saveAppearance } = await import("/src/lib/theme/appearance.ts"); saveAppearance({ theme: "default", mode }); }, theme);
|
||||
await graph.waitFor();
|
||||
assert.equal(await graph.locator("svg").count(), 1);
|
||||
assert.equal(await graph.getAttribute("title"), null);
|
||||
assert.equal(await graph.getAttribute("data-tooltip"), "Graph");
|
||||
assert.equal(await graph.evaluate(node => [...node.childNodes].filter(child => child.nodeType === Node.TEXT_NODE && child.textContent.trim()).length), 0);
|
||||
assert.equal(await graph.locator(":scope > :not(.rs-git-icon)").count(), 0, "Graph has no visible text label");
|
||||
await page.mouse.move(800, 800);
|
||||
await graph.evaluate(node => node.blur());
|
||||
assert.equal(await tooltip.count(), 0);
|
||||
await graph.hover();
|
||||
await tooltip.waitFor();
|
||||
assert.equal(await tooltip.innerText(), "Graph");
|
||||
await page.mouse.move(800, 800);
|
||||
await page.keyboard.press("Tab");
|
||||
await graph.focus();
|
||||
assert.equal(await graph.evaluate(node => node.matches(":focus-visible")), true);
|
||||
await tooltip.waitFor();
|
||||
assert.equal(await tooltip.innerText(), "Graph");
|
||||
await page.screenshot({ path: path.join(output, `git-toolbar-${theme}.png`) });
|
||||
}
|
||||
await graph.click();
|
||||
assert.equal(await page.evaluate(() => window.gitGraphOpens), 1);
|
||||
await page.evaluate(() => window.disposeGitSmoke());
|
||||
console.log("PASS: icon-only Graph control with accessible name, hover and focus tooltips in both themes, and Graph opens");
|
||||
}, { timeout: 15000 });
|
||||
Reference in New Issue
Block a user