Skip to content

Commit 32d9f2f

Browse files
committed
msglist test: Future-proof a test against failing with ArgumentError in August 2035
As Ruhaan pointed out at https://github.com/zulip/zulip-flutter/pull/2455/changes#r4057078244 , this test would've started failing on 2035-08-21 without this change (because `async.elapse` with a negative duration is an ArgumentError).
1 parent 34dac67 commit 32d9f2f

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

‎test/model/message_list_test.dart‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3895,18 +3895,15 @@ void main() {
38953895
doTest(narrow: MentionsNarrow(), expected: true);
38963896
});
38973897

3898-
test('showSender is maintained correctly', () => awaitFakeAsync((async) async {
3898+
test('showSender is maintained correctly', () => awaitFakeAsync(
3899+
// Pin the clock, to avoid flakes.
3900+
initialTime: DateTime(2035, 8, 21), (async) async {
38993901
// TODO(#150): This will get more complicated with message moves.
39003902
// Until then, we always compute this sequentially from oldest to newest.
39013903
// So we just need to exercise the different cases of the logic for
39023904
// whether the sender should be shown, but the difference between
39033905
// fetchInitial and handleMessageEvent etc. doesn't matter.
39043906

3905-
// Elapse test's clock to a specific time, to avoid any flaky-ness
3906-
// that may be caused by a specific local time of the day.
3907-
final initialTime = DateTime(2035, 8, 21);
3908-
async.elapse(initialTime.difference(clock.now()));
3909-
39103907
final now = clock.now();
39113908
final t1 = eg.utcTimestamp(now.subtract(Duration(days: 1)));
39123909
final t2 = t1 + Duration(minutes: 1).inSeconds;

0 commit comments

Comments
 (0)