Skip to content

Commit 177ad1c

Browse files
committed
home test [nfc]: Move some find.descendants
This duplicates the `find.descendant`s in `tester.tap` callsites, but that's temporary; we'll deduplicate with a new helper function, coming up.
1 parent e094fdc commit 177ad1c

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

test/widgets/home_test.dart

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,9 @@ void main () {
138138
group('menu', () {
139139
final designVariables = DesignVariables.light;
140140

141-
final inboxMenuIconFinder = find.descendant(
142-
of: find.byType(BottomSheet),
143-
matching: find.byIcon(ZulipIcons.inbox));
144-
final channelsMenuIconFinder = find.descendant(
145-
of: find.byType(BottomSheet),
146-
matching: find.byIcon(ZulipIcons.hash_italic));
147-
final combinedFeedMenuIconFinder = find.descendant(
148-
of: find.byType(BottomSheet),
149-
matching: find.byIcon(ZulipIcons.message_feed));
141+
final inboxMenuIconFinder = find.byIcon(ZulipIcons.inbox);
142+
final channelsMenuIconFinder = find.byIcon(ZulipIcons.hash_italic);
143+
final combinedFeedMenuIconFinder = find.byIcon(ZulipIcons.message_feed);
150144

151145
Future<void> tapOpenMenu(WidgetTester tester) async {
152146
await tester.tap(find.byIcon(ZulipIcons.menu));
@@ -156,12 +150,18 @@ void main () {
156150
}
157151

158152
void checkIconSelected(WidgetTester tester, Finder finder) {
159-
check(tester.widget(finder)).isA<Icon>().color.isNotNull()
153+
final widget = tester.widget(find.descendant(
154+
of: find.byType(BottomSheet),
155+
matching: finder));
156+
check(widget).isA<Icon>().color.isNotNull()
160157
.isSameColorAs(designVariables.iconSelected);
161158
}
162159

163160
void checkIconNotSelected(WidgetTester tester, Finder finder) {
164-
check(tester.widget(finder)).isA<Icon>().color.isNotNull()
161+
final widget = tester.widget(find.descendant(
162+
of: find.byType(BottomSheet),
163+
matching: finder));
164+
check(widget).isA<Icon>().color.isNotNull()
165165
.isSameColorAs(designVariables.icon);
166166
}
167167

@@ -192,7 +192,9 @@ void main () {
192192
check(find.byType(InboxPageBody)).findsOne();
193193
check(find.byType(SubscriptionListPageBody)).findsNothing();
194194

195-
await tester.tap(channelsMenuIconFinder);
195+
await tester.tap(find.descendant(
196+
of: find.byType(BottomSheet),
197+
matching: channelsMenuIconFinder));
196198
await tester.pump(Duration.zero); // tap the button
197199
await tester.pump(const Duration(milliseconds: 250)); // wait for animation
198200
check(find.byType(BottomSheet)).findsNothing();
@@ -208,7 +210,9 @@ void main () {
208210
await prepare(tester);
209211
await tapOpenMenu(tester);
210212

211-
await tester.tap(channelsMenuIconFinder);
213+
await tester.tap(find.descendant(
214+
of: find.byType(BottomSheet),
215+
matching: channelsMenuIconFinder));
212216
await tester.pump(Duration.zero); // tap the button
213217
await tester.pump(const Duration(milliseconds: 250)); // wait for animation
214218
check(find.byType(BottomSheet)).findsNothing();
@@ -237,7 +241,9 @@ void main () {
237241

238242
connection.prepare(json: eg.newestGetMessagesResult(
239243
foundOldest: true, messages: [eg.streamMessage()]).toJson());
240-
await tester.tap(combinedFeedMenuIconFinder);
244+
await tester.tap(find.descendant(
245+
of: find.byType(BottomSheet),
246+
matching: combinedFeedMenuIconFinder));
241247
await tester.pump(Duration.zero); // tap the button
242248
await tester.pump(const Duration(milliseconds: 250)); // wait for animation
243249

0 commit comments

Comments
 (0)