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.
This commit is contained in:
@@ -1,55 +1,38 @@
|
||||
// Run against pnpm dev with PLAYWRIGHT_MODULE and CHROME_PATH if needed.
|
||||
import { createRequire } from "node:module";
|
||||
// Sidebar layout persistence: the hidden outline, resized sidebars, and the navigation view survive layout changes, reloads, and reopened windows.
|
||||
import assert from "node:assert/strict";
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const context = await browser.newContext({ viewport: { width: 1280, height: 800 } });
|
||||
await context.addInitScript(() => {
|
||||
window.isTauri = true;
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: "main" }, currentWebview: { label: "main" } },
|
||||
transformCallback: () => 1, unregisterCallback: () => {},
|
||||
invoke: async (command, args = {}) => {
|
||||
if (command === "plugins_snapshot") return { root: "D:\\LayoutTest\\plugins", plugins: [] };
|
||||
if (command === "workspace_last_path") return "D:\\LayoutTest";
|
||||
if (command === "workspace_open") return { root: "D:\\LayoutTest", name: "LayoutTest", watch_mode: "native" };
|
||||
if (command === "workspace_list") return args.rel ? [] : [{ name: "note.md", rel_path: "note.md", kind: "file" }];
|
||||
if (command === "workspace_read") {
|
||||
if (args.rel === "note.md") return "# Layout test\n\nA note.\n";
|
||||
throw new Error("Missing file");
|
||||
}
|
||||
return null;
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
|
||||
});
|
||||
const errors = [];
|
||||
context.on("page", page => page.on("pageerror", error => errors.push(error.message)));
|
||||
const url = process.env.SMOKE_URL || "http://127.0.0.1:1420";
|
||||
let page = await context.newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
async function ready() { await page.getByRole("button", { name: /^(Hide|Show) outline$/ }).waitFor(); }
|
||||
async function reopen() {
|
||||
await page.close();
|
||||
page = await context.newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
await page.goto(url);
|
||||
await ready();
|
||||
}
|
||||
async function resize(index, x) {
|
||||
const box = await page.locator(".gutter-v").nth(index).boundingBox();
|
||||
await page.mouse.move(box.x + box.width / 2, box.y + 60);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(x, box.y + 60);
|
||||
await page.mouse.up();
|
||||
}
|
||||
async function widths() {
|
||||
return page.locator(".shell").evaluate(element => [element.style.getPropertyValue("--left"), element.style.getPropertyValue("--right")]);
|
||||
}
|
||||
try {
|
||||
await page.goto(url);
|
||||
await ready();
|
||||
import { mockTauri, openPage, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
await runSmoke("layout/outline", async ({ browser }) => {
|
||||
// Pages share one context, so a reopened window keeps the saved layout.
|
||||
const context = await browser.newContext({ viewport: { width: 1280, height: 800 } });
|
||||
// Unknown commands return null, as the original mock did.
|
||||
await mockTauri(context, {
|
||||
strict: false,
|
||||
commands: test => ({
|
||||
...test.workspace({ root: "D:\\LayoutTest", files: { "note.md": "# Layout test\n\nA note.\n" } }),
|
||||
plugins_snapshot: () => ({ root: "D:\\LayoutTest\\plugins", plugins: [] }),
|
||||
}),
|
||||
});
|
||||
const errors = [];
|
||||
let page;
|
||||
async function ready() { await page.getByRole("button", { name: /^(Hide|Show) outline$/ }).waitFor(); }
|
||||
async function reopen() {
|
||||
if (page) { errors.push(...page.errors); await page.close(); }
|
||||
page = await openPage(context, { timeout: 5000 });
|
||||
await page.goto(smokeUrl);
|
||||
await ready();
|
||||
}
|
||||
async function resize(index, x) {
|
||||
const box = await page.locator(".gutter-v").nth(index).boundingBox();
|
||||
await page.mouse.move(box.x + box.width / 2, box.y + 60);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(x, box.y + 60);
|
||||
await page.mouse.up();
|
||||
}
|
||||
async function widths() {
|
||||
return page.locator(".shell").evaluate(element => [element.style.getPropertyValue("--left"), element.style.getPropertyValue("--right")]);
|
||||
}
|
||||
await reopen();
|
||||
await page.getByText("LayoutTest", { exact: true }).waitFor();
|
||||
await page.keyboard.press("Control+p");
|
||||
await page.getByRole("textbox", { name: "Find a file" }).fill("note.md");
|
||||
@@ -91,5 +74,6 @@ try {
|
||||
await page.getByRole("button", { name: "Show outline", exact: true }).click();
|
||||
assert.deepEqual(await widths(), resized);
|
||||
console.log("PASS: collapsed sidebars retain their sizes and navigation view");
|
||||
errors.push(...page.errors);
|
||||
assert.deepEqual(errors, []);
|
||||
} finally { await browser.close(); }
|
||||
});
|
||||
|
||||
@@ -1,93 +1,78 @@
|
||||
import { createRequire } from "node:module";
|
||||
// Document splits: independent modes, edits, saves, selections, and conflicts per pane; nested relative links; narrow stacking; and the close guard.
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdir } from "node:fs/promises";
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
||||
page.setDefaultTimeout(15000);
|
||||
const errors = [];
|
||||
page.on("pageerror", error => errors.push(error.message));
|
||||
page.on("console", message => { if (message.text().includes("binding_property_non_reactive")) errors.push(message.text()); });
|
||||
await mkdir(".audit", { recursive: true });
|
||||
await page.addInitScript(() => {
|
||||
window.isTauri = true;
|
||||
const root = "C:\\tab-menu-workspace";
|
||||
const files = new Map(["a.md", "b.md", "c.md", "d.md"].map(name => [name, `# ${name}\n\nOriginal text.\n\n\`\`\`js\nconst answer = 42;\n\`\`\`\n\n| Name | Value |\n| --- | --- |\n| Alpha | One |\n`]));
|
||||
files.set("a.md", "# Links\n\nSelected reading text.\n\n[Web label](https://example.com/path)\n\n[[b.md|Workspace note]]\n");
|
||||
files.set("a.md", "# Alpha\n\nOrigin paragraph.\n\n[[notes/b.md|Right note]]\n");
|
||||
files.set("notes/b.md", "# Bravo\n\nSecond paragraph.\n\n[Relative](c.md)\n\n[[/a.md|Original note]]\n");
|
||||
files.set("notes/c.md", "# Charlie\n\nThird paragraph.\n");
|
||||
files.set("sample.txt", "const answer = 42;\n");
|
||||
window.tabMenuTest = { prompts: [], answer: "Cancel", revealed: null, clipboard: null, opened: null, app: null, windows: [] };
|
||||
Object.defineProperty(navigator, "clipboard", { value: { writeText: async text => { window.tabMenuTest.clipboard = text; } } });
|
||||
window.tabMenuTest.files = files;
|
||||
let sequence = 0;
|
||||
const callbacks = new Map(), listeners = new Map();
|
||||
window.tabMenuTest.change = (path, text) => { files.set(path, text); callbacks.get(listeners.get("workspace-event"))?.({ event: "workspace-event", id: 1, payload: { root, kind: "modify", paths: [path] } }); };
|
||||
window.tabMenuTest.writes = [];
|
||||
window.spellingTest = { commands: [], emit: payload => callbacks.get(listeners.get("spelling-menu"))?.({ event: "spelling-menu", id: 1, payload }) };
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: "main" }, currentWebview: { label: "main" } },
|
||||
transformCallback: callback => { callbacks.set(++sequence, callback); return sequence; }, unregisterCallback: id => callbacks.delete(id),
|
||||
invoke: async (command, args = {}) => {
|
||||
if (command === "plugin:event|listen") { listeners.set(args.event, args.handler); return ++sequence; }
|
||||
if (command === "plugin:event|unlisten") return;
|
||||
if (command.startsWith("spelling_menu_")) { window.spellingTest.commands.push({ method: command, ...args }); return; }
|
||||
if (command === "spelling_suggestions") return { language: "en-US", words: ["Corrected"], misspelled: args.word === "Original" };
|
||||
if (command === "workspace_last_path") return root;
|
||||
if (command === "workspace_open") return { root, name: "tab-menu-workspace", watch_mode: "native" };
|
||||
if (command === "workspace_read") { if (!files.has(args.rel)) throw new Error("missing"); return files.get(args.rel); }
|
||||
if (command === "workspace_list") return [...(!args.rel ? [{ name: "notes", rel_path: "notes", kind: "folder" }] : []), ...[...files.keys()].filter(path => path.split("/").slice(0, -1).join("/") === (args.rel || "")).map(path => ({ name: path.split("/").at(-1), rel_path: path, kind: "file" }))];
|
||||
if (command === "workspace_search") { window.tabMenuTest.searched = args.query; return []; }
|
||||
if (command === "plugin:opener|open_url") { window.tabMenuTest.opened = args.url; return; }
|
||||
if (command === "workspace_open_default") { window.tabMenuTest.app = args.rel; return; }
|
||||
if (command === "workspace_open_window") { window.tabMenuTest.windows.push(args); return; }
|
||||
if (command === "workspace_write") { if (args.expected !== undefined && files.get(args.rel) !== args.expected) throw new Error("conflict"); files.set(args.rel, args.contents); window.tabMenuTest.writes.push(args.rel); return; }
|
||||
if (command === "workspace_rename") { files.set(args.to, files.get(args.from)); files.delete(args.from); return; }
|
||||
if (command === "workspace_abs_path") return `${root}\\${args.rel}`;
|
||||
if (command === "workspace_reveal") { window.tabMenuTest.revealed = args.rel; return; }
|
||||
if (command === "plugin:dialog|message") { window.tabMenuTest.prompts.push(args.message); return window.tabMenuTest.answer; }
|
||||
throw new Error(`Unhandled IPC: ${command}`);
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
|
||||
});
|
||||
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
const output = '.audit/document-splits';
|
||||
await mkdir(output, {recursive:true});
|
||||
const pane = path => page.locator(`[data-document-path="${path}"]`);
|
||||
const item = name => page.getByRole('menuitem',{name,exact:true});
|
||||
async function openRight(path,label) {
|
||||
const current = pane(path);
|
||||
await current.locator('.cm-content').getByText(path === 'a.md' ? 'Origin paragraph.' : 'Second paragraph.',{exact:true}).click();
|
||||
await current.locator('.cm-content').getByText(label,{exact:true}).click({button:'right'});
|
||||
await item('Open to the right').click();
|
||||
}
|
||||
async function append(path, text) {
|
||||
const target=pane(path).locator('.cm-content');
|
||||
await target.click(); await page.keyboard.press('Control+End'); await page.keyboard.type(text);
|
||||
}
|
||||
async function text(path) { return pane(path).locator('.cm-content').evaluate(async node=> { const {EditorView}=await import('/node_modules/@codemirror/view/dist/index.js'); return EditorView.findFromDOM(node).state.doc.toString(); }); }
|
||||
async function focus(path) { await pane(path).locator('.cm-content').click(); }
|
||||
try {
|
||||
await page.goto(process.env.SMOKE_URL || 'http://127.0.0.1:1420');
|
||||
await runSmoke("layout/splits", async ({ page }) => {
|
||||
const output = await outputDir("layout/splits");
|
||||
page.on("console", message => { if (message.text().includes("binding_property_non_reactive")) page.errors.push(message.text()); });
|
||||
// The checks need edits to stay unsaved; autosave runs every 5 s by default (src/lib/workspace/settings.ts:12, src/lib/layout/Workbench.svelte:1165).
|
||||
await page.addInitScript(() => localStorage.setItem("runestone.settings", JSON.stringify({ autosaveEnabled: false })));
|
||||
await mockTauri(page, {
|
||||
state: { answer: "Cancel" },
|
||||
commands: test => {
|
||||
const workspace = test.workspace({
|
||||
root: "C:\\tab-menu-workspace",
|
||||
files: {
|
||||
"a.md": "# Alpha\n\nOrigin paragraph.\n\n[[notes/b.md|Right note]]\n",
|
||||
"b.md": "# b.md\n\nOriginal text.\n\n```js\nconst answer = 42;\n```\n\n| Name | Value |\n| --- | --- |\n| Alpha | One |\n",
|
||||
"c.md": "# c.md\n\nOriginal text.\n\n```js\nconst answer = 42;\n```\n\n| Name | Value |\n| --- | --- |\n| Alpha | One |\n",
|
||||
"d.md": "# d.md\n\nOriginal text.\n\n```js\nconst answer = 42;\n```\n\n| Name | Value |\n| --- | --- |\n| Alpha | One |\n",
|
||||
"notes/b.md": "# Bravo\n\nSecond paragraph.\n\n[Relative](c.md)\n\n[[/a.md|Original note]]\n",
|
||||
"notes/c.md": "# Charlie\n\nThird paragraph.\n",
|
||||
"sample.txt": "const answer = 42;\n",
|
||||
},
|
||||
});
|
||||
Object.assign(test, { files: workspace.files, writes: [], prompts: [] });
|
||||
return {
|
||||
...workspace,
|
||||
workspace_write: args => {
|
||||
if (args.expected !== undefined && workspace.files.get(args.rel) !== args.expected) throw new Error("conflict");
|
||||
workspace.files.set(args.rel, args.contents);
|
||||
test.writes.push(args.rel);
|
||||
},
|
||||
spelling_menu_install: () => {},
|
||||
"plugin:dialog|message": args => { test.prompts.push(args.message); return test.state.answer; },
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
const pane = path => page.locator(`[data-document-path="${path}"]`);
|
||||
const item = name => page.getByRole('menuitem',{name,exact:true});
|
||||
async function openRight(path,label) {
|
||||
const current = pane(path);
|
||||
await current.locator('.cm-content').getByText(path === 'a.md' ? 'Origin paragraph.' : 'Second paragraph.',{exact:true}).click();
|
||||
await current.locator('.cm-content').getByText(label,{exact:true}).click({button:'right'});
|
||||
await item('Open to the right').click();
|
||||
}
|
||||
async function append(path, text) {
|
||||
const target=pane(path).locator('.cm-content');
|
||||
await target.click(); await page.keyboard.press('Control+End'); await page.keyboard.type(text);
|
||||
}
|
||||
async function text(path) { return pane(path).locator('.cm-content').evaluate(async node=> { const {EditorView}=await import('/node_modules/@codemirror/view/dist/index.js'); return EditorView.findFromDOM(node).state.doc.toString(); }); }
|
||||
async function focus(path) { await pane(path).locator('.cm-content').click(); }
|
||||
async function changeOnDisk(path, text) {
|
||||
await page.evaluate(([path, text]) => {
|
||||
window.__TEST__.files.set(path, text);
|
||||
window.__TEST__.emit("workspace-event", { root: "C:\\tab-menu-workspace", kind: "modify", paths: [path] });
|
||||
}, [path, text]);
|
||||
}
|
||||
await page.goto(smokeUrl);
|
||||
await page.locator('[data-tree-rel="a.md"]').click(); await pane('a.md').locator('.cm-content').waitFor();
|
||||
await append('a.md','\nLeft unsaved.');
|
||||
await openRight('a.md','Right note'); await pane('notes/b.md').locator('.cm-content').waitFor();
|
||||
assert.equal(await page.locator('.document-pane').count(),2);
|
||||
assert.match(await text('a.md'),/Left unsaved/);
|
||||
await append('notes/b.md','\nRight saved.'); await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(()=>window.tabMenuTest.writes.includes('notes/b.md'));
|
||||
assert.equal(await page.evaluate(()=>window.tabMenuTest.writes.includes('a.md')),false,'Save uses the focused right pane');
|
||||
await focus('a.md'); await page.keyboard.press('Control+s'); await page.waitForFunction(()=>window.tabMenuTest.writes.includes('a.md'));
|
||||
await page.waitForFunction(()=>window.__TEST__.writes.includes('notes/b.md'));
|
||||
assert.equal(await page.evaluate(()=>window.__TEST__.writes.includes('a.md')),false,'Save uses the focused right pane');
|
||||
await focus('a.md'); await page.keyboard.press('Control+s'); await page.waitForFunction(()=>window.__TEST__.writes.includes('a.md'));
|
||||
await pane('notes/b.md').getByRole('group',{name:'Editor layout',exact:true}).hover();
|
||||
await pane('notes/b.md').getByRole('button',{name:'IDE',exact:true}).click(); await pane('notes/b.md').locator('.monaco-editor').waitFor();
|
||||
assert.equal(await pane('a.md').locator('.cm-content').count(),1,'Changing the right mode keeps the left editor');
|
||||
await openRight('a.md','Right note');
|
||||
assert.equal(await page.locator('.document-pane').count(),2);
|
||||
await page.waitForFunction(async()=>{const {monaco}=await import('/src/lib/editor/monacoEnv.ts');return monaco.editor.getEditors().some(editor=>editor.getModel()?.uri.path.endsWith('/b.md') && editor.hasTextFocus());}); await page.keyboard.press('Control+End'); await page.keyboard.type('\nIDE edit.'); await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(()=>window.tabMenuTest.files.get('notes/b.md').includes('IDE edit.'));
|
||||
await page.waitForFunction(()=>window.__TEST__.files.get('notes/b.md').includes('IDE edit.'));
|
||||
await pane('notes/b.md').getByRole('group',{name:'Editor layout',exact:true}).hover();
|
||||
await pane('notes/b.md').getByRole('button',{name:'Writer',exact:true}).click(); await pane('notes/b.md').locator('.cm-content').waitFor();
|
||||
assert.match(await text('notes/b.md'),/IDE edit/);
|
||||
@@ -123,7 +108,7 @@ try {
|
||||
assert.match(await text('notes/c.md'),/Charlie/,'Relative links use the pane document folder');
|
||||
await pane('notes/c.md').getByRole('button',{name:'Close split',exact:true}).click();
|
||||
assert.equal(await page.locator('.document-pane').count(),2);
|
||||
await page.evaluate(()=>window.tabMenuTest.change('notes/b.md','# Bravo disk\n\nExternal update.\n'));
|
||||
await changeOnDisk('notes/b.md','# Bravo disk\n\nExternal update.\n');
|
||||
await pane('notes/b.md').getByRole('alert').waitFor();
|
||||
assert.equal(await pane('a.md').getByRole('alert').count(),0);
|
||||
assert.match(await text('notes/b.md'),/Right still unsaved/,'A disk conflict preserves the right pane edits');
|
||||
@@ -140,21 +125,20 @@ try {
|
||||
await page.screenshot({path:`${output}/stacked-${theme}.png`});
|
||||
}
|
||||
await append('notes/b.md','\nNarrow edit.'); await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(()=>window.tabMenuTest.files.get('notes/b.md').includes('Narrow edit.'));
|
||||
await page.waitForFunction(()=>window.__TEST__.files.get('notes/b.md').includes('Narrow edit.'));
|
||||
await pane('notes/b.md').getByRole('button',{name:'Close split',exact:true}).click();
|
||||
await append('a.md','\nAfter closing split.'); await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(()=>window.tabMenuTest.files.get('a.md').includes('After closing split.'));
|
||||
await page.waitForFunction(()=>window.__TEST__.files.get('a.md').includes('After closing split.'));
|
||||
await page.setViewportSize({width:1440,height:1000});
|
||||
await openRight('a.md','Right note'); await pane('notes/b.md').locator('.cm-content').waitFor();
|
||||
await append('notes/b.md','\nClose guard.');
|
||||
await page.keyboard.press('Control+w');
|
||||
await page.waitForFunction(()=>window.tabMenuTest.prompts.length>0);
|
||||
await page.waitForFunction(()=>window.__TEST__.prompts.length>0);
|
||||
assert.equal(await pane('notes/b.md').count(),1,'Cancel keeps the dirty split open');
|
||||
await page.keyboard.press('Control+s'); await page.waitForFunction(()=>window.tabMenuTest.files.get('notes/b.md').includes('Close guard.'));
|
||||
await page.keyboard.press('Control+s'); await page.waitForFunction(()=>window.__TEST__.files.get('notes/b.md').includes('Close guard.'));
|
||||
await page.keyboard.press('Control+w'); await pane('notes/b.md').waitFor({state:'detached'});
|
||||
await focus('a.md'); await append('a.md','\nOther tab closed.'); await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(()=>window.tabMenuTest.files.get('a.md').includes('Other tab closed.'));
|
||||
await page.waitForFunction(()=>window.__TEST__.files.get('a.md').includes('Other tab closed.'));
|
||||
assert.equal(await page.evaluate(async()=>{const {monaco}=await import('/src/lib/editor/monacoEnv.ts');return monaco.editor.getModels().some(model=>model.uri.path.endsWith('/b.md'));}),false,'Closing the tab releases only its model');
|
||||
assert.deepEqual(errors,[]);
|
||||
console.log(JSON.stringify({passed:['independent Writer/IDE/Reading modes','dirty close cancellation and model release','independent edits and saves','per-pane selections','focus existing duplicate target','closing split retains unsaved tabs and models','nested relative link origin','per-pane conflict resolution','narrow layout and save','light/dark screenshots'],nativeDesktop:'not tested'},null,2));
|
||||
} catch(error) { await page.screenshot({path:`${output}/failure.png`}); console.log(await page.locator('.status,.rs-menu').allTextContents()); throw error; } finally { await browser.close(); }
|
||||
}, { timeout: 15000 });
|
||||
|
||||
@@ -1,51 +1,36 @@
|
||||
// Run against `pnpm dev`. PLAYWRIGHT_MODULE may point to a shared installation.
|
||||
import { createRequire } from "node:module";
|
||||
// Custom window controls: maximize, restore, minimize, the terminal close guard, the keyboard tooltip, and the header at 1400 and 880 px.
|
||||
// @requires plugin:terminal plugin:table-formulas
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const page = await browser.newPage({ viewport: { width: 1400, height: 900 } });
|
||||
const errors = [];
|
||||
page.on("pageerror", error => errors.push(error.message));
|
||||
await page.addInitScript(() => {
|
||||
window.isTauri = true;
|
||||
const callbacks = new Map(), listeners = new Map();
|
||||
let sequence = 0;
|
||||
const state = { maximized: false, confirm: "Cancel", calls: [] };
|
||||
const emit = (event, payload) => {
|
||||
for (const id of listeners.get(event) || []) callbacks.get(id)?.({ event, id, payload });
|
||||
};
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: "main" }, currentWebview: { label: "main" } },
|
||||
transformCallback: callback => { const id = ++sequence; callbacks.set(id, callback); return id; },
|
||||
unregisterCallback: id => callbacks.delete(id),
|
||||
invoke: async (command, args = {}) => {
|
||||
state.calls.push(command);
|
||||
if (command === "plugin:event|listen") {
|
||||
const list = listeners.get(args.event) || []; list.push(args.handler); listeners.set(args.event, list); return args.handler;
|
||||
}
|
||||
if (command === "plugin:event|unlisten") { callbacks.delete(args.eventId); return; }
|
||||
if (command === "workspace_last_path") return null;
|
||||
if (command === "plugin:window|is_maximized") return state.maximized;
|
||||
if (command === "plugin:window|toggle_maximize") { state.maximized = !state.maximized; emit("tauri://resize", { width: 1400, height: 900 }); return; }
|
||||
if (command === "plugin:window|minimize" || command === "plugin:window|destroy") return;
|
||||
if (command === "plugin:window|close") { emit("tauri://close-requested"); return; }
|
||||
if (command === "plugin:dialog|message") return state.confirm;
|
||||
throw new Error(`Unhandled IPC: ${command}`);
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: (_event, id) => callbacks.delete(id) };
|
||||
window.__TEST__ = { state, emit };
|
||||
});
|
||||
try {
|
||||
const config = JSON.parse(await readFile(new URL("../../../src-tauri/tauri.conf.json", import.meta.url), "utf8"));
|
||||
import path from "node:path";
|
||||
import { mockTauri, outputDir, repoRoot, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
import { mockFeaturePlugins } from "../_harness/pluginMocks.mjs";
|
||||
|
||||
await runSmoke("layout/windowControls", async ({ page }) => {
|
||||
const output = await outputDir("layout/windowControls");
|
||||
await mockTauri(page, {
|
||||
state: { maximized: false, confirm: "Cancel" },
|
||||
commands: test => ({
|
||||
workspace_last_path: () => null,
|
||||
"plugin:window|is_maximized": () => test.state.maximized,
|
||||
"plugin:window|toggle_maximize": () => { test.state.maximized = !test.state.maximized; test.emit("tauri://resize", { width: 1400, height: 900 }); },
|
||||
"plugin:window|minimize": () => {},
|
||||
"plugin:window|destroy": () => {},
|
||||
"plugin:window|close": () => { test.emit("tauri://close-requested"); },
|
||||
"plugin:dialog|message": () => test.state.confirm,
|
||||
}),
|
||||
});
|
||||
// The Terminal button belongs to the terminal plug-in (src/lib/layout/Workbench.svelte:1305).
|
||||
await mockFeaturePlugins(page);
|
||||
const called = command => page.evaluate(command => window.__TEST__.calls.some(call => call.command === command), command);
|
||||
|
||||
const config = JSON.parse(await readFile(path.join(repoRoot, "src-tauri/tauri.conf.json"), "utf8"));
|
||||
assert.equal(config.app.windows[0].decorations, false);
|
||||
const capability = JSON.parse(await readFile(new URL("../../../src-tauri/capabilities/default.json", import.meta.url), "utf8"));
|
||||
const capability = JSON.parse(await readFile(path.join(repoRoot, "src-tauri/capabilities/default.json"), "utf8"));
|
||||
for (const permission of ["close", "minimize", "toggle-maximize", "start-dragging"]) {
|
||||
assert.ok(capability.permissions.includes(`core:window:allow-${permission}`));
|
||||
}
|
||||
await page.goto(process.env.SMOKE_URL || "http://localhost:1420");
|
||||
await page.goto(smokeUrl);
|
||||
await page.getByRole("button", { name: "Maximize window", exact: true }).click();
|
||||
await page.getByRole("button", { name: "Restore window", exact: true }).waitFor();
|
||||
await page.getByRole("button", { name: "Restore window", exact: true }).click();
|
||||
@@ -54,17 +39,17 @@ try {
|
||||
await page.evaluate(() => { window.__TEST__.state.maximized = true; window.__TEST__.emit("tauri://resize", { width: 1920, height: 1080 }); });
|
||||
await page.getByRole("button", { name: "Restore window", exact: true }).waitFor();
|
||||
await page.getByRole("button", { name: "Minimize window", exact: true }).click();
|
||||
assert.ok(await page.evaluate(() => window.__TEST__.state.calls.includes("plugin:window|minimize")));
|
||||
assert.ok(await called("plugin:window|minimize"));
|
||||
await page.getByRole("button", { name: "Close window", exact: true }).focus();
|
||||
await page.getByRole("tooltip", { name: "Close window", exact: true }).waitFor();
|
||||
// Opening the terminal engages the existing close guard; cancellation must not destroy the window.
|
||||
await page.getByRole("button", { name: "Terminal", exact: true }).click();
|
||||
await page.getByRole("button", { name: "Close window", exact: true }).click();
|
||||
await page.waitForFunction(() => window.__TEST__.state.calls.includes("plugin:dialog|message"));
|
||||
assert.equal(await page.evaluate(() => window.__TEST__.state.calls.includes("plugin:window|destroy")), false);
|
||||
await page.waitForFunction(() => window.__TEST__.calls.some(call => call.command === "plugin:dialog|message"));
|
||||
assert.equal(await called("plugin:window|destroy"), false);
|
||||
await page.evaluate(() => window.__TEST__.state.confirm = "Ok");
|
||||
await page.getByRole("button", { name: "Close window", exact: true }).click();
|
||||
await page.waitForFunction(() => window.__TEST__.state.calls.includes("plugin:window|destroy"));
|
||||
await page.waitForFunction(() => window.__TEST__.calls.some(call => call.command === "plugin:window|destroy"));
|
||||
await page.getByRole("button", { name: "Terminal", exact: true }).click();
|
||||
for (const width of [1400, 880]) {
|
||||
await page.setViewportSize({ width, height: 900 });
|
||||
@@ -77,8 +62,7 @@ try {
|
||||
assert.equal(layout.top, 0);
|
||||
assert.ok(layout.fits);
|
||||
assert.ok(layout.drag >= 40);
|
||||
await page.screenshot({ path: `.audit/window-controls-${width}.png` });
|
||||
await page.screenshot({ path: path.join(output, `window-controls-${width}.png`) });
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
console.log("Window controls smoke passed: actions, restore state, close guard, keyboard tooltip, and 1400/880px layouts.");
|
||||
} finally { await browser.close(); }
|
||||
}, { viewport: { width: 1400, height: 900 }, timeout: 30000 });
|
||||
|
||||
@@ -1,106 +1,77 @@
|
||||
// Core workbench: source edits and history, agent refresh and conflicts, persistent terminals, Reading and Mermaid previews, the live Writer, tables and their menus, and narrow layouts.
|
||||
// @requires plugin:terminal plugin:table-formulas
|
||||
import { mockFeaturePlugins } from "../_harness/pluginMocks.mjs";
|
||||
// Run against `pnpm dev`. PLAYWRIGHT_MODULE may point to a shared installation.
|
||||
import { createRequire } from "node:module";
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
const require = createRequire(import.meta.url);
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
|
||||
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
|
||||
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
||||
page.setDefaultTimeout(10000);
|
||||
const errors = [];
|
||||
const showcase = await readFile(new URL("../../../fixtures/reader-showcase.md", import.meta.url), "utf8");
|
||||
page.on("console", message => { if (message.type() === "error" || message.type() === "warning") console.log(message.type(), message.text()); });
|
||||
page.on("pageerror", error => errors.push(error.message));
|
||||
await page.addInitScript(() => {
|
||||
window.isTauri = true;
|
||||
const root = "C:\\smoke-workspace";
|
||||
const files = new Map([
|
||||
["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"],
|
||||
]);
|
||||
const callbacks = new Map();
|
||||
const listeners = new Map();
|
||||
let sequence = 0;
|
||||
const calls = [];
|
||||
const emit = (event, payload) => {
|
||||
for (const id of listeners.get(event) || []) callbacks.get(id)?.({ event, id, payload });
|
||||
};
|
||||
window.__TAURI_INTERNALS__ = {
|
||||
metadata: { currentWindow: { label: "main" }, currentWebview: { label: "main" } },
|
||||
transformCallback: callback => { const id = ++sequence; callbacks.set(id, callback); return id; },
|
||||
unregisterCallback: id => callbacks.delete(id),
|
||||
invoke: async (command, args = {}) => {
|
||||
calls.push({ command, args });
|
||||
if (command === "plugin:event|listen") {
|
||||
const list = listeners.get(args.event) || []; list.push(args.handler); listeners.set(args.event, list); return args.handler;
|
||||
}
|
||||
if (command === "plugin:event|unlisten") { callbacks.delete(args.eventId); return; }
|
||||
if (command === "workspace_last_path") return root;
|
||||
if (command === "workspace_open") return { root, name: "smoke-workspace", watch_mode: "native" };
|
||||
if (command === "workspace_read") { if (!files.has(args.rel)) throw new Error("missing"); return files.get(args.rel); }
|
||||
if (command === "workspace_write") {
|
||||
if (args.expected !== undefined && files.get(args.rel) !== args.expected) throw new Error("Save blocked: file changed on disk");
|
||||
files.set(args.rel, args.contents); emit("workspace-event", { root, kind: "modify", paths: [args.rel] }); return;
|
||||
}
|
||||
if (command === "workspace_list") {
|
||||
const prefix = args.rel ? args.rel + "/" : "";
|
||||
const entries = new Map();
|
||||
for (const path of files.keys()) {
|
||||
if (!path.startsWith(prefix) || path.startsWith(".runestone/")) continue;
|
||||
const tail = path.slice(prefix.length); const name = tail.split("/")[0];
|
||||
entries.set(name, { name, rel_path: prefix + name, kind: tail.includes("/") ? "folder" : "file" });
|
||||
}
|
||||
return [...entries.values()];
|
||||
}
|
||||
if (command === "workspace_create") { if (files.has(args.rel)) throw new Error("exists"); files.set(args.rel, ""); return; }
|
||||
if (command === "workspace_search") return [];
|
||||
if (command === "pty_profiles") return [{ id: "powershell", title: "PowerShell", kind: "powershell" }];
|
||||
if (command === "pty_open") {
|
||||
const data = [...new TextEncoder().encode("READY 🪨\r\n\x1b[6n")];
|
||||
emit("pty-data", { id: args.id, data: data.slice(0, 8) });
|
||||
emit("pty-data", { id: args.id, data: data.slice(8) });
|
||||
await new Promise(resolve => setTimeout(resolve, 50));
|
||||
return;
|
||||
}
|
||||
if (command.startsWith("pty_")) return;
|
||||
if (command === "plugin:dialog|message") return "Cancel";
|
||||
throw new Error(`Unhandled IPC: ${command}`);
|
||||
import path from "node:path";
|
||||
import { mockTauri, outputDir, repoRoot, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
import { mockFeaturePlugins } from "../_harness/pluginMocks.mjs";
|
||||
|
||||
await runSmoke("layout/workbench", async ({ page }) => {
|
||||
const output = await outputDir("layout/workbench");
|
||||
const showcase = await readFile(path.join(repoRoot, "fixtures/reader-showcase.md"), "utf8");
|
||||
await mockTauri(page, {
|
||||
commands: test => {
|
||||
const workspace = test.workspace({
|
||||
root: "C:\\smoke-workspace",
|
||||
writeEvents: true,
|
||||
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",
|
||||
},
|
||||
});
|
||||
Object.assign(test, { files: workspace.files, root: workspace.root });
|
||||
// The terminal plug-in opens shells through these commands.
|
||||
const pty = {};
|
||||
for (const command of ["pty_write", "pty_resize", "pty_close"]) pty[command] = () => {};
|
||||
return {
|
||||
...workspace,
|
||||
...pty,
|
||||
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);
|
||||
},
|
||||
workspace_search: () => [],
|
||||
pty_profiles: () => [{ id: "powershell", title: "PowerShell", kind: "powershell" }],
|
||||
pty_open: async args => {
|
||||
const data = [...new TextEncoder().encode("READY 🪨\r\n\x1b[6n")];
|
||||
test.emit("pty-data", { id: args.id, data: data.slice(0, 8) });
|
||||
test.emit("pty-data", { id: args.id, data: data.slice(8) });
|
||||
await new Promise(resolve => setTimeout(resolve, 50));
|
||||
},
|
||||
"plugin:dialog|message": () => "Cancel",
|
||||
};
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: (_event, id) => callbacks.delete(id) };
|
||||
window.__TEST__ = { files, calls, emit, root };
|
||||
});
|
||||
await mockFeaturePlugins(page);
|
||||
|
||||
|
||||
async function quickOpen(name) {
|
||||
await page.keyboard.press("Control+p");
|
||||
await page.getByRole("textbox", { name: "Find a file" }).fill(name);
|
||||
await page.getByRole("dialog").getByRole("button").filter({ hasText: name }).first().click();
|
||||
if (await page.getByRole("button", { name: "Switch to IDE layout (Ctrl E)", exact: true }).count()) {
|
||||
await page.getByRole("button", { name: "Switch to IDE layout (Ctrl E)", exact: true }).click();
|
||||
}
|
||||
await page.locator(".monaco-editor textarea").waitFor();
|
||||
}
|
||||
async function contents() {
|
||||
return page.evaluate(async () => {
|
||||
const { monaco } = await import("/src/lib/editor/monacoEnv.ts");
|
||||
return monaco.editor.getEditors().find(editor => editor.getDomNode()?.isConnected)?.getValue();
|
||||
});
|
||||
}
|
||||
async function waitForText(text) {
|
||||
await page.evaluate(async () => { window.__MONACO__ = (await import("/src/lib/editor/monacoEnv.ts")).monaco; });
|
||||
await page.waitForFunction(expected => window.__MONACO__.editor.getEditors().some(editor => editor.getDomNode()?.isConnected && editor.getValue() === expected), text);
|
||||
}
|
||||
async function focusEditor() {
|
||||
await page.locator(".monaco-host .view-lines").click({position:{x:120,y:12}});
|
||||
}
|
||||
await mockFeaturePlugins(page);
|
||||
|
||||
try {
|
||||
await page.goto(process.env.SMOKE_URL || "http://127.0.0.1:1420");
|
||||
// Choose a mode from a compact mode switcher, such as "Editor layout" or "Document view".
|
||||
async function mode(group, value) {
|
||||
await page.getByRole("group", { name: group, exact: true }).hover();
|
||||
await page.getByRole("button", { name: value, exact: true }).click();
|
||||
}
|
||||
async function quickOpen(name) {
|
||||
await page.keyboard.press("Control+p");
|
||||
await page.getByRole("textbox", { name: "Find a file" }).fill(name);
|
||||
await page.getByRole("dialog").getByRole("button").filter({ hasText: name }).first().click();
|
||||
await mode("Editor layout", "IDE");
|
||||
await page.locator(".monaco-editor textarea").waitFor();
|
||||
}
|
||||
async function contents() {
|
||||
return page.evaluate(async () => {
|
||||
const { monaco } = await import("/src/lib/editor/monacoEnv.ts");
|
||||
return monaco.editor.getEditors().find(editor => editor.getDomNode()?.isConnected)?.getValue();
|
||||
});
|
||||
}
|
||||
async function waitForText(text) {
|
||||
await page.evaluate(async () => { window.__MONACO__ = (await import("/src/lib/editor/monacoEnv.ts")).monaco; });
|
||||
await page.waitForFunction(expected => window.__MONACO__.editor.getEditors().some(editor => editor.getDomNode()?.isConnected && editor.getValue() === expected), text);
|
||||
}
|
||||
async function focusEditor() {
|
||||
await page.locator(".monaco-host .view-lines").click({position:{x:120,y:12}});
|
||||
}
|
||||
|
||||
await page.goto(smokeUrl);
|
||||
await page.getByText("smoke-workspace", { exact: true }).waitFor();
|
||||
await quickOpen("welcome.md");
|
||||
const original = await contents();
|
||||
@@ -119,7 +90,7 @@ try {
|
||||
await page.keyboard.press("Control+s");
|
||||
await page.waitForFunction(expected => window.__TEST__.files.get("notes/welcome.md") === expected, original + "Added in source.");
|
||||
|
||||
await page.getByRole("button", { name: "Split", exact: true }).click();
|
||||
await mode("Document view", "Split");
|
||||
await page.locator(".md-page h1").first().waitFor();
|
||||
assert.ok(await page.locator(".monaco-host").isVisible());
|
||||
await page.evaluate(() => {
|
||||
@@ -143,8 +114,8 @@ try {
|
||||
await page.getByRole("button", { name: "Terminal", exact: true }).click();
|
||||
await page.waitForFunction(() => window.__TEST__.calls.some(c => c.command === "pty_open"));
|
||||
await page.waitForFunction(() => window.__TEST__.calls.some(c => c.command === "pty_write" && /\x1b\[\d+;\d+R/.test(c.args.data)));
|
||||
await page.screenshot({ path: ".audit/core-rebuild-terminal.png" });
|
||||
await page.getByRole("button", { name: "Hide terminal (sessions keep running)" }).click();
|
||||
await page.screenshot({ path: path.join(output, "core-rebuild-terminal.png") });
|
||||
await page.getByRole("button", { name: "Terminal", exact: true }).click();
|
||||
assert.equal(await page.evaluate(() => window.__TEST__.calls.filter(c => c.command === "pty_close").length), 0);
|
||||
await page.getByRole("button", { name: "Terminal", exact: true }).click();
|
||||
assert.equal(await page.evaluate(() => window.__TEST__.calls.filter(c => c.command === "pty_open").length), 1);
|
||||
@@ -152,24 +123,31 @@ try {
|
||||
await page.waitForFunction(() => window.__TEST__.calls.filter(c => c.command === "pty_open").length === 2);
|
||||
await page.getByRole("button", { name: "Kill terminal", exact: true }).first().click();
|
||||
await page.waitForFunction(() => window.__TEST__.calls.filter(c => c.command === "pty_close").length === 1);
|
||||
await page.getByRole("button", { name: "Hide terminal (sessions keep running)" }).click();
|
||||
await page.getByRole("button", { name: "Terminal", exact: true }).click();
|
||||
await page.keyboard.press("Control+n");
|
||||
await page.getByLabel("New file path relative to the workspace").fill("notes/new-note.md");
|
||||
await page.getByRole("button", { name: "Continue", exact: true }).click();
|
||||
await page.getByRole("tab", { name: "new-note.md", exact: true }).waitFor();
|
||||
await page.screenshot({ path: ".audit/core-rebuild.png" });
|
||||
// A new note starts in its filename field, which keeps its own keys (src/lib/editor/LiveWriter.svelte:381, src/lib/editor/noteTitle.ts:80).
|
||||
await page.getByRole("textbox", { name: "Note filename", exact: true }).waitFor();
|
||||
await page.screenshot({ path: path.join(output, "core-rebuild.png") });
|
||||
await page.keyboard.press("Escape");
|
||||
|
||||
await page.evaluate(text => {
|
||||
window.__TEST__.files.set("reader-showcase.md", text);
|
||||
window.__TEST__.emit("workspace-event", { root: window.__TEST__.root, kind: "create", paths: ["reader-showcase.md"] });
|
||||
}, showcase);
|
||||
await quickOpen("reader-showcase.md");
|
||||
const read = page.getByRole("button", { name: "Read", exact: true });
|
||||
// The Read mode is a compact switcher button; its tooltip is a decorative child (src/lib/ui/ModeSwitcher.svelte:108).
|
||||
const documentView = page.getByRole("group", { name: "Document view", exact: true });
|
||||
const read = documentView.locator('button[aria-label="Read"]');
|
||||
const readTip = read.locator(".tooltip");
|
||||
assert.equal(await read.innerText(), "");
|
||||
assert.equal(await read.locator("svg").count(), 1);
|
||||
await documentView.hover();
|
||||
await read.hover();
|
||||
await page.getByRole("tooltip", { name: "Read", exact: true }).waitFor({ state: "visible" });
|
||||
const tip = await page.getByRole("tooltip", { name: "Read", exact: true }).boundingBox();
|
||||
await readTip.waitFor({ state: "visible" });
|
||||
const tip = await readTip.boundingBox();
|
||||
assert.ok(tip.x >= 0 && tip.x + tip.width <= 1440);
|
||||
await read.click();
|
||||
assert.equal(await read.getAttribute("aria-pressed"), "true");
|
||||
@@ -184,37 +162,38 @@ try {
|
||||
const surface = await page.locator(".reading").boundingBox();
|
||||
assert.ok(surface.width <= 741);
|
||||
await page.mouse.move(700, 980);
|
||||
await page.screenshot({ path: ".audit/reader-mode.png" });
|
||||
await page.screenshot({ path: path.join(output, "reader-mode.png") });
|
||||
await page.locator(".md-table-scroll").scrollIntoViewIfNeeded();
|
||||
await page.getByRole("button", { name: "Copy code", exact: true }).click();
|
||||
await page.getByRole("button", { name: "Copied", exact: true }).waitFor();
|
||||
await page.screenshot({ path: ".audit/reader-details.png" });
|
||||
await page.screenshot({ path: path.join(output, "reader-details.png") });
|
||||
|
||||
await page.setViewportSize({ width: 1000, height: 900 });
|
||||
await page.locator(".md-page").evaluate(element => { element.scrollTop = 0; });
|
||||
await page.screenshot({ path: ".audit/reader-narrow.png" });
|
||||
await page.screenshot({ path: path.join(output, "reader-narrow.png") });
|
||||
assert.ok(await page.locator(".md-page").evaluate(element => element.scrollWidth <= element.clientWidth + 1));
|
||||
await page.getByRole("button", { name: "Split", exact: true }).click();
|
||||
await mode("Document view", "Split");
|
||||
await page.waitForFunction(() => {
|
||||
const host = document.querySelector(".monaco-host");
|
||||
const rendered = host?.querySelector(".monaco-editor");
|
||||
return rendered && Math.abs(host.clientWidth - rendered.clientWidth) < 2;
|
||||
});
|
||||
assert.equal(await page.locator(".body.split").evaluate(element => getComputedStyle(element).flexDirection), "column");
|
||||
await page.screenshot({ path: ".audit/reader-split.png" });
|
||||
await page.screenshot({ path: path.join(output, "reader-split.png") });
|
||||
assert.ok(await page.locator(".md-page").evaluate(element => element.scrollWidth <= element.clientWidth + 1));
|
||||
|
||||
await page.setViewportSize({ width: 1440, height: 1000 });
|
||||
await page.waitForFunction(() => getComputedStyle(document.querySelector(".body.split")).flexDirection === "row");
|
||||
await page.screenshot({ path: ".audit/reader-split-wide.png" });
|
||||
await page.screenshot({ path: path.join(output, "reader-split-wide.png") });
|
||||
|
||||
await page.getByRole("button", { name: "Edit", exact: true }).click();
|
||||
await mode("Document view", "Edit");
|
||||
assert.equal(await contents(), showcase);
|
||||
assert.equal(await page.evaluate(() => window.__TEST__.files.get("reader-showcase.md")), showcase);
|
||||
await page.getByRole("button", { name: "Read", exact: true }).focus();
|
||||
await page.getByRole("tooltip", { name: "Read", exact: true }).waitFor({ state: "visible" });
|
||||
await documentView.hover();
|
||||
await read.focus();
|
||||
await readTip.waitFor({ state: "visible" });
|
||||
await page.keyboard.press("Escape");
|
||||
await page.getByRole("tooltip", { name: "Read", exact: true }).waitFor({ state: "hidden" });
|
||||
await readTip.waitFor({ state: "hidden" });
|
||||
|
||||
// Continuous live Markdown: only active lines reveal source; checkboxes
|
||||
// remain inline and update the original file without HTML serialization.
|
||||
@@ -224,7 +203,7 @@ try {
|
||||
window.__TEST__.emit("workspace-event", { root: window.__TEST__.root, kind: "create", paths: ["writing.md"] });
|
||||
}, writingSource);
|
||||
await quickOpen("writing.md");
|
||||
await page.getByRole("button", { name: "Switch to writing layout (Ctrl E)", exact: true }).click();
|
||||
await mode("Editor layout", "Writer");
|
||||
const writer = page.getByRole("textbox", { name: "Writing editor", exact: true });
|
||||
await writer.waitFor();
|
||||
assert.equal(await page.locator('.live-writer [contenteditable="true"]').count(), 1);
|
||||
@@ -245,12 +224,12 @@ try {
|
||||
await page.keyboard.press("Control+y");
|
||||
await page.keyboard.press("Control+s");
|
||||
await page.waitForFunction(text => window.__TEST__.files.get("writing.md") === text, editedSource);
|
||||
await page.getByRole("button", { name: "Switch to IDE layout (Ctrl E)", exact: true }).click();
|
||||
await mode("Editor layout", "IDE");
|
||||
await waitForText(editedSource);
|
||||
await focusEditor();
|
||||
await page.keyboard.press("Control+z");
|
||||
await waitForText(writingSource);
|
||||
await page.getByRole("button", { name: "Switch to writing layout (Ctrl E)", exact: true }).click();
|
||||
await mode("Editor layout", "Writer");
|
||||
await writer.waitFor();
|
||||
await paragraph.click();
|
||||
await page.keyboard.press("End");
|
||||
@@ -297,9 +276,10 @@ try {
|
||||
assert.equal(await task.locator('.writer-completed').evaluate(el => getComputedStyle(el).textDecorationLine), 'line-through');
|
||||
await page.keyboard.press("Control+s");
|
||||
await page.waitForFunction(() => window.__TEST__.files.get("writing.md").includes('- [x] Ship draft'));
|
||||
// Task markers stay rendered until the cursor reaches them (src/lib/editor/liveMarkdown.ts:262-268).
|
||||
await task.locator('.writer-completed').click();
|
||||
await page.locator('.live-writer .cm-line').filter({ hasText: '- [x] Ship draft' }).waitFor();
|
||||
await page.keyboard.press("Home");
|
||||
await page.locator('.live-writer .cm-line').filter({ hasText: '- [x] Ship draft' }).waitFor();
|
||||
await page.keyboard.press("Shift+End");
|
||||
await page.keyboard.type('- [ ] Revised task');
|
||||
await page.keyboard.press("ArrowUp");
|
||||
@@ -307,7 +287,7 @@ try {
|
||||
await page.keyboard.press("Control+s");
|
||||
await page.waitForFunction(() => window.__TEST__.files.get("writing.md").includes('- [ ] Revised task'));
|
||||
await page.locator(".live-writer .md-diagram svg").waitFor();
|
||||
await page.screenshot({ path: ".audit/writing-continuous.png" });
|
||||
await page.screenshot({ path: path.join(output, "writing-continuous.png") });
|
||||
await page.setViewportSize({ width: 1000, height: 900 });
|
||||
assert.ok(await page.locator(".cm-scroller").evaluate(el => el.scrollWidth <= el.clientWidth + 1));
|
||||
await page.evaluate(() => {
|
||||
@@ -315,7 +295,7 @@ try {
|
||||
window.__TEST__.emit("workspace-event", { root: window.__TEST__.root, kind: "create", paths: ["crlf.md"] });
|
||||
});
|
||||
await quickOpen("crlf.md");
|
||||
await page.getByRole("button", { name: "Switch to writing layout (Ctrl E)", exact: true }).click();
|
||||
await mode("Editor layout", "Writer");
|
||||
await page.locator(".live-writer .cm-line").filter({ hasText: "A paragraph." }).click();
|
||||
await page.keyboard.press("Home");
|
||||
await page.keyboard.type("Changed ");
|
||||
@@ -324,6 +304,8 @@ try {
|
||||
await page.keyboard.press("Control+n");
|
||||
await page.getByLabel("New file path relative to the workspace").fill("blank.md");
|
||||
await page.getByRole("button", { name: "Continue", exact: true }).click();
|
||||
// Enter keeps the new note's filename and moves to its body (src/lib/editor/noteTitle.ts:57, 83).
|
||||
await page.getByRole("textbox", { name: "Note filename", exact: true }).press("Enter");
|
||||
await writer.waitFor();
|
||||
await page.keyboard.type("One");
|
||||
await page.keyboard.press("Enter");
|
||||
@@ -342,7 +324,8 @@ try {
|
||||
await page.keyboard.press("Control+s");
|
||||
await page.waitForFunction(() => window.__TEST__.files.get("blank.md").replace(/\r\n/g, "\n") === "One\nTwo\nThree");
|
||||
await page.keyboard.press("Control+f");
|
||||
await page.getByRole("textbox", { name: "Find", exact: true }).fill("Two");
|
||||
// The find field is labelled "Find in document" (src/lib/editor/FindPanel.svelte:60).
|
||||
await page.getByRole("textbox", { name: "Find in document", exact: true }).fill("Two");
|
||||
await page.keyboard.press("Escape");
|
||||
await page.keyboard.press("Control+a");
|
||||
await page.keyboard.type("- [ ] First task");
|
||||
@@ -365,7 +348,7 @@ try {
|
||||
}, tableSource);
|
||||
await page.setViewportSize({ width: 1440, height: 1000 });
|
||||
await quickOpen("tables.md");
|
||||
await page.getByRole("button", { name: "Switch to writing layout (Ctrl E)", exact: true }).click();
|
||||
await mode("Editor layout", "Writer");
|
||||
const table = page.locator('.live-writer table');
|
||||
await table.waitFor();
|
||||
assert.equal(await page.locator('.live-writer .document-title').innerText(), 'tables');
|
||||
@@ -381,7 +364,11 @@ try {
|
||||
assert.equal(await table.locator('tbody tr').count(), 2);
|
||||
assert.equal(await table.locator('br').count(), 4);
|
||||
assert.ok(!(await table.innerText()).includes('<br>'));
|
||||
assert.ok(await table.locator('th').evaluateAll(cells => cells.every(cell => cell.getBoundingClientRect().width >= 100)));
|
||||
// Columns keep the 3rem minimum width (src/app.css:289; reduced from 8rem in 909894b).
|
||||
assert.ok(await table.locator('th').evaluateAll(cells => {
|
||||
const minimum = 3 * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
||||
return cells.every(cell => cell.getBoundingClientRect().width >= minimum - 0.5);
|
||||
}));
|
||||
assert.ok(await table.locator('td').evaluateAll(cells => cells.every(cell => getComputedStyle(cell).verticalAlign === 'top')));
|
||||
assert.ok(await page.locator('.cm-scroller').evaluate(el => el.scrollWidth <= el.clientWidth + 1));
|
||||
const addColumn = page.getByRole('button', { name: 'Add column to the right', exact: true });
|
||||
@@ -393,12 +380,12 @@ try {
|
||||
await page.waitForFunction(() => [...document.querySelectorAll('.table-add')].every(button => getComputedStyle(button).opacity === '0'));
|
||||
await addColumn.hover();
|
||||
await page.waitForFunction(() => getComputedStyle(document.querySelector('.table-add-column')).opacity === '1');
|
||||
await page.screenshot({ path: '.audit/writing-table-column.png' });
|
||||
await page.screenshot({ path: path.join(output, 'writing-table-column.png') });
|
||||
await addColumn.click();
|
||||
await page.waitForFunction(() => document.querySelectorAll('.live-writer th').length === 6);
|
||||
await addRow.hover();
|
||||
await page.waitForFunction(() => getComputedStyle(document.querySelector('.table-add-row')).opacity === '1');
|
||||
await page.screenshot({ path: '.audit/writing-table-row.png' });
|
||||
await page.screenshot({ path: path.join(output, 'writing-table-row.png') });
|
||||
await addRow.click();
|
||||
await page.waitForFunction(() => document.querySelectorAll('.live-writer tbody tr').length === 3);
|
||||
await page.keyboard.press('Control+s');
|
||||
@@ -426,12 +413,13 @@ try {
|
||||
await table.locator('tbody tr').first().locator('td').nth(4).click();
|
||||
assert.equal(await cellEditor.locator('br:not(.ProseMirror-trailingBreak)').count(), 3);
|
||||
await page.keyboard.press('Control+End');
|
||||
await page.keyboard.press('Enter');
|
||||
// Shift+Enter adds a line break in a cell; Enter moves to the next row (src/lib/editor/tableControls.ts:278-286).
|
||||
await page.keyboard.press('Shift+Enter');
|
||||
await page.keyboard.type('Plain | pipe and *stars*');
|
||||
await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(() => window.__TEST__.files.get('tables.md').includes('<br>Plain \\| pipe and \\*stars\\*'));
|
||||
assert.equal(await table.locator('th').count(), 6);
|
||||
await page.screenshot({ path: '.audit/writing-table-cell-edit.png' });
|
||||
await page.screenshot({ path: path.join(output, 'writing-table-cell-edit.png') });
|
||||
await page.keyboard.press('Control+z');
|
||||
await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(() => !window.__TEST__.files.get('tables.md').includes('Plain'));
|
||||
@@ -453,7 +441,7 @@ try {
|
||||
await page.keyboard.press('Escape');
|
||||
await page.setViewportSize({ width: 1000, height: 900 });
|
||||
assert.ok(await page.locator('.cm-scroller').evaluate(el => el.scrollWidth <= el.clientWidth + 1));
|
||||
await page.getByRole('button', { name: 'Read', exact: true }).click();
|
||||
await mode('Document view', 'Read');
|
||||
assert.equal(await page.locator('.md-page .document-title').innerText(), 'tables');
|
||||
assert.equal(await page.locator('.md-page table br').count(), 5);
|
||||
assert.ok(await page.locator('.md-page').evaluate(el => el.scrollWidth <= el.clientWidth + 1));
|
||||
@@ -463,14 +451,16 @@ try {
|
||||
window.__TEST__.files.set('selection-table.md', text);
|
||||
window.__TEST__.emit('workspace-event', { root: window.__TEST__.root, kind: 'create', paths: ['selection-table.md'] });
|
||||
window.__TEST__.clipboard = '';
|
||||
// Cell copies write plain text and HTML through clipboard.write (src/lib/editor/tableSelectionControls.ts:80-85).
|
||||
Object.defineProperty(navigator, 'clipboard', { configurable: true, value: {
|
||||
write: async items => { window.__TEST__.clipboard = await (await items[0].getType('text/plain')).text(); },
|
||||
writeText: async text => { window.__TEST__.clipboard = text; },
|
||||
readText: async () => window.__TEST__.clipboard,
|
||||
} });
|
||||
}, selectionTable);
|
||||
await quickOpen('selection-table.md');
|
||||
await page.getByRole('button', { name: 'Edit', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'Switch to writing layout (Ctrl E)', exact: true }).click();
|
||||
await mode('Document view', 'Edit');
|
||||
await mode('Editor layout', 'Writer');
|
||||
const selectedTable = page.locator('.live-writer table');
|
||||
const selectedCell = (r, c) => selectedTable.locator('tr').nth(r).locator('th, td').nth(c);
|
||||
const fromCell = await selectedCell(1, 0).boundingBox(), toCell = await selectedCell(2, 1).boundingBox();
|
||||
@@ -482,7 +472,7 @@ try {
|
||||
await selectedCell(1, 0).click({ button: 'right' });
|
||||
await page.getByRole('menuitem', { name: 'Format', exact: true }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Bold', exact: true }).waitFor();
|
||||
await page.screenshot({ path: '.audit/table-cell-selection-menu.png' });
|
||||
await page.screenshot({ path: path.join(output, 'table-cell-selection-menu.png') });
|
||||
await page.getByRole('menuitem', { name: 'Bold', exact: true }).click();
|
||||
await page.waitForFunction(() => document.querySelectorAll('.live-writer table strong').length === 4);
|
||||
await page.waitForFunction(() => document.querySelectorAll('.is-cell-selected').length === 4);
|
||||
@@ -502,7 +492,8 @@ try {
|
||||
await cellAction('Clear formatting', true);
|
||||
await page.waitForFunction(() => document.querySelectorAll('.live-writer table strong').length === 0);
|
||||
await cellAction('Copy');
|
||||
assert.equal(await page.evaluate(() => window.__TEST__.clipboard), 'one\ttwo\nfour\tfive');
|
||||
// clipboard.write resolves its items asynchronously.
|
||||
await page.waitForFunction(expected => window.__TEST__.clipboard === expected, 'one\ttwo\nfour\tfive');
|
||||
await cellAction('Cut');
|
||||
await page.waitForFunction(() => [...document.querySelectorAll('.is-cell-selected')].every(cell => !cell.textContent.trim()));
|
||||
await cellAction('Paste');
|
||||
@@ -560,8 +551,8 @@ try {
|
||||
window.__TEST__.emit('workspace-event', { root: window.__TEST__.root, kind: 'create', paths: ['table-actions.md'] });
|
||||
}, actionsSource);
|
||||
await quickOpen('table-actions.md');
|
||||
await page.getByRole('button', { name: 'Edit', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'Switch to writing layout (Ctrl E)', exact: true }).click();
|
||||
await mode('Document view', 'Edit');
|
||||
await mode('Editor layout', 'Writer');
|
||||
const actionTable = page.locator('.live-writer table');
|
||||
const actionCell = (r, c) => actionTable.locator('tr').nth(r).locator('th, td').nth(c);
|
||||
async function actionItem(label, group, r = 1, c = 0) {
|
||||
@@ -623,9 +614,9 @@ try {
|
||||
assert.equal(await page.getByRole('menuitem', { name: 'Copy', exact: true }).isDisabled(), false);
|
||||
assert.ok(await page.locator('.table-cell-menu button').evaluateAll(buttons => buttons.every(button => button.querySelector('svg[aria-hidden="true"]'))));
|
||||
await page.getByRole('menuitem', { name: 'Row', exact: true }).hover();
|
||||
await page.screenshot({ path: '.audit/table-text-row-menu.png' });
|
||||
await page.screenshot({ path: path.join(output, 'table-text-row-menu.png') });
|
||||
await page.getByRole('menuitem', { name: 'Column', exact: true }).hover();
|
||||
await page.screenshot({ path: '.audit/table-text-column-menu.png' });
|
||||
await page.screenshot({ path: path.join(output, 'table-text-column-menu.png') });
|
||||
await page.getByRole('menuitem', { name: 'Column', exact: true }).focus();
|
||||
await page.keyboard.press('ArrowRight');
|
||||
assert.equal(await page.evaluate(() => document.activeElement.textContent), 'Add column to the left');
|
||||
@@ -697,8 +688,8 @@ try {
|
||||
window.__TEST__.emit('workspace-event', { root: window.__TEST__.root, kind: 'create', paths: ['rich-table.md'] });
|
||||
}, richTable);
|
||||
await quickOpen('rich-table.md');
|
||||
await page.getByRole('button', { name: 'Edit', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'Switch to writing layout (Ctrl E)', exact: true }).click();
|
||||
await mode('Document view', 'Edit');
|
||||
await mode('Editor layout', 'Writer');
|
||||
const richCell = page.locator('.live-writer tbody tr').first().locator('td').last();
|
||||
assert.equal(await page.locator('.live-writer .document-title').innerText(), 'rich-table');
|
||||
await richCell.click();
|
||||
@@ -746,7 +737,7 @@ try {
|
||||
window.__TEST__.emit('workspace-event', { root: window.__TEST__.root, kind: 'create', paths: ['table-hit-testing.md'] });
|
||||
}, hitTestSource);
|
||||
await quickOpen('table-hit-testing.md');
|
||||
await page.getByRole('button', { name: 'Switch to writing layout (Ctrl E)', exact: true }).click();
|
||||
await mode('Editor layout', 'Writer');
|
||||
async function clickRenderedLine(locator, expected) {
|
||||
await locator.scrollIntoViewIfNeeded();
|
||||
const rect = await locator.boundingBox();
|
||||
@@ -790,13 +781,6 @@ try {
|
||||
await checkLinesAfterTables();
|
||||
await page.setViewportSize({ width: 1000, height: 900 });
|
||||
await checkLinesAfterTables();
|
||||
await page.screenshot({ path: '.audit/table-cursor-position.png' });
|
||||
assert.deepEqual(errors, []);
|
||||
await page.screenshot({ path: path.join(output, 'table-cursor-position.png') });
|
||||
console.log("PASS: continuous live Markdown, raw active lines, editable links and checklists, completed-task strikethrough, cross-line selection, preservation and history, search, table layout/line breaks/edge insertion/cell editing/undo, save, agent refresh, conflicts, persistent terminals, reader and Mermaid previews, narrow layouts (mocked desktop IPC).");
|
||||
} catch (error) {
|
||||
console.error("Browser errors:", errors);
|
||||
console.error("Writing source:", await page.evaluate(() => window.__TEST__?.files.get("writing.md")));
|
||||
console.error("Visible text:", (await page.locator("body").innerText()).slice(0, 5000));
|
||||
await page.screenshot({ path: ".audit/core-rebuild-failure.png" });
|
||||
throw error;
|
||||
} finally { await browser.close(); }
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user