Add automated test suite for the Flutter frontend

Introduce a headless `flutter test` suite (83 tests) covering models,
utilities, every API endpoint, and the five screens, with shared helpers
and fixtures so new tests stay terse.

API endpoint methods are statically-dispatched extensions on the
BackendAPI singleton, so they cannot be mocked via `implements`. Mock at
the Dio HTTP-adapter layer (http_mock_adapter) instead, enabled by two
small @visibleForTesting seams: BackendAPI.dioForTesting swaps the
singleton's Dio, and BackendReachability.forceOnlineForTesting() forces a
deterministic online state so polling widgets load.

Add frontend/run_tests.sh and document it in CLAUDE.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
rzuasti
2026-06-03 19:41:52 -04:00
co-authored by Claude Opus 4.8
parent e6813a78fb
commit 98b5fa267f
33 changed files with 1690 additions and 2 deletions
+3 -1
View File
@@ -23,6 +23,7 @@ For Flutter/Dart code:
- `cd backend && ./run.sh` from the `backend/` folder - Run the backend
- `cd frontend && ./run.sh` from the `frontend/` folder - Run the front-end for the web
- `cd backend && ./run_tests.sh` - Run the backend tests
- `cd frontend && ./run_tests.sh` - Run the front-end tests
- `cd backend && ./lint.sh` - Run the clippy linter for Rust code
- `dart analyze` - Run the Dart linter
- `cd backend/data && ./update_mac_vendors --llm` - Update the MAC vendors list from the web and re-calculate the vedors -> device type list
@@ -49,7 +50,8 @@ For Flutter/Dart code:
## Important notes
- NEVER add or commit .env files or files with secrets (passwords, API keys or similar information)
- Code must be as simple as possible, human readable and modularized
- ALWAYS write unit tests for new or modified backend components
- ALWAYS write and/or update unit tests for new or modified backend components
- ALWAYS write and/or update unit, API and widget tests for new or modified frontend components
- ALWAYS run all tests after making a new change and do not continue until all tests pass
- When adding a new API endpoint, ALWAYS wire it to the OpenAPI generation
- When adding a significant chunk of new code (either Rust or Dart), run the corresponding linter