test(determinism): deterministic waits + stableShot screenshots; drop blind sleeps/ifs/retries
Make the Playwright e2e + kicad suites deterministic so screenshot flake stops tracing to timing races. - Blind page.waitForTimeout -> condition waits (expect.poll, web-first assertions, waitUntil) + readiness helpers (waitForWxApp, waitForCanvasApp). Remaining sleeps are documented interaction dwells (annotated). - Defensive "if element exists" branches -> loud asserts; label-fallback chains -> normalized clickMenuItemByText. First-run wizard for/if loops removed by seeding calculator/gerbview/pcbnew HTMLs. - Screenshots: new stableShot(page, name) settles the render in-page (canvas hash over rAF) then writes a raw PNG to test-results/ for the existing offline gate (tools/screenshots vs baseline-screenshots). Replaces toHaveScreenshot, which did inline compare + its own baselines and had decoupled the specs from the real gate. scale:'css' pinned. - retries: 0 in both configs. - Guard: tests/tools/lint-determinism.ts (npm run lint:determinism) bans blind sleeps / toHaveScreenshot / inline retries / swallowed catches in specs; documented exceptions carry a marker. Rules in tests/TESTING.md. Assertions, coverage, and renders unchanged (semantic-equivalence reviewed; captures pixel-identical modulo inherent timer/timestamp/3d-raytrace variance). Both suites green at retries:0 (e2e 340, kicad 92); ~35-61% faster. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BVX1pHMvRPYHdp6ZfEawrk
This commit is contained in:
parent
d9264549bf
commit
4c3a4cacd4
102 changed files with 2867 additions and 3407 deletions
|
|
@ -1,37 +1,35 @@
|
|||
// wxSplitterWindow and wxScrolledWindow Tests - Layout controls KiCad uses
|
||||
import { test, expect, MAIN_CANVAS, tryLoadApp, getCanvasBox } from './utils/fixtures';
|
||||
import { getSplitterSash, findRenderedByType } from './utils/element-tracker';
|
||||
import { test, expect, MAIN_CANVAS, getCanvasBox } from './utils/fixtures';
|
||||
import { getSplitterSash, findRenderedByType, waitForWxApp, stableShot } from './utils/element-tracker';
|
||||
|
||||
test.describe('wxSplitterWindow & wxScrolledWindow Tests', () => {
|
||||
|
||||
test('Layout test app loads successfully', async ({ page, testLogger }) => {
|
||||
await page.goto('/standalone/layout/layout_test.html');
|
||||
const loaded = await tryLoadApp(page);
|
||||
await waitForWxApp(page);
|
||||
|
||||
await page.screenshot({ path: 'test-results/layout-01-loaded.png', fullPage: true });
|
||||
await stableShot(page, 'layout-01-loaded.png', { fullPage: true });
|
||||
|
||||
const hasStartup = testLogger.consoleLogs.some(l => l.includes('Layout test app started'));
|
||||
|
||||
expect(loaded, 'Layout app should load').toBe(true);
|
||||
expect(testLogger.errors.filter(e => !e.includes('favicon'))).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('Splitter is visible with two panes', async ({ page, testLogger }) => {
|
||||
await page.goto('/standalone/layout/layout_test.html');
|
||||
const loaded = await tryLoadApp(page);
|
||||
expect(loaded, 'App should load').toBe(true);
|
||||
await waitForWxApp(page);
|
||||
|
||||
await page.screenshot({ path: 'test-results/layout-02-splitter.png', fullPage: true });
|
||||
await expect.poll(
|
||||
() => testLogger.consoleLogs.some(l => l.includes('Splitter position')),
|
||||
{ message: 'Splitter position should be logged' }
|
||||
).toBe(true);
|
||||
|
||||
const hasSplitterLog = testLogger.consoleLogs.some(l => l.includes('Splitter position'));
|
||||
|
||||
expect(hasSplitterLog).toBe(true);
|
||||
await stableShot(page, 'layout-02-splitter.png', { fullPage: true });
|
||||
});
|
||||
|
||||
test('Splitter sash can be dragged', async ({ page, testLogger }) => {
|
||||
await page.goto('/standalone/layout/layout_test.html');
|
||||
const loaded = await tryLoadApp(page);
|
||||
expect(loaded, 'App should load').toBe(true);
|
||||
await waitForWxApp(page);
|
||||
|
||||
// Get splitter sash from element registry
|
||||
const sash = await getSplitterSash(page);
|
||||
|
|
@ -42,9 +40,8 @@ test.describe('wxSplitterWindow & wxScrolledWindow Tests', () => {
|
|||
await page.mouse.down();
|
||||
await page.mouse.move(sash!.centerX + 100, sash!.centerY, { steps: 10 });
|
||||
await page.mouse.up();
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
await page.screenshot({ path: 'test-results/layout-03-sash-dragged.png', fullPage: true });
|
||||
await stableShot(page, 'layout-03-sash-dragged.png', { fullPage: true });
|
||||
|
||||
// Verify sash position updated
|
||||
const sashAfter = await getSplitterSash(page);
|
||||
|
|
@ -53,32 +50,28 @@ test.describe('wxSplitterWindow & wxScrolledWindow Tests', () => {
|
|||
|
||||
test('Scrolled windows show content', async ({ page, testLogger }) => {
|
||||
await page.goto('/standalone/layout/layout_test.html');
|
||||
const loaded = await tryLoadApp(page);
|
||||
expect(loaded, 'App should load').toBe(true);
|
||||
await waitForWxApp(page);
|
||||
|
||||
const box = await getCanvasBox(page);
|
||||
|
||||
// Scroll in left pane
|
||||
await page.mouse.move(box.x + 150, box.y + 200);
|
||||
await page.mouse.wheel(0, 100);
|
||||
await page.waitForTimeout(300);
|
||||
|
||||
await page.screenshot({ path: 'test-results/layout-04-scrolled-left.png', fullPage: true });
|
||||
await stableShot(page, 'layout-04-scrolled-left.png', { fullPage: true });
|
||||
|
||||
// Scroll in right pane
|
||||
await page.mouse.move(box.x + 500, box.y + 200);
|
||||
await page.mouse.wheel(0, 100);
|
||||
await page.waitForTimeout(300);
|
||||
|
||||
await page.screenshot({ path: 'test-results/layout-05-scrolled-right.png', fullPage: true });
|
||||
await stableShot(page, 'layout-05-scrolled-right.png', { fullPage: true });
|
||||
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
|
||||
test('Layout controls work together', async ({ page, testLogger }) => {
|
||||
await page.goto('/standalone/layout/layout_test.html');
|
||||
const loaded = await tryLoadApp(page);
|
||||
expect(loaded, 'App should load').toBe(true);
|
||||
await waitForWxApp(page);
|
||||
|
||||
// Get splitter sash from element registry
|
||||
const sash = await getSplitterSash(page);
|
||||
|
|
@ -89,7 +82,7 @@ test.describe('wxSplitterWindow & wxScrolledWindow Tests', () => {
|
|||
await page.mouse.down();
|
||||
await page.mouse.move(sash!.centerX + 100, sash!.centerY, { steps: 5 });
|
||||
await page.mouse.up();
|
||||
await page.waitForTimeout(300);
|
||||
await page.waitForTimeout(300); // eslint-disable-line -- documented interaction dwell (splitter drag commit before re-reading sash from registry)
|
||||
|
||||
// Get updated sash position after drag
|
||||
const sashAfter = await getSplitterSash(page);
|
||||
|
|
@ -98,14 +91,13 @@ test.describe('wxSplitterWindow & wxScrolledWindow Tests', () => {
|
|||
// Scroll left pane (use position left of sash)
|
||||
await page.mouse.move(sashAfter!.centerX - 100, sashAfter!.centerY);
|
||||
await page.mouse.wheel(0, 50);
|
||||
await page.waitForTimeout(200);
|
||||
await page.waitForTimeout(200); // eslint-disable-line -- documented interaction dwell (scroll commit between the two pane scrolls)
|
||||
|
||||
// Scroll right pane (use position right of sash)
|
||||
await page.mouse.move(sashAfter!.centerX + 100, sashAfter!.centerY);
|
||||
await page.mouse.wheel(0, 50);
|
||||
await page.waitForTimeout(200);
|
||||
|
||||
await page.screenshot({ path: 'test-results/layout-06-combined.png', fullPage: true });
|
||||
await stableShot(page, 'layout-06-combined.png', { fullPage: true });
|
||||
|
||||
expect(testLogger.errors.filter(e => !e.includes('favicon'))).toHaveLength(0);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue