首次远程推送
This commit is contained in:
@@ -12,6 +12,8 @@ import 'package:focus_seed/src/models/reflection_entry.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
setUp(() {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
});
|
||||
@@ -77,4 +79,99 @@ void main() {
|
||||
'reflection-yesterday',
|
||||
]);
|
||||
});
|
||||
|
||||
test('default focus duration persists and survives record cleanup', () async {
|
||||
final database = FocusSeedDatabase(NativeDatabase.memory());
|
||||
addTearDown(database.close);
|
||||
final store = FocusSeedStore(database: database);
|
||||
final controller = FocusSeedController(store: store);
|
||||
await controller.load();
|
||||
|
||||
final changed = await controller.setDefaultFocusMinutes(45);
|
||||
expect(changed, isTrue);
|
||||
expect(controller.state!.defaultFocusMinutes, 45);
|
||||
|
||||
final reloaded = FocusSeedController(store: store);
|
||||
await reloaded.load();
|
||||
expect(reloaded.state!.defaultFocusMinutes, 45);
|
||||
|
||||
final cleared = await reloaded.clearData();
|
||||
expect(cleared, isTrue);
|
||||
expect(reloaded.state!.defaultFocusMinutes, 45);
|
||||
});
|
||||
|
||||
test('completed focus sessions snapshot the active daily focus', () async {
|
||||
final database = FocusSeedDatabase(NativeDatabase.memory());
|
||||
addTearDown(database.close);
|
||||
final store = FocusSeedStore(database: database);
|
||||
final controller = FocusSeedController(store: store);
|
||||
await controller.load();
|
||||
|
||||
final savedFocus = await controller.setTodayAnchor('Review launch notes');
|
||||
final savedSession = await controller.completeFocusSession(
|
||||
10,
|
||||
actualSeconds: 60,
|
||||
);
|
||||
|
||||
expect(savedFocus, isTrue);
|
||||
expect(savedSession, isTrue);
|
||||
expect(controller.state!.sessions.single.intention, 'Review launch notes');
|
||||
|
||||
final reloaded = FocusSeedController(store: store);
|
||||
await reloaded.load();
|
||||
expect(reloaded.state!.sessions.single.intention, 'Review launch notes');
|
||||
});
|
||||
|
||||
test('progress notes can be backfilled for a past record date', () async {
|
||||
final database = FocusSeedDatabase(NativeDatabase.memory());
|
||||
addTearDown(database.close);
|
||||
final store = FocusSeedStore(database: database);
|
||||
final controller = FocusSeedController(store: store);
|
||||
await controller.load();
|
||||
|
||||
const pastDate = '2026-06-12';
|
||||
final saved = await controller.saveReflectionForDate(
|
||||
pastDate,
|
||||
'Recovered the next step.',
|
||||
Mood.clear,
|
||||
);
|
||||
|
||||
expect(saved, isTrue);
|
||||
expect(controller.state!.reflections.single.dateKey, pastDate);
|
||||
expect(
|
||||
controller.state!.reflections.single.note,
|
||||
'Recovered the next step.',
|
||||
);
|
||||
});
|
||||
|
||||
test('today anchor does not create a daily action object', () async {
|
||||
final database = FocusSeedDatabase(NativeDatabase.memory());
|
||||
addTearDown(database.close);
|
||||
final store = FocusSeedStore(database: database);
|
||||
final controller = FocusSeedController(store: store);
|
||||
await controller.load();
|
||||
|
||||
final savedToday = await controller.setTodayAnchor('Review launch notes');
|
||||
|
||||
expect(savedToday, isTrue);
|
||||
expect(controller.state!.activeAnchor(todayKey()), 'Review launch notes');
|
||||
expect(controller.state!.actions, isEmpty);
|
||||
});
|
||||
|
||||
test('focus can complete without a today anchor', () async {
|
||||
final database = FocusSeedDatabase(NativeDatabase.memory());
|
||||
addTearDown(database.close);
|
||||
final store = FocusSeedStore(database: database);
|
||||
final controller = FocusSeedController(store: store);
|
||||
await controller.load();
|
||||
|
||||
final savedSession = await controller.completeFocusSession(
|
||||
10,
|
||||
actualSeconds: 120,
|
||||
);
|
||||
|
||||
expect(savedSession, isTrue);
|
||||
expect(controller.state!.sessions.single.intention, isEmpty);
|
||||
expect(controller.state!.actions, isEmpty);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user