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,110 +1,50 @@
|
||||
// Run against `pnpm dev`. PLAYWRIGHT_MODULE may point to a shared installation.
|
||||
import { createRequire } from "node:module";
|
||||
// Table drag handles: hover and focus grips, previews, row and column moves, undo, cancellation, keyboard moves, and auto-scroll.
|
||||
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 page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
||||
page.setDefaultTimeout(10000);
|
||||
const errors = [];
|
||||
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}`);
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: (_event, id) => callbacks.delete(id) };
|
||||
window.__TEST__ = { files, calls, emit, root };
|
||||
});
|
||||
|
||||
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 page.getByRole("group", { name: "Editor layout" }).locator("button.current").press("Home");
|
||||
await page.locator(".monaco-editor textarea").waitFor();
|
||||
}
|
||||
import path from "node:path";
|
||||
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
const source = '# Drag tables\n\n| Name | Value | Notes |\n| :--- | ---: | :---: |\n| Alpha | 10 | **Bold**<br>second line |\n| Beta | 20 | Two |\n| Gamma | 30 | Three |\n| Delta | 40 | Four |\n\nAfter.\n';
|
||||
const table = page.locator('.live-writer table');
|
||||
const rows = () => table.locator('tbody tr td:first-child').allTextContents();
|
||||
const headers = () => table.locator('th').allTextContents();
|
||||
async function grip(axis, index) {
|
||||
const handle = page.locator(`.table-drag-${axis}[data-index="${index}"]`);
|
||||
await handle.scrollIntoViewIfNeeded();
|
||||
const rect = await handle.boundingBox();
|
||||
await page.mouse.move(rect.x + rect.width / 2, rect.y + rect.height / 2);
|
||||
await page.mouse.down();
|
||||
}
|
||||
async function target(axis, index, after = false) {
|
||||
const rect = await (axis === 'row' ? table.locator('tr').nth(index) : table.locator('th').nth(index)).boundingBox();
|
||||
await page.mouse.move(axis === 'row' ? rect.x + 10 : rect.x + (after ? rect.width - 2 : 2), axis === 'row' ? rect.y + (after ? rect.height - 2 : 2) : rect.y + 10, { steps: 8 });
|
||||
}
|
||||
async function save() {
|
||||
await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(() => !document.querySelector('[aria-label^="Save changes"]'));
|
||||
return page.evaluate(() => window.__TEST__.files.get('drag.md'));
|
||||
}
|
||||
try {
|
||||
await page.goto(process.env.SMOKE_URL || 'http://127.0.0.1:1420');
|
||||
const long = '# Long table\n\n| Item | Value |\n| --- | --- |\n' + Array.from({ length: 30 }, (_, i) => `| Item ${i + 1} | ${i + 1} |`).join('\n') + '\n\nAfter.\n';
|
||||
|
||||
await runSmoke("tables/drag", async ({ page }) => {
|
||||
const output = await outputDir("tables/drag");
|
||||
await mockTauri(page, {
|
||||
state: { files: { 'drag.md': source, 'long.md': long } },
|
||||
commands: test => {
|
||||
const workspace = test.workspace({ root: "C:\\smoke-workspace", files: test.state.files, writeEvents: true });
|
||||
test.files = workspace.files;
|
||||
return workspace;
|
||||
},
|
||||
});
|
||||
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 page.getByRole("group", { name: "Editor layout" }).locator("button.current").press("Home");
|
||||
await page.locator(".monaco-editor textarea").waitFor();
|
||||
}
|
||||
const table = page.locator('.live-writer table');
|
||||
const rows = () => table.locator('tbody tr td:first-child').allTextContents();
|
||||
const headers = () => table.locator('th').allTextContents();
|
||||
async function grip(axis, index) {
|
||||
const handle = page.locator(`.table-drag-${axis}[data-index="${index}"]`);
|
||||
await handle.scrollIntoViewIfNeeded();
|
||||
const rect = await handle.boundingBox();
|
||||
await page.mouse.move(rect.x + rect.width / 2, rect.y + rect.height / 2);
|
||||
await page.mouse.down();
|
||||
}
|
||||
async function target(axis, index, after = false) {
|
||||
const rect = await (axis === 'row' ? table.locator('tr').nth(index) : table.locator('th').nth(index)).boundingBox();
|
||||
await page.mouse.move(axis === 'row' ? rect.x + 10 : rect.x + (after ? rect.width - 2 : 2), axis === 'row' ? rect.y + (after ? rect.height - 2 : 2) : rect.y + 10, { steps: 8 });
|
||||
}
|
||||
async function save() {
|
||||
await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(() => !document.querySelector('[aria-label^="Save changes"]'));
|
||||
return page.evaluate(() => window.__TEST__.files.get('drag.md'));
|
||||
}
|
||||
|
||||
await page.goto(smokeUrl);
|
||||
await page.getByText('smoke-workspace', { exact: true }).waitFor();
|
||||
await page.evaluate(text => {
|
||||
window.__TEST__.files.set('drag.md', text);
|
||||
window.__TEST__.emit('workspace-event', { root: window.__TEST__.root, kind: 'create', paths: ['drag.md'] });
|
||||
}, source);
|
||||
await quickOpen('drag.md');
|
||||
await page.getByRole("group", { name: "Editor layout" }).locator("button.current").press("End");
|
||||
await table.waitFor();
|
||||
@@ -131,7 +71,7 @@ try {
|
||||
assert.equal(await preview.locator('.table-drag-preview-label').innerText(), 'Row 2 → 5');
|
||||
assert.equal(await table.locator('.is-cell-selected').count(), 3);
|
||||
await page.locator('.table-drop-indicator:visible').waitFor();
|
||||
await page.screenshot({ path: '.audit/table-drag-row.png' });
|
||||
await page.screenshot({ path: path.join(output, 'row.png') });
|
||||
await page.mouse.up();
|
||||
assert.equal(await preview.count(), 0);
|
||||
await page.mouse.move(5, 5);
|
||||
@@ -148,7 +88,7 @@ try {
|
||||
await grip('column', 0); await target('column', 2, true);
|
||||
assert.deepEqual(await preview.locator('tr').allTextContents(), ['Name', 'Alpha', 'Beta', 'Gamma', 'Delta']);
|
||||
await page.locator('.table-drop-indicator:visible').waitFor();
|
||||
await page.screenshot({ path: '.audit/table-drag-column.png' });
|
||||
await page.screenshot({ path: path.join(output, 'column.png') });
|
||||
await page.mouse.up();
|
||||
assert.deepEqual(await headers(), ['Value', 'Notes', 'Name']);
|
||||
await save();
|
||||
@@ -192,13 +132,9 @@ try {
|
||||
await page.waitForFunction(() => { const el = document.querySelector('.writer-table .md-table-scroll'); return el.scrollLeft + el.clientWidth >= el.scrollWidth - 2; });
|
||||
await target('column', 2, true); await page.mouse.up();
|
||||
assert.deepEqual(await headers(), ['Value', 'Notes', 'Name']);
|
||||
await page.screenshot({ path: '.audit/table-drag-narrow.png' });
|
||||
await page.screenshot({ path: path.join(output, 'narrow.png') });
|
||||
// Long tables scroll the document while the pointer stays at its lower edge.
|
||||
await page.setViewportSize({ width: 1440, height: 700 });
|
||||
await page.evaluate(() => {
|
||||
window.__TEST__.files.set('long.md', '# Long table\n\n| Item | Value |\n| --- | --- |\n' + Array.from({ length: 30 }, (_, i) => `| Item ${i + 1} | ${i + 1} |`).join('\n') + '\n\nAfter.\n');
|
||||
window.__TEST__.emit('workspace-event', { root: window.__TEST__.root, kind: 'create', paths: ['long.md'] });
|
||||
});
|
||||
await quickOpen('long.md');
|
||||
await page.getByRole("group", { name: "Editor layout" }).locator("button.current").press("End");
|
||||
await table.waitFor();
|
||||
@@ -223,10 +159,4 @@ try {
|
||||
assert.equal((await rows())[1], 'Item 2');
|
||||
assert.equal(await page.locator('.is-table-dragging').count(), 0);
|
||||
assert.equal(await preview.count(), 0);
|
||||
assert.deepEqual(errors, []);
|
||||
console.log('PASS: hover/focus grips, pointer-following previews and cleanup, row/column drag in both directions, indicators, alignment, undo/redo, cancellation, keyboard movement, active edits, horizontal and vertical auto-scroll.');
|
||||
} catch (error) {
|
||||
console.error('Browser errors:', errors);
|
||||
await page.screenshot({ path: '.audit/table-drag-failure.png' });
|
||||
throw error;
|
||||
} finally { await browser.close(); }
|
||||
});
|
||||
|
||||
@@ -1,80 +1,17 @@
|
||||
// Run against `pnpm dev`. PLAYWRIGHT_MODULE may point to a shared installation.
|
||||
import { createRequire } from "node:module";
|
||||
// Table Enter and Shift+Enter, table clipboard with line breaks, task marker editing, and title Tab, in both themes and a narrow window.
|
||||
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(10000);
|
||||
const errors = [];
|
||||
await mkdir(".audit", { recursive: true });
|
||||
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 === "spelling_menu_install") return;
|
||||
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}`);
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: (_event, id) => callbacks.delete(id) };
|
||||
window.__TEST__ = { files, calls, emit, root };
|
||||
});
|
||||
import path from "node:path";
|
||||
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
try {
|
||||
await mkdir('output/october15-editor', { recursive: true });
|
||||
await page.goto(process.env.SMOKE_URL || 'http://127.0.0.1:1420');
|
||||
await runSmoke("tables/enterKey", async ({ page }) => {
|
||||
const output = await outputDir("tables/enterKey");
|
||||
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" }, writeEvents: true }),
|
||||
spelling_menu_install: () => null,
|
||||
}),
|
||||
});
|
||||
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');
|
||||
@@ -90,6 +27,7 @@ try {
|
||||
await page.locator('.live-writer table').waitFor();
|
||||
};
|
||||
const cell = (r, c) => page.locator('.live-writer table tr').nth(r).locator('th,td').nth(c);
|
||||
const shot = name => page.screenshot({ path: path.join(output, `${name}.png`) });
|
||||
for (const mode of ['dark', 'light']) {
|
||||
await page.evaluate(async mode => (await import('/src/lib/theme/appearance.ts')).saveAppearance({ theme: 'default', mode }), mode);
|
||||
await reset();
|
||||
@@ -103,7 +41,7 @@ try {
|
||||
await page.keyboard.press('Shift+Enter');
|
||||
await page.keyboard.type('Line');
|
||||
assert.match(await page.evaluate(() => window.__CM__.state.sliceDoc()), /New<br>Line/);
|
||||
await page.screenshot({ path: `output/october15-editor/${mode}-table-enter.png` });
|
||||
await shot(`${mode}-table-enter`);
|
||||
await reset();
|
||||
await cell(0, 0).click();
|
||||
await page.keyboard.press('Shift+F10');
|
||||
@@ -128,32 +66,27 @@ try {
|
||||
}, copied);
|
||||
assert.equal(await page.locator('.live-writer table').count(), 2);
|
||||
assert.match(await page.evaluate(() => window.__CM__.state.sliceDoc()), /First<br>Second/);
|
||||
await page.screenshot({ path: `output/october15-editor/${mode}-table-paste.png` });
|
||||
await shot(`${mode}-table-paste`);
|
||||
await reset();
|
||||
await page.evaluate(() => {
|
||||
const view = window.__CM__;
|
||||
view.dispatch({ selection: { anchor: view.state.sliceDoc().indexOf('A task') + 3 } }); view.focus();
|
||||
});
|
||||
assert.equal(await page.locator('.writer-checkbox').count(), 1);
|
||||
await page.screenshot({ path: `output/october15-editor/${mode}-checklist-text.png` });
|
||||
await shot(`${mode}-checklist-text`);
|
||||
await page.evaluate(() => {
|
||||
const view = window.__CM__;
|
||||
view.dispatch({ selection: { anchor: view.state.sliceDoc().indexOf('[ ]') + 1 } }); view.focus();
|
||||
});
|
||||
assert.equal(await page.locator('.writer-checkbox').count(), 0);
|
||||
await page.screenshot({ path: `output/october15-editor/${mode}-checklist-source.png` });
|
||||
await shot(`${mode}-checklist-source`);
|
||||
await page.getByRole('button', { name: 'Rename note', exact: true }).click();
|
||||
await page.getByRole('textbox', { name: 'Note filename', exact: true }).press('Tab');
|
||||
await page.waitForFunction(() => document.activeElement?.classList.contains('cm-content'));
|
||||
await page.screenshot({ path: `output/october15-editor/${mode}-title-tab.png` });
|
||||
await shot(`${mode}-title-tab`);
|
||||
await page.setViewportSize({ width: 600, height: 760 });
|
||||
await reset();
|
||||
await page.screenshot({ path: `output/october15-editor/${mode}-narrow.png` });
|
||||
await shot(`${mode}-narrow`);
|
||||
await page.setViewportSize({ width: 1440, height: 1000 });
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
console.log('PASS: Enter advances and creates rows in the same column, Shift+Enter, table clipboard with line breaks, task marker editing, title Tab, both themes and narrow layouts.');
|
||||
} catch (error) {
|
||||
await page.screenshot({ path: 'output/october15-editor/failure.png' });
|
||||
throw error;
|
||||
} finally { await browser.close(); }
|
||||
});
|
||||
|
||||
@@ -1,105 +1,61 @@
|
||||
// Table formulas: live recalculation, raw formula editing, Enter and Tab, undo, cycles, saving, the footer layout, and the Read and Split views.
|
||||
// @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";
|
||||
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 = [];
|
||||
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}`);
|
||||
},
|
||||
};
|
||||
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();
|
||||
await page.locator('.live-writer').waitFor();
|
||||
await page.keyboard.press('Control+e');
|
||||
await page.locator(".monaco-editor textarea").waitFor();
|
||||
}
|
||||
import path from "node:path";
|
||||
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
import { mockFeaturePlugins } from "../_harness/pluginMocks.mjs";
|
||||
|
||||
const source = '# Table formulas\n\n| Name | Appearance | Charisma | Combined |\n| --- | ---: | ---: | ---: |\n| First | 9 | 10 | =AVERAGE(B2:C2) |\n| Second | 7 | 9 | =SUM(B3+C3)/2 |\n| Total | | | =SUM(D2:D3) |\n\nAfter.\n';
|
||||
const table = page.locator('.live-writer table');
|
||||
const cell = (r, c) => table.locator('tr').nth(r).locator('th, td').nth(c);
|
||||
const edit = page.locator('.writer-cell-editor');
|
||||
const result = (r, c) => cell(r, c).locator('.md-table-formula');
|
||||
async function save() {
|
||||
await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(() => !document.querySelector('[aria-label^="Save changes"]'));
|
||||
return page.evaluate(() => window.__TEST__.files.get('formulas.md'));
|
||||
}
|
||||
try {
|
||||
await page.goto(process.env.SMOKE_URL || 'http://127.0.0.1:1420');
|
||||
|
||||
await runSmoke("tables/formulas", async ({ page }) => {
|
||||
const output = await outputDir("tables/formulas");
|
||||
await mockTauri(page, {
|
||||
state: { files: { 'formulas.md': source } },
|
||||
commands: test => {
|
||||
const workspace = test.workspace({ root: "C:\\smoke-workspace", files: test.state.files, writeEvents: true });
|
||||
test.files = workspace.files;
|
||||
return workspace;
|
||||
},
|
||||
});
|
||||
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();
|
||||
await page.locator('.live-writer').waitFor();
|
||||
await page.keyboard.press('Control+e');
|
||||
await page.locator(".monaco-editor textarea").waitFor();
|
||||
}
|
||||
const table = page.locator('.live-writer table');
|
||||
const cell = (r, c) => table.locator('tr').nth(r).locator('th, td').nth(c);
|
||||
const edit = page.locator('.writer-cell-editor');
|
||||
const result = (r, c) => cell(r, c).locator('.md-table-formula');
|
||||
const shot = name => page.screenshot({ path: path.join(output, `${name}.png`) });
|
||||
async function save() {
|
||||
await page.keyboard.press('Control+s');
|
||||
await page.waitForFunction(() => !document.querySelector('[aria-label^="Save changes"]'));
|
||||
return page.evaluate(() => window.__TEST__.files.get('formulas.md'));
|
||||
}
|
||||
// Footer controls share one normal-flow block aligned to the table at any width.
|
||||
async function checkFooter() {
|
||||
const geometry = await page.evaluate(() => {
|
||||
const rect = selector => document.querySelector(selector).getBoundingClientRect().toJSON();
|
||||
return { table: rect('.live-writer .md-table-scroll'), footer: rect('.table-footer'), tools: rect('.table-formula-tools'), help: rect('.table-edit-help'), helpHidden: document.querySelector('.table-edit-help').hidden, summary: rect('.table-formula-help summary'), status: rect('.table-formula-status') };
|
||||
});
|
||||
assert.ok(Math.abs(geometry.table.x - geometry.footer.x) < 2);
|
||||
assert.ok(Math.abs(geometry.footer.x - geometry.tools.x) < 2);
|
||||
if (!geometry.helpHidden) assert.ok(Math.abs(geometry.help.x - geometry.tools.x) < 2);
|
||||
assert.ok(geometry.footer.y >= geometry.table.bottom);
|
||||
assert.ok(geometry.footer.y - geometry.table.bottom <= 28, 'Only the add-row control sits between table and footer');
|
||||
if (!geometry.helpHidden) {
|
||||
assert.ok(geometry.tools.y >= geometry.help.bottom, 'Help must not overlap the controls');
|
||||
assert.ok(geometry.help.right <= geometry.footer.right + 1);
|
||||
}
|
||||
if (geometry.status.x > geometry.summary.right) assert.ok(Math.abs((geometry.status.y + geometry.status.height / 2) - (geometry.summary.y + geometry.summary.height / 2)) < 2);
|
||||
}
|
||||
|
||||
await page.goto(smokeUrl);
|
||||
await page.getByText('smoke-workspace', { exact: true }).waitFor();
|
||||
await page.evaluate(text => {
|
||||
window.__TEST__.files.set('formulas.md', text);
|
||||
window.__TEST__.emit('workspace-event', { root: window.__TEST__.root, kind: 'create', paths: ['formulas.md'] });
|
||||
}, source);
|
||||
await quickOpen('formulas.md');
|
||||
await page.keyboard.press('Control+e');
|
||||
await table.waitFor();
|
||||
@@ -109,7 +65,7 @@ try {
|
||||
await page.locator('.rs-tooltip:popover-open').waitFor();
|
||||
assert.equal(await cell(1, 3).getAttribute('title'), null);
|
||||
assert.match(await page.locator('.rs-tooltip:popover-open').innerText(), /D2.*AVERAGE/);
|
||||
await page.screenshot({ path: '.audit/table-cell-hint.png' });
|
||||
await shot('cell-hint');
|
||||
await page.keyboard.press('Escape');
|
||||
assert.equal(await page.locator('.rs-tooltip:popover-open').count(), 0);
|
||||
await cell(1, 3).click();
|
||||
@@ -144,7 +100,8 @@ try {
|
||||
assert.equal(await result(3, 3).innerText(), '58');
|
||||
await cell(2, 3).click();
|
||||
await edit.fill('=D3');
|
||||
await page.keyboard.press('Enter');
|
||||
// Enter would start editing D4 below (src/lib/editor/tableControls.ts:283), so leave the table to render both results.
|
||||
await page.keyboard.press('Control+Enter');
|
||||
assert.equal(await result(2, 3).innerText(), '#CYCLE!');
|
||||
assert.equal(await result(3, 3).innerText(), '#CYCLE!');
|
||||
await cell(2, 3).click();
|
||||
@@ -157,34 +114,17 @@ try {
|
||||
const saved = await save();
|
||||
assert.match(saved, /=SUM\(B2:B3\)/);
|
||||
assert.doesNotMatch(saved, /\\=/);
|
||||
// Footer controls share one normal-flow block aligned to the table at any width.
|
||||
async function checkFooter() {
|
||||
const geometry = await page.evaluate(() => {
|
||||
const rect = selector => document.querySelector(selector).getBoundingClientRect().toJSON();
|
||||
return { table: rect('.live-writer .md-table-scroll'), footer: rect('.table-footer'), tools: rect('.table-formula-tools'), help: rect('.table-edit-help'), helpHidden: document.querySelector('.table-edit-help').hidden, summary: rect('.table-formula-help summary'), status: rect('.table-formula-status') };
|
||||
});
|
||||
assert.ok(Math.abs(geometry.table.x - geometry.footer.x) < 2);
|
||||
assert.ok(Math.abs(geometry.footer.x - geometry.tools.x) < 2);
|
||||
if (!geometry.helpHidden) assert.ok(Math.abs(geometry.help.x - geometry.tools.x) < 2);
|
||||
assert.ok(geometry.footer.y >= geometry.table.bottom);
|
||||
assert.ok(geometry.footer.y - geometry.table.bottom <= 28, 'Only the add-row control sits between table and footer');
|
||||
if (!geometry.helpHidden) {
|
||||
assert.ok(geometry.tools.y >= geometry.help.bottom, 'Help must not overlap the controls');
|
||||
assert.ok(geometry.help.right <= geometry.footer.right + 1);
|
||||
}
|
||||
if (geometry.status.x > geometry.summary.right) assert.ok(Math.abs((geometry.status.y + geometry.status.height / 2) - (geometry.summary.y + geometry.summary.height / 2)) < 2);
|
||||
}
|
||||
await cell(3, 1).click();
|
||||
await checkFooter();
|
||||
await page.screenshot({ path: '.audit/table-formula-footer.png' });
|
||||
await shot('footer');
|
||||
await page.setViewportSize({ width: 850, height: 1000 });
|
||||
await checkFooter();
|
||||
await page.screenshot({ path: '.audit/table-formula-footer-narrow.png' });
|
||||
await shot('footer-narrow');
|
||||
await page.locator('.table-formula-help summary').click();
|
||||
assert.equal(await page.locator('.table-formula-help').getAttribute('open'), '');
|
||||
await checkFooter();
|
||||
await page.setViewportSize({ width: 1440, height: 1000 });
|
||||
await page.screenshot({ path: '.audit/table-formulas.png' });
|
||||
await shot('formulas');
|
||||
await page.keyboard.press('Control+e');
|
||||
await page.keyboard.press('Control+e');
|
||||
assert.equal(await result(3, 1).innerText(), '12');
|
||||
@@ -193,8 +133,8 @@ try {
|
||||
await page.getByRole('group', { name: 'Document view', exact: true }).getByRole('button', { pressed: true }).press('ArrowRight');
|
||||
const preview = page.locator('.md-page table').first();
|
||||
await preview.waitFor();
|
||||
assert.equal(await preview.locator('tbody tr').last().locator('.md-table-formula').last().innerText(), '58');
|
||||
// Enter in the last row added an empty row below Total (src/lib/editor/tableControls.ts:285).
|
||||
const total = preview.locator('tbody tr').filter({ hasText: 'Total' });
|
||||
assert.equal(await total.locator('.md-table-formula').last().innerText(), '58', `${mode} view`);
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
console.log('PASS: live recalculation, raw formula editing, Enter/Tab, undo/redo, cycle recovery, Markdown saves, help, remount, Read, and Split');
|
||||
} finally { await browser.close(); }
|
||||
});
|
||||
|
||||
@@ -1,82 +1,60 @@
|
||||
import { createRequire } from "node:module";
|
||||
// Links in table cells: clicks keep the caret in place, keyboard entry, inline Edit link, wiki aliases, repeated targets, save, and undo, in both themes and a narrow window.
|
||||
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));
|
||||
await mkdir(".audit", { recursive: true });
|
||||
await page.addInitScript(() => {
|
||||
localStorage.clear();
|
||||
window.isTauri = true;
|
||||
const root = "C:\\tab-menu-workspace";
|
||||
const files = new Map([["a.md", '# Links\n\nOutside table.\n\n| Name | Value |\n| --- | --- |\n| One | Text |\n| Two | Text |\n| Three | Text |\n| Four | Text |\n| Five | [Roadmp](docs/roadmap.md) |\n| Keyboard | Before [Guide](docs/guide.md) after |\n| Wiki | [[guide\\|Guide]] |\n| Repeated | **Prefix** [One](same.md) + [Sec**ond**](same.md "Title") |\n']]);
|
||||
window.tabMenuTest = { files, prompts: [], answer: "Cancel", revealed: null, clipboard: null };
|
||||
Object.defineProperty(navigator, "clipboard", { value: { writeText: async text => { window.tabMenuTest.clipboard = text; } } });
|
||||
let sequence = 0;
|
||||
const callbacks = new Map(), listeners = new Map();
|
||||
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: [], misspelled: false };
|
||||
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()].map(name => ({ name, rel_path: name, kind: "file" }))];
|
||||
if (command === "workspace_search") return [];
|
||||
if (command === "workspace_write") { files.set(args.rel, args.contents); 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}`);
|
||||
import path from "node:path";
|
||||
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
await runSmoke("tables/linkCaret", async ({ page }) => {
|
||||
const output = await outputDir("tables/linkCaret");
|
||||
await mockTauri(page, {
|
||||
commands: test => {
|
||||
localStorage.clear();
|
||||
const workspace = test.workspace({
|
||||
root: "C:\\tab-menu-workspace",
|
||||
folders: ["notes"],
|
||||
files: { "a.md": '# Links\n\nOutside table.\n\n| Name | Value |\n| --- | --- |\n| One | Text |\n| Two | Text |\n| Three | Text |\n| Four | Text |\n| Five | [Roadmp](docs/roadmap.md) |\n| Keyboard | Before [Guide](docs/guide.md) after |\n| Wiki | [[guide\\|Guide]] |\n| Repeated | **Prefix** [One](same.md) + [Sec**ond**](same.md "Title") |\n' },
|
||||
});
|
||||
test.files = workspace.files;
|
||||
test.prompts = [];
|
||||
return {
|
||||
...workspace,
|
||||
spelling_menu_install: () => null,
|
||||
"plugin:dialog|message": ({ message }) => { test.prompts.push(message); return "Cancel"; },
|
||||
};
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
|
||||
});
|
||||
});
|
||||
page.setDefaultTimeout(15000);
|
||||
const sourceCell = () => page.locator('.is-source-editing .writer-cell-editor');
|
||||
async function clickTextAt(locator, offset, button = 'left') {
|
||||
const point = await locator.evaluate((element, offset) => {
|
||||
const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
|
||||
let node;
|
||||
while ((node = walker.nextNode())) {
|
||||
if (offset > node.textContent.length) { offset -= node.textContent.length; continue; }
|
||||
const range = document.createRange();
|
||||
range.setStart(node, offset); range.collapse(true);
|
||||
const rect = range.getBoundingClientRect();
|
||||
return { x: rect.x, y: rect.y + rect.height / 2 };
|
||||
}
|
||||
throw new Error('No text position');
|
||||
}, offset);
|
||||
await page.mouse.click(point.x, point.y, { button });
|
||||
}
|
||||
const selected = () => page.evaluate(() => getSelection().toString());
|
||||
const caretPrefix = () => page.evaluate(() => {
|
||||
const selection = getSelection(), range = document.createRange();
|
||||
range.selectNodeContents(document.querySelector('.is-source-editing .writer-cell-editor'));
|
||||
range.setEnd(selection.anchorNode, selection.anchorOffset);
|
||||
return range.toString();
|
||||
});
|
||||
const documentText = () => page.locator('.cm-content').evaluate(async node => {
|
||||
const { EditorView } = await import('/node_modules/@codemirror/view/dist/index.js');
|
||||
return EditorView.findFromDOM(node).state.doc.toString();
|
||||
});
|
||||
const shot = name => page.screenshot({ path: path.join(output, `${name}.png`) });
|
||||
|
||||
const output = '.audit/table-link-caret';
|
||||
await mkdir(output, { recursive: true });
|
||||
const sourceCell = () => page.locator('.is-source-editing .writer-cell-editor');
|
||||
async function clickTextAt(locator, offset, button = 'left') {
|
||||
const point = await locator.evaluate((element, offset) => {
|
||||
const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
|
||||
let node;
|
||||
while ((node = walker.nextNode())) {
|
||||
if (offset > node.textContent.length) { offset -= node.textContent.length; continue; }
|
||||
const range = document.createRange();
|
||||
range.setStart(node, offset); range.collapse(true);
|
||||
const rect = range.getBoundingClientRect();
|
||||
return { x: rect.x, y: rect.y + rect.height / 2 };
|
||||
}
|
||||
throw new Error('No text position');
|
||||
}, offset);
|
||||
await page.mouse.click(point.x, point.y, { button });
|
||||
}
|
||||
const selected = () => page.evaluate(() => getSelection().toString());
|
||||
const caretPrefix = () => page.evaluate(() => {
|
||||
const selection = getSelection(), range = document.createRange();
|
||||
range.selectNodeContents(document.querySelector('.is-source-editing .writer-cell-editor'));
|
||||
range.setEnd(selection.anchorNode, selection.anchorOffset);
|
||||
return range.toString();
|
||||
});
|
||||
const documentText = () => page.locator('.cm-content').evaluate(async node => {
|
||||
const { EditorView } = await import('/node_modules/@codemirror/view/dist/index.js');
|
||||
return EditorView.findFromDOM(node).state.doc.toString();
|
||||
});
|
||||
|
||||
try {
|
||||
for (const theme of ['dark', 'light']) for (const width of [1440, 620]) {
|
||||
await page.setViewportSize({ width, height: 1000 });
|
||||
await page.goto(process.env.SMOKE_URL || 'http://127.0.0.1:1420');
|
||||
await page.goto(smokeUrl);
|
||||
await page.locator('[data-tree-rel="a.md"]').click();
|
||||
await page.locator('.writer-table').waitFor();
|
||||
await page.evaluate(async mode => (await import('/src/lib/theme/appearance.ts')).saveAppearance({ theme:'default', mode }), theme);
|
||||
@@ -91,7 +69,7 @@ try {
|
||||
assert.equal(await caretPrefix(), '[Roadm', 'The caret stays at the clicked label character');
|
||||
await page.keyboard.type('a');
|
||||
assert.equal(await sourceCell().innerText(), '[Roadmap](docs/roadmap.md)');
|
||||
await page.screenshot({ path:`${output}/click-label-${theme}-${width}.png` });
|
||||
await shot(`click-label-${theme}-${width}`);
|
||||
await page.keyboard.press('Escape');
|
||||
assert.equal(await cell.locator('a').innerText(), 'Roadmap');
|
||||
await clickTextAt(cell.locator('a'), 3);
|
||||
@@ -99,7 +77,7 @@ try {
|
||||
await page.getByRole('menuitem', { name:'Edit link', exact:true }).click();
|
||||
assert.equal(await selected(), 'docs/roadmap.md');
|
||||
assert.equal(await page.getByRole('dialog').count(), 0);
|
||||
await page.screenshot({ path:`${output}/edit-target-${theme}-${width}.png` });
|
||||
await shot(`edit-target-${theme}-${width}`);
|
||||
await page.keyboard.type('docs/changed.md');
|
||||
await page.keyboard.press('Enter');
|
||||
assert.equal(await cell.locator('a').getAttribute('href'), 'docs/changed.md');
|
||||
@@ -109,7 +87,7 @@ try {
|
||||
await page.keyboard.press('Control+y');
|
||||
assert.equal(await cell.locator('a').getAttribute('href'), 'docs/changed.md');
|
||||
await page.keyboard.press('Control+s');
|
||||
assert.match(await page.evaluate(() => window.tabMenuTest.files.get('a.md')), /\[Roadmap\]\(docs\/changed.md\)/);
|
||||
assert.match(await page.evaluate(() => window.__TEST__.files.get('a.md')), /\[Roadmap\]\(docs\/changed.md\)/);
|
||||
|
||||
const keyboard = page.getByRole('cell', { name:'Row 7, column 2', exact:true });
|
||||
await clickTextAt(keyboard, 7);
|
||||
@@ -118,7 +96,7 @@ try {
|
||||
await sourceCell().waitFor();
|
||||
assert.equal(await keyboard.locator('.writer-link-target').innerText(), 'docs/guide.md');
|
||||
assert.equal(await caretPrefix(), 'Before [G');
|
||||
await page.screenshot({ path:`${output}/keyboard-${theme}-${width}.png` });
|
||||
await shot(`keyboard-${theme}-${width}`);
|
||||
await page.keyboard.press('Escape');
|
||||
|
||||
const wiki = page.getByRole('cell', { name:'Row 8, column 2', exact:true });
|
||||
@@ -144,14 +122,6 @@ try {
|
||||
assert.equal(await repeated.locator('a').first().getAttribute('href'), 'same.md');
|
||||
assert.equal(await repeated.locator('a').nth(1).getAttribute('href'), 'second.md');
|
||||
assert.match(await documentText(), /\[Sec\*\*ond\*\*\]\(second.md "Title"\)/);
|
||||
assert.deepEqual(await page.evaluate(() => window.tabMenuTest.prompts), []);
|
||||
assert.deepEqual(await page.evaluate(() => window.__TEST__.prompts), []);
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
console.log('PASS: ordinary link click reveals Markdown, exact spelling caret, keyboard entry, inline Edit link, URL selection, wiki aliases, repeated targets, formatted labels, title preservation, save, undo/redo, both themes, and narrow windows. Native WebView acceptance remains open.');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
await page.screenshot({ path:`${output}/failure.png` });
|
||||
console.log(await page.locator('.writer-cell-editor').allTextContents());
|
||||
console.log({errors, active:await page.evaluate(() => document.activeElement?.outerHTML.slice(0,300))});
|
||||
throw error;
|
||||
} finally { await browser.close(); }
|
||||
});
|
||||
|
||||
@@ -1,134 +1,73 @@
|
||||
// Table keyboard navigation: arrows, caret positions, entry and exit in all directions, goal columns, line breaks, stable cell sizes, saving, and undo.
|
||||
// @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";
|
||||
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 = [];
|
||||
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 { mockTauri, runSmoke, settle, smokeUrl } from "../_harness/index.mjs";
|
||||
import { mockFeaturePlugins } from "../_harness/pluginMocks.mjs";
|
||||
|
||||
await runSmoke("tables/navigation", async ({ page }) => {
|
||||
await mockTauri(page, {
|
||||
commands: test => {
|
||||
const workspace = test.workspace({ root: "C:\\smoke-workspace", writeEvents: true });
|
||||
test.files = workspace.files;
|
||||
return workspace;
|
||||
},
|
||||
};
|
||||
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();
|
||||
await page.locator('.live-writer .cm-content').waitFor();
|
||||
}
|
||||
|
||||
const source = '# Navigation\n\nBefore.\n\n| Name | Value | Formula |\n| --- | --- | --- |\n| Alpha | 12 | =B2*2 |\n| Beta | | tail |\n| Two<br>lines | short | end |\n\nAfter.\n';
|
||||
const table = page.locator('.live-writer table');
|
||||
const cell = (r, c) => table.locator('tr').nth(r).locator('th, td').nth(c);
|
||||
const edit = page.locator('.writer-cell-editor');
|
||||
async function expectCell(r, c) {
|
||||
await page.waitForFunction(({ r, c }) => {
|
||||
const active = document.activeElement;
|
||||
const cell = active?.closest('th, td');
|
||||
return active?.matches('.writer-cell-editor') && cell?.cellIndex === c && cell.parentElement.rowIndex === r;
|
||||
}, { r, c });
|
||||
await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve))));
|
||||
}
|
||||
async function at(r, c, edge = 'End') {
|
||||
await cell(r, c).click();
|
||||
// ProseMirror guards native selections at the start for 200ms after focus.
|
||||
await page.waitForTimeout(220);
|
||||
await page.keyboard.press(`Control+${edge}`);
|
||||
await expectCell(r, c);
|
||||
}
|
||||
async function arrow(key, r, c) {
|
||||
await page.keyboard.press(key);
|
||||
await expectCell(r, c);
|
||||
}
|
||||
async function expectProse(after) {
|
||||
await page.waitForFunction(after => {
|
||||
const content = document.querySelector('.live-writer .cm-content');
|
||||
const table = content?.querySelector('table');
|
||||
const caret = document.getSelection()?.focusNode;
|
||||
return content === document.activeElement && !content.querySelector('.writer-cell-editor') && table && caret &&
|
||||
(table.compareDocumentPosition(caret) & (after ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING));
|
||||
}, after);
|
||||
}
|
||||
async function caret() {
|
||||
return edit.evaluate(el => {
|
||||
const selection = window.getSelection();
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(el);
|
||||
range.setEnd(selection.focusNode, selection.focusOffset);
|
||||
return { offset: range.toString().length, selected: selection.toString() };
|
||||
});
|
||||
}
|
||||
try {
|
||||
await page.goto(process.env.SMOKE_URL || 'http://127.0.0.1:1420');
|
||||
await mockFeaturePlugins(page);
|
||||
// Add a file after the workspace opens, as an external change would.
|
||||
const addFile = (name, text) => page.evaluate(({ name, text }) => {
|
||||
window.__TEST__.files.set(name, text);
|
||||
window.__TEST__.emit('workspace-event', { root: 'C:\\smoke-workspace', kind: 'create', paths: [name] });
|
||||
}, { name, text });
|
||||
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 page.locator('.live-writer .cm-content').waitFor();
|
||||
}
|
||||
const source = '# Navigation\n\nBefore.\n\n| Name | Value | Formula |\n| --- | --- | --- |\n| Alpha | 12 | =B2*2 |\n| Beta | | tail |\n| Two<br>lines | short | end |\n\nAfter.\n';
|
||||
const table = page.locator('.live-writer table');
|
||||
const cell = (r, c) => table.locator('tr').nth(r).locator('th, td').nth(c);
|
||||
const edit = page.locator('.writer-cell-editor');
|
||||
async function expectCell(r, c) {
|
||||
await page.waitForFunction(({ r, c }) => {
|
||||
const active = document.activeElement;
|
||||
const cell = active?.closest('th, td');
|
||||
return active?.matches('.writer-cell-editor') && cell?.cellIndex === c && cell.parentElement.rowIndex === r;
|
||||
}, { r, c });
|
||||
await settle(page);
|
||||
}
|
||||
async function at(r, c, edge = 'End') {
|
||||
await cell(r, c).click();
|
||||
// ProseMirror guards native selections at the start for 200ms after focus.
|
||||
await page.waitForTimeout(220);
|
||||
await page.keyboard.press(`Control+${edge}`);
|
||||
await expectCell(r, c);
|
||||
}
|
||||
async function arrow(key, r, c) {
|
||||
await page.keyboard.press(key);
|
||||
await expectCell(r, c);
|
||||
}
|
||||
async function expectProse(after) {
|
||||
await page.waitForFunction(after => {
|
||||
const content = document.querySelector('.live-writer .cm-content');
|
||||
const table = content?.querySelector('table');
|
||||
const caret = document.getSelection()?.focusNode;
|
||||
return content === document.activeElement && !content.querySelector('.writer-cell-editor') && table && caret &&
|
||||
(table.compareDocumentPosition(caret) & (after ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING));
|
||||
}, after);
|
||||
}
|
||||
async function caret() {
|
||||
return edit.evaluate(el => {
|
||||
const selection = window.getSelection();
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(el);
|
||||
range.setEnd(selection.focusNode, selection.focusOffset);
|
||||
return { offset: range.toString().length, selected: selection.toString() };
|
||||
});
|
||||
}
|
||||
await page.goto(smokeUrl);
|
||||
await page.getByText('smoke-workspace', { exact: true }).waitFor();
|
||||
await page.evaluate(text => {
|
||||
window.__TEST__.files.set('navigation.md', text);
|
||||
window.__TEST__.emit('workspace-event', { root: window.__TEST__.root, kind: 'create', paths: ['navigation.md'] });
|
||||
}, source);
|
||||
await addFile('navigation.md', source);
|
||||
await quickOpen('navigation.md');
|
||||
await table.waitFor();
|
||||
|
||||
@@ -307,10 +246,7 @@ try {
|
||||
await page.setViewportSize({ width, height: 1000 });
|
||||
await page.evaluate(theme => { document.documentElement.dataset.theme = theme; }, theme);
|
||||
const name = `stable-${theme}-${width}.md`;
|
||||
await page.evaluate(({ name, text }) => {
|
||||
window.__TEST__.files.set(name, text);
|
||||
window.__TEST__.emit('workspace-event', { root: window.__TEST__.root, kind: 'create', paths: [name] });
|
||||
}, { name, text: stableSource });
|
||||
await addFile(name, stableSource);
|
||||
await quickOpen(name);
|
||||
await table.waitFor();
|
||||
const initial = await dimensions();
|
||||
@@ -352,10 +288,7 @@ try {
|
||||
// A line break in a tall table keeps the caret and viewport in the active cell.
|
||||
const tallSource = '# Tall table\n\nBefore.\n\n| Name | Value |\n| --- | --- |\n' +
|
||||
Array.from({ length: 45 }, (_, i) => `| Row ${i + 1} | |`).join('\n') + '\n\nAfter.\n';
|
||||
await page.evaluate(text => {
|
||||
window.__TEST__.files.set('line-breaks.md', text);
|
||||
window.__TEST__.emit('workspace-event', { root: window.__TEST__.root, kind: 'create', paths: ['line-breaks.md'] });
|
||||
}, tallSource);
|
||||
await addFile('line-breaks.md', tallSource);
|
||||
await quickOpen('line-breaks.md');
|
||||
await table.waitFor();
|
||||
for (const [r, c, key] of [[1, 0, 'Shift+Enter'], [20, 0, 'Shift+Enter'], [21, 0, 'Shift+Enter'], [20, 0, 'Shift+Enter'], [20, 1, 'Shift+Enter'], [0, 0, 'Shift+Enter']]) {
|
||||
@@ -383,10 +316,7 @@ try {
|
||||
const loneTable = '| Name |\n| --- |\n| Value |';
|
||||
for (const [key, after] of [['ArrowLeft', false], ['ArrowUp', false], ['ArrowRight', true], ['ArrowDown', true]]) {
|
||||
const name = `${key}.md`;
|
||||
await page.evaluate(({ name, text }) => {
|
||||
window.__TEST__.files.set(name, text);
|
||||
window.__TEST__.emit('workspace-event', { root: window.__TEST__.root, kind: 'create', paths: [name] });
|
||||
}, { name, text: loneTable });
|
||||
await addFile(name, loneTable);
|
||||
await quickOpen(name);
|
||||
await table.waitFor();
|
||||
await at(after ? 1 : 0, 0, after ? 'End' : 'Home');
|
||||
@@ -404,9 +334,4 @@ try {
|
||||
const expected = after ? `${loneTable}\n\nOutside.` : `\nOutside.\n${loneTable}`;
|
||||
await page.waitForFunction(({ name, expected }) => window.__TEST__.files.get(name) === expected, { name, expected });
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
console.log('PASS: arrows, caret positions, row wrapping, empty/formula/header cells, entry/exit in all directions, goal columns, document boundaries, text selection, word movement, multiline/wrapped text, line breaks and scrolling in tall tables, save, undo/redo, Tab and Escape, stable cell dimensions and table/prose boundaries in both themes at wide/narrow widths');
|
||||
} catch (error) {
|
||||
await page.screenshot({ path: '.audit/table-navigation-failure.png' });
|
||||
throw error;
|
||||
} finally { await browser.close(); }
|
||||
});
|
||||
|
||||
@@ -1,81 +1,17 @@
|
||||
// Run against `pnpm dev`. PLAYWRIGHT_MODULE may point to a shared installation.
|
||||
import { createRequire } from "node:module";
|
||||
// Table cell selection: drag and Shift-click ranges, keyboard ranges, and clearing or deleting cells, rows, columns, and tables, in both themes and a narrow window.
|
||||
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(10000);
|
||||
const errors = [];
|
||||
await mkdir(".audit", { recursive: true });
|
||||
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 === "spelling_menu_install") return;
|
||||
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}`);
|
||||
},
|
||||
};
|
||||
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: (_event, id) => callbacks.delete(id) };
|
||||
window.__TEST__ = { files, calls, emit, root };
|
||||
});
|
||||
import path from "node:path";
|
||||
import { mockTauri, outputDir, runSmoke, smokeUrl } from "../_harness/index.mjs";
|
||||
|
||||
|
||||
try {
|
||||
await mkdir('output/todo-table', { recursive: true });
|
||||
await page.goto(process.env.SMOKE_URL || 'http://127.0.0.1:1420');
|
||||
await runSmoke("tables/selection", async ({ page }) => {
|
||||
const output = await outputDir("tables/selection");
|
||||
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" }, writeEvents: true }),
|
||||
spelling_menu_install: () => null,
|
||||
}),
|
||||
});
|
||||
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');
|
||||
@@ -94,6 +30,7 @@ try {
|
||||
await table.waitFor();
|
||||
}
|
||||
const contents = () => page.evaluate(() => window.__CM__.state.sliceDoc());
|
||||
const shot = name => page.screenshot({ path: path.join(output, `${name}.png`) });
|
||||
async function drag(r,c,r2,c2) {
|
||||
const start = await cell(r,c).boundingBox(), end = await cell(r2,c2).boundingBox();
|
||||
await page.mouse.move(start.x+start.width/2,start.y+start.height/2);
|
||||
@@ -156,9 +93,9 @@ try {
|
||||
for (let row = 0; row < 3; row++) await page.keyboard.press('Shift+ArrowDown');
|
||||
assert.equal(await selected.count(),8);
|
||||
assert.ok(await selected.evaluateAll(cells => cells.every(c => getComputedStyle(c).borderRadius === '0px')));
|
||||
await page.screenshot({path:`output/todo-table/selection-${theme}-${width}.png`});
|
||||
await shot(`selection-${theme}-${width}`);
|
||||
await page.keyboard.press('Shift+F10');
|
||||
await page.screenshot({path:`output/todo-table/menu-${theme}-${width}.png`});
|
||||
await shot(`menu-${theme}-${width}`);
|
||||
await page.keyboard.press('Escape');
|
||||
assert.equal(await page.locator('.writer-table').evaluate(el => document.activeElement === el),true);
|
||||
await page.evaluate(source => window.__CM__.dispatch({ changes: { from: 0, to: window.__CM__.state.doc.length, insert: source }, selection: { anchor: 0 } }), emptyColumns);
|
||||
@@ -170,13 +107,13 @@ try {
|
||||
for (let col = 0; col < 2; col++) await page.keyboard.press('Shift+ArrowRight');
|
||||
for (let row = 0; row < 4; row++) await page.keyboard.press('Shift+ArrowDown');
|
||||
assert.equal(await selected.count(),15);
|
||||
await page.screenshot({path:`output/todo-table/empty-columns-selected-${theme}-${width}.png`});
|
||||
await shot(`empty-columns-selected-${theme}-${width}`);
|
||||
await page.keyboard.press('Delete');
|
||||
assert.equal(await table.locator('th').count(),3);
|
||||
assert.equal(await table.locator('tr').count(),5);
|
||||
assert.equal(await selected.count(),1);
|
||||
assert.ok((await contents()).includes('| 2cm | Value | |'));
|
||||
await page.screenshot({path:`output/todo-table/empty-columns-deleted-${theme}-${width}.png`});
|
||||
await shot(`empty-columns-deleted-${theme}-${width}`);
|
||||
await page.keyboard.press('Control+z');
|
||||
await page.waitForFunction(source => window.__CM__.state.sliceDoc() === source,emptyColumns);
|
||||
await cell(0,0).click();
|
||||
@@ -213,10 +150,4 @@ try {
|
||||
assert.equal(await table.count(),0);
|
||||
assert.ok((await contents()).includes('After.'));
|
||||
}
|
||||
assert.deepEqual(errors,[]);
|
||||
console.log('PASS: drag and Shift-click ranges, keyboard range entry and extension, Delete/Backspace remove cells, explicit clear, undo, partial/row/column/all delete, outer edges, light/dark narrow screenshots.');
|
||||
} catch(error) {
|
||||
await page.screenshot({path:'output/todo-table/failure.png'});
|
||||
console.error(errors);
|
||||
throw error;
|
||||
} finally { await browser.close(); }
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user