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
|
|
@ -120,10 +120,42 @@
|
|||
}
|
||||
};
|
||||
|
||||
// Land the user in a sane, writable directory instead of MEMFS root.
|
||||
var setupHomeDir = function() {
|
||||
var home = '/home/kicad';
|
||||
FS.mkdirTree(home);
|
||||
FS.chdir(home);
|
||||
console.log('[KICAD] cwd set to ' + home);
|
||||
};
|
||||
|
||||
// single_top.cpp runs STARTWIZARD on launch: a modal first-run "Setup"
|
||||
// wizard shown whenever the settings dir lacks a kicad_common.json or valid
|
||||
// global library tables. In this ephemeral MEMFS that is EVERY load. Seed a
|
||||
// minimal default config before main() so every provider reports
|
||||
// NeedsUserInput()==false and the wizard never opens — same as eeschema.html
|
||||
// and pl_editor.html.
|
||||
var seedKicadConfig = function() {
|
||||
var cfgDir = '/home/kicad/.config/kicad/kicad/9.99';
|
||||
FS.mkdirTree(cfgDir);
|
||||
|
||||
var writeIfAbsent = function(path, contents) {
|
||||
try { FS.stat(path); return; } catch (e) { /* absent — seed it */ }
|
||||
FS.writeFile(path, contents);
|
||||
console.log('[KICAD] Seeded ' + path);
|
||||
};
|
||||
|
||||
writeIfAbsent(cfgDir + '/kicad_common.json', JSON.stringify({
|
||||
do_not_show_again: { update_check_prompt: true, data_collection_prompt: true }
|
||||
}, null, 2));
|
||||
writeIfAbsent(cfgDir + '/sym-lib-table', '(sym_lib_table\n (version 7)\n)\n');
|
||||
writeIfAbsent(cfgDir + '/fp-lib-table', '(fp_lib_table\n (version 7)\n)\n');
|
||||
writeIfAbsent(cfgDir + '/design-block-lib-table', '(design_block_lib_table\n (version 7)\n)\n');
|
||||
};
|
||||
|
||||
var Module = {
|
||||
thisProgram: '/usr/bin/pcb_calculator', // argv[0]
|
||||
|
||||
preRun: [createCanvas, writeResources],
|
||||
preRun: [createCanvas, writeResources, setupHomeDir, seedKicadConfig],
|
||||
postRun: [],
|
||||
|
||||
print: function(text) {
|
||||
|
|
|
|||
|
|
@ -123,10 +123,31 @@
|
|||
console.log('[KICAD] cwd set to ' + home);
|
||||
};
|
||||
|
||||
// Seed a minimal default config before main() so STARTWIZARD finds
|
||||
// NeedsUserInput()==false and the first-run setup wizard never opens —
|
||||
// same as eeschema.html / pl_editor.html.
|
||||
var seedKicadConfig = function() {
|
||||
var cfgDir = '/home/kicad/.config/kicad/kicad/9.99';
|
||||
FS.mkdirTree(cfgDir);
|
||||
|
||||
var writeIfAbsent = function(path, contents) {
|
||||
try { FS.stat(path); return; } catch (e) { /* absent — seed it */ }
|
||||
FS.writeFile(path, contents);
|
||||
console.log('[KICAD] Seeded ' + path);
|
||||
};
|
||||
|
||||
writeIfAbsent(cfgDir + '/kicad_common.json', JSON.stringify({
|
||||
do_not_show_again: { update_check_prompt: true, data_collection_prompt: true }
|
||||
}, null, 2));
|
||||
writeIfAbsent(cfgDir + '/sym-lib-table', '(sym_lib_table\n (version 7)\n)\n');
|
||||
writeIfAbsent(cfgDir + '/fp-lib-table', '(fp_lib_table\n (version 7)\n)\n');
|
||||
writeIfAbsent(cfgDir + '/design-block-lib-table', '(design_block_lib_table\n (version 7)\n)\n');
|
||||
};
|
||||
|
||||
var Module = {
|
||||
thisProgram: '/usr/bin/gerbview', // Fake absolute path for argv[0]
|
||||
|
||||
preRun: [createCanvas, writeResources, setupHomeDir],
|
||||
preRun: [createCanvas, writeResources, setupHomeDir, seedKicadConfig],
|
||||
postRun: [],
|
||||
|
||||
print: function(text) {
|
||||
|
|
|
|||
|
|
@ -120,6 +120,35 @@
|
|||
}
|
||||
};
|
||||
|
||||
// Land in a sane, writable cwd instead of MEMFS root.
|
||||
var setupHomeDir = function() {
|
||||
var home = '/home/kicad';
|
||||
FS.mkdirTree(home);
|
||||
FS.chdir(home);
|
||||
console.log('[KICAD] cwd set to ' + home);
|
||||
};
|
||||
|
||||
// Seed a minimal default config before main() so STARTWIZARD finds
|
||||
// NeedsUserInput()==false and the first-run setup wizard never opens —
|
||||
// same as eeschema.html / pl_editor.html.
|
||||
var seedKicadConfig = function() {
|
||||
var cfgDir = '/home/kicad/.config/kicad/kicad/9.99';
|
||||
FS.mkdirTree(cfgDir);
|
||||
|
||||
var writeIfAbsent = function(path, contents) {
|
||||
try { FS.stat(path); return; } catch (e) { /* absent — seed it */ }
|
||||
FS.writeFile(path, contents);
|
||||
console.log('[KICAD] Seeded ' + path);
|
||||
};
|
||||
|
||||
writeIfAbsent(cfgDir + '/kicad_common.json', JSON.stringify({
|
||||
do_not_show_again: { update_check_prompt: true, data_collection_prompt: true }
|
||||
}, null, 2));
|
||||
writeIfAbsent(cfgDir + '/sym-lib-table', '(sym_lib_table\n (version 7)\n)\n');
|
||||
writeIfAbsent(cfgDir + '/fp-lib-table', '(fp_lib_table\n (version 7)\n)\n');
|
||||
writeIfAbsent(cfgDir + '/design-block-lib-table', '(design_block_lib_table\n (version 7)\n)\n');
|
||||
};
|
||||
|
||||
var Module = {
|
||||
thisProgram: '/usr/bin/pcbnew', // Fake absolute path for argv[0] (KiCad DEBUG check)
|
||||
|
||||
|
|
@ -128,7 +157,7 @@
|
|||
// FRAME_PCB_EDITOR at runtime.
|
||||
arguments: ['--frame=pcb'],
|
||||
|
||||
preRun: [createCanvas, writeResources],
|
||||
preRun: [createCanvas, writeResources, setupHomeDir, seedKicadConfig],
|
||||
postRun: [],
|
||||
|
||||
print: function(text) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue