fix: resolve navigation-cache regressions and todo UX
This commit is contained in:
@@ -30,7 +30,6 @@ void main() {
|
||||
calendarService: calendarService,
|
||||
notificationService: notificationService,
|
||||
outboxStore: outboxStore,
|
||||
isAppActive: () => true,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -58,50 +57,13 @@ void main() {
|
||||
expect(pending, isEmpty);
|
||||
});
|
||||
|
||||
test(
|
||||
'archive action should send remote archive immediately when app active',
|
||||
() async {
|
||||
when(
|
||||
() => notificationService.cancelEventReminder('evt_live'),
|
||||
).thenAnswer((_) async {});
|
||||
when(
|
||||
() => calendarService.archiveEvent('evt_live'),
|
||||
).thenAnswer((_) async => null);
|
||||
|
||||
executor = ReminderActionExecutor(
|
||||
calendarService: calendarService,
|
||||
notificationService: notificationService,
|
||||
outboxStore: outboxStore,
|
||||
isAppActive: () => true,
|
||||
);
|
||||
|
||||
await executor.handleAction(
|
||||
action: ReminderAction.archive,
|
||||
payload: ReminderPayload(
|
||||
eventId: 'evt_live',
|
||||
title: 'sync',
|
||||
startAt: DateTime.parse('2026-03-18T16:00:00+08:00'),
|
||||
timezone: 'Asia/Shanghai',
|
||||
),
|
||||
);
|
||||
|
||||
verify(() => calendarService.archiveEvent('evt_live')).called(1);
|
||||
final pending = await outboxStore.listPending();
|
||||
expect(pending, isEmpty);
|
||||
},
|
||||
);
|
||||
|
||||
test('archive in inactive app writes pending outbox item', () async {
|
||||
test('archive failure writes pending outbox item', () async {
|
||||
when(
|
||||
() => notificationService.cancelEventReminder('evt_1'),
|
||||
).thenAnswer((_) async {});
|
||||
|
||||
executor = ReminderActionExecutor(
|
||||
calendarService: calendarService,
|
||||
notificationService: notificationService,
|
||||
outboxStore: outboxStore,
|
||||
isAppActive: () => false,
|
||||
);
|
||||
when(
|
||||
() => calendarService.archiveEvent('evt_1'),
|
||||
).thenThrow(Exception('offline'));
|
||||
|
||||
await executor.handleAction(
|
||||
action: ReminderAction.archive,
|
||||
@@ -117,6 +79,7 @@ void main() {
|
||||
expect(pending.length, 1);
|
||||
expect(pending.first.eventId, 'evt_1');
|
||||
expect(pending.first.state, ReminderOutboxState.pending);
|
||||
verify(() => calendarService.archiveEvent('evt_1')).called(1);
|
||||
});
|
||||
|
||||
test('snooze reschedules +10m when event not expired', () async {
|
||||
|
||||
@@ -12,7 +12,7 @@ class _MockTodoApi extends Mock implements TodoApi {}
|
||||
|
||||
void main() {
|
||||
test(
|
||||
'complete todo should optimistically update and invalidate pending list key',
|
||||
'complete todo should optimistically remove item and invalidate pending list key',
|
||||
() async {
|
||||
final api = _MockTodoApi();
|
||||
final store = HybridCacheStore(
|
||||
@@ -50,7 +50,7 @@ void main() {
|
||||
final updated = await store.read<CacheEntry<List<TodoResponse>>>(
|
||||
TodoRepository.pendingListKey,
|
||||
);
|
||||
expect(updated?.value.first.status, 'completed');
|
||||
expect(updated, isNull);
|
||||
expect(invalidator.wasInvalidated(TodoRepository.pendingListKey), true);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user