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
-44
View File
@@ -1,44 +0,0 @@
import assert from 'node:assert/strict';
import { test } from 'node:test';
import { characterTheme, SYNTAX_ROLES } from '../../../src/lib/theme/characterThemes.ts';
const rgb = (color: string) => color.slice(1).match(/../g)!.map(value => parseInt(value, 16));
const mix = (foreground: string, background: string, opacity: number) => '#' + rgb(foreground)
.map((value, index) => Math.round(value * opacity + rgb(background)[index] * (1 - opacity)).toString(16).padStart(2, '0')).join('');
function luminance(color: string) {
return rgb(color).map(value => value / 255)
.map(value => value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4)
.reduce((sum, value, index) => sum + value * [0.2126, 0.7152, 0.0722][index], 0);
}
function contrast(foreground: string, background: string) {
const [high, low] = [luminance(foreground), luminance(background)].sort((a, b) => b - a);
return (high + 0.05) / (low + 0.05);
}
test('Crimson Pilot text and syntax remain readable in active and selected states', () => {
const palette = characterTheme('crimson-pilot')!;
const [background, elevated, active, , dim, text, strong, accent, selection] = palette.surfaces;
const foregrounds = { dim, text, strong, accent, secondary: palette.secondary,
...Object.fromEntries(SYNTAX_ROLES.map((role, index) => [`syntax-${role}`, palette.syntax[index]])) };
for (const [role, foreground] of Object.entries(foregrounds)) {
for (const surface of [background, elevated, active, selection]) {
assert(contrast(foreground, surface) >= 4.5, `${role} on ${surface} needs 4.5:1 contrast`);
}
}
});
test('Crimson Pilot text remains readable on image-tinted editor and panel surfaces', () => {
const palette = characterTheme('crimson-pilot')!;
const [background, elevated, , , dim, text, strong] = palette.surfaces;
const editor = mix(background, '#ffffff', 0.9);
const codeBlock = mix(elevated, editor, 0.82);
const panel = mix(elevated, '#ffffff', 0.82);
for (const foreground of palette.syntax) {
for (const surface of [editor, codeBlock]) {
assert(contrast(foreground, surface) >= 4.5, `${foreground} on ${surface} needs 4.5:1 contrast`);
}
}
for (const foreground of [dim, text, strong]) {
assert(contrast(foreground, panel) >= 4.5, `${foreground} on image panel ${panel} needs 4.5:1 contrast`);
}
});
@@ -0,0 +1,87 @@
// Character palettes: WCAG contrast of text and syntax colors on opaque and image-tinted surfaces, plus per-theme palette rules.
import assert from 'node:assert/strict';
import { test } from 'node:test';
import { characterTheme, characterSyntax, SYNTAX_ROLES } from '../../../src/lib/theme/characterThemes.ts';
const rgb = (color: string) => color.slice(1).match(/../g)!.map(value => parseInt(value, 16));
const mix = (foreground: string, background: string, opacity: number) => '#' + rgb(foreground)
.map((value, index) => Math.round(value * opacity + rgb(background)[index] * (1 - opacity)).toString(16).padStart(2, '0')).join('');
function luminance(color: string) {
return rgb(color).map(value => value / 255)
.map(value => value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4)
.reduce((sum, value, index) => sum + value * [0.2126, 0.7152, 0.0722][index], 0);
}
function contrast(foreground: string, background: string) {
const [high, low] = [luminance(foreground), luminance(background)].sort((a, b) => b - a);
return (high + 0.05) / (low + 0.05);
}
/** Named foreground groups and surfaces of a palette. Image surfaces are tinted over a white image. */
function roles(theme: string) {
const palette = characterTheme(theme)!;
const [bg, elevated, active, , dim, text, strong, accent, selection] = palette.surfaces;
const editorOnWhite = mix(bg, '#ffffff', 0.9);
const panelOnWhite = mix(elevated, '#ffffff', 0.82);
const foregrounds = {
ui: { dim, text, strong },
accents: { accent, secondary: palette.secondary },
syntax: Object.fromEntries(SYNTAX_ROLES.map((role, index) => [`syntax-${role}`, palette.syntax[index]])),
};
const surfaces = {
bg, elevated, active, selection, editorOnWhite, panelOnWhite,
codeBlockOnWhite: mix(elevated, editorOnWhite, 0.82),
menuHoverOnWhite: mix(active, panelOnWhite, 0.82),
controlHoverOnWhite: mix(active, '#ffffff', 0.92),
};
return { foregrounds, surfaces };
}
type Roles = ReturnType<typeof roles>;
type Check = [foregrounds: (keyof Roles['foregrounds'])[], surfaces: (keyof Roles['surfaces'])[]];
// Every listed foreground needs 4.5:1 contrast on every listed surface.
const readable: { theme: string; name: string; checks: Check[] }[] = [
{ theme: 'harvest-moon', name: 'Harvest Moon', checks: [
[['ui', 'accents'], ['bg', 'elevated', 'active', 'selection']],
[['syntax'], ['bg', 'elevated', 'selection']],
] },
{ theme: 'crimson-pilot', name: 'Crimson Pilot', checks: [
[['ui', 'accents', 'syntax'], ['bg', 'elevated', 'active', 'selection']],
[['syntax'], ['editorOnWhite', 'codeBlockOnWhite']],
[['ui'], ['panelOnWhite']],
] },
{ theme: 'silver-serpent', name: 'Silver Serpent', checks: [
[['ui', 'accents', 'syntax'], ['bg', 'elevated', 'active', 'selection', 'panelOnWhite', 'editorOnWhite', 'menuHoverOnWhite', 'controlHoverOnWhite', 'codeBlockOnWhite']],
] },
];
for (const { theme, name, checks } of readable) {
test(`${name} text and syntax remain readable on opaque and image surfaces`, () => {
const { foregrounds, surfaces } = roles(theme);
for (const [groups, surfaceNames] of checks) {
for (const [role, foreground] of groups.flatMap(group => Object.entries(foregrounds[group]))) {
for (const surface of surfaceNames) {
assert(contrast(foreground, surfaces[surface]) >= 4.5, `${role} ${foreground} on ${surface} ${surfaces[surface]} needs 4.5:1 contrast`);
}
}
}
});
}
test('Harvest Moon uses the warm character colors for all palette roles', () => {
const palette = characterTheme('harvest-moon')!;
for (const color of [...palette.surfaces, palette.secondary, ...palette.syntax]) {
assert.match(color, /^#[0-9a-f]{6}$/i);
const [red, green, blue] = rgb(color);
assert(red >= green && green >= blue, `${color} must follow the copper, amber, red, or cream palette`);
}
assert.equal(palette.mode, 'dark');
assert.equal(Object.keys(characterSyntax('harvest-moon')).length, SYNTAX_ROLES.length);
assert.deepEqual(characterSyntax('unknown'), {});
});
test('Silver Serpent selection has a readable perimeter and a separate fill', () => {
const { surfaces: { bg, elevated, selection }, foregrounds: { accents: { accent } } } = roles('silver-serpent');
assert(contrast(accent, selection) >= 3, 'selection perimeter');
assert(contrast(selection, bg) >= 1.5, 'selection against the editor');
assert(contrast(selection, elevated) >= 1.5, 'selection against a panel');
});
-40
View File
@@ -1,40 +0,0 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { CHARACTER_THEMES, SYNTAX_ROLES } from '../../../src/lib/theme/characterThemes.ts';
const rgb = (hex: string) => hex.match(/[0-9a-f]{2}/gi)!.map(channel => parseInt(channel, 16));
const luminance = (hex: string) => rgb(hex).map(channel => channel / 255)
.map(channel => channel <= .04045 ? channel / 12.92 : ((channel + .055) / 1.055) ** 2.4)
.reduce((sum, channel, index) => sum + channel * [.2126, .7152, .0722][index], 0);
const contrast = (a: string, b: string) => (Math.max(luminance(a), luminance(b)) + .05) / (Math.min(luminance(a), luminance(b)) + .05);
const mix = (a: string, b: string, ratio: number) => '#' + rgb(a)
.map((channel, index) => Math.round(channel * ratio + rgb(b)[index] * (1 - ratio)).toString(16).padStart(2, '0')).join('');
test('Silver Serpent text and syntax remain readable on opaque and image surfaces', () => {
const { surfaces, syntax, secondary } = CHARACTER_THEMES['silver-serpent'];
const [bg, elevated, active, , dim, text, strong, accent, selection] = surfaces;
const panelOnWhite = mix(elevated, '#ffffff', .82);
const editorOnWhite = mix(bg, '#ffffff', .9);
const backgrounds = {
bg, elevated, active, selection,
panelOnWhite,
editorOnWhite,
menuHoverOnWhite: mix(active, panelOnWhite, .82),
controlHoverOnWhite: mix(active, '#ffffff', .92),
codeBlockOnWhite: mix(elevated, editorOnWhite, .82),
};
const foregrounds = { dim, text, strong, accent, secondary,
...Object.fromEntries(SYNTAX_ROLES.map((role, index) => [`syntax-${role}`, syntax[index]])) };
for (const [backgroundName, background] of Object.entries(backgrounds)) {
for (const [foregroundName, foreground] of Object.entries(foregrounds)) {
assert(contrast(foreground, background) >= 4.5, `${foregroundName} on ${backgroundName}`);
}
}
});
test('Silver Serpent selection has a readable perimeter and a separate fill', () => {
const [bg, elevated, , , , , , accent, selection] = CHARACTER_THEMES['silver-serpent'].surfaces;
assert(contrast(accent, selection) >= 3, 'selection perimeter');
assert(contrast(selection, bg) >= 1.5, 'selection against the editor');
assert(contrast(selection, elevated) >= 1.5, 'selection against a panel');
});
-40
View File
@@ -1,40 +0,0 @@
import assert from 'node:assert/strict';
import { test } from 'node:test';
import { characterTheme, characterSyntax, SYNTAX_ROLES } from '../../../src/lib/theme/characterThemes.ts';
const rgb = (color: string) => color.slice(1).match(/../g)!.map(value => parseInt(value, 16) / 255);
function luminance(color: string) {
return rgb(color).map(value => value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4)
.reduce((sum, value, index) => sum + value * [0.2126, 0.7152, 0.0722][index], 0);
}
function contrast(foreground: string, background: string) {
const values = [luminance(foreground), luminance(background)].sort((a, b) => b - a);
return (values[0] + 0.05) / (values[1] + 0.05);
}
test('Harvest Moon text and syntax stay readable on editor, panel, and selected surfaces', () => {
const palette = characterTheme('harvest-moon')!;
const [background, elevated, active, , dim, text, strong, accent, selection] = palette.surfaces;
for (const foreground of [dim, text, strong, accent, palette.secondary]) {
for (const surface of [background, elevated, active, selection]) {
assert(contrast(foreground, surface) >= 4.5, `${foreground} on ${surface} needs 4.5:1 contrast`);
}
}
for (const [index, foreground] of palette.syntax.entries()) {
for (const surface of [background, elevated, selection]) {
assert(contrast(foreground, surface) >= 4.5, `${SYNTAX_ROLES[index]} on ${surface} needs 4.5:1 contrast`);
}
}
});
test('Harvest Moon uses the warm character colors for all palette roles', () => {
const palette = characterTheme('harvest-moon')!;
for (const color of [...palette.surfaces, palette.secondary, ...palette.syntax]) {
assert.match(color, /^#[0-9a-f]{6}$/i);
const [red, green, blue] = rgb(color);
assert(red >= green && green >= blue, `${color} must follow the copper, amber, red, or cream palette`);
}
assert.equal(palette.mode, 'dark');
assert.equal(Object.keys(characterSyntax('harvest-moon')).length, SYNTAX_ROLES.length);
assert.deepEqual(characterSyntax('unknown'), {});
});