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
+18 -21
View File
@@ -1,25 +1,23 @@
// Local Autocomplete settings choices use the shared action menu in a modal: keyboard choice, saving, focus return, and cleanup.
// @requires repo:RuneStone_Local_Autocomplete/src
import assert from 'node:assert/strict';
import { readFile, mkdir } from 'node:fs/promises';
import { createRequire } from 'node:module';
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();
const url = process.env.SMOKE_URL || 'http://127.0.0.1:1420';
const errors = [];
page.on('pageerror', error => errors.push(error.message));
await mkdir('.audit/menu-audit', { recursive: true });
await page.route('**/__choice-audit__', route => route.fulfill({ contentType: 'text/html', body: '<link rel="stylesheet" href="/src/lib/theme/tokens.css"><link rel="stylesheet" href="/src/lib/ui/menu.css"><style>dialog{inset:0;margin:0;max-width:none;max-height:none;width:100%;height:100%;box-sizing:border-box;background:var(--rs-bg);color:var(--rs-text);padding:0;border:0}</style><dialog><main></main></dialog>' }));
await page.route('**/__autocomplete__/*.mjs', async route => {
const name = new URL(route.request().url()).pathname.split('/').pop();
assert.ok(['main.mjs', 'engine.mjs'].includes(name));
await route.fulfill({ contentType: 'application/javascript', body: await readFile(new URL(`../../../../RuneStone_Local_Autocomplete/src/${name}`, import.meta.url), 'utf8') });
});
try {
import { readFile } from 'node:fs/promises';
import path from 'node:path';
import { outputDir, pluginRepo, runSmoke, smokeUrl } from '../_harness/index.mjs';
const autocompleteSource = path.join(pluginRepo('RuneStone_Local_Autocomplete'), 'src');
await runSmoke('plugins/choiceMenus', async ({ page }) => {
const output = await outputDir('plugins/choiceMenus');
await page.route('**/__choice-audit__', route => route.fulfill({ contentType: 'text/html', body: '<link rel="stylesheet" href="/src/lib/theme/tokens.css"><link rel="stylesheet" href="/src/lib/ui/menu.css"><style>dialog{inset:0;margin:0;max-width:none;max-height:none;width:100%;height:100%;box-sizing:border-box;background:var(--rs-bg);color:var(--rs-text);padding:0;border:0}</style><dialog><main></main></dialog>' }));
await page.route('**/__autocomplete__/*.mjs', async route => {
const name = new URL(route.request().url()).pathname.split('/').pop();
assert.ok(['main.mjs', 'engine.mjs'].includes(name));
await route.fulfill({ contentType: 'application/javascript', body: await readFile(path.join(autocompleteSource, name), 'utf8') });
});
for (const theme of ['light', 'dark']) for (const width of [1100, 390]) {
await page.setViewportSize({ width, height: 850 });
await page.goto(url + '/__choice-audit__');
await page.goto(smokeUrl + '/__choice-audit__');
await page.evaluate(async theme => {
document.documentElement.dataset.theme = theme;
const { showActionMenu } = await import('/src/lib/ui/managedActionMenu.ts');
@@ -38,7 +36,7 @@ try {
assert.equal(await menu.evaluate(node => !!node.closest('dialog[open]')), true);
await page.keyboard.press('End');
assert.equal(await page.getByRole('menuitemradio', { name: 'Ollama', exact: true }).evaluate(node => node === document.activeElement), true);
await page.screenshot({ path: `.audit/menu-audit/autocomplete-${theme}-${width}.png` });
await page.screenshot({ path: path.join(output, `autocomplete-${theme}-${width}.png`) });
await page.keyboard.press('Enter');
assert.match(await trigger.innerText(), /Ollama/);
await page.getByRole('button', { name: 'Save settings', exact: true }).click();
@@ -48,6 +46,5 @@ try {
await trigger.click(); await page.evaluate(() => window.choiceAudit.dispose());
assert.equal(await page.locator('.rs-menu').count(), 0);
}
assert.deepEqual(errors, []);
console.log('PASS: Local Autocomplete shared choices, modal input, saved adapter, focus return, and cleanup in both themes at 1100/390px.');
} finally { await browser.close(); }
}, { timeout: 30000 });