Files
RuneStone/tests/smoke/editor/markdownPaste.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

53 lines
2.8 KiB
JavaScript

// Pasting large Markdown keeps the source exact and renders every bold span.
import assert from "node:assert/strict";
import { mockTauri, runSmoke, smokeUrl } from "../_harness/index.mjs";
await runSmoke("editor/markdownPaste", async ({ page }) => {
await mockTauri(page, {
commands: test => 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",
},
}),
});
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();
await page.getByRole("textbox", { name: "Writing editor", exact: true }).waitFor();
await page.evaluate(async () => {
const { EditorView } = await import("/node_modules/.vite/deps/@codemirror_view.js");
window.__CM__ = EditorView.findFromDOM(document.querySelector(".cm-content"));
});
for (const count of [3, 1000, 5000]) {
const result = await page.evaluate(async count => {
const { EditorView } = await import("/node_modules/.vite/deps/@codemirror_view.js");
const view = window.__CM__;
const source = Array.from({ length: count }, (_, i) => "## Heading " + i + "\n\n**Bold** and *italic*\n\n").join("");
view.dispatch({ changes: { from: 0, to: view.state.doc.length, insert: "" } });
view.focus();
const clipboardData = new DataTransfer();
clipboardData.setData("text/plain", source);
view.contentDOM.dispatchEvent(new ClipboardEvent("paste", { bubbles: true, cancelable: true, clipboardData }));
view.dispatch({ selection: { anchor: 0 } });
const { forceParsing, syntaxTree } = await import("/node_modules/.vite/deps/@codemirror_language.js");
forceParsing(view, view.state.doc.length, 5000);
const nodes = [];
syntaxTree(view.state).iterate({ enter(node) { if (node.name === "StrongEmphasis") nodes.push(node.from); } });
const marks = [];
for (const set of view.state.facet(EditorView.decorations)) {
if (typeof set !== "function") set.between(0, view.state.doc.length, (from, to, decoration) => { if (decoration.spec.class === "writer-strong") marks.push(from); });
}
return { correctSource: view.state.sliceDoc() === source, nodes: nodes.length, marks: marks.length };
}, count);
console.log({ count, ...result });
assert.equal(result.correctSource, true);
assert.equal(result.nodes, count);
assert.equal(result.marks, count);
}
});