diet-guard/app/test/kuchnia_fill_cancel_test.dart
Krzysztof kuhy Rudnicki 5cd89a4e99
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
file-length / file length <= 250 lines (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint) (push) Waiting to run
Tests / test (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Update app/diet_guard (17 files)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-10 13:49:58 +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);
});
}