@@ -170,6 +170,43 @@ void main() {
170170 });
171171 });
172172
173+ group ('clock-skew (future timestamp)' , () {
174+ test (
175+ 'does not show banner when stored timestamp is 12 hours in the future (< 1 day clock skew)' ,
176+ () {
177+ when (spamReportRepository
178+ .getLastTimeDismissedSpamReportedMilliseconds ())
179+ .thenAnswer ((_) async => msAgo (- 12 ));
180+
181+ expect (
182+ interactor.execute (accountId, userName),
183+ emitsInOrder ([
184+ Right (GetSpamMailboxCachedLoading ()),
185+ leftWithException <SpamDismissCooldownActiveException >(),
186+ ]),
187+ );
188+ });
189+
190+ test (
191+ 'shows banner when stored timestamp is 25 hours in the future (>= 1 day clock skew, likely clock reset)' ,
192+ () {
193+ final spamMailbox = makeSpamMailbox (unreadCount: 3 );
194+ when (spamReportRepository
195+ .getLastTimeDismissedSpamReportedMilliseconds ())
196+ .thenAnswer ((_) async => msAgo (- 25 ));
197+ when (spamReportRepository.getSpamMailboxCached (accountId, userName))
198+ .thenAnswer ((_) async => spamMailbox);
199+
200+ expect (
201+ interactor.execute (accountId, userName),
202+ emitsInOrder ([
203+ Right (GetSpamMailboxCachedLoading ()),
204+ Right (GetSpamMailboxCachedSuccess (spamMailbox)),
205+ ]),
206+ );
207+ });
208+ });
209+
173210 group ('error handling' , () {
174211 test ('wraps repository exception in GetSpamMailboxCachedFailure' , () {
175212 final exception = Exception ('cache error' );
0 commit comments