0

I used the widget to build a basic application for self learning purpose. I would like to widget test what I am done but there's something unclear to me on the topic. In the widget test I wrote this:

// Render the widget.
await tester.pumpWidget(MaterialApp(
    title: 'Firestore test', home: Calendar(firestore: firestore)));

// Let the snapshots stream fire a snapshot.
await tester.idle();

// Re-render.
await tester.pump();

// Verify the output.
expect(find.text('Appointments'), findsOneWidget);
expect(find.text('No selected date'), findsOneWidget);

With last line that verifies that without any interaction the SyncFusion calendar should display "No selected date" in the agenda. That line fails as no widget are found. I also tried to do a test with the tap to a given date to display the events for a day, but the tap does not work as well.

// pre filled data before
// ...
await tester.pumpWidget(MaterialApp(
    title: 'Firestore test', home: Calendar(firestore: firestore)));

// Let the snapshots stream fire a snapshot.
await tester.idle();

// Re-render.
await tester.pump();

await tester.tap(find.text(datetime.day.toString()));
await tester.pumpAndSettle();

await tester.pump();

// Verify the output.
expect(find.text('Appointments'), findsOneWidget);
expect(find.text('Mark', skipOffstage: false), findsOneWidget);

Could you help me understand what I am missing in order to verify the above behaviour?

Momo
  • 345
  • 1
  • 5
  • 16
  • Be aware that the SyncFusion products in the Dart/Flutter pub are *not* open source. They are released under a commercial license that may subject you or your organization to a financial liability, and might affect downstream re-users of your code. – Randal Schwartz Oct 26 '22 at 18:31
  • Hey @Randal thanks for the reply. Yes I know it but it's just for myself learning Dart/Flutter as I am new to the topic. So I just wanted to understand how test should be written, just to complete my learning :) – Momo Oct 27 '22 at 08:28

0 Answers0