Skip to content

Commit 8d800f0

Browse files
committed
action_sheet test [nfc]: Make checkButtons helper for showTopicActionSheet
1 parent a4f2270 commit 8d800f0

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

test/widgets/action_sheet_test.dart

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,19 @@ void main() {
125125
await store.addMessage(message);
126126
}
127127

128+
void checkButtons() {
129+
final actionSheetFinder = find.byType(BottomSheet);
130+
check(actionSheetFinder).findsOne();
131+
132+
void checkButton(String label) {
133+
check(
134+
find.descendant(of: actionSheetFinder, matching: find.text(label))
135+
).findsOne();
136+
}
137+
138+
checkButton('Follow topic');
139+
}
140+
128141
testWidgets('show from inbox', (tester) async {
129142
await prepare();
130143
await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id,
@@ -135,8 +148,7 @@ void main() {
135148
await tester.longPress(find.text(topic));
136149
// sheet appears onscreen; default duration of bottom-sheet enter animation
137150
await tester.pump(const Duration(milliseconds: 250));
138-
check(find.byType(BottomSheet)).findsOne();
139-
check(find.text('Follow topic')).findsOne();
151+
checkButtons();
140152
});
141153

142154
testWidgets('show from app bar', (tester) async {
@@ -153,8 +165,7 @@ void main() {
153165
await tester.longPress(topicRow);
154166
// sheet appears onscreen; default duration of bottom-sheet enter animation
155167
await tester.pump(const Duration(milliseconds: 250));
156-
check(find.byType(BottomSheet)).findsOne();
157-
check(find.text('Follow topic')).findsOne();
168+
checkButtons();
158169
});
159170

160171
testWidgets('show from recipient header', (tester) async {
@@ -170,8 +181,7 @@ void main() {
170181
of: find.byType(RecipientHeader), matching: find.text(topic)));
171182
// sheet appears onscreen; default duration of bottom-sheet enter animation
172183
await tester.pump(const Duration(milliseconds: 250));
173-
check(find.byType(BottomSheet)).findsOne();
174-
check(find.text('Follow topic')).findsOne();
184+
checkButtons();
175185
});
176186
});
177187

0 commit comments

Comments
 (0)