Skip to content

Commit 3823ec4

Browse files
committed
autocomplete test: Cut tests that could flake due to indeterminate sort
The [List.sort] method is documented as being not necessarily stable, meaning that elements that compare equal could end up in an arbitrary order in the result. Here, that means that users which aren't distinguished by recency in the topic or stream or in DM conversations can appear in any order in the autocomplete results. Several of these test cases were therefore vulnerable to flaking because users 2 and 4 have no DMs and (in these tests) no messages in the stream or topic. I think what they cover is now also covered by the "ranking across signals" tests above, together with the tests for RecentSenders and RecentDmConversations that check those data structures' handling of events. So just cut the tests.
1 parent 37e643d commit 3823ec4

File tree

1 file changed

+0
-53
lines changed

1 file changed

+0
-53
lines changed

test/model/autocomplete_test.dart

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,6 @@ void main() {
583583
const topic = 'topic';
584584
final streamNarrow = StreamNarrow(stream.streamId);
585585
final topicNarrow = TopicNarrow(stream.streamId, topic);
586-
final dmNarrow = DmNarrow.withUser(eg.selfUser.userId, selfUserId: eg.selfUser.userId);
587586

588587
final users = List.generate(5, (i) => eg.user(userId: i));
589588

@@ -673,62 +672,10 @@ void main() {
673672
await checkResultsIn(streamNarrow, expected: [4, 0, 2, 1, 3]);
674673
});
675674

676-
test('TopicNarrow, no other messages are in stream', () async {
677-
await checkInitialResultsIn(topicNarrow, expected: [0, 3, 1, 2, 4]);
678-
});
679-
680675
test('TopicNarrow, other messages are in stream', () async {
681676
await checkInitialResultsIn(topicNarrow, expected: [0, 4, 3, 1, 2],
682677
includeStream: true);
683678
});
684-
685-
test('TopicNarrow, new message arrives', () async {
686-
await checkInitialResultsIn(topicNarrow, expected: [0, 3, 1, 2, 4]);
687-
688-
// Until now, latest message id in [topic] is 50.
689-
await store.addMessage(streamMessage(id: 60, senderId: 2, topic: topic));
690-
691-
await checkResultsIn(topicNarrow, expected: [2, 0, 3, 1, 4]);
692-
});
693-
694-
test('TopicNarrow, a batch of older messages arrives', () async {
695-
await checkInitialResultsIn(topicNarrow, expected: [0, 3, 1, 2, 4]);
696-
697-
// Until now, oldest message id in [topic] is 50.
698-
final oldMessages = [
699-
streamMessage(id: 30, senderId: 2, topic: topic),
700-
streamMessage(id: 40, senderId: 4, topic: topic),
701-
];
702-
connection.prepare(json: olderResult(
703-
anchor: 50, foundOldest: false,
704-
messages: oldMessages,
705-
).toJson());
706-
707-
await messageList.fetchOlder();
708-
await checkResultsIn(topicNarrow, expected: [0, 4, 2, 3, 1]);
709-
});
710-
});
711-
712-
group('DmNarrow', () {
713-
test('DmNarrow, with no topic/stream message history', () async {
714-
await prepareStore();
715-
await checkResultsIn(dmNarrow, expected: [3, 0, 1, 2, 4]);
716-
});
717-
718-
test('DmNarrow, with topic/stream message history', () async {
719-
await prepareStore(includeMessageHistory: true);
720-
await checkResultsIn(dmNarrow, expected: [3, 0, 1, 2, 4]);
721-
});
722-
723-
test('DmNarrow, new message arrives', () async {
724-
await prepareStore();
725-
await checkResultsIn(dmNarrow, expected: [3, 0, 1, 2, 4]);
726-
727-
// Until now, latest message id in recent DMs is 300.
728-
await store.addMessage(eg.dmMessage(id: 400, from: users[1], to: [eg.selfUser]));
729-
730-
await checkResultsIn(dmNarrow, expected: [1, 3, 0, 2, 4]);
731-
});
732679
});
733680
});
734681
});

0 commit comments

Comments
 (0)