Files
RuneStone/tests/smoke/appearance/tooltipPlacement.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

54 lines
2.6 KiB
JavaScript

// Shared tooltips (attachTooltip) in both themes: no title attribute, rounded corners, Escape and focus, and placement inside a narrow window.
import assert from "node:assert/strict";
import path from "node:path";
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
const name = "appearance/tooltipPlacement";
await runSmoke(name, async ({ browser }) => {
const output = await outputDir(name);
for (const theme of ["light", "dark"]) {
const page = await openPage(browser, { viewport: { width: 1100, height: 780 } });
await mockTauri(page, {
commands: test => ({
...test.workspace({ root: "C:\\tooltip-placement", files: { "sample.md": "# Tooltip sample\n" } }),
plugins_snapshot: () => ({ root: "C:/plugins", plugins: [] }),
}),
});
await page.goto(smokeUrl);
await page.getByText("tooltip-placement", { exact: true }).waitFor();
await page.evaluate(async theme => {
const { saveAppearance } = await import("/src/lib/theme/appearance.ts");
saveAppearance({ theme: "default", mode: theme });
const { attachTooltip } = await import("/src/lib/ui/tooltip.ts");
const cell = document.createElement("button");
cell.id = "tooltip-test";
cell.textContent = "Formula cell";
Object.assign(cell.style, { position: "fixed", left: "20px", top: "100px", zIndex: "2000" });
document.body.append(cell);
window.disposeTip = attachTooltip(cell, () => "B6 · Click to edit · Type = for a formula");
}, theme);
const target = page.locator("#tooltip-test");
const tooltip = page.locator(".rs-tooltip:popover-open");
await target.hover();
await tooltip.waitFor();
assert.equal(await target.getAttribute("title"), null);
assert.equal(await tooltip.evaluate(node => getComputedStyle(node).borderRadius), "5px");
await page.screenshot({ path: path.join(output, `${theme}-tooltip.png`) });
await page.keyboard.press("Escape");
assert.equal(await page.locator(".rs-tooltip:popover-open").count(), 0);
await target.focus();
await tooltip.waitFor();
await page.setViewportSize({ width: 390, height: 620 });
await page.locator("header").first().hover();
await target.hover();
await tooltip.waitFor();
const bounds = await tooltip.boundingBox();
assert(bounds.x >= 8 && bounds.x + bounds.width <= 382);
await page.screenshot({ path: path.join(output, `${theme}-narrow-tooltip.png`) });
await page.evaluate(() => { window.disposeTip(); document.getElementById("tooltip-test").remove(); });
assert.deepEqual(page.errors, []);
await page.close();
console.log(`PASS: ${theme} tooltip`);
}
});