mirror of
https://github.com/kuhyx/wake-alarm.git
synced 2026-11-22 21:22:17 +01:00
Tapping today or a later normal day opens a sheet with one switch per locker (Workout lock, LeetCode, Book, Diet, Wake alarm), all off, and "Mark sick"; a sick day reopens with its switches, "Save" (keep-only edit, nothing written when unchanged) and "Clear sick day". Past days stay inert. A sick day keeping any locker carries a dot in the calendar and a "Kept: ..." line in the list. DayCell moves to day_cell.dart for the 250-line cap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PAhbNszs5JKdtnD4uBi3xp
55 lines
1.7 KiB
Dart
55 lines
1.7 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:wake_alarm_sync/screens/sick_day_sheet.dart';
|
|
import 'package:wake_alarm_sync/services/free_day_pool.dart';
|
|
import 'package:wake_alarm_sync/services/sick_day_pool.dart';
|
|
|
|
import 'fake_day_pool_store.dart';
|
|
|
|
/// `applySickSheet` on its own: the free-day check holds even when the
|
|
/// screen's own pre-check is bypassed.
|
|
final _today = DateTime(2026, 10, 16);
|
|
final _day = DateTime(2026, 10, 20);
|
|
const SickSheetResult _mark = (action: SickSheetAction.mark, keep: {'diet'});
|
|
|
|
void main() {
|
|
late SickDayPool sick;
|
|
late FreeDayPool free;
|
|
|
|
setUp(() async {
|
|
sick = await SickDayPool.open(persistence: MemPersistence(), deviceId: 'p');
|
|
free = await FreeDayPool.open(persistence: MemPersistence(), deviceId: 'p');
|
|
});
|
|
|
|
test('a mark with no free-day pool is refused', () async {
|
|
await expectLater(
|
|
applySickSheet(sick, _day, _mark, free: null, now: _today),
|
|
throwsA(
|
|
isA<SickDayPolicyError>().having(
|
|
(e) => e.message,
|
|
'message',
|
|
contains('Free-day pool unavailable'),
|
|
),
|
|
),
|
|
);
|
|
expect(sick.isSick(_day), isFalse);
|
|
});
|
|
|
|
test('a mark on a free day is refused, naming the pool', () async {
|
|
await free.mark(_day, now: _today);
|
|
expect(freeDayRefusal(free, _day), contains('is a free day'));
|
|
await expectLater(
|
|
applySickSheet(sick, _day, _mark, free: free, now: _today),
|
|
throwsA(isA<SickDayPolicyError>()),
|
|
);
|
|
});
|
|
|
|
test('a mark keeps exactly the switched-on lockers', () async {
|
|
expect(
|
|
await applySickSheet(sick, _day, _mark, free: free, now: _today),
|
|
isTrue,
|
|
);
|
|
expect(sick.keptLockers(_day), {'diet'});
|
|
expect(keptLabel(sick.keptLockers(_day)), 'Diet');
|
|
});
|
|
}
|