Skip to content

Latest commit

 

History

History
109 lines (94 loc) · 11.8 KB

testing.md

File metadata and controls

109 lines (94 loc) · 11.8 KB

Testing and verification

Navigation: documentation index · regression baseline · validation log.

Status: sections 1–5 are current (section 2 lists each layer with the milestone that created it: the regression baseline layer and quality.yml since M1, service and protocol tests since M4, the frontend Vitest and Storybook layers since M6, Playwright since M9, MCP tests since M13); section 6 is proposed where it goes beyond the existing workflows.

1. Current checks

Check Command Notes
Regression baseline pixi run -e test test-baseline (part of pixi run -e test test) Captures every sample and coverage project with the headless engine (tools/baseline/capture.py: no GTK, no display) and compares with tests/baseline/ (regression baseline); the baseline was captured with the legacy GTK application, retired in M15 (ADR 0030); about 3 minutes
Engine unit tests pixi run -e test test-engine tests/engine/ (PyGObject blocked: fields, registry, geometry vs cairo.Region, symbols, persistence round trip, pipeline, headless import; M3: safe expressions with every stored curve expression checked against Python eval, static check for eval/exec/pickle/Mako, malicious projects, clipboard, report escaping) No display needed
Headless run pixi run headless path/to/x.gepro [--out DIR] Open, analyse, rules check, export JSON/report/drawing without GTK
Service and protocol tests pixi run -e test test-services tests/services/ (M4, PyGObject blocked, no display): legacy action vs service command table (undo label, one entry, same document, undo/redo), command contract (validation, injected-failure rollback, preview, stale revision, bounded history), sessions, uid persistence, atomic save, analysis of every baseline project through analysis.start compared with tests/baseline/*/pf_bal, JSON Lines tests against a spawned python -m modern.backend, JSON Schemas and the generated method table current. M11: test_properties.py (field behaviour of every placeable element type equal to the legacy field view path, multiple selection, databases and the user library, load profiles, coordination equal to the engine data set, settings spreadsheet, curve files, project and program settings, fonts). About 2 minutes
Snapshot cost pixi run python tools/measure_services.py [--synthetic N] Capture, command, undo and delete times (ADR 0019)
Sidecar build pixi run -e bundle bundle-backend PyInstaller onedir into modern/src-tauri/resources/backend/ and --check-imports of the frozen executable (M5, ADR 0010)
Sidecar smoke and timings python tools/sidecar_smoke.py --backend <frozen exe> [--runs N --fresh-cache --json FILE] (or pixi run sidecar-smoke for the development backend) Open, analysis twice, report and drawing export, shutdown per start; killed-parent check. Standard library only (M5)
Tauri shell cargo check in modern/src-tauri/; GELECTRICAL_POC_AUTORUN=1 on the built app The window is the Vue app (M9); autorun redirects it to the M5 page, which opens the sample, analyses, exports, prints a JSON report and exits (ADR 0020, 0021)
Symbol pipeline and scenes pixi run -e test pytest tests/engine/test_symbol_scene.py; pixi run python tools/schematic/export.py symbols --check M7: schem_model → SVG primitives, symbol files current and ports equal to the element classes, every sheet of every sample/coverage project rasterised through rsvg-convert equals the Cairo renderer (labels excluded). Part of test-engine
Schematic PoC replay pixi run -e test pytest tests/services/test_schematic_replay.py M7: commands recorded by the PoC editor (both candidates recorded the same ones before maxGraph was removed) replayed through the services; connectivity equals the legacy engine driven like the GTK view; displayed geometry equals the backend's. Part of test-services
Schematic PoC scenario and measurements node tools/schematic_poc_bench.mjs [--out FILE] [--screenshots DIR] [--update] M7: builds modern/, runs the scripted scenario in the custom SVG editor in Chromium (commands and geometry equal to tests/schematic/poc_scenario.json), coordinate fidelity, load, pan/zoom and selection timings on a 1,000-element sheet, bundle size. About 2 minutes; not in CI
Coordination data set pixi run -e test pytest tests/engine/test_coordination.py; pixi run python tools/charts/export.py fixtures --check M8: headless coordination graphs (order, roles, limits) and chart fixtures current (relative tolerance 1e-6). Part of test-engine
Chart components npm run test -w @kavilgroup/engineering-ui (part of npm run check) M8: tests/charts.spec.ts (formatting, minor grid, point editing, option builders, SSR SVG export, editor keyboard) and the chart stories (keyboard play functions, axe in light and dark)
Chart measurements node tools/charts_poc_bench.mjs [--out FILE] [--svg DIR] M8: render, zoom and update timings in Chromium (production build), SVG export, charts bundle size. About 1 minute; not in CI
Frontend (all) npm run check Prettier, dependency boundary, licences, tool tests, vue-tsc, Vitest, library and app builds
EngineeringUI tests npm test -w @kavilgroup/engineering-ui Vitest projects unit (happy-dom) and storybook (every story in Chromium via Playwright: play functions plus axe; any violation fails). Needs npx playwright install chromium-headless-shell once
App shell tests npm test -w gelectrical-modern Vitest: shell composition and document workflows against a scripted transport (src/App.spec.ts), result formatting
Shell workflows (real backend) npm run e2e (Playwright; pixi on PATH, npx playwright install chromium-headless-shell once) M9: modern/e2e/workflows.spec.ts through the Vite backend bridge: open → analyse (baseline pf_bal settings) → every numeric result shown in the inspector equals tests/baseline/<project>/pf_bal (186 values, three samples) → export drawing PDF, report, network JSON → save as, save; node results, messages, unsaved guard, undo/redo, open errors, help and about. M10: modern/e2e/editing.spec.ts, schematic editing rows checked against drawing.sheet and the undo label and count after each action; the scripted sequence's commands must equal tests/schematic/m10_scenario.json (GELECTRICAL_UPDATE_SCENARIO=1 rewrites it). M11: modern/e2e/properties.spec.ts, project and program settings with the theme, multiple selection and database values, load profile editor and choice, coordination view and settings export, curve field dialog and data file. About 1 min in all; CI job workflows
Dev shell against the real backend npm run dev M9: the Vite dev server spawns python -m modern.backend (bridge, ADR 0021); GELECTRICAL_BRIDGE=0 disables it
Dependency boundary npm run check:boundaries EngineeringUI imports nothing outside its package, no app code or Tauri; root/theme/icons/composables never reach Quasar
Storybook build npm run build-storybook Static Storybook in packages/engineering-ui/storybook-static/
CI .github/workflows/quality.yml Linux: headless run and pytest tests (baseline, engine, services); Windows: engine and service tests, headless run; Linux: frontend job (all npm checks + Storybook build); Linux: shell workflows (npm run e2e, M9)
CI (packaging) .github/workflows/sidecar.yml Ubuntu 22.04 and Windows (manual, or pull requests touching the sidecar/shell): sidecar build, smoke with timings, Tauri bundle, install, autorun, orphan check, sizes (M5)
Manual UI npm run dev (browser, real backend) or npm run tauri:dev (desktop window) Exercise the change by hand
Calculation changes Compare before/after on sample_files/ State what moved and why

2. Test layers

Layer Tool Location Created in
Regression baseline pytest tests/test_baseline.py, tests/baseline/ M1
Engine unit tests pytest tests/engine/ M2
Expression evaluator and security pytest tests/engine/test_expressions.py, tests/engine/test_security.py M3
Services (commands, undo, revisions, jobs, sessions) pytest tests/services/ M4
Protocol (spawned backend) pytest tests/services/test_protocol.py M4
MCP (SDK client) pytest tests/services/test_mcp.py (mcp_client.py, mcp_build.py, mcp_tools.json) M13 (current)
Frontend units/components Vitest modern/src/**/*.spec.ts, packages/engineering-ui/tests/ M6
Component stories, a11y, interactions Storybook + Vitest addon packages/engineering-ui/stories/ M6
Browser workflows against the real backend Playwright modern/e2e/ M9 (current, Chromium)
Drawing/report visual parity pytest + raster diff tests/visual/ (proposed; not created yet) M2, M12
Packaged application scripted checks on clean machines tools/sidecar_smoke.py, PoC autorun, .github/workflows/sidecar.yml M5 (current), M14

3. What to run for a change

Change Required checks
Engine (gelectrical/) Engine unit tests, regression baseline, headless run
Services / protocol Service and protocol tests, baseline subset through services
MCP MCP tests, service tests
EngineeringUI Vitest, Storybook build and test run, boundary check
App frontend Type check, Vitest, affected Playwright workflows
Rust shell cargo fmt --check, cargo clippy -- -D warnings, cargo test, protocol tests with sidecar
Packaging Packaged smoke on the affected OS
Docs only Link check, git diff --check; Sphinx build if user manual pages change

4. Required test topics

  • Sample project loading and save/load round trips (canonical equality).
  • Network topology equivalence (node sets, references, upstream/downstream).
  • Power flow, time-series, short-circuit, voltage drop results within tolerance.
  • Protection and damage curves (evaluated points and polygons).
  • Rules check outcomes.
  • Element property validation and derived field state for every registered element.
  • Undo/redo sequences with legacy labels and granularity.
  • Report and drawing generation (content and visual parity).
  • Backward compatibility (legacy files, modern-saved files in legacy loader).
  • MCP operations, permissions, previews, batch atomicity and desktop synchronization.
  • Frontend interactions (keyboard, selection, editing, dialogs, themes).
  • Cross-platform packaging and process cleanup.

Numerical tolerances are defined once in the regression baseline.

5. Principles

  • Test against real backend operations where practical; mock only the native transport (Tauri) in browser tests (GEstimator workspaceHarness.ts pattern).
  • Never weaken a check, widen a tolerance or regenerate a baseline to make a change pass; explain differences instead.
  • Native Tauri features (file association, single instance, installers, sidecar lifecycle) are tested separately from browser tests and recorded as manual or packaged checks.
  • Use local open-source tools only (no hosted visual-diff service).

6. CI (proposed)

  • quality.yml on pull requests: pixi install; pytest (all Python layers, no display); npm ci; type check; Vitest; Storybook test run; Playwright (Chromium and WebKit) against the real backend; Rust checks; dependency boundary and licence checks; static check forbidding eval/exec/pickle.loads in engine and backend code.
  • release.yml on tags: per-OS sidecar and Tauri bundles, packaged smoke where runners allow, artefact upload.
  • Record results of local and hosted runs in the validation log.