Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Anchor theme-fade assertions on the transition, not a frame grid (#4514)
Nick Gomez0a5b43ba1b35
diff --git a/packages/app/tests/stress/_helpers/index.ts b/packages/app/tests/stress/_helpers/index.tsindex 2c9558b77..6780f0684 100644--- a/packages/app/tests/stress/_helpers/index.ts+++ b/packages/app/tests/stress/_helpers/index.ts@@ -49,6 +49,7 @@ export {waitForHttpReady,} from './server-process.ts';export {+ openColorThemes,openProjectPluginsPanel,openSettingsSection,SETTINGS_PANEL_TIMEOUT_MS,@@ -72,6 +73,14 @@ export {} from './slash-menu.ts';export { blockMarker, generateTallDoc } from './tall-doc-fixture.ts';export { removeAllDuringTeardown } from './teardown-fs.ts';+export {+ type ArmedThemeFade,+ FADE_DURATION_MS,+ FADE_REPORT_WINDOW_MS,+ installThemeFadeProbe,+ type ThemeFadeProbeWindow,+ type ThemeFadeReport,+} from './theme-fade.ts';export {createMp3Buffer,createMp4Buffer,diff --git a/packages/app/tests/stress/_helpers/settings.ts b/packages/app/tests/stress/_helpers/settings.tsindex 3dd4c2f3e..95bf4dd19 100644--- a/packages/app/tests/stress/_helpers/settings.ts+++ b/packages/app/tests/stress/_helpers/settings.ts@@ -2,6 +2,7 @@ import type { Locator, Page } from '@playwright/test';import { expect } from './fixtures.ts';export const SETTINGS_PANEL_TIMEOUT_MS = 30_000;+const SETTINGS_DIALOG_TIMEOUT_MS = 15_000;const PLUGIN_BINDING_TIMEOUT_MS = process.env.CI ? 15_000 : 10_000;@@ -20,6 +21,18 @@ export async function openSettingsSection(await waitForSettingsPanel(page, panelTestId);}+export async function openColorThemes(page: Page): Promise<void> {+ await page.goto('/#settings');+ await expect(page.getByTestId('settings-dialog')).toBeVisible({+ timeout: SETTINGS_DIALOG_TIMEOUT_MS,+ });+ await page.getByTestId('settings-search-input').fill('Color theme');+ await page.getByTestId('settings-search-results').getByText('Color theme').first().click();+ await expect(page.getByRole('group', { name: 'Dracula' })).toBeVisible({+ timeout: SETTINGS_PANEL_TIMEOUT_MS,+ });+}+export async function openProjectPluginsPanel(page: Page): Promise<void> {await openSettingsSection(page, 'plugins-manage', 'settings-plugins-manage');}diff --git a/packages/app/tests/stress/_helpers/theme-fade.ts b/packages/app/tests/stress/_helpers/theme-fade.tsnew file mode 100644index 000000000..c9c465ca8--- /dev/null+++ b/packages/app/tests/stress/_helpers/theme-fade.ts@@ -0,0 +1,172 @@+import type { Page } from '@playwright/test';++const FADE_REPORT_TIMEOUT_MS = process.env.CI ? 15_000 : 5_000;+const SEQUENTIAL_REPORT_SENTINELS = 2;+export const FADE_REPORT_WINDOW_MS = FADE_REPORT_TIMEOUT_MS * SEQUENTIAL_REPORT_SENTINELS;+export const FADE_DURATION_MS = 200;++type ThemeFadeStart = 'run' | 'timeout';+export type ThemeFadeSettle = 'end' | 'cancel' | 'timeout';++export interface ThemeFadeReport<K extends string> {+ token: string;+ settle: ThemeFadeSettle;+ durationMs: number;+ beforeClick: Record<K, string>;+ atFadeStart: Record<K, string>;+ atMidpoint: Record<K, string>;+ afterSettle: Record<K, string>;+}++export interface ArmedThemeFade<K extends string> {+ report(): Promise<ThemeFadeReport<K>>;+}++export interface ThemeFadeProbeOptions<K extends string> {+ token: string;+ read: Record<K, () => string>;+}++export interface ThemeFadeProbeWindow {+ armThemeFade?<K extends string>(options: ThemeFadeProbeOptions<K>): ArmedThemeFade<K>;+}++export async function installThemeFadeProbe(page: Page): Promise<void> {+ await page.evaluate((reportTimeoutMs: number) => {+ const root = document.documentElement;++ const readAll = <K extends string>(read: Record<K, () => string>): Record<K, string> => {+ const values = {} as Record<K, string>;+ for (const key of Object.keys(read) as K[]) values[key] = read[key]();+ return values;+ };++ const isTransition = (animation: Animation): animation is CSSTransition =>+ 'transitionProperty' in animation;++ const transitionFor =+ (token: string) =>+ (animation: Animation): animation is CSSTransition =>+ isTransition(animation) && animation.transitionProperty === token;++ const runningTransitions = (): string[] =>+ root+ .getAnimations({ subtree: false })+ .filter(isTransition)+ .map((transition) => transition.transitionProperty);++ (window as typeof window & ThemeFadeProbeWindow).armThemeFade = <K extends string>({+ token,+ read,+ }: ThemeFadeProbeOptions<K>): ArmedThemeFade<K> => {+ const timeoutMs = reportTimeoutMs;+ type Capture =+ | { matched: false; reason: string }+ | { matched: true; transition: CSSTransition; durationMs: number; delayMs: number };+ let captured: Capture = { matched: false, reason: 'no transition was captured' };+ let resolveStart!: (value: ThemeFadeStart) => void;+ const started = new Promise<ThemeFadeStart>((resolve) => {+ resolveStart = resolve;+ });+ let resolveSettle!: (value: ThemeFadeSettle) => void;+ const settled = new Promise<ThemeFadeSettle>((resolve) => {+ resolveSettle = resolve;+ });++ const lifetime = new AbortController();+ let startTimer = 0;+ let settleTimer = 0;+ let reported = false;+ const teardown = () => {+ window.clearTimeout(startTimer);+ window.clearTimeout(settleTimer);+ lifetime.abort();+ };++ const onRun = (event: TransitionEvent) => {+ if (event.target !== root || event.propertyName !== token) return;+ window.clearTimeout(startTimer);+ const match = root.getAnimations({ subtree: false }).find(transitionFor(token));+ const timing = match?.effect?.getComputedTiming();+ const duration = timing?.duration;+ const delay = timing?.delay;+ if (!match) {+ captured = { matched: false, reason: 'no matching transition was running' };+ } else if (typeof duration !== 'number' || !Number.isFinite(duration)) {+ captured = {+ matched: false,+ reason: `the matching transition reported a non-finite duration ${String(duration)}`,+ };+ } else if (typeof delay !== 'number' || !Number.isFinite(delay)) {+ captured = {+ matched: false,+ reason: `the matching transition reported a non-finite delay ${String(delay)}`,+ };+ } else {+ captured = { matched: true, transition: match, durationMs: duration, delayMs: delay };+ }+ resolveStart('run');+ };+ const onSettle = (event: TransitionEvent) => {+ if (event.target !== root || event.propertyName !== token) return;+ resolveSettle(event.type === 'transitioncancel' ? 'cancel' : 'end');+ teardown();+ };++ const beforeClick = readAll(read);+ const failureState = () =>+ JSON.stringify({ runningTransitions: runningTransitions(), beforeClick });+ root.addEventListener('transitionrun', onRun, { signal: lifetime.signal });+ root.addEventListener('transitionend', onSettle, { signal: lifetime.signal });+ root.addEventListener('transitioncancel', onSettle, { signal: lifetime.signal });+ startTimer = window.setTimeout(() => {+ resolveStart('timeout');+ teardown();+ }, timeoutMs);++ return {+ async report(): Promise<ThemeFadeReport<K>> {+ if (reported) {+ throw new Error(+ `report() for ${token} was already awaited; arm a new fade; ${failureState()}`,+ );+ }+ reported = true;+ try {+ if ((await started) !== 'run') {+ throw new Error(+ `theme fade for ${token} never started within ${timeoutMs}ms; ${failureState()}`,+ );+ }+ const capture = captured;+ if (!capture.matched) {+ throw new Error(+ `transitionrun fired for ${token} but ${capture.reason}; ${failureState()}`,+ );+ }+ settleTimer = window.setTimeout(() => resolveSettle('timeout'), timeoutMs);+ const { delayMs, durationMs, transition } = capture;+ transition.pause();+ transition.currentTime = 0;+ const atFadeStart = readAll(read);+ transition.currentTime = delayMs + durationMs / 2;+ const atMidpoint = readAll(read);+ transition.play();+ const settle = await settled;+ return {+ token,+ settle,+ durationMs,+ beforeClick,+ atFadeStart,+ atMidpoint,+ afterSettle: readAll(read),+ };+ } finally {+ teardown();+ }+ },+ };+ };+ }, FADE_REPORT_TIMEOUT_MS);+}diff --git a/packages/app/tests/stress/theme-color-conversion.e2e.ts b/packages/app/tests/stress/theme-color-conversion.e2e.tsindex 1bd54438d..68783caba 100644--- a/packages/app/tests/stress/theme-color-conversion.e2e.ts+++ b/packages/app/tests/stress/theme-color-conversion.e2e.ts@@ -1,15 +1,12 @@import { PREVIEW_THEME_TOKENS } from '@inkeep/open-knowledge-core';-import { expect, SETTINGS_PANEL_TIMEOUT_MS, test } from './_helpers';--async function openColorThemes(page: import('@playwright/test').Page) {- await page.goto('/#settings');- await expect(page.getByTestId('settings-dialog')).toBeVisible({ timeout: 15_000 });- await page.getByTestId('settings-search-input').fill('Color theme');- await page.getByTestId('settings-search-results').getByText('Color theme').first().click();- await expect(page.getByRole('group', { name: 'Dracula' })).toBeVisible({- timeout: SETTINGS_PANEL_TIMEOUT_MS,- });-}+import {+ expect,+ FADE_DURATION_MS,+ installThemeFadeProbe,+ openColorThemes,+ type ThemeFadeProbeWindow,+ test,+} from './_helpers';test('painted comment underlines retain their sRGB contrast in both default modes', async ({page,@@ -132,21 +129,60 @@ test('converts CSS Color 4 tokens for live xterm themes without losing alpha cha.toBe(0);const monokai = page.getByRole('button', { name: 'Use Monokai for the active light mode' });- await monokai.click();-- const samples = await page.evaluate(async () => {- const modulePath = '/src/components/terminal-theme.ts';- const { computeLiveXtermTheme } = await import(modulePath);- const values: string[] = [];- for (let index = 0; index < 24; index += 1) {- values.push(computeLiveXtermTheme('dark').selectionBackground ?? '');- await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));- }- return values;- });+ await installThemeFadeProbe(page);+ const fade = await monokai.evaluate(+ async (element, { token }) => {+ if (!(element instanceof HTMLButtonElement)) throw new Error('Expected a palette button');+ const modulePath = '/src/components/terminal-theme.ts';+ const { computeLiveXtermTheme } = await import(modulePath);+ const { armThemeFade } = window as typeof window & ThemeFadeProbeWindow;+ if (!armThemeFade) {+ throw new Error(+ 'window.armThemeFade is absent; installThemeFadeProbe(page) must run after the last navigation',+ );+ }+ const armed = armThemeFade({+ token,+ read: {+ selection: (): string => computeLiveXtermTheme('dark').selectionBackground ?? '',+ },+ });+ element.click();+ return armed.report();+ },+ { token: '--selection-soft' },+ );- expect(samples.every((value) => /^#[0-9a-f]{8}$/.test(value))).toBe(true);- expect(new Set(samples).size).toBeGreaterThan(2);- expect(samples[0]).not.toBe(samples.at(-1));+ const detail = `\n${fade.token} fade report:\n${JSON.stringify(fade)}\n`;+ expect(fade.settle, `the fade did not reach transitionend.${detail}`).toBe('end');+ expect(fade.durationMs, `the :root transition is not the product's fade duration.${detail}`).toBe(+ FADE_DURATION_MS,+ );+ for (const [phase, value] of Object.entries({+ beforeClick: fade.beforeClick.selection,+ atFadeStart: fade.atFadeStart.selection,+ atMidpoint: fade.atMidpoint.selection,+ afterSettle: fade.afterSettle.selection,+ })) {+ expect(value, `the ${phase} xterm selection is not an 8-digit hex.${detail}`).toMatch(+ /^#[0-9a-f]{8}$/,+ );+ }+ expect(+ fade.atFadeStart.selection,+ `seeking to currentTime 0 did not reproduce the pre-click selection.${detail}`,+ ).toBe(fade.beforeClick.selection);+ expect(+ fade.atMidpoint.selection,+ `the midpoint never left the pre-click selection — the fade did not interpolate.${detail}`,+ ).not.toBe(fade.beforeClick.selection);+ expect(+ fade.atMidpoint.selection,+ `the midpoint already equals the settled selection — the fade snapped.${detail}`,+ ).not.toBe(fade.afterSettle.selection);+ expect(+ fade.afterSettle.selection,+ `the settled selection equals the pre-click one — the palette never changed.${detail}`,+ ).not.toBe(fade.beforeClick.selection);await expect.poll(() => page.locator('html').getAttribute('data-color-theme')).toBe('monokai');});diff --git a/packages/app/tests/stress/theme-fade.e2e.ts b/packages/app/tests/stress/theme-fade.e2e.tsindex 5b430745d..8d6f0d8d9 100644--- a/packages/app/tests/stress/theme-fade.e2e.ts+++ b/packages/app/tests/stress/theme-fade.e2e.ts@@ -1,28 +1,36 @@-import { expect, SETTINGS_PANEL_TIMEOUT_MS, test } from './_helpers';+import {+ expect,+ FADE_DURATION_MS,+ FADE_REPORT_WINDOW_MS,+ installThemeFadeProbe,+ openColorThemes,+ type ThemeFadeProbeWindow,+ test,+} from './_helpers';-async function openColorThemes(page: import('@playwright/test').Page) {- await page.goto('/#settings');- await expect(page.getByTestId('settings-dialog')).toBeVisible({ timeout: 15_000 });- await page.getByTestId('settings-search-input').fill('Color theme');- await page.getByTestId('settings-search-results').getByText('Color theme').first().click();- await expect(page.getByRole('group', { name: 'Dracula' })).toBeVisible({- timeout: SETTINGS_PANEL_TIMEOUT_MS,- });-}+const PROBE_REPORT_WINDOWS_TO_OUTLAST = 2;+const PROBE_DURATION_MS = FADE_REPORT_WINDOW_MS * PROBE_REPORT_WINDOWS_TO_OUTLAST;-async function backgroundSamples(button: import('@playwright/test').Locator): Promise<string[]> {- return button.evaluate(async (element) => {- if (!(element instanceof HTMLButtonElement)) throw new Error('Expected a palette button');- const values = new Set<string>();- element.click();- for (let index = 0; index < 20; index += 1) {- values.add(- getComputedStyle(document.documentElement).getPropertyValue('--background').trim(),- );- await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));- }- return [...values];- });+async function paletteFadeProbe(button: import('@playwright/test').Locator) {+ return button.evaluate(+ async (element, { token }) => {+ if (!(element instanceof HTMLButtonElement)) throw new Error('Expected a palette button');+ const root = document.documentElement;+ const { armThemeFade } = window as typeof window & ThemeFadeProbeWindow;+ if (!armThemeFade) {+ throw new Error(+ 'window.armThemeFade is absent; installThemeFadeProbe(page) must run after the last navigation',+ );+ }+ const armed = armThemeFade({+ token,+ read: { background: () => getComputedStyle(root).getPropertyValue(token).trim() },+ });+ element.click();+ return armed.report();+ },+ { token: '--background' },+ );}test('theme settings fade typed tokens and persist a same-mode palette switch', async ({@@ -54,12 +62,40 @@ test('theme settings fade typed tokens and persist a same-mode palette switch',await expect.poll(() => page.locator('html').evaluate((root) => root.getAnimations().length)).toBe(0);- const samples = await backgroundSamples(+ await installThemeFadeProbe(page);+ const fade = await paletteFadeProbe(page.getByRole('button', { name: 'Use Monokai for the active light mode' }),);- expect(samples).toContain('rgb(39, 40, 34)');- expect(new Set(samples).size).toBeGreaterThan(2);+ const detail = `\n${fade.token} fade report:\n${JSON.stringify(fade)}\n`;+ expect(fade.settle, `the fade did not reach transitionend.${detail}`).toBe('end');+ expect(fade.durationMs, `the :root transition is not the product's fade duration.${detail}`).toBe(+ FADE_DURATION_MS,+ );+ for (const [phase, value] of Object.entries({+ beforeClick: fade.beforeClick.background,+ atFadeStart: fade.atFadeStart.background,+ atMidpoint: fade.atMidpoint.background,+ afterSettle: fade.afterSettle.background,+ })) {+ expect(value, `the ${phase} --background read is empty or absent.${detail}`).toMatch(/\S/);+ }+ expect(+ fade.atFadeStart.background,+ `seeking to currentTime 0 did not reproduce the pre-click value.${detail}`,+ ).toBe(fade.beforeClick.background);+ expect(+ fade.atMidpoint.background,+ `the midpoint never left the pre-click value — the fade did not interpolate.${detail}`,+ ).not.toBe(fade.beforeClick.background);+ expect(+ fade.atMidpoint.background,+ `the midpoint already equals the settled value — the fade snapped.${detail}`,+ ).not.toBe(fade.afterSettle.background);+ expect(+ fade.afterSettle.background,+ `the settled token is not Monokai's background.${detail}`,+ ).toBe('rgb(39, 40, 34)');await expect.poll(() => page.locator('html').getAttribute('data-color-theme')).toBe('monokai');await page.reload();@@ -127,68 +163,163 @@ test('default light and dark modes fade surfaces without losing selection', asyn.poll(() => page.locator('html').evaluate((root) => root.getAnimations().length)).toBe(0);const search = page.getByTestId('settings-search-input');- await search.focus();- const samples = await page.evaluate(async () => {- const input = document.querySelector<HTMLInputElement>('[data-testid="settings-search-input"]');- input?.setSelectionRange(0, 0);- const transformProbe = document.createElement('div');- const opacityProbe = document.createElement('div');- const sizeProbe = document.createElement('div');- const shadowProbe = document.createElement('div');- const colorProbe = document.createElement('div');- transformProbe.style.transition = 'transform 1s linear';- opacityProbe.style.transition = 'opacity 1s linear';- sizeProbe.style.transition = 'width 1s linear';- shadowProbe.style.transition = 'box-shadow 1s linear';- colorProbe.style.transition = 'color 1s linear';- opacityProbe.style.opacity = '1';- sizeProbe.style.width = '1px';- shadowProbe.style.boxShadow = '0 0 0 transparent';- colorProbe.style.color = 'rgb(0, 0, 0)';- const probes = [transformProbe, opacityProbe, sizeProbe, shadowProbe, colorProbe];- document.body.append(...probes);- void getComputedStyle(sizeProbe).width;- const initial = getComputedStyle(document.body).backgroundColor;- document.querySelector<HTMLButtonElement>('[data-testid="theme-picker-dark"]')?.click();- transformProbe.style.transform = 'translateX(1px)';- opacityProbe.style.opacity = '0.5';- sizeProbe.style.width = '2px';- shadowProbe.style.boxShadow = '0 0 1px black';- colorProbe.style.color = 'rgb(1, 1, 1)';- await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));- await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));- await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));- const transitionProperties = document- .getAnimations()- .map((animation) => (animation as CSSTransition).transitionProperty);- const colorTransitionProperties = colorProbe- .getAnimations()- .map((animation) => (animation as CSSTransition).transitionProperty);- const colors = [initial];- for (let index = 0; index < 24; index += 1) {- await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));- colors.push(getComputedStyle(document.body).backgroundColor);- }- probes.forEach((probe) => {- probe.remove();- });- return {- colors,- focused: document.activeElement === input,- selection: input?.selectionStart,- transitionProperties,- colorTransitionProperties,- };- });- expect(new Set(samples.colors).size).toBeGreaterThan(2);- expect(samples.colors[0]).not.toBe(samples.colors.at(-1));- expect(samples.focused).toBe(true);- expect(samples.selection).toBe(0);- expect(samples.transitionProperties).toContain('transform');- expect(samples.transitionProperties).toContain('opacity');- expect(samples.transitionProperties).toContain('width');- expect(samples.transitionProperties).toContain('box-shadow');- expect(samples.colorTransitionProperties).toEqual([]);+ await search.fill('theme');+ await expect(search).toHaveValue('theme');+ await installThemeFadeProbe(page);+ const fade = await page.evaluate(+ async ({ token, probeDurationMs }) => {+ const input = document.querySelector<HTMLInputElement>(+ '[data-testid="settings-search-input"]',+ );+ if (!input) {+ throw new Error('settings-search-input not found; cannot pin the caret before the fade');+ }+ input.setSelectionRange(2, 2);+ const transformProbe = document.createElement('div');+ const opacityProbe = document.createElement('div');+ const sizeProbe = document.createElement('div');+ const shadowProbe = document.createElement('div');+ const colorProbe = document.createElement('div');+ transformProbe.style.transition = `transform ${probeDurationMs}ms linear`;+ opacityProbe.style.transition = `opacity ${probeDurationMs}ms linear`;+ sizeProbe.style.transition = `width ${probeDurationMs}ms linear`;+ shadowProbe.style.transition = `box-shadow ${probeDurationMs}ms linear`;+ colorProbe.style.transition = `color ${probeDurationMs}ms linear`;+ opacityProbe.style.opacity = '1';+ sizeProbe.style.width = '1px';+ shadowProbe.style.boxShadow = '0 0 0 transparent';+ colorProbe.style.color = 'rgb(0, 0, 0)';+ const probes = [transformProbe, opacityProbe, sizeProbe, shadowProbe, colorProbe];+ document.body.append(...probes);+ void getComputedStyle(sizeProbe).width;+ try {+ const root = document.documentElement;+ const canvas = document.createElement('canvas');+ canvas.width = canvas.height = 1;+ const context = canvas.getContext('2d');+ if (!context) throw new Error('Canvas unavailable');+ const acceptedFrom = (seed: string, value: string): string => {+ context.fillStyle = seed;+ context.fillStyle = value;+ return context.fillStyle;+ };+ const normalize = (value: string): string => {+ if (acceptedFrom('#000000', value) !== acceptedFrom('#ffffff', value)) {+ throw new Error(`Canvas rejected the color ${JSON.stringify(value)}`);+ }+ context.clearRect(0, 0, 1, 1);+ context.fillStyle = value;+ context.fillRect(0, 0, 1, 1);+ return [...context.getImageData(0, 0, 1, 1).data].join(',');+ };+ const darkPicker = document.querySelector<HTMLButtonElement>(+ '[data-testid="theme-picker-dark"]',+ );+ if (!darkPicker) {+ throw new Error('theme-picker-dark not found; the fade was never triggered');+ }+ const { armThemeFade } = window as typeof window & ThemeFadeProbeWindow;+ if (!armThemeFade) {+ throw new Error(+ 'window.armThemeFade is absent; installThemeFadeProbe(page) must run after the last navigation',+ );+ }+ const armed = armThemeFade({+ token,+ read: {+ body: () => normalize(getComputedStyle(document.body).backgroundColor),+ sidebar: () => getComputedStyle(root).getPropertyValue(token).trim(),+ },+ });+ darkPicker.click();+ transformProbe.style.transform = 'translateX(1px)';+ opacityProbe.style.opacity = '0.5';+ sizeProbe.style.width = '2px';+ shadowProbe.style.boxShadow = '0 0 1px black';+ colorProbe.style.color = 'rgb(1, 1, 1)';+ const report = await armed.report();+ return {+ ...report,+ connected: input.isConnected,+ focused: document.activeElement === input,+ activeTestId: document.activeElement?.getAttribute('data-testid') ?? null,+ activeTag: document.activeElement?.tagName ?? null,+ value: input.value,+ selectionStart: input.selectionStart,+ selectionEnd: input.selectionEnd,+ probeTransitionProperties: [transformProbe, opacityProbe, sizeProbe, shadowProbe].flatMap(+ (probe) =>+ probe+ .getAnimations()+ .map((animation) => (animation as CSSTransition).transitionProperty),+ ),+ colorTransitionProperties: colorProbe+ .getAnimations()+ .map((animation) => (animation as CSSTransition).transitionProperty),+ };+ } finally {+ probes.forEach((probe) => {+ probe.remove();+ });+ }+ },+ { token: '--sidebar', probeDurationMs: PROBE_DURATION_MS },+ );+ const detail = `\n${fade.token} fade report (body samples are r,g,b,a):\n${JSON.stringify(fade)}\n`;+ expect(fade.settle, `the fade did not reach transitionend.${detail}`).toBe('end');+ expect(fade.durationMs, `the :root transition is not the product's fade duration.${detail}`).toBe(+ FADE_DURATION_MS,+ );+ for (const [phase, value] of Object.entries({+ beforeClick: fade.beforeClick.body,+ atFadeStart: fade.atFadeStart.body,+ atMidpoint: fade.atMidpoint.body,+ afterSettle: fade.afterSettle.body,+ })) {+ expect(value, `the ${phase} body sample is not an r,g,b,a byte join.${detail}`).toMatch(+ /^\d{1,3},\d{1,3},\d{1,3},\d{1,3}$/,+ );+ }+ expect(+ fade.atFadeStart.body,+ `seeking to currentTime 0 did not reproduce the pre-click surface.${detail}`,+ ).toBe(fade.beforeClick.body);+ expect(+ fade.atMidpoint.body,+ `the midpoint never left the light surface — the fade did not interpolate.${detail}`,+ ).not.toBe(fade.beforeClick.body);+ expect(+ fade.atMidpoint.body,+ `the midpoint already equals the settled surface — the fade snapped.${detail}`,+ ).not.toBe(fade.afterSettle.body);+ expect(+ fade.afterSettle.body,+ `the settled surface equals the light one — the mode never switched.${detail}`,+ ).not.toBe(fade.beforeClick.body);+ expect(fade.afterSettle.sidebar, `the settled token is not dark --sidebar.${detail}`).toBe(+ 'oklch(0.205 0 0)',+ );+ expect(+ fade.connected,+ `the search input node was replaced during the theme switch.${detail}`,+ ).toBe(true);+ expect(+ fade.focused,+ `the search input no longer holds focus after the theme switch.${detail}`,+ ).toBe(true);+ expect(fade.value, `the theme switch discarded the search query.${detail}`).toBe('theme');+ expect(fade.selectionStart, `the theme switch moved the caret.${detail}`).toBe(2);+ expect(fade.selectionEnd, `the theme switch extended the selection.${detail}`).toBe(2);+ for (const property of ['transform', 'opacity', 'width', 'box-shadow']) {+ expect(+ fade.probeTransitionProperties,+ `the fade guard cancelled the non-color ${property} transition it must leave running.${detail}`,+ ).toContain(property);+ }+ expect(+ fade.colorTransitionProperties,+ `the fade guard left a descendant color transition running during the theme fade.${detail}`,+ ).toEqual([]);await expect(page.locator('html')).toHaveClass(/dark/);await expect(page.locator('html')).not.toHaveAttribute('data-theme-color-fading');const selectionColor = await page.evaluate(async () => {@@ -198,8 +329,16 @@ test('default light and dark modes fade surfaces without losing selection', asyn});expect(selectionColor).toMatch(/^#[0-9a-f]{6}52$/);+ await search.fill('');+ await expect(search).toHaveValue('');await page.emulateMedia({ reducedMotion: 'reduce' });const reducedMotion = await page.evaluate(async () => {+ const lightPicker = document.querySelector<HTMLButtonElement>(+ '[data-testid="theme-picker-light"]',+ );+ if (!lightPicker) {+ throw new Error('theme-picker-light not found; the mode switch was never triggered');+ }const colorProbe = document.createElement('div');const flashProbe = document.createElement('div');const opacityProbe = document.createElement('div');@@ -209,7 +348,7 @@ test('default light and dark modes fade surfaces without losing selection', asyndocument.body.append(colorProbe, flashProbe, opacityProbe);void getComputedStyle(colorProbe).color;void getComputedStyle(flashProbe).boxShadow;- document.querySelector<HTMLButtonElement>('[data-testid="theme-picker-light"]')?.click();+ lightPicker.click();colorProbe.style.color = 'rgb(1, 1, 1)';flashProbe.className = 'ok-landing-flash';opacityProbe.style.opacity = '0.5';@@ -222,13 +361,16 @@ test('default light and dark modes fade surfaces without losing selection', asynconst flashTransitions = flashProbe.getAnimations().map((animation) => (animation as CSSTransition).transitionProperty);+ const opacityTransitions = opacityProbe+ .getAnimations()+ .map((animation) => (animation as CSSTransition).transitionProperty);colorProbe.remove();flashProbe.remove();opacityProbe.remove();- return { transitionProperties, flashTransitions };+ return { transitionProperties, flashTransitions, opacityTransitions };});expect(reducedMotion.flashTransitions).toContain('box-shadow');- expect(reducedMotion.transitionProperties).toContain('opacity');+ expect(reducedMotion.opacityTransitions).toContain('opacity');expect(reducedMotion.transitionProperties.filter((property) => !['transform', 'opacity', 'box-shadow'].includes(property),diff --git a/packages/app/tsconfig.json b/packages/app/tsconfig.jsonindex 1168fd854..0ec2d12d5 100644--- a/packages/app/tsconfig.json+++ b/packages/app/tsconfig.json@@ -37,12 +37,31 @@// to `HTMLImageElement` still compiles (a downcast within the union is// permitted), and the `.complete` conjunct is not pinned. It imports only// `@playwright/test`, so its closure adds no other file to the program.+ //+ // `tests/stress/_helpers/theme-fade.ts` is named for the same reason, and its+ // guarantee is narrower. It pins the transition probe's own types: the+ // `Capture` discriminated union that makes a matched capture missing its+ // `transition`, `durationMs` or `delayMs` unrepresentable, the+ // `transitionFor` type predicate that keeps `getAnimations().find(...)`+ // returning `CSSTransition | undefined` with no cast at the use site, and the+ // `typeof duration !== 'number'` and `typeof delay !== 'number'` rejections+ // that narrow what `getComputedTiming()` gives those two: respectively a+ // `string | number | CSSNumericValue | undefined` union and an optional+ // `number`. Delete any of them and this compile fails inside `armThemeFade`.+ // As with `image.ts` above, replacing one with a cast still compiles: the pin+ // is against silent removal, not against a deliberate assertion. The+ // guarantee also stops at the module boundary: the three `*.e2e.ts` call+ // sites stay outside the program, so their+ // `window as typeof window & ThemeFadeProbeWindow` casts and their reads off+ // the returned report are unchecked. It imports only `@playwright/test`, so+ // its closure adds no other file to the program."include": ["src","*.ts","tests/stress/fixtures","tests/half-open-forced-close.test-helper.ts",- "tests/stress/_helpers/image.ts"+ "tests/stress/_helpers/image.ts",+ "tests/stress/_helpers/theme-fade.ts"],"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.test.tsx"]}