Skip to content

Commit faed229

Browse files
committed
action_sheet test: Move some logic out of checkButtons helper
Upcoming tests for the resolve/unresolve button can use this to test an edge case where the button isn't offered. While we're at it, replace finder logic in some existing checks, making some a bit more targeted (so a not-NFC change): when finding `UserTopicUpdateButton`s by their label text, we now require the text to be under a BottomSheet widget.
1 parent f4e3457 commit faed229

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

test/widgets/action_sheet_test.dart

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,16 @@ void main() {
214214
await tester.pump(const Duration(milliseconds: 250));
215215
}
216216

217+
final actionSheetFinder = find.byType(BottomSheet);
218+
Finder findButtonForLabel(String label) =>
219+
find.descendant(of: actionSheetFinder, matching: find.text(label));
220+
217221
group('showTopicActionSheet', () {
218222
void checkButtons() {
219-
final actionSheetFinder = find.byType(BottomSheet);
220223
check(actionSheetFinder).findsOne();
221224

222225
void checkButton(String label) {
223-
check(
224-
find.descendant(of: actionSheetFinder, matching: find.text(label))
225-
).findsOne();
226+
check(findButtonForLabel(label)).findsOne();
226227
}
227228

228229
checkButton('Follow topic');
@@ -255,10 +256,10 @@ void main() {
255256
group('UserTopicUpdateButton', () {
256257
late String topic;
257258

258-
final mute = find.text('Mute topic');
259-
final unmute = find.text('Unmute topic');
260-
final follow = find.text('Follow topic');
261-
final unfollow = find.text('Unfollow topic');
259+
final mute = findButtonForLabel('Mute topic');
260+
final unmute = findButtonForLabel('Unmute topic');
261+
final follow = findButtonForLabel('Follow topic');
262+
final unfollow = findButtonForLabel('Unfollow topic');
262263

263264
/// Prepare store and bring up a topic action sheet.
264265
///
@@ -288,10 +289,10 @@ void main() {
288289

289290
void checkButtons(List<Finder> expectedButtonFinders) {
290291
if (expectedButtonFinders.isEmpty) {
291-
check(find.byType(BottomSheet)).findsNothing();
292+
check(actionSheetFinder).findsNothing();
292293
return;
293294
}
294-
check(find.byType(BottomSheet)).findsOne();
295+
check(actionSheetFinder).findsOne();
295296

296297
for (final buttonFinder in expectedButtonFinders) {
297298
check(buttonFinder).findsOne();

0 commit comments

Comments
 (0)