Skip to content

Commit d13e3d9

Browse files
gnpricechrisbobbe
authored andcommitted
new-dm test: Split out muted-user checks as own test case
This lets us make it a bit more thorough, while not adding to the complexity of reading the test case for the basic logic.
1 parent 0ce94c4 commit d13e3d9

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

test/widgets/new_dm_sheet_test.dart

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,24 +116,19 @@ void main() {
116116
});
117117

118118
group('user filtering', () {
119-
final mutedUser = eg.user(fullName: 'Someone Muted');
120119
final testUsers = [
121120
eg.user(fullName: 'Alice Anderson'),
122121
eg.user(fullName: 'Bob Brown'),
123122
eg.user(fullName: 'Charlie Carter'),
124-
mutedUser,
125123
];
126124

127-
testWidgets('shows all non-muted users initially', (tester) async {
128-
await setupSheet(tester, users: testUsers, mutedUserIds: [mutedUser.userId]);
125+
testWidgets('shows full list initially', (tester) async {
126+
await setupSheet(tester, users: testUsers);
129127
check(findText(includePlaceholders: false, 'Alice Anderson')).findsOne();
130128
check(findText(includePlaceholders: false, 'Bob Brown')).findsOne();
131129
check(findText(includePlaceholders: false, 'Charlie Carter')).findsOne();
132-
133130
check(find.byIcon(ZulipIcons.check_circle_unchecked)).findsExactly(3);
134131
check(find.byIcon(ZulipIcons.check_circle_checked)).findsNothing();
135-
check(findText(includePlaceholders: false, 'Someone Muted')).findsNothing();
136-
check(findText(includePlaceholders: false, 'Muted user')).findsNothing();
137132
});
138133

139134
testWidgets('shows filtered users based on search', (tester) async {
@@ -145,6 +140,27 @@ void main() {
145140
check(findText(includePlaceholders: false, 'Bob Brown')).findsNothing();
146141
});
147142

143+
testWidgets('muted users excluded', (tester) async {
144+
// Omit muted users both before there's a query…
145+
final mutedUser = eg.user(fullName: 'Someone Muted');
146+
await setupSheet(tester,
147+
users: [...testUsers, mutedUser], mutedUserIds: [mutedUser.userId]);
148+
check(findText(includePlaceholders: false, 'Someone Muted')).findsNothing();
149+
check(findText(includePlaceholders: false, 'Muted user')).findsNothing();
150+
check(findText(includePlaceholders: false, 'Alice Anderson')).findsOne();
151+
check(find.byIcon(ZulipIcons.check_circle_unchecked)).findsExactly(3);
152+
153+
// … and after a query. One which matches both the user's actual name and
154+
// the replacement text "Muted user", for good measure.
155+
await tester.enterText(find.byType(TextField), 'e');
156+
await tester.pump();
157+
check(findText(includePlaceholders: false, 'Someone Muted')).findsNothing();
158+
check(findText(includePlaceholders: false, 'Muted user')).findsNothing();
159+
check(findText(includePlaceholders: false, 'Alice Anderson')).findsOne();
160+
check(findText(includePlaceholders: false, 'Charlie Carter')).findsOne();
161+
check(find.byIcon(ZulipIcons.check_circle_unchecked)).findsExactly(2);
162+
});
163+
148164
// TODO test sorting by recent-DMs
149165
// TODO test that scroll position resets on query change
150166

0 commit comments

Comments
 (0)