Skip to content

Commit 1c1b16d

Browse files
dab246hoangdat
authored andcommitted
fixup! fixup! fixup! TF-4385 Fix spam banner show it once per day
1 parent 38fc79d commit 1c1b16d

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

test/features/mailbox_dashboard/domain/usecases/get_spam_mailbox_cached_interactor_test.dart

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)