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,31 +1,44 @@
|
|||
// Early Size Test - Verifies GetClientSize() returns reasonable values before Show()
|
||||
// This reproduces KiCad's pattern where GetClientSize() is called in the constructor.
|
||||
import { test, expect, tryLoadApp } from './utils/fixtures';
|
||||
//
|
||||
// Determinism: no waitForTimeout. Readiness via waitForWxApp (loud). The app emits its
|
||||
// early client/frame size logs and a terminal PASS/FAIL during init; instead of sleeping
|
||||
// 500ms we poll for the terminal PASS/FAIL marker, which guarantees every size log the
|
||||
// assertions parse is already present. Static loaded/result states use stableShot.
|
||||
import { test, expect, waitForWxApp } from './utils/fixtures';
|
||||
import { stableShot } from './utils/element-tracker';
|
||||
|
||||
test.describe('Early GetClientSize() Tests', () => {
|
||||
|
||||
test('Early size test app loads successfully', async ({ page, testLogger }) => {
|
||||
await page.goto('/standalone/earlysize/earlysize_test.html');
|
||||
const loaded = await tryLoadApp(page);
|
||||
await waitForWxApp(page);
|
||||
|
||||
await page.screenshot({ path: 'test-results/earlysize-01-loaded.png', fullPage: true });
|
||||
await stableShot(page, 'earlysize-01-loaded.png', { fullPage: true });
|
||||
|
||||
const hasStartup = testLogger.consoleLogs.some(l => l.includes('[EARLYSIZE_TEST] Early size test app started'));
|
||||
|
||||
expect(loaded, 'Early size app should load').toBe(true);
|
||||
expect(hasStartup, 'Startup log should be present').toBe(true);
|
||||
expect(testLogger.errors.filter(e => !e.includes('favicon'))).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('GetClientSize() returns reasonable values before Show()', async ({ page, testLogger }) => {
|
||||
await page.goto('/standalone/earlysize/earlysize_test.html');
|
||||
const loaded = await tryLoadApp(page);
|
||||
expect(loaded, 'App should load').toBe(true);
|
||||
await waitForWxApp(page);
|
||||
|
||||
// Wait for the app to finish initialization
|
||||
await page.waitForTimeout(500);
|
||||
// Wait for the app to finish initialization: it logs a terminal PASS/FAIL result once
|
||||
// its early size checks are done, which implies the client/frame size logs are present.
|
||||
await expect
|
||||
.poll(
|
||||
() =>
|
||||
testLogger.consoleLogs.some(
|
||||
l => l.includes('[EARLYSIZE_TEST] PASS') || l.includes('[EARLYSIZE_TEST] FAIL'),
|
||||
),
|
||||
{ message: 'earlysize test should log its terminal PASS/FAIL result' },
|
||||
)
|
||||
.toBe(true);
|
||||
|
||||
await page.screenshot({ path: 'test-results/earlysize-02-result.png', fullPage: true });
|
||||
await stableShot(page, 'earlysize-02-result.png', { fullPage: true });
|
||||
|
||||
// Check for early client size log
|
||||
const clientSizeLogs = testLogger.consoleLogs.filter(l => l.includes('[EARLYSIZE_TEST] Early client size:'));
|
||||
|
|
|
|||
Loading…
Reference in a new issue