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
+51 -75
View File
@@ -1,70 +1,44 @@
import { createRequire } from 'node:module';
// Splash actions and order, and New folder with inline rename in the root, collapsed, and empty folders, with and without a workspace.
import assert from 'node:assert/strict';
import { mkdir, writeFile } from 'node:fs/promises';
import { writeFile } from 'node:fs/promises';
import path from 'node:path';
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from '../_harness/index.mjs';
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: 850 } });
const page = await context.newPage();
page.setDefaultTimeout(10000);
const errors = [];
page.on('pageerror', error => errors.push(error.message));
await context.addInitScript(() => {
window.isTauri = true;
const root = 'C:\\navigation-check';
const folders = new Set(['Untitled', 'Parent', 'Empty']);
const files = new Map([['note.md', '# Note'], ['Parent/existing.md', '# Existing']]);
const state = { folders, files, calls: [] };
window.__NAVIGATION_CHECK__ = state;
let sequence = 0;
window.__TAURI_INTERNALS__ = {
metadata: { currentWindow: { label: 'main' }, currentWebview: { label: 'main' } },
transformCallback: () => ++sequence, unregisterCallback: () => {},
invoke: async (command, args = {}) => {
state.calls.push({ command, args });
if (command === 'plugins_snapshot') return { root: 'C:/plugins', plugins: [] };
if (command === 'workspace_last_path') return state.noWorkspace ? null : root;
if (command === 'workspace_open') return { root, name: 'navigation-check', watch_mode: 'native' };
if (command === 'workspace_read') { if (!files.has(args.rel)) throw new Error('Missing file'); return files.get(args.rel); }
if (command === 'workspace_write') { files.set(args.rel, args.contents); return; }
if (command === 'workspace_list') {
const prefix = args.rel ? args.rel + '/' : '';
return [...[...folders].filter(path => path.startsWith(prefix) && !path.slice(prefix.length).includes('/')).map(path => ({ name: path.slice(prefix.length), rel_path: path, kind: 'folder' })),
...[...files.keys()].filter(path => path.startsWith(prefix) && !path.slice(prefix.length).includes('/') && !path.startsWith('.runestone/')).map(path => ({ name: path.slice(prefix.length), rel_path: path, kind: 'file' }))];
}
if (command === 'workspace_create') { if (folders.has(args.rel) || files.has(args.rel)) throw new Error('Destination exists'); if (args.kind === 'folder') folders.add(args.rel); else files.set(args.rel, ''); return; }
if (command === 'workspace_rename') {
if (folders.has(args.to) || files.has(args.to)) throw new Error('Destination exists');
if (folders.delete(args.from)) folders.add(args.to);
else { files.set(args.to, files.get(args.from)); files.delete(args.from); }
return;
}
if (command === 'plugin:event|listen') return ++sequence;
if (command === 'plugin:window|is_maximized') return false;
if (command === 'workspace_recent' || command === 'workspace_search') return [];
return null;
await runSmoke('tree/navigation', async ({ browser }) => {
const context = await browser.newContext({ viewport: { width: 1280, height: 850 } });
await mockTauri(context, {
strict: false,
commands: test => {
const ws = test.workspace({ root: 'C:\\navigation-check', folders: ['Untitled', 'Parent', 'Empty'], files: { 'note.md': '# Note', 'Parent/existing.md': '# Existing' } });
test.folders = ws.folders;
return {
...ws,
workspace_last_path: () => test.noWorkspace ? null : ws.root,
workspace_list: args => ws.workspace_list(args).filter(entry => !entry.rel_path.startsWith('.runestone')),
workspace_search: () => [],
plugins_snapshot: () => ({ root: 'C:/plugins', plugins: [] }),
'plugin:window|is_maximized': () => false,
};
},
};
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
});
const output = '.audit/todo-navigation';
await mkdir(output, { recursive: true });
const row = path => page.locator(`[data-tree-rel="${path}"]`);
const input = () => page.locator('.tree input');
const folderAction = () => page.getByRole('menuitem', { name: 'New folder', exact: true });
async function checkRename(name) {
await input().waitFor();
await page.waitForFunction(() => document.activeElement?.matches('.tree input'));
const state = await input().evaluate(node => ({ name: node.value, start: node.selectionStart, end: node.selectionEnd }));
assert.deepEqual(state, { name, start: 0, end: name.length });
assert.equal(await page.getByRole('dialog').count(), 0, 'New folder uses inline rename');
}
async function setMode(mode) {
await page.evaluate(async mode => { const { saveAppearance } = await import('/src/lib/theme/appearance.ts'); saveAppearance({ theme: 'default', mode }); }, mode);
}
try {
await page.goto(process.env.SMOKE_URL || 'http://127.0.0.1:5194');
});
const page = await openPage(context);
const output = await outputDir('tree/navigation');
const shot = name => page.screenshot({ path: path.join(output, name) });
const row = rel => page.locator(`[data-tree-rel="${rel}"]`);
const input = () => page.locator('.tree input');
const folderAction = () => page.getByRole('menuitem', { name: 'New folder', exact: true });
async function checkRename(name) {
await input().waitFor();
await page.waitForFunction(() => document.activeElement?.matches('.tree input'));
const state = await input().evaluate(node => ({ name: node.value, start: node.selectionStart, end: node.selectionEnd }));
assert.deepEqual(state, { name, start: 0, end: name.length });
assert.equal(await page.getByRole('dialog').count(), 0, 'New folder uses inline rename');
}
async function setMode(mode) {
await page.evaluate(async mode => { const { saveAppearance } = await import('/src/lib/theme/appearance.ts'); saveAppearance({ theme: 'default', mode }); }, mode);
}
await page.goto(smokeUrl);
await row('Untitled').waitFor();
const welcome = page.locator('.welcome-actions');
await welcome.waitFor();
@@ -82,9 +56,9 @@ try {
for (const mode of ['dark', 'light']) {
await setMode(mode);
await welcome.getByRole('button', { name: /^New file/ }).focus();
await page.screenshot({ path: `${output}/splash-${mode}.png` });
await shot(`splash-${mode}.png`);
await page.setViewportSize({ width: 850, height: 650 });
await page.screenshot({ path: `${output}/splash-${mode}-narrow.png` });
await shot(`splash-${mode}-narrow.png`);
assert.ok(await welcome.locator('button').evaluateAll(nodes => nodes.every(node => { const rect = node.getBoundingClientRect(); return rect.left >= 0 && rect.right <= innerWidth; })), 'Narrow splash controls fit');
await page.setViewportSize({ width: 1280, height: 850 });
}
@@ -110,9 +84,9 @@ try {
await folderAction().click();
const expected = mode === 'dark' ? 'untitled 2' : 'untitled 3';
await checkRename(expected);
await page.screenshot({ path: `${output}/new-folder-${mode}.png` });
await shot(`new-folder-${mode}.png`);
await page.setViewportSize({ width: 850, height: 650 });
await page.screenshot({ path: `${output}/new-folder-${mode}-narrow.png` });
await shot(`new-folder-${mode}-narrow.png`);
await input().press('Escape');
await page.setViewportSize({ width: 1280, height: 850 });
}
@@ -122,16 +96,18 @@ try {
await input().fill('First folder');
await input().press('Enter');
await row('Empty/First folder').waitFor();
assert.equal(await page.evaluate(() => window.__NAVIGATION_CHECK__.folders.has('Empty/First folder')), true);
const emptyPage = await context.newPage();
await emptyPage.addInitScript(() => { window.__NAVIGATION_CHECK__.noWorkspace = true; });
await emptyPage.goto(process.env.SMOKE_URL || 'http://127.0.0.1:5194');
assert.equal(await page.evaluate(() => window.__TEST__.folders.has('Empty/First folder')), true);
const emptyPage = await openPage(context);
await emptyPage.addInitScript(() => { window.__TEST__.noWorkspace = true; });
await emptyPage.goto(smokeUrl);
await emptyPage.locator('.welcome-actions').waitFor();
await emptyPage.locator('.welcome-actions').getByRole('button', { name: 'Open browser', exact: true }).waitFor();
assert.deepEqual(await emptyPage.locator('.welcome-actions button').allTextContents().then(values => values.map(value => value.replace(/Ctrl O/g, '').trim())), ['Open folder', 'Open browser']);
await emptyPage.screenshot({ path: `${output}/splash-no-workspace.png` });
await emptyPage.screenshot({ path: path.join(output, 'splash-no-workspace.png') });
await emptyPage.close();
const errors = [...page.errors, ...emptyPage.errors];
assert.deepEqual(errors, []);
await writeFile(`${output}/checks.json`, JSON.stringify({ passed: true, checks: ['Case-insensitive root name collision', 'Selected inline name and no dialog', 'Enter saves rename', 'Escape retains created folder', 'Collapsed cached parent opens', 'Empty parent', 'Repeated unique names', 'Splash order and three-column maximum', 'Keyboard tab order', 'No workspace actions', 'Dark/light wide/narrow screenshots'], errors }, null, 2));
await writeFile(path.join(output, 'checks.json'), JSON.stringify({ passed: true, checks: ['Case-insensitive root name collision', 'Selected inline name and no dialog', 'Enter saves rename', 'Escape retains created folder', 'Collapsed cached parent opens', 'Empty parent', 'Repeated unique names', 'Splash order and three-column maximum', 'Keyboard tab order', 'No workspace actions', 'Dark/light wide/narrow screenshots'], errors }, null, 2));
console.log(`Navigation checks passed. Evidence: ${output}`);
} finally { await browser.close(); }
});