From 1c1b16ded169c059fc858fd6bedcce6b625e47d1 Mon Sep 17 00:00:00 2001 From: dab246 Date: Fri, 27 Mar 2026 19:18:16 +0700 Subject: [PATCH] fixup! fixup! fixup! TF-4385 Fix spam banner show it once per day --- ...t_spam_mailbox_cached_interactor_test.dart | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) 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');