RuneStone 1.0.0

This commit is contained in:
Knotty Wyvern
2026-11-16 04:21:21 -07:00
commit b52eeb14a1
827 changed files with 241421 additions and 0 deletions
+87
View File
@@ -0,0 +1,87 @@
// Dividers: thematic break syntax, width, source editing, keyboard navigation, selection, undo, and save.
import assert from "node:assert/strict";
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("editor/dividers", async ({ page }) => {
await mockTauri(page, {
commands: test => {
const workspace = 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,
});
test.files = workspace.files;
return {
...workspace,
// Saves send the last saved text. Reject a save when the file changed, as the backend does.
workspace_write: args => {
if (args.expected !== undefined && workspace.files.get(args.rel) !== args.expected) throw new Error("Save blocked: file changed on disk");
return workspace.workspace_write(args);
},
};
},
});
const output = await outputDir("editor/dividers");
await page.goto(smokeUrl);
await page.getByText("smoke-workspace", { exact: true }).waitFor();
await page.keyboard.press("Control+p");
await page.getByRole("textbox", { name: "Find a file" }).fill("welcome.md");
await page.getByRole("dialog").getByRole("button").filter({ hasText: "welcome.md" }).first().click();
const writer = page.getByRole("textbox", { name: "Writing editor", exact: true });
await writer.waitFor();
const dividers = "content\n___\ncontent\n***\n\n---\n\n* * *\n\n_ _ _\n\n- - -\n\nHeading\n---\n\n`___`\n\n```text\n___\n```\n\n ***\n\nEnd\n";
await page.evaluate(async value => {
const { EditorView } = await import("/node_modules/@codemirror/view/dist/index.js");
window.__CM__ = EditorView.findFromDOM(document.querySelector(".cm-content"));
window.__CM__.dispatch({ changes: { from: 0, to: window.__CM__.state.doc.length, insert: value }, selection: { anchor: 0 } });
}, dividers);
await page.waitForFunction(() => document.querySelectorAll(".writer-divider").length === 6);
assert.equal(await page.getByRole("separator").and(page.locator(".writer-divider")).count(), 6);
const dividerStyle = await page.locator(".writer-divider").first().evaluate(node => ({
width: node.getBoundingClientRect().width,
lineWidth: node.parentElement.getBoundingClientRect().width,
border: getComputedStyle(node, "::after").borderTopWidth,
color: getComputedStyle(node, "::after").borderTopColor,
}));
assert.ok(Math.abs(dividerStyle.width - dividerStyle.lineWidth) < 2);
assert.equal(dividerStyle.border, "1px");
assert.notEqual(dividerStyle.color, "rgba(0, 0, 0, 0)");
await page.setViewportSize({ width: 1100, height: 900 });
await page.screenshot({ path: `${output}/markdown-dividers.png` });
await page.locator(".writer-divider").first().click();
assert.equal(await page.locator(".writer-divider").count(), 5);
assert.equal(await page.evaluate(() => window.__CM__.state.doc.lineAt(window.__CM__.state.selection.main.head).text), "___");
await page.keyboard.press("End");
await page.keyboard.press("Backspace");
await page.keyboard.press("Control+Home");
assert.equal(await page.locator(".writer-divider").count(), 5);
assert.ok((await writer.textContent()).includes("__"));
await page.keyboard.press("Control+z");
await page.keyboard.press("Control+Home");
assert.equal(await page.locator(".writer-divider").count(), 6);
await page.keyboard.press("ArrowDown");
assert.equal(await page.locator(".writer-divider").count(), 5);
assert.equal(await page.evaluate(() => window.__CM__.state.doc.lineAt(window.__CM__.state.selection.main.head).text), "___");
await page.keyboard.press("Control+a");
assert.equal(await page.locator(".writer-divider").count(), 0);
assert.equal(await page.evaluate(() => window.__CM__.state.sliceDoc()), dividers);
await page.keyboard.press("Control+Home");
assert.equal(await page.locator(".writer-divider").count(), 6);
await page.keyboard.press("Control+s");
await page.waitForFunction(value => window.__TEST__.files.get("notes/welcome.md") === value, dividers);
await page.evaluate(() => {
window.__CM__.dispatch({ changes: { from: 0, to: window.__CM__.state.doc.length, insert: "Above\n\n ___\n\n> ***\n\nEnd" }, selection: { anchor: 0 } });
});
assert.equal(await page.locator(".writer-divider").count(), 2);
for (const divider of await page.locator(".writer-divider").all()) {
assert.ok(await divider.evaluate(node => node.getBoundingClientRect().right <= node.parentElement.getBoundingClientRect().right + 1));
}
console.log("PASS: Divider syntax, width, source editing, keyboard navigation, selection, undo and save.");
});