RuneStone 1.0.0
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
// 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`);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user