diet-guard/app/test/kuchnia_fill_cancel_test.dart
Krzysztof kuhy Rudnicki 66650ca3cc
Some checks failed
dependency freshness / dependencies on newest stable (push) Has been cancelled
file-length / file length <= 250 lines (push) Has been cancelled
md-naming / markdown naming convention (push) Has been cancelled
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Has been cancelled
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Has been cancelled
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint) (push) Has been cancelled
Tests / test (push) Has been cancelled
release-apk / release (APK) (push) Has been cancelled
repo-contract / repo contract (push) Has been cancelled
Catering fill: honour the "Log for later" date
Fill all with catering always fetched and filled today, so picking 24.10
on 23.10 reported "No catering delivery today." FillAllFlow.tap now takes
the picked day: fetch, slot schedule, occupancy and dedup all resolve
against it, and logDishes stamps each dish at its slot time on that day.

- A plan only confirms onto the day it was proposed for; changing the
  date (or back to today) disarms it.
- A later-day fill leaves today's delivery queue and prefill alone and
  returns the form to today, as a manual "Log for later" does.
- Only today's fetch records the single-day "already fetched" marker;
  recording a later date would skip that day's automatic fetch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VwYgigocPkPWa73QZRtU38
2026-10-23 19:01:44 +02:00

41 lines
1.2 KiB
Dart

/// Cancelling "Fill all" while its first-tap fetch is still in flight.
///
/// Its own file because `kuchnia_fill_flow_test.dart` is at the 250-line cap.
/// The UI disables Cancel while busy, so this guards the flow itself: a
/// dismissed proposal must not arm when the late fetch lands.
library;
import 'dart:async';
import 'package:diet_guard_app/services/kuchnia_fill_flow.dart';
import 'package:diet_guard_app/services/kuchnia_import.dart';
import 'package:diet_guard_app/services/log_storage_service.dart';
import 'package:flutter_test/flutter_test.dart';
import 'kuchnia_fill_support.dart';
void main() {
tearDown(LogStorageService.resetForTesting);
test('cancel during the fetch leaves nothing armed', () async {
final gate = Completer<void>();
final flow = FillAllFlow(
fetch: (_) async {
await gate.future;
return KuchniaRefresh(dishes: dishes(4));
},
now: () => DateTime(2026, 8, 23, 10),
slots: (_) => defaultSlots,
occupiedSlots: (_) async => <int>{},
storage: freshStorage(),
);
final pending = flow.tap();
flow.cancel();
gate.complete();
expect(await pending, isNull);
expect(flow.armedCount, 0);
});
}