Skip to content

Commit b8bff54

Browse files
committed
add tests for the new support of non-keyed button presses
1 parent dd15eaa commit b8bff54

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

flutter/test/user_interaction/sentry_user_interaction_widget_test.dart

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,40 @@ void main() {
347347
}));
348348
});
349349
});
350+
351+
testWidgets('Add crumb for button without key', (tester) async {
352+
await tester.runAsync(() async {
353+
final sut = fixture.getSut(sendDefaultPii: true);
354+
355+
await tester.pumpWidget(sut);
356+
await tester.tap(find.byElementPredicate((element) {
357+
final widget = element.widget;
358+
if (widget is MaterialButton) {
359+
return (widget.child as Text).data == 'Button 5';
360+
}
361+
return false;
362+
}));
363+
364+
expect(
365+
fixture.getBreadcrumb().data?.replaceHashCodes(),
366+
equals({
367+
'path': [
368+
{'element': 'MaterialButton'},
369+
{'element': 'Column'},
370+
{'element': 'Center'},
371+
{'name': '[GlobalKey#00000]', 'element': 'KeyedSubtree'},
372+
{'element': 'MediaQuery'},
373+
{'name': '_ScaffoldSlot.body', 'element': 'LayoutId'},
374+
{'element': 'CustomMultiChildLayout'},
375+
{'element': 'Actions'},
376+
{'element': 'AnimatedBuilder'},
377+
{'element': 'DefaultTextStyle'}
378+
],
379+
'label': 'Button 5',
380+
'view.class': 'MaterialButton'
381+
}));
382+
});
383+
});
350384
});
351385

352386
group('$SentryUserInteractionWidget performance', () {
@@ -486,7 +520,6 @@ Future<void> tapMe(
486520
if (pumpWidget) {
487521
await tester.pumpWidget(widget);
488522
}
489-
490523
await tester.tap(find.byKey(Key(key)));
491524
}
492525

@@ -604,7 +637,11 @@ class Page1 extends StatelessWidget {
604637
onPressed: () {},
605638
child: Text('Button text'),
606639
),
607-
)
640+
),
641+
MaterialButton(
642+
onPressed: () {},
643+
child: const Text('Button 5'),
644+
),
608645
],
609646
),
610647
),

0 commit comments

Comments
 (0)