diet-guard/app/test/screens/log_meal_progress_test.dart
Krzysztof kuhy Rudnicki 97af520fdd
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
Add log sound cue and progress card motion
- lightImpact + 160 ms confirm cue on a validated log (audioplayers,
  no audio focus); device-local opt-out switch in Settings, on by default
- post-log card: confirmation line (slot + the meal's kcal), entrance and
  kcal/streak count-up on motion tokens transcribed into ui/theme.dart;
  durations collapse to zero under disableAnimations
- test/flutter_test_config.dart mutes the cue suite-wide

Todo: 8e66c1b9
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWVHMLzeojNP4AaPoEj
2026-11-02 21:12:46 +01:00

41 lines
1.2 KiB
Dart

import 'package:diet_guard_app/models/food_entry.dart';
import 'package:diet_guard_app/models/local_time.dart';
import 'package:diet_guard_app/models/slot.dart';
import 'package:diet_guard_app/screens/log_meal_progress.dart';
import 'package:diet_guard_app/services/meal_schedule_service.dart';
import 'package:flutter_test/flutter_test.dart';
FoodEntry _entry({int? slotMinute}) => FoodEntry(
time: DateTime.now().toIso8601String(),
desc: 'oats',
grams: 100,
kcal: 300,
proteinG: 10,
carbsG: 50,
fatG: 5,
source: 'manual',
id: 'e1',
slotMinute: slotMinute,
);
void main() {
test('the logged slot is the stamped one when the entry carries it', () {
final entry = _entry(slotMinute: 480);
final progress = buildTodayProgress({
localDateKey(DateTime.now()): [entry],
}, logged: entry);
expect(progress.loggedSlotMinute, 480);
});
test('an unstamped entry falls back to the slot its time maps to', () {
final entry = _entry();
final progress = buildTodayProgress({
localDateKey(DateTime.now()): [entry],
}, logged: entry);
expect(
progress.loggedSlotMinute,
slotForLog(DateTime.parse(entry.time), MealScheduleService.current),
);
});
}