Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widget tree is not cleaned up between invocations of customPump passed to multiScreenGolden #177

Closed
maBarabas opened this issue Aug 10, 2023 · 2 comments

Comments

@maBarabas
Copy link

Some of the tests require scrolling the page, or tapping on buttons to expand ExpansionTile and other similar widgets. I implemented this using the customPump parameter of multiScreenGolden.

For example:

        final uuid = const Uuid().v4();
        print('pumping $uuid');
        final hiddenWidget = find.byType(HiddenWidget);
        expect(hiddenWidget, findsNothing);

        await tester.pump();
        await tester.tap(find.text('Show hidden widget'));

        await tester.pump();
        await tester.pump(const Duration(milliseconds: 1000));

        expect(hiddenWidget, findsOneWidget);
        print('pumping done $uuid');

A button labelled 'Show hidden widget' makes the HiddenWidget appear in the UI. e.g.

ExpansionTile(
  title: Text('Show hidden widget'),
  children: [HiddenWidget()],
)

It works as expected when there is only a single device, and the logs indicate that it works for the first device only when there are multiple devices. The hidden widget is visible when customPump is called for the second device.

I expected the widget tree to be completely cleaned up, then custom pump to be called.

@maBarabas
Copy link
Author

#146 looks like it would have the same root cause

@maBarabas
Copy link
Author

I found a suitable workaround:

Instead of this:

    await multiScreenGolden(
      tester,
      'name',
      customPump: (_) {
        await tester.tap(find.text('hello'));
        await tester.pump();
      },
    );

Call the pump function before the goldens are checked:

    await tester.tap(find.text('hello'));
    await tester.pump();

    await multiScreenGolden(
      tester,
      'name',
      customPump: (_) async {
         /* disable default pump */
      },
    );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant