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
62 lines
2.6 KiB
TypeScript
62 lines
2.6 KiB
TypeScript
// Draggable scrollbar e2e — the DOM scrollbar widget reports drags back to
|
|
// C++ (wxEVT_SCROLL for the standalone wxScrollBar; wxEVT_SCROLLWIN for the
|
|
// wxScrolledWindow gutter, which scrolls the content). The thumb registers as
|
|
// 'slider' + 'slidertrack' so Playwright can drag it.
|
|
import { test, expect, waitForWxApp } from './utils/fixtures';
|
|
import { findRenderedByType, stableShot } from './utils/element-tracker';
|
|
|
|
test.describe('DOM-port scrollbars', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto('/standalone/scrollbar/scrollbar_test.html');
|
|
await waitForWxApp(page);
|
|
});
|
|
|
|
test('scrollbars render draggable thumbs', async ({ page, testLogger }) => {
|
|
await expect.poll(
|
|
async () => (await findRenderedByType(page, 'slider')).length,
|
|
{ timeout: 8000, message: 'scrollbar thumbs should register' },
|
|
).toBeGreaterThanOrEqual(2);
|
|
|
|
await stableShot(page, 'scrollbar-01-loaded.png', { fullPage: true });
|
|
expect(testLogger.errors.filter((e) => !e.includes('favicon'))).toHaveLength(0);
|
|
});
|
|
|
|
test('dragging a thumb scrolls (standalone control fires wxEVT_SCROLL)', async ({
|
|
page,
|
|
testLogger,
|
|
}) => {
|
|
await expect.poll(
|
|
async () => (await findRenderedByType(page, 'slider')).length,
|
|
{ timeout: 8000 },
|
|
).toBeGreaterThanOrEqual(2);
|
|
|
|
const sliders = await findRenderedByType(page, 'slider');
|
|
const tracks = await findRenderedByType(page, 'slidertrack');
|
|
|
|
// Drag every thumb toward the far end of its track. The standalone
|
|
// scrollbars log "[SCROLLBAR_EVENT] scrollbar pos N"; the scrolled-window
|
|
// gutters scroll the content (captured in the screenshot).
|
|
for (let i = 0; i < sliders.length; i++) {
|
|
const s = sliders[i];
|
|
const t = tracks.find((tr) => tr.parentId === s.parentId) ?? tracks[i];
|
|
if (!t) continue;
|
|
const horizontal = t.width > t.height;
|
|
const tx = horizontal ? t.screenX + t.width * 0.85 : t.centerX;
|
|
const ty = horizontal ? t.centerY : t.screenY + t.height * 0.85;
|
|
|
|
await page.mouse.move(s.centerX, s.centerY);
|
|
await page.mouse.down();
|
|
await page.mouse.move(tx, ty, { steps: 6 });
|
|
await page.mouse.up();
|
|
await page.waitForTimeout(150); // eslint-disable-line -- documented interaction dwell
|
|
}
|
|
|
|
// At least one standalone scrollbar must have reported a non-zero position.
|
|
await expect.poll(
|
|
() => testLogger.consoleLogs.some((l) => /\[SCROLLBAR_EVENT\] scrollbar pos [1-9]/.test(l)),
|
|
{ timeout: 8000, message: 'a standalone scrollbar drag should report a non-zero position' },
|
|
).toBe(true);
|
|
|
|
await stableShot(page, 'scrollbar-02-dragged.png', { fullPage: true });
|
|
});
|
|
});
|