- pnpm smoke runs tests/smoke/ in parallel. It starts Vite when nothing serves SMOKE_URL, finds an installed Chrome when Playwright has no Chromium, and skips a test with a reason when a requirement that the test declares with "// @requires" is missing. Logs go to output/smoke/logs/. - tests/smoke/_harness/ holds the Playwright launch, page error collection, the Tauri IPC mock with an in-memory workspace, and output folders. tabs/order uses it as the first converted test. - Pin Playwright 1.63.0, the version that browser-runtime uses. - RUNESTONE_PLUGIN_REPOS names the folder of the sibling plugin checkouts for buildPlugins, the menu audit, and the smoke tests. - buildInstaller restores the version fields after Ctrl+C, keeps the backups of each attempt, stops when the browser runtime is not staged, and writes the file name instead of absolute paths to host.json. - buildPlugins clears the staged Table Formulas package before copying. - plugins/choiceMenus used the wrong Local Autocomplete folder name.
54 lines
3.8 KiB
JavaScript
54 lines
3.8 KiB
JavaScript
// @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 {
|
|
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.evaluate(async theme => {
|
|
document.documentElement.dataset.theme = theme;
|
|
const { showActionMenu } = await import('/src/lib/ui/managedActionMenu.ts');
|
|
const { activate } = await import('/__autocomplete__/main.mjs');
|
|
let view;
|
|
window.choiceAudit = { saved: null };
|
|
await activate({ ui: { showActionMenu }, completion: { version: 1, transport() {}, invalidate() {}, registerProvider() { return () => {}; }, registerInput() { return { dispose() {}, request() {} }; } },
|
|
settings: { read: async () => ({}), write: async value => { window.choiceAudit.saved = value; } },
|
|
onDispose() {}, registerCommand() {}, registerView(value) { view = value; } });
|
|
document.querySelector('dialog').showModal();
|
|
window.choiceAudit.dispose = view.mount(document.querySelector('main'), { surface: 'settings' });
|
|
}, theme);
|
|
const trigger = page.getByRole('button', { name: 'Server type', exact: true });
|
|
await trigger.click();
|
|
const menu = page.getByRole('menu', { name: 'Server type', exact: true });
|
|
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.keyboard.press('Enter');
|
|
assert.match(await trigger.innerText(), /Ollama/);
|
|
await page.getByRole('button', { name: 'Save settings', exact: true }).click();
|
|
await page.waitForFunction(() => window.choiceAudit.saved?.adapter === 'ollama');
|
|
await trigger.click(); await page.keyboard.press('Escape');
|
|
assert.equal(await trigger.evaluate(node => node === document.activeElement), true);
|
|
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(); }
|