diet-guard/app/test/services
Krzysztof kuhy Rudnicki fe28c8a395
Some checks are pending
pre-commit / pre-commit (push) Waiting to run
Tests / test (3.10) (push) Waiting to run
Tests / test (3.11) (push) Waiting to run
Tests / test (3.12) (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
Step Dart dates by the calendar, not by 24 hours
A Duration is an absolute span, so stepping a local DateTime by
Duration(days: 1) moves 23 or 25 hours across a DST boundary and lands on
the wrong wall-clock day. Under Europe/Warsaw, spring-forward 2026-03-29:

  lastCompleteDay(2026-03-30)  ->  2026-03-28 23:00, the day before
                                   yesterday, not yesterday
  weeksAgo: 1 from 2026-04-01  ->  2026-03-24 23:00, a Tuesday, so the
                                   wrong ISO week entirely
  a 03-27..03-31 period        ->  emits four day keys, silently dropping
                                   2026-03-31

The Python half computes all three correctly, because timedelta on a date
has no clock to drift against. So for about two weeks a year the phone and
the PC would report different averages for the same log -- exactly the kind
of device-local divergence the shared-source-of-truth rule exists to stop.

Passing out-of-range components to DateTime's constructor normalizes on the
calendar (day 0 is the previous month's last day), which is what timedelta
already does. The same fix goes to day_status_service's streak walker: it
had the identical pattern and predates this feature, so a streak that
spanned the clock change could break when it should have held.

None of the existing tests could see any of this -- every fixture date sits
in a DST-free span -- so the regression tests use dates that straddle
2026-03-29 and assert on the calendar day rather than the DateTime, which
keeps them meaningful whatever zone the runner is in. Verified they fail
against the old arithmetic before fixing it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DjJqpcEsaV5WRhPXyxCThd
2026-08-09 15:06:41 +02:00
..
app_settings_service_test.dart Remove unused features; fix reminder false alarms; share all state 2026-07-26 16:39:52 +02:00
average_service_test.dart Step Dart dates by the calendar, not by 24 hours 2026-08-09 15:06:41 +02:00
background_sync_service_test.dart Sync meals and the food bank through Firebase, mirroring to GitHub 2026-08-05 08:35:21 +02:00
budget_history_service_test.dart Remove unused features; fix reminder false alarms; share all state 2026-07-26 16:39:52 +02:00
budget_schedule_test.dart Remove unused features; fix reminder false alarms; share all state 2026-07-26 16:39:52 +02:00
day_status_service_test.dart Remove unused features; fix reminder false alarms; share all state 2026-07-26 16:39:52 +02:00
due_slot_check_test.dart Remove unused features; fix reminder false alarms; share all state 2026-07-26 16:39:52 +02:00
foodbank_service_test.dart app: run the companion app's desktop target as a web build 2026-07-20 16:31:32 +02:00
fuzzy_test.dart Add food bank, edit-entry, and app settings screens; history redesign 2026-07-04 05:18:32 +02:00
github_device_auth_test.dart Add OAuth device flow, background notifications, and fix AGP9 release crash (Milestones 3–4) 2026-06-25 17:29:23 +02:00
indexeddb_stores_test.dart Remove unused features; fix reminder false alarms; share all state 2026-07-26 16:39:52 +02:00
log_storage_service_test.dart Remove unused features; fix reminder false alarms; share all state 2026-07-26 16:39:52 +02:00
notification_service_test.dart app: run the companion app's desktop target as a web build 2026-07-20 16:31:32 +02:00
sync_merge_test.dart Remove unused features; fix reminder false alarms; share all state 2026-07-26 16:39:52 +02:00
sync_service_test.dart Sync meals and the food bank through Firebase, mirroring to GitHub 2026-08-05 08:35:21 +02:00
sync_settings_test.dart Point sync at the consolidated utils/syncs monorepos 2026-07-10 14:12:16 +02:00
sync_state_factory_test.dart Sync meals and the food bank through Firebase, mirroring to GitHub 2026-08-05 08:35:21 +02:00