RuneStone 1.0.0
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
// Mouse drag selection across a heading and a rendered link keeps the layout stable and selects the hidden link syntax.
|
||||
import assert from "node:assert/strict";
|
||||
import path from "node:path";
|
||||
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
await runSmoke("editor/linkSelection", async ({ page }) => {
|
||||
page.setDefaultTimeout(15000);
|
||||
// The original mock returned null for commands it did not handle.
|
||||
await mockTauri(page, {
|
||||
strict: false,
|
||||
commands: test => ({
|
||||
...test.workspace({ root: "C:\\tab-menu-workspace", files: { "a.md": "# Links\n\nOriginal text.\n" }, folders: ["notes"] }),
|
||||
workspace_search: () => [],
|
||||
"plugin:window|is_maximized": () => false,
|
||||
plugins_snapshot: () => ({ root: "C:/plugins", plugins: [] }),
|
||||
spelling_suggestions: () => ({ language: "en-US", words: [], misspelled: false }),
|
||||
"plugin:dialog|message": () => "Cancel",
|
||||
}),
|
||||
});
|
||||
const output = await outputDir("editor/linkSelection");
|
||||
async function reset(text) {
|
||||
await page.locator(".cm-content").evaluate(async (node, text) => {
|
||||
const { EditorView } = await import("/node_modules/@codemirror/view/dist/index.js");
|
||||
const view = EditorView.findFromDOM(node);
|
||||
view.dispatch({ changes: { from: 0, to: view.state.doc.length, insert: text }, selection: { anchor: 0 } });
|
||||
view.focus();
|
||||
}, text);
|
||||
}
|
||||
async function selected() {
|
||||
return page.locator(".cm-content").evaluate(async node => {
|
||||
const { EditorView } = await import("/node_modules/@codemirror/view/dist/index.js");
|
||||
const view = EditorView.findFromDOM(node), range = view.state.selection.main;
|
||||
return view.state.sliceDoc(range.from, range.to);
|
||||
});
|
||||
}
|
||||
|
||||
await page.goto(smokeUrl);
|
||||
await page.locator('[data-tree-rel="a.md"]').click();
|
||||
await page.locator(".cm-content").waitFor();
|
||||
await page.getByRole("button", { name: "Files", exact: true }).click();
|
||||
await page.getByRole("button", { name: "Hide outline", exact: true }).click();
|
||||
for (const theme of ["dark", "light"]) for (const width of [1440, 620]) {
|
||||
await page.setViewportSize({ width, height: 1000 });
|
||||
await page.evaluate(async mode => (await import("/src/lib/theme/appearance.ts")).saveAppearance({ theme: "default", mode }), theme);
|
||||
for (const link of ["[gpt-oss-120b-heretic](https://huggingface.co/kldzj/gpt-oss-120b-heretic)", "[[models/gpt-oss-120b-heretic|gpt-oss-120b-heretic]]"]) {
|
||||
const heading = "### Agentic Coding (DeepSWE 1.1)";
|
||||
const text = "Outside.\n\n" + heading + "\n" + link + "\n\nEnd.";
|
||||
for (const reverse of [false, true]) {
|
||||
await reset(text);
|
||||
const title = await page.locator(".cm-line").filter({ hasText: "Agentic Coding" }).boundingBox();
|
||||
const label = await page.locator(".writer-link").boundingBox();
|
||||
const start = { x: title.x + 1, y: title.y + title.height / 2 };
|
||||
const end = { x: label.x + label.width + 2, y: label.y + label.height / 2 };
|
||||
await page.mouse.move(reverse ? end.x : start.x, reverse ? end.y : start.y);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(reverse ? start.x : end.x, reverse ? start.y : end.y, { steps: 12 });
|
||||
await page.mouse.up();
|
||||
assert.equal(await selected(), heading + "\n" + link, `${theme}/${width}/${reverse}/${link}`);
|
||||
await page.screenshot({ path: path.join(output, `${theme}-${width}-${reverse}-${link.startsWith("[[") ? "wiki" : "markdown"}.png`) });
|
||||
}
|
||||
await reset(text);
|
||||
await page.locator(".writer-link").click({ position: { x: 30, y: 8 } });
|
||||
assert.equal(await selected(), "", "A click places the caret without selecting the link");
|
||||
assert.equal(await page.locator(".writer-link-source").count(), 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user