Skip to content

feat: draft out frontend fuzzer - #1193

Draft
martinjrobins wants to merge 4 commits into
developfrom
gui-fuzzing
Draft

feat: draft out frontend fuzzer#1193
martinjrobins wants to merge 4 commits into
developfrom
gui-fuzzing

Conversation

@martinjrobins

@martinjrobins martinjrobins commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Add stateful Playwright exploratory tester for PKPDApp

What it does: Fuzzes the PKPDApp frontend by systematically exploring simulation model state changes, verifying that each action produces exactly the expected semantic diff and nothing else. Detects unexplained parameter shifts, missing API responses, simulation result regressions, and UI error states.

Architecture

Layer Purpose
Snapshot (snapshot.py + JS extractor) Injects JS into the page, reads the RTK Query Redux cache + DOM slider values, parses into a frozen SimulationModelSnapshot with 16 domain fields (model config, parameters, outputs, mappings, doses, compound, plots, sliders, sim results)
Actions (7 modules, ~60 action classes) Each action declares preconditions(snapshot), execute(page, snapshot) via Playwright, and expected_diff(snapshot). Covers project creation, model selection, parameter editing (5 discrete values each), PK→PD mappings, dose configuration, plot/slider management. Navigation is handled implicitly.
Explorer (explorer.py) Coverage-guided — tracks visited (state_hash, action_key) edges and prioritizes unexplored transitions
Checker (checker.py) Three-layer validation: (1) snapshot diff — every change must match expectations, (2) simulation results — must/must-not change as declared, (3) UI errors — detects .MuiAlert-standardError snackbars
Fuzzer (fuzzer.py) Main loop: snapshot → explore → execute → check → report. Returns FuzzerReport with categorized findings

Files changed

Modified:

  • frontend-v2/src/app/store.ts — 2 lines to expose window.__pkpd_store__ in dev mode
  • frontend-v2/package.json — added test:exploratory script

Added: frontend-v2/exploratory_tester/ (21 files)

  • snapshot.py, checker.py, explorer.py, fuzzer.py, conftest.py, test_fuzzer.py
  • actions/base.py, actions/navigation.py, actions/project.py, actions/model_config.py, actions/parameters.py, actions/mappings.py, actions/dosing.py, actions/simulation.py, actions/registry.py
  • js_extractors/redux_snapshot.js
  • pytest.ini, requirements.txt, README.md, .gitignore

How to run

cd frontend-v2/exploratory_tester
pip install -r requirements.txt
playwright install chromium
pytest . --base-url http://localhost:5173 --username demo --password 12345
Verified behavior
Tested against a live dev server — the explorer correctly transitions from project creation → model selection → parameter editing → dosing → simulation actions as preconditions unlock. The checker correctly flags missing expected changes and simulation result mismatches.

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 71.10%. Comparing base (f434c8e) to head (c88921f).
⚠️ Report is 4 commits behind head on develop.

Files with missing lines Patch % Lines
frontend-v2/src/app/store.ts 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1193      +/-   ##
===========================================
- Coverage    79.98%   71.10%   -8.89%     
===========================================
  Files          162      306     +144     
  Lines         5947    12096    +6149     
  Branches         0     1464    +1464     
===========================================
+ Hits          4757     8601    +3844     
- Misses        1190     2889    +1699     
- Partials         0      606     +606     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud

sonarqubecloud Bot commented Jul 7, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'pkpdapp-team_pkpdapp_frontend'

Failed conditions
32.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@sonarqubecloud

sonarqubecloud Bot commented Jul 7, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant