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,114 +1,87 @@
|
|||
// Specialized wxWidgets Controls Tests - Treebook, RearrangeCtrl, BitmapComboBox
|
||||
import { test, expect, tryLoadApp } from './utils/fixtures';
|
||||
import { clickByLabel, clickComboButton, selectComboItem, clickListboxItem, clickTreeItem } from './utils/element-tracker';
|
||||
import { test, expect } from './utils/fixtures';
|
||||
import { clickByLabel, clickComboButton, selectComboItem, clickListboxItem, clickTreeItem, waitForWxApp, stableShot } from './utils/element-tracker';
|
||||
|
||||
test.describe('Specialized wxWidgets Controls Tests', () => {
|
||||
|
||||
test('Specialized controls test app loads successfully', async ({ page, testLogger }) => {
|
||||
await page.goto('/standalone/specialized/specialized_test.html');
|
||||
const loaded = await tryLoadApp(page);
|
||||
await waitForWxApp(page);
|
||||
|
||||
await page.screenshot({ path: 'test-results/specialized-01-loaded.png', fullPage: true });
|
||||
await stableShot(page, 'specialized-01-loaded.png', { fullPage: true });
|
||||
|
||||
expect(loaded, 'Specialized controls app should load').toBe(true);
|
||||
expect(testLogger.errors.filter(e => !e.includes('favicon'))).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('wxTreebook displays tree with pages', async ({ page, testLogger }) => {
|
||||
await page.goto('/standalone/specialized/specialized_test.html');
|
||||
const loaded = await tryLoadApp(page);
|
||||
expect(loaded, 'App should load').toBe(true);
|
||||
|
||||
await page.waitForTimeout(500);
|
||||
await waitForWxApp(page);
|
||||
|
||||
// Treebook should show General page by default with tree on left
|
||||
await page.screenshot({ path: 'test-results/specialized-02-treebook-initial.png', fullPage: true });
|
||||
await stableShot(page, 'specialized-02-treebook-initial.png', { fullPage: true });
|
||||
});
|
||||
|
||||
test('wxTreebook can navigate between pages', async ({ page, testLogger }) => {
|
||||
await page.goto('/standalone/specialized/specialized_test.html');
|
||||
const loaded = await tryLoadApp(page);
|
||||
expect(loaded, 'App should load').toBe(true);
|
||||
|
||||
await page.waitForTimeout(300);
|
||||
await waitForWxApp(page);
|
||||
|
||||
// Click on Display page using element registry
|
||||
await clickTreeItem(page, 'Display');
|
||||
await page.waitForTimeout(200);
|
||||
await page.waitForTimeout(200); // eslint-disable-line -- documented interaction dwell: treebook page-switch settle before the next tree click (no console observable in this app)
|
||||
|
||||
// Click on Printing page using element registry
|
||||
await clickTreeItem(page, 'Printing');
|
||||
await page.waitForTimeout(200);
|
||||
|
||||
await page.screenshot({ path: 'test-results/specialized-03-treebook-subpage.png', fullPage: true });
|
||||
await stableShot(page, 'specialized-03-treebook-subpage.png', { fullPage: true });
|
||||
});
|
||||
|
||||
test('wxTreebook can expand tree nodes', async ({ page, testLogger }) => {
|
||||
await page.goto('/standalone/specialized/specialized_test.html');
|
||||
const loaded = await tryLoadApp(page);
|
||||
expect(loaded, 'App should load').toBe(true);
|
||||
|
||||
await page.waitForTimeout(300);
|
||||
await waitForWxApp(page);
|
||||
|
||||
// Click on Editing page using element registry
|
||||
await clickTreeItem(page, 'Editing');
|
||||
await page.waitForTimeout(200);
|
||||
|
||||
await page.screenshot({ path: 'test-results/specialized-04-treebook-expand.png', fullPage: true });
|
||||
await stableShot(page, 'specialized-04-treebook-expand.png', { fullPage: true });
|
||||
});
|
||||
|
||||
test('wxBitmapComboBox displays layer swatches', async ({ page, testLogger }) => {
|
||||
await page.goto('/standalone/specialized/specialized_test.html');
|
||||
const loaded = await tryLoadApp(page);
|
||||
expect(loaded, 'App should load').toBe(true);
|
||||
|
||||
await page.waitForTimeout(300);
|
||||
await waitForWxApp(page);
|
||||
|
||||
// Click on layer combo box to open dropdown using element tracking
|
||||
const opened = await clickComboButton(page);
|
||||
expect(opened, 'Should be able to open BitmapComboBox dropdown').toBe(true);
|
||||
await page.waitForTimeout(300);
|
||||
|
||||
await page.screenshot({ path: 'test-results/specialized-05-bitmapcombo-dropdown.png', fullPage: true });
|
||||
await stableShot(page, 'specialized-05-bitmapcombo-dropdown.png', { fullPage: true });
|
||||
});
|
||||
|
||||
test('wxBitmapComboBox can select different layer', async ({ page, testLogger }) => {
|
||||
await page.goto('/standalone/specialized/specialized_test.html');
|
||||
const loaded = await tryLoadApp(page);
|
||||
expect(loaded, 'App should load').toBe(true);
|
||||
|
||||
await page.waitForTimeout(300);
|
||||
await waitForWxApp(page);
|
||||
|
||||
// Select B.Cu layer using element tracking
|
||||
const selected = await selectComboItem(page, 'B.Cu');
|
||||
expect(selected, 'Should be able to select B.Cu from dropdown').toBe(true);
|
||||
await page.waitForTimeout(200);
|
||||
|
||||
await page.screenshot({ path: 'test-results/specialized-06-bitmapcombo-select.png', fullPage: true });
|
||||
await stableShot(page, 'specialized-06-bitmapcombo-select.png', { fullPage: true });
|
||||
});
|
||||
|
||||
test('wxRearrangeCtrl displays layer order', async ({ page, testLogger }) => {
|
||||
await page.goto('/standalone/specialized/specialized_test.html');
|
||||
const loaded = await tryLoadApp(page);
|
||||
expect(loaded, 'App should load').toBe(true);
|
||||
|
||||
await page.waitForTimeout(500);
|
||||
await waitForWxApp(page);
|
||||
|
||||
// RearrangeCtrl should show list of layers with checkboxes
|
||||
await page.screenshot({ path: 'test-results/specialized-07-rearrange-list.png', fullPage: true });
|
||||
await stableShot(page, 'specialized-07-rearrange-list.png', { fullPage: true });
|
||||
});
|
||||
|
||||
test('wxRearrangeCtrl Get Layer Status button works', async ({ page, testLogger }) => {
|
||||
await page.goto('/standalone/specialized/specialized_test.html');
|
||||
const loaded = await tryLoadApp(page);
|
||||
expect(loaded, 'App should load').toBe(true);
|
||||
|
||||
await page.waitForTimeout(300);
|
||||
await waitForWxApp(page);
|
||||
|
||||
// Click Get Layer Status button using element registry
|
||||
await clickByLabel(page, 'Get Layer Status');
|
||||
await page.waitForTimeout(200);
|
||||
|
||||
await page.screenshot({ path: 'test-results/specialized-08-get-order.png', fullPage: true });
|
||||
await stableShot(page, 'specialized-08-get-order.png', { fullPage: true });
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue