diet-guard/app/test/services
Krzysztof kuhy Rudnicki 3d82ddefd4 feat: let the phone fetch and bank the catering delivery itself
The phone now walks the panel on its own -- login, active order, delivery,
menu -- parses the dishes and banks them, so the feature works with the PC
switched off. Read-only: nothing here logs a meal.

`package:http` has no cookie jar, so the `SESSION` cookie is read off the login
response and replayed by hand. `Response.headers` folds duplicate `set-cookie`
values into one comma-joined string, so the parser splits on both `,` and `;`
and looks for the named cookie rather than assuming the header holds only it --
tested against both orderings and against a panel that sets no session cookie
at all.

Android-only, as decided: the panel sends no CORS headers, so a browser cannot
call it. `refreshDelivery` checks `kIsWeb` first and returns the unsupported
reason without touching the network. No `dart:io` anywhere -- `package:http`
compiles for web, it is the panel that refuses, not the toolchain, so this
needs no `_io`/`_web` seam.

The idempotency guard is ported with its teeth: `addManualEntry` restamps
`editedAt` unconditionally, so re-banking an unchanged dish republishes the
whole curated bank to every peer. `bankDishes` compares the nutritional fields
first and returns a write *count*, which is what the tests assert on -- "the
entry exists" passes while this misbehaves. The comparison is numeric, not
string, so `270 == 270.0` is a match exactly as in Python's `_matches`.

Every failure becomes a reason string, never a throw, so a catering outage
cannot break the caller: a rejected login, a delivery whose dishes all fail
the unit check, and missing credentials each have a test.

One test bug worth noting: the assertion that nothing is logged was missing an
`await` and so was comparing a Future against `isEmpty` -- the single most
important guarantee in this file was passing vacuously until the split forced
it to run.

Test files split three ways for the 250-line cap; block counts checked against
the pre-split file (16 either side), not just a green suite.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QQpCiPaSbyRpwsLkH3dgsX
2026-08-23 08:30:21 +02:00
..
app_settings_service_sync_test.dart Split the remaining seven Dart test files 2026-08-15 20:53:55 +02:00
app_settings_service_test.dart Split the remaining seven Dart test files 2026-08-15 20:53:55 +02:00
average_service_periods_test.dart Split the remaining seven Dart test files 2026-08-15 20:53:55 +02:00
average_service_test.dart Split the remaining seven Dart test files 2026-08-15 20:53:55 +02:00
background_sync_service_test.dart feat: carry the catering credential to the phone 2026-08-23 08:25:27 +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_streaks_test.dart Split the remaining seven Dart test files 2026-08-15 20:53:55 +02:00
day_status_service_test.dart Split the remaining seven Dart test files 2026-08-15 20:53:55 +02:00
due_slot_check_test.dart feat: carry the catering credential to the phone 2026-08-23 08:25:27 +02:00
foodbank_service_manual_test.dart Split six Dart test files; share the sync fixtures via a support sibling 2026-08-15 20:49:54 +02:00
foodbank_service_test.dart Split six Dart test files; share the sync fixtures via a support sibling 2026-08-15 20:49:54 +02:00
fuzzy_test.dart Add food bank, edit-entry, and app settings screens; history redesign 2026-07-04 05:18:32 +02:00
indexeddb_stores_test.dart Remove unused features; fix reminder false alarms; share all state 2026-07-26 16:39:52 +02:00
kuchnia_bank_guard_test.dart feat: let the phone fetch and bank the catering delivery itself 2026-08-23 08:30:21 +02:00
kuchnia_credential_service_test.dart feat: carry the catering credential to the phone 2026-08-23 08:25:27 +02:00
kuchnia_import_test.dart feat: let the phone fetch and bank the catering delivery itself 2026-08-23 08:30:21 +02:00
kuchnia_orders_test.dart feat: let the phone fetch and bank the catering delivery itself 2026-08-23 08:30:21 +02:00
log_storage_service_edit_test.dart Split six Dart test files; share the sync fixtures via a support sibling 2026-08-15 20:49:54 +02:00
log_storage_service_test.dart Split six Dart test files; share the sync fixtures via a support sibling 2026-08-15 20:49:54 +02:00
meal_schedule_history_test.dart Read the meal schedule from a forward-only history (Dart) 2026-08-16 14:41:37 +02:00
meal_schedule_service_test.dart Read the meal schedule from a forward-only history (Dart) 2026-08-16 14:41:37 +02:00
notification_service_test.dart Read the meal schedule from a forward-only history (Dart) 2026-08-16 14:41:37 +02:00
sync_device_id_test.dart Push under a persisted per-install uuid, not a fixed role id 2026-08-09 17:18:42 +02:00
sync_health_test.dart Make the phone publish on every tick, and fail closed on Firebase errors 2026-08-10 14:35:37 +02:00
sync_merge_banks_test.dart Split six Dart test files; share the sync fixtures via a support sibling 2026-08-15 20:49:54 +02:00
sync_merge_budget_test.dart Split six Dart test files; share the sync fixtures via a support sibling 2026-08-15 20:49:54 +02:00
sync_merge_curated_test.dart Split six Dart test files; share the sync fixtures via a support sibling 2026-08-15 20:49:54 +02:00
sync_merge_schedule_test.dart Sync the meal schedule as sched: fields on the budget record 2026-08-16 14:49:08 +02:00
sync_merge_test.dart Split six Dart test files; share the sync fixtures via a support sibling 2026-08-15 20:49:54 +02:00
sync_merge_wire_test.dart Split six Dart test files; share the sync fixtures via a support sibling 2026-08-15 20:49:54 +02:00
sync_service_budget_test.dart Split six Dart test files; share the sync fixtures via a support sibling 2026-08-15 20:49:54 +02:00
sync_service_test_support.dart Split six Dart test files; share the sync fixtures via a support sibling 2026-08-15 20:49:54 +02:00
sync_service_test.dart Split six Dart test files; share the sync fixtures via a support sibling 2026-08-15 20:49:54 +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 Split the last four Dart lib files; file-length gate now reports zero 2026-08-15 21:07:24 +02:00