Skip to content

Commit 4eca289

Browse files
committed
(squash) Demo using the new findText and includePlaceholders
1 parent 9aa3c62 commit 4eca289

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

test/widgets/new_dm_sheet_test.dart

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import '../flutter_checks.dart';
1919
import '../model/binding.dart';
2020
import '../model/test_store.dart';
2121
import '../test_navigation.dart';
22+
import 'finders.dart';
2223
import 'test_app.dart';
2324

2425
late PerAccountStore store;
@@ -125,23 +126,23 @@ void main() {
125126

126127
testWidgets('shows all non-muted users initially', (tester) async {
127128
await setupSheet(tester, users: testUsers, mutedUserIds: [mutedUser.userId]);
128-
check(find.textContaining('Alice Anderson')).findsOne();
129-
check(find.textContaining('Bob Brown')).findsOne();
130-
check(find.textContaining('Charlie Carter')).findsOne();
129+
check(findText(includePlaceholders: false, 'Alice Anderson')).findsOne();
130+
check(findText(includePlaceholders: false, 'Bob Brown')).findsOne();
131+
check(findText(includePlaceholders: false, 'Charlie Carter')).findsOne();
131132

132133
check(find.byIcon(ZulipIcons.check_circle_unchecked)).findsExactly(3);
133134
check(find.byIcon(ZulipIcons.check_circle_checked)).findsNothing();
134-
check(find.textContaining('Someone Muted')).findsNothing();
135-
check(find.textContaining('Muted user')).findsNothing();
135+
check(findText(includePlaceholders: false, 'Someone Muted')).findsNothing();
136+
check(findText(includePlaceholders: false, 'Muted user')).findsNothing();
136137
});
137138

138139
testWidgets('shows filtered users based on search', (tester) async {
139140
await setupSheet(tester, users: testUsers);
140141
await tester.enterText(find.byType(TextField), 'Alice');
141142
await tester.pump();
142-
check(find.textContaining('Alice Anderson')).findsOne();
143-
check(find.textContaining('Charlie Carter')).findsNothing();
144-
check(find.textContaining('Bob Brown')).findsNothing();
143+
check(findText(includePlaceholders: false, 'Alice Anderson')).findsOne();
144+
check(findText(includePlaceholders: false, 'Charlie Carter')).findsNothing();
145+
check(findText(includePlaceholders: false, 'Bob Brown')).findsNothing();
145146
});
146147

147148
// TODO test sorting by recent-DMs
@@ -151,43 +152,43 @@ void main() {
151152
await setupSheet(tester, users: testUsers);
152153
await tester.enterText(find.byType(TextField), 'alice');
153154
await tester.pump();
154-
check(find.textContaining('Alice Anderson')).findsOne();
155+
check(findText(includePlaceholders: false, 'Alice Anderson')).findsOne();
155156

156157
await tester.enterText(find.byType(TextField), 'ALICE');
157158
await tester.pump();
158-
check(find.textContaining('Alice Anderson')).findsOne();
159+
check(findText(includePlaceholders: false, 'Alice Anderson')).findsOne();
159160
});
160161

161162
testWidgets('partial name and last name search handling', (tester) async {
162163
await setupSheet(tester, users: testUsers);
163164

164165
await tester.enterText(find.byType(TextField), 'Ali');
165166
await tester.pump();
166-
check(find.textContaining('Alice Anderson')).findsOne();
167-
check(find.textContaining('Bob Brown')).findsNothing();
168-
check(find.textContaining('Charlie Carter')).findsNothing();
167+
check(findText(includePlaceholders: false, 'Alice Anderson')).findsOne();
168+
check(findText(includePlaceholders: false, 'Bob Brown')).findsNothing();
169+
check(findText(includePlaceholders: false, 'Charlie Carter')).findsNothing();
169170

170171
await tester.enterText(find.byType(TextField), 'Anderson');
171172
await tester.pump();
172-
check(find.textContaining('Alice Anderson')).findsOne();
173-
check(find.textContaining('Charlie Carter')).findsNothing();
174-
check(find.textContaining('Bob Brown')).findsNothing();
173+
check(findText(includePlaceholders: false, 'Alice Anderson')).findsOne();
174+
check(findText(includePlaceholders: false, 'Charlie Carter')).findsNothing();
175+
check(findText(includePlaceholders: false, 'Bob Brown')).findsNothing();
175176

176177
await tester.enterText(find.byType(TextField), 'son');
177178
await tester.pump();
178-
check(find.textContaining('Alice Anderson')).findsOne();
179-
check(find.textContaining('Charlie Carter')).findsNothing();
180-
check(find.textContaining('Bob Brown')).findsNothing();
179+
check(findText(includePlaceholders: false, 'Alice Anderson')).findsOne();
180+
check(findText(includePlaceholders: false, 'Charlie Carter')).findsNothing();
181+
check(findText(includePlaceholders: false, 'Bob Brown')).findsNothing();
181182
});
182183

183184
testWidgets('shows empty state when no users match', (tester) async {
184185
await setupSheet(tester, users: testUsers);
185186
await tester.enterText(find.byType(TextField), 'Zebra');
186187
await tester.pump();
187-
check(find.textContaining('No users found')).findsOne();
188-
check(find.textContaining('Alice Anderson')).findsNothing();
189-
check(find.textContaining('Bob Brown')).findsNothing();
190-
check(find.textContaining('Charlie Carter')).findsNothing();
188+
check(findText(includePlaceholders: false, 'No users found')).findsOne();
189+
check(findText(includePlaceholders: false, 'Alice Anderson')).findsNothing();
190+
check(findText(includePlaceholders: false, 'Bob Brown')).findsNothing();
191+
check(findText(includePlaceholders: false, 'Charlie Carter')).findsNothing();
191192
});
192193

193194
testWidgets('search text clears when user is selected', (tester) async {

test/widgets/recent_dm_conversations_test.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import '../model/binding.dart';
2222
import '../model/test_store.dart';
2323
import '../test_navigation.dart';
2424
import 'content_checks.dart';
25+
import 'finders.dart';
2526
import 'message_list_checks.dart';
2627
import 'page_checks.dart';
2728
import 'test_app.dart';
@@ -180,8 +181,9 @@ void main() {
180181
// TODO(#232): syntax like `check(find(…), findsOneWidget)`
181182
final widget = tester.widget(find.descendant(
182183
of: find.byType(RecentDmConversationsItem),
183-
matching: find.textContaining(expectedText),
184-
));
184+
// The title might contain a WidgetSpan (for status emoji); exclude
185+
// the resulting placeholder character from the text to be matched.
186+
matching: findText(expectedText, includePlaceholders: false)));
185187
if (expectedLines != null) {
186188
final renderObject = tester.renderObject<RenderParagraph>(find.byWidget(widget));
187189
check(renderObject.size.height).equals(

0 commit comments

Comments
 (0)