cmdrootaccess / another-flushbar

A flexible widget for user notification. Customize your text, button, duration, animations and much more. For Android devs, it is made to replace Snackbars and Toasts.
https://pub.dev/packages/another_flushbar
MIT License
145 stars 88 forks source link

[Question] how to catch flushbars in integration test? #126

Open abdallah-odeh opened 4 months ago

abdallah-odeh commented 4 months ago

I am writing integration tests for my app and within my cases, there are cases were a A flushbar with title "Success" must appear and A flushbar with title "Error" must appear

so my Finder instance is

Finder findSuccessMessage() {
  return find.byWidgetPredicate(
      (widget) => widget is Flushbar && widget.title == 'lb_success'.tr());
}

here is my integration test code

      await tester.tap(find.byType(AppButton)); //press submit
      await tester.pumpAndSettle(); //wait until the loader goes away

      expect(findSuccessMessage(), findsOneWidget); //expect a successful result

the flushbar is indeed appear correctly, but the expect fails because it reaches that line of code when the flushbar goes away Flushbar duration is 2 seconds

and when I try to remove the await tester.pumpAndSettle(); it checks for the success message immediately after pressing the button so the API did not yet return a response!