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
+58 -74
View File
@@ -1,100 +1,84 @@
// Theme variants: transparency slider in eight variants, custom theme fonts, a single tooltip, and slideshow command icons.
import assert from 'node:assert/strict';
import { 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 origin = process.env.SMOKE_URL || 'http://127.0.0.1:1420';
const browser = await chromium.launch({ headless: true, ...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}) });
const errors = [];
await mkdir('.audit/host-ui', { recursive: true });
try {
import path from 'node:path';
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from '../_harness/index.mjs';
await runSmoke('appearance/themeVariants', async ({ browser }) => {
const output = await outputDir('appearance/themeVariants');
const context = await browser.newContext({ viewport: { width: 1100, height: 800 } });
await context.addInitScript(() => {
window.isTauri = true;
const root = "C:\\appearance-smoke";
const files = new Map(Array.from({ length: 12 }, (_, index) => [`theme-${index}.py`, `# Theme sample ${index}\ndef sample(parameter):\n return parameter\nname = "RuneStone"\nprint(name, 42)\n`]));
const callbacks = new Map();
let sequence = 0;
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 === "plugins_snapshot") return { root: "C:/appearance-smoke-plugins", plugins: [] };
if (command === "workspace_last_path") return root;
if (command === "workspace_open") return { root, name: "appearance-smoke", watch_mode: "native" };
if (command === "workspace_read") { if (!files.has(args.rel)) throw new Error("File absent"); return files.get(args.rel); }
if (command === "workspace_write") { files.set(args.rel, args.contents); return; }
if (command === "workspace_list") return [...files.keys()].filter(path => !path.startsWith(".")).map(path => ({ name: path, rel_path: path, kind: "file" }));
if (command === "workspace_search") return [];
if (command === "plugin:event|listen") return args.handler;
if (command === "plugin:window|is_maximized") return false;
return null;
},
};
window.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
await mockTauri(context, {
commands: test => ({
...test.workspace({
root: 'C:\\appearance-smoke',
files: Object.fromEntries(Array.from({ length: 12 }, (_, index) => [`theme-${index}.py`, `# Theme sample ${index}\ndef sample(parameter):\n return parameter\nname = "RuneStone"\nprint(name, 42)\n`])),
}),
plugins_snapshot: () => ({ root: 'C:/appearance-smoke-plugins', plugins: [] }),
'plugin:window|is_maximized': () => false,
}),
});
const page = await context.newPage();
page.on('pageerror', error => errors.push(error.message));
await page.goto(`${origin}/?settingsWindow=true`);
const page = await openPage(context);
await page.goto(`${smokeUrl}/?settingsWindow=true`);
await page.getByRole('button', { name: 'Appearance', exact: true }).click();
for (const [theme, mode] of [['default','dark'],['default','light'],['claude','dark'],['claude','light'],['sakura','light'],['harvest-moon','dark'],['crimson-pilot','dark'],['silver-serpent','dark']]) {
await page.evaluate(async ({theme,mode}) => {
(await import('/src/lib/theme/appearance.ts')).saveAppearance({theme,mode,transparency:{enabled:true,amount:18}});
const transparent = page.getByRole('switch', { name: 'Transparent surfaces', exact: true });
for (const [theme, mode] of [['default', 'dark'], ['default', 'light'], ['claude', 'dark'], ['claude', 'light'], ['sakura', 'light'], ['harvest-moon', 'dark'], ['crimson-pilot', 'dark'], ['silver-serpent', 'dark']]) {
await page.evaluate(async ({ theme, mode }) => {
(await import('/src/lib/theme/appearance.ts')).saveAppearance({ theme, mode, transparency: { enabled: true, amount: 18 } });
window.dispatchEvent(new Event('focus'));
},{theme,mode});
}, { theme, mode });
const slider = page.locator('#surface-transparency');
await slider.fill('100');
assert.equal(await page.evaluate(() => JSON.parse(localStorage.getItem('runestone.appearance')).transparency.amount),100);
await slider.focus(); await page.keyboard.press('Home'); assert.equal(await slider.inputValue(),'0');
await page.keyboard.press('End'); assert.equal(await slider.inputValue(),'100');
await page.screenshot({path:`.audit/host-ui/${theme}-${mode}-slider-focus.png`});
await page.getByRole('switch',{name:'Transparent surfaces',exact:true}).uncheck();
assert.equal(await page.evaluate(() => JSON.parse(localStorage.getItem('runestone.appearance')).transparency.amount), 100);
await slider.focus(); await page.keyboard.press('Home'); assert.equal(await slider.inputValue(), '0');
await page.keyboard.press('End'); assert.equal(await slider.inputValue(), '100');
await page.screenshot({ path: path.join(output, `${theme}-${mode}-slider-focus.png`) });
await transparent.uncheck();
assert(await slider.isDisabled());
await page.screenshot({path:`.audit/host-ui/${theme}-${mode}-slider-disabled.png`});
await page.getByRole('switch',{name:'Transparent surfaces',exact:true}).check();
await page.setViewportSize({width:360,height:740}); await slider.scrollIntoViewIfNeeded();
await page.screenshot({ path: path.join(output, `${theme}-${mode}-slider-disabled.png`) });
await transparent.check();
await page.setViewportSize({ width: 360, height: 740 }); await slider.scrollIntoViewIfNeeded();
assert(await page.locator('.content').evaluate(node => node.scrollWidth <= node.clientWidth));
await page.screenshot({path:`.audit/host-ui/${theme}-${mode}-narrow.png`});
await page.setViewportSize({width:1100,height:800});
await page.screenshot({ path: path.join(output, `${theme}-${mode}-narrow.png`) });
await page.setViewportSize({ width: 1100, height: 800 });
}
await page.evaluate(async () => {
const {installTheme} = await import('/src/lib/theme/customThemes.ts');
const {saveAppearance,exportAppearanceTheme} = await import('/src/lib/theme/appearance.ts');
const theme = exportAppearanceTheme('default'); theme.fonts = {ui:'Arial, sans-serif',prose:'Georgia, serif',heading:'Georgia, serif',mono:'Consolas, monospace'};
installTheme(theme); saveAppearance({theme:'custom:my-theme',mode:'dark'}); window.dispatchEvent(new Event('focus'));
const { installTheme } = await import('/src/lib/theme/customThemes.ts');
const { saveAppearance, exportAppearanceTheme } = await import('/src/lib/theme/appearance.ts');
const theme = exportAppearanceTheme('default'); theme.fonts = { ui: 'Arial, sans-serif', prose: 'Georgia, serif', heading: 'Georgia, serif', mono: 'Consolas, monospace' };
installTheme(theme); saveAppearance({ theme: 'custom:my-theme', mode: 'dark' }); window.dispatchEvent(new Event('focus'));
});
assert.match(await page.locator('.preview-prose').evaluate(node => getComputedStyle(node).fontFamily),/Georgia/);
assert.match(await page.evaluate(async () => (await import('/src/lib/theme/appearance.ts')).exportAppearanceTheme('custom:my-theme').fonts.ui),/Arial/);
await page.screenshot({path:'.audit/host-ui/custom-fonts.png'});
const main = await context.newPage(); await main.goto(origin);
assert.match(await page.locator('.preview-prose').evaluate(node => getComputedStyle(node).fontFamily), /Georgia/);
assert.match(await page.evaluate(async () => (await import('/src/lib/theme/appearance.ts')).exportAppearanceTheme('custom:my-theme').fonts.ui), /Arial/);
await page.screenshot({ path: path.join(output, 'custom-fonts.png') });
const main = await openPage(context); await main.goto(smokeUrl);
await main.bringToFront();
await main.getByRole('button',{name:'Files',exact:true}).waitFor();
await main.getByRole('button', { name: 'Files', exact: true }).waitFor();
await main.evaluate(async () => {
const loaded = performance.getEntriesByType('resource').map(entry => entry.name).find(name => new URL(name).pathname === '/src/lib/plugins/external.ts');
const {pluginTools,refreshPlugins} = await import(loaded || '/src/lib/plugins/external.ts');
const { pluginTools, refreshPlugins } = await import(loaded || '/src/lib/plugins/external.ts');
await refreshPlugins();
const invoke = window.__TAURI_INTERNALS__.invoke;
window.__TAURI_INTERNALS__.invoke = (command,args) => command === 'plugins_snapshot' ? Promise.resolve(null) : invoke(command,args);
const commands = [{owner:'runestone.background-slideshow',id:'next-image',title:'Next background image',kind:'command',surface:'commands',icon:'skip-forward'},{owner:'runestone.background-slideshow',id:'pause-resume',title:'Pause or resume background slideshow',kind:'command',surface:'commands',icon:'pause'}];
window.__TAURI_INTERNALS__.invoke = (command, args) => command === 'plugins_snapshot' ? Promise.resolve(null) : invoke(command, args);
const commands = [{ owner: 'runestone.background-slideshow', id: 'next-image', title: 'Next background image', kind: 'command', surface: 'commands', icon: 'skip-forward' }, { owner: 'runestone.background-slideshow', id: 'pause-resume', title: 'Pause or resume background slideshow', kind: 'command', surface: 'commands', icon: 'pause' }];
pluginTools.set(commands);
});
for (const mode of ['dark','light']) {
await main.evaluate(async mode => (await import('/src/lib/theme/appearance.ts')).saveAppearance({theme:'default',mode}),mode);
const button = main.getByRole('button',{name:'Commands',exact:true});
assert.equal(await button.getAttribute('title'),null);
const visibleTooltips = () => main.locator('[role=tooltip]:visible').count();
for (const mode of ['dark', 'light']) {
await main.evaluate(async mode => (await import('/src/lib/theme/appearance.ts')).saveAppearance({ theme: 'default', mode }), mode);
const button = main.getByRole('button', { name: 'Commands', exact: true });
assert.equal(await button.getAttribute('title'), null);
await button.hover(); await main.waitForTimeout(1100);
assert.equal(await main.locator('[role=tooltip]:visible').count(),1);
await main.screenshot({path:`.audit/host-ui/${mode}-single-tooltip.png`});
await main.keyboard.press('Escape'); assert.equal(await main.locator('[role=tooltip]:visible').count(),0);
await main.mouse.move(400,400);
assert.equal(await visibleTooltips(), 1);
await main.screenshot({ path: path.join(output, `${mode}-single-tooltip.png`) });
await main.keyboard.press('Escape'); assert.equal(await visibleTooltips(), 0);
await main.mouse.move(400, 400);
await button.evaluate(node => node.blur());
await button.focus(); await main.waitForTimeout(600); assert.equal(await main.locator('[role=tooltip]:visible').count(),1);
await button.focus(); await main.waitForTimeout(600); assert.equal(await visibleTooltips(), 1);
await button.click(); await main.getByRole('menu').waitFor();
const paths = await main.locator('.rs-menu svg').evaluateAll(nodes => nodes.map(node => node.innerHTML));
assert(paths.some(path => path.includes('M7 4v16'))); assert(paths.some(path => path.includes('m4 4 12 8')));
await main.screenshot({path:`.audit/host-ui/${mode}-slideshow-command-icons.png`}); await main.keyboard.press('Escape');
await main.screenshot({ path: path.join(output, `${mode}-slideshow-command-icons.png`) }); await main.keyboard.press('Escape');
}
assert.deepEqual(errors,[]);
assert.deepEqual([...page.errors, ...main.errors], []);
console.log('PASS: eight theme variants, slider endpoints, persistence, disabled states, narrow layout, font import/export, single tooltip, and command icons.');
} finally { await browser.close(); }
});