diff --git a/test/features/mailbox_dashboard/domain/usecases/get_spam_mailbox_cached_interactor_test.dart b/test/features/mailbox_dashboard/domain/usecases/get_spam_mailbox_cached_interactor_test.dart index b25f73725..f531cbe39 100644 --- a/test/features/mailbox_dashboard/domain/usecases/get_spam_mailbox_cached_interactor_test.dart +++ b/test/features/mailbox_dashboard/domain/usecases/get_spam_mailbox_cached_interactor_test.dart @@ -170,6 +170,43 @@ void main() { }); }); + group('clock-skew (future timestamp)', () { + test( + 'does not show banner when stored timestamp is 12 hours in the future (< 1 day clock skew)', + () { + when(spamReportRepository + .getLastTimeDismissedSpamReportedMilliseconds()) + .thenAnswer((_) async => msAgo(-12)); + + expect( + interactor.execute(accountId, userName), + emitsInOrder([ + Right(GetSpamMailboxCachedLoading()), + leftWithException(), + ]), + ); + }); + + test( + 'shows banner when stored timestamp is 25 hours in the future (>= 1 day clock skew, likely clock reset)', + () { + final spamMailbox = makeSpamMailbox(unreadCount: 3); + when(spamReportRepository + .getLastTimeDismissedSpamReportedMilliseconds()) + .thenAnswer((_) async => msAgo(-25)); + when(spamReportRepository.getSpamMailboxCached(accountId, userName)) + .thenAnswer((_) async => spamMailbox); + + expect( + interactor.execute(accountId, userName), + emitsInOrder([ + Right(GetSpamMailboxCachedLoading()), + Right(GetSpamMailboxCachedSuccess(spamMailbox)), + ]), + ); + }); + }); + group('error handling', () { test('wraps repository exception in GetSpamMailboxCachedFailure', () { final exception = Exception('cache error');