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:
Knotty Wyvern
2026-10-27 20:58:55 -07:00
parent c66ea1ce83
commit 69f90df571
109 changed files with 5920 additions and 7915 deletions
+15 -9
View File
@@ -1,9 +1,14 @@
// Use only an isolated com.runestone.spelling-test debug window.
import { createRequire } from 'node:module';
import { mkdir, writeFile } from 'node:fs/promises';
// Native editing menus in inputs, textareas, and dialogs: unsupported WebView2 commands stay hidden, Undo and spelling work, and focus returns, in both themes.
// Start a debug app with the isolated identifier com.runestone.spelling-test and remote debugging on port 9237:
// set WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=9237
// pnpm tauri dev --config "{\"identifier\":\"com.runestone.spelling-test\"}"
// Run `node tests/native/menuScope.native.mjs`. NATIVE_CDP_URL (or the older SPELLING_CDP_URL) overrides http://127.0.0.1:9237.
import { writeFile } from 'node:fs/promises';
import path from 'node:path';
import assert from 'node:assert/strict';
const { chromium } = createRequire(import.meta.url)(process.env.PLAYWRIGHT_MODULE || 'playwright');
const browser = await chromium.connectOverCDP(process.env.SPELLING_CDP_URL || 'http://127.0.0.1:9237');
import { outputDir, playwright } from '../smoke/_harness/index.mjs';
const { chromium } = playwright();
const browser = await chromium.connectOverCDP(process.env.NATIVE_CDP_URL || process.env.SPELLING_CDP_URL || 'http://127.0.0.1:9237');
const page = browser.contexts()[0].pages()[0];
page.setDefaultTimeout(15000);
const captures = [];
@@ -18,7 +23,8 @@ try {
await listen('spelling-menu', ({ payload }) => window.nativeMenuPayload = payload);
await (await import('/node_modules/@tauri-apps/api/core.js')).invoke('spelling_menu_install');
});
await mkdir('output/todo-menus', { recursive: true });
const output = await outputDir('native/menuScope');
const capturesFile = path.join(output, 'native-filtered-items.json');
const menu = page.getByRole('menu', { name: 'Spelling actions', exact: true });
for (const mode of ['dark', 'light']) {
await page.evaluate(async mode => { const { saveAppearance } = await import('/src/lib/theme/appearance.ts'); saveAppearance({ theme: 'default', mode }); }, mode);
@@ -39,7 +45,7 @@ try {
await menu.waitFor();
const payload = await page.evaluate(() => window.nativeMenuPayload);
captures.push({ mode, kind, value: await field.inputValue(), payload });
await writeFile('output/todo-menus/native-filtered-items.json', JSON.stringify(captures, null, 2));
await writeFile(capturesFile, JSON.stringify(captures, null, 2));
const flatten = items => items.flatMap(item => [item, ...flatten(item.children)]);
const entries = flatten(payload.items);
assert.ok(entries.every(item => item.kind === 3 || !['share', 'writingDirection', 'voiceTyping', 'other'].includes(item.name)));
@@ -48,7 +54,7 @@ try {
assert.ok(entries.some(item => item.name === 'copy'));
assert.equal(await menu.getByRole('menuitem', { name: /More tools|Writing direction|Voice typing|Share/ }).count(), 0);
assert.equal(await menu.evaluate(node => getComputedStyle(node).borderColor), 'rgba(0, 0, 0, 0)');
if (kind === 'textarea') await page.screenshot({ path: `output/todo-menus/native-${mode}.png` });
if (kind === 'textarea') await page.screenshot({ path: path.join(output, `native-${mode}.png`) });
await menu.getByRole('menuitem', { name: 'Undo Ctrl+Z', exact: true }).click();
await page.waitForFunction(() => document.getElementById('native-menu-field').value === 'I recieved a letter.').catch(async error => { console.error('Undo result', await field.inputValue()); throw error; });
await field.click({ button: 'right', position: { x: 48, y: kind === 'input' ? 50 : 22 } });
@@ -62,7 +68,7 @@ try {
assert.equal(await field.evaluate(node => document.activeElement === node), true);
}
}
await writeFile('output/todo-menus/native-filtered-items.json', JSON.stringify(captures, null, 2));
await writeFile(capturesFile, JSON.stringify(captures, null, 2));
console.log('PASS: real WebView2 menus omit unsupported commands, retain editing and spelling, execute native Undo, correct spelling with undo, and restore focus in fields and dialogs in both themes.');
} finally {
await page.evaluate(() => { document.getElementById('native-menu-field')?.remove(); document.getElementById('native-menu-dialog')?.remove(); }).catch(() => {});