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
+53 -65
View File
@@ -1,70 +1,62 @@
// Find in plug-in views: privacy attributes, Project Management views, plug-in documents, custom find handlers, focus, both themes, and narrow layouts.
// @requires repo:RuneStone_Project_Management/dist/plugin
// Run against the host development server with PLAYWRIGHT_MODULE set when needed.
import { createRequire } from 'node:module';
import assert from 'node:assert/strict';
import { mkdir, 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 = [];
page.on('pageerror', error => errors.push(error.message));
const output = '.audit/host-privacy-find';
await mkdir(output, { recursive: true });
const pm = {
manifest: JSON.parse(await readFile(new URL('../../../../RuneStone_Project_Management/dist/plugin/plugin.json', import.meta.url), 'utf8')),
code: await readFile(new URL('../../../../RuneStone_Project_Management/dist/plugin/main.js', import.meta.url), 'utf8'),
};
await page.addInitScript(({ pm }) => {
window.isTauri = true;
const files = new Map([['untitled.md', '# Existing note\n'], ['sample.finddoc', 'Alpha alpha alphabet']]);
files.set('Board.md', '---\nrunestone_pm:\n schema: 1\n kind: board\n id: host-find-board\n lists:\n - {id: todo, name: To do, status: todo, collapsed: false}\n - {id: doing, name: In progress, status: doing, collapsed: false}\n - {id: done, name: Done, status: done, collapsed: false}\n defaults: {todo: todo, doing: doing, done: done}\n---\n');
const callbacks = new Map(), listeners = new Map();
let sequence = 0;
const manifest = { schemaVersion: 1, id: 'test.find', name: 'Find test', author: 'Test', description: 'Search checks', version: '1.0.0', apiVersion: 1, entry: 'main.js', access: 'full-app' };
const code = `export function activate(api) {
api.registerDocumentType({ id: 'document', title: 'Test document', extensions: ['finddoc'], identify: path => ({ id: path }), mount(root) {
root.innerHTML = '<section><h2>Test document</h2><p>Alpha alpha alphabet</p><button>Alpha card</button><p hidden>Hidden Alpha</p><button class="focus-return">Details</button></section>';
}});
for (const name of ['Board', 'Changes']) api.registerView({ id: name.toLowerCase(), title: name, placement: 'editor', navigation: true, icon: 'list', mount(root) {
root.innerHTML = '<section><h2>' + name + '</h2><p>Alpha alpha alphabet</p><button>Alpha card</button><p hidden>Hidden Alpha</p><button class="focus-return">Details</button></section>';
}});
api.registerView({ id: 'native', title: 'Custom find', placement: 'editor', navigation: true, find() { window.customFindCalls = (window.customFindCalls || 0) + 1; }, mount(root) { root.innerHTML = '<p>Native content</p>'; } });
}`;
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 = {}) => {
if (command === 'plugin:event|listen') { const ids = listeners.get(args.event) || []; ids.push(args.handler); listeners.set(args.event, ids); return args.handler; }
if (command === 'plugin:event|unlisten') return;
if (command === 'workspace_last_path') return 'C:/find-test';
if (command === 'workspace_open') return { root: 'C:/find-test', name: 'find-test', watch_mode: 'native' };
if (command === 'workspace_list') return args.rel ? [] : [...files.keys()].map(name => ({ name, rel_path: name, kind: 'file' }));
if (command === 'workspace_read') { if (!files.has(args.rel) && args.missingOk) return null; if (!files.has(args.rel)) throw Error('Missing file'); return files.get(args.rel); }
if (command === 'workspace_list_markdown') return [...files.keys()].filter(path => !path.startsWith('.') && path.endsWith('.md'));
if (command === 'workspace_read_many') return args.paths.map(path => ({ path, source: files.get(path) }));
if (command === 'workspace_create') { if (files.has(args.rel)) throw Error('File exists'); files.set(args.rel, ''); return; }
if (command === 'workspace_write') { files.set(args.rel, args.contents); return; }
if (command === 'plugins_snapshot') return { root: 'C:/test/plugins', plugins: [manifest, pm.manifest].map(item => ({ manifest: item, hash: item.id, enabled: true, path: 'C:/test/plugins/' + item.id, error: null, removal: false })) };
if (command === 'plugins_load') return args.id === pm.manifest.id ? pm.code : code;
if (command === 'plugins_data') return 'null';
if (command === 'browser_connect') return 'test';
return null;
},
import { readFile } from 'node:fs/promises';
import path from 'node:path';
import { mockTauri, outputDir, pluginRepo, runSmoke, smokeUrl } from '../_harness/index.mjs';
await runSmoke('find/pluginViews', async ({ page }) => {
const output = await outputDir('find/pluginViews');
const pmDist = pluginRepo('RuneStone_Project_Management/dist/plugin');
const pm = {
manifest: JSON.parse(await readFile(path.join(pmDist, 'plugin.json'), 'utf8')),
code: await readFile(path.join(pmDist, 'main.js'), 'utf8'),
};
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener() {} };
window.__FILES__ = files;
}, { pm });
try {
await page.goto(process.env.SMOKE_URL || 'http://127.0.0.1:1420');
// Unknown commands return null, as the original mock did.
await mockTauri(page, {
strict: false,
state: { pm },
commands: test => {
const workspace = test.workspace({
root: 'C:/find-test',
files: {
'untitled.md': '# Existing note\n',
'sample.finddoc': 'Alpha alpha alphabet',
'Board.md': '---\nrunestone_pm:\n schema: 1\n kind: board\n id: host-find-board\n lists:\n - {id: todo, name: To do, status: todo, collapsed: false}\n - {id: doing, name: In progress, status: doing, collapsed: false}\n - {id: done, name: Done, status: done, collapsed: false}\n defaults: {todo: todo, doing: doing, done: done}\n---\n',
},
});
test.files = workspace.files;
const { pm } = test.state;
const manifest = { schemaVersion: 1, id: 'test.find', name: 'Find test', author: 'Test', description: 'Search checks', version: '1.0.0', apiVersion: 1, entry: 'main.js', access: 'full-app' };
const code = `export function activate(api) {
api.registerDocumentType({ id: 'document', title: 'Test document', extensions: ['finddoc'], identify: path => ({ id: path }), mount(root) {
root.innerHTML = '<section><h2>Test document</h2><p>Alpha alpha alphabet</p><button>Alpha card</button><p hidden>Hidden Alpha</p><button class="focus-return">Details</button></section>';
}});
for (const name of ['Board', 'Changes']) api.registerView({ id: name.toLowerCase(), title: name, placement: 'editor', navigation: true, icon: 'list', mount(root) {
root.innerHTML = '<section><h2>' + name + '</h2><p>Alpha alpha alphabet</p><button>Alpha card</button><p hidden>Hidden Alpha</p><button class="focus-return">Details</button></section>';
}});
api.registerView({ id: 'native', title: 'Custom find', placement: 'editor', navigation: true, find() { window.customFindCalls = (window.customFindCalls || 0) + 1; }, mount(root) { root.innerHTML = '<p>Native content</p>'; } });
}`;
return {
...workspace,
workspace_read: args => {
if (!workspace.files.has(args.rel) && args.missingOk) return null;
return workspace.workspace_read(args);
},
plugins_snapshot: () => ({ root: 'C:/test/plugins', plugins: [manifest, pm.manifest].map(item => ({ manifest: item, hash: item.id, enabled: true, path: 'C:/test/plugins/' + item.id, error: null, removal: false })) }),
plugins_load: args => args.id === pm.manifest.id ? pm.code : code,
plugins_data: () => 'null',
browser_connect: () => 'test',
};
},
});
await page.goto(smokeUrl);
await page.locator('.ws').getByText('find-test', { exact: true }).waitFor();
await page.getByRole('button', { name: 'Plug-in views', exact: true }).waitFor();
const note = page.locator('.tree-tools').getByRole('button', { name: 'New note', exact: true });
assert.equal(await page.locator('.tree-tools').getByRole('button', { name: 'New file', exact: true }).count(), 0);
await note.click();
await page.waitForFunction(() => window.__FILES__.has('untitled 2.md'));
await page.waitForFunction(() => window.__TEST__.files.has('untitled 2.md'));
await page.getByRole('textbox', { name: 'Writing editor', exact: true }).waitFor();
await page.getByRole('textbox', { name: 'Writing editor', exact: true }).click();
await page.keyboard.press('Control+f');
@@ -75,7 +67,7 @@ try {
await page.screenshot({ path: `${output}/new-note-dark.png` });
assert.equal(await page.getByRole('dialog').count(), 0, 'The note opens without a filename dialog');
await note.click();
await page.waitForFunction(() => window.__FILES__.has('untitled 3.md'));
await page.waitForFunction(() => window.__TEST__.files.has('untitled 3.md'));
for (const theme of ['dark', 'light']) {
await page.evaluate(async mode => { const { saveAppearance } = await import('/src/lib/theme/appearance.ts'); saveAppearance({ theme: 'default', mode }); }, theme);
await page.getByRole('tab', { name: 'untitled 3.md', exact: true }).click();
@@ -169,9 +161,5 @@ try {
await page.keyboard.press('Control+f');
assert.equal(await page.evaluate(() => window.customFindCalls), 1, 'Plugin find handlers retain ownership');
assert.equal(await page.locator('.rs-find-bar:visible').count(), 0);
assert.deepEqual(errors, []);
console.log('PASS: Find privacy attributes, actual PM All Tasks and board scope, plugin document Find, custom handlers, focus, both themes, and narrow layouts');
} catch (error) {
await page.screenshot({ path: `${output}/failure.png` });
throw error;
} finally { await browser.close(); }
});