Update AGENTS.md

This commit is contained in:
Roland Geider
2026-10-29 21:45:44 +01:00
parent f6ee298a12
commit b6b032a51c

View File

@@ -88,6 +88,7 @@ integration_test/ screenshot driver
## Tests
- **Prove a test can fail.** After writing one, break the production side it guards (flip a type, delete the branch, drop a registry entry) and watch it go red, then restore. A test nobody has seen fail is a guess. This is how the suite grew tests that could never fail: a finder comparing element types against a widget type, an `every(...)` without an `expect`, a `contains('10')` that the prefilled `100` already satisfied, a file without the `_test` suffix that the runner never collected.
- **Don't test library behavior.** No tests that only show that Drift stores a column, Riverpod rebuilds, freezed generates `copyWith`/`==` or `json_serializable` maps a field; test our own code (custom mappings, overrides, logic).
- **Layering:** repositories are tested against a real in-memory Drift DB (`test/helpers/in_memory_drift.dart`), notifiers against a mocked repository (`MockFooRepository`, never a `_FakeFoo extends Foo`), widgets with `authProvider.overrideWith(() => FakeAuthNotifier(...))` from `test/helpers/fake_auth_notifier.dart` instead of seeding prefs and stubbing every auto-login request. One test file per source file, mirroring its path.
- **Test the clearing, not just the change.** Every bug this rule would have caught came from a null crossing a boundary: `toCompanion()` mapping null to `Value.absent()` (an update then leaves the column untouched), a hand-written `copyWith` with `?? this.x` swallowing a cleared field. When a field becomes editable, assert non-null → null against the stored row, not only non-null → non-null.
- **Test the boundary day of a date range.** Callers pass calendar days, entries carry timestamps, and the mismatch hides in the edges: an entry recorded during the end day, the day after, the start day. Same for anything counting days: `difference().inDays` measures elapsed time, so a range spanning the spring-forward switch comes up one day short. Count calendar days as UTC midnights.