leancodepl/patrol

await pumpWidgetAndSettle not awaiting?

Closed this issue · 16 comments

Steps to reproduce

I have a test that goes through the setup process which ends with:

await $.pumpWidgetAndSettle(UncontrolledProviderScope(
        container: ProviderContainer(
          observers: [],
        ),
        child: const MyApp(),
      ));

For the test portion, I have a very simple login form that checks for the presence of the fields, fills them in and submits:

expect($('LOGIN'), findsOneWidget); 
await $(Keys.authEmailField).enterText('user');
await $(Keys.authPasswordField).enterText('password');     
await $('LOGIN').tap();

Actual results

As it is shown it does not work for me. However, if I move the order of when I check for the button it does work. It is very strange. It is like it doesn't render the screen until the first await ($Keys.....) line

//expect($('LOGIN'), findsOneWidget); 
await $(Keys.authEmailField).enterText('user');
await $(Keys.authPasswordField).enterText('password');     
expect($('LOGIN'), findsOneWidget);  //THIS WORKS??
await $('LOGIN').tap();

I even tried to put a delay in there to just see if the pumpAndSettle needed more time to settle

Logs

Logs
<!-- Replace this line with your logs. Do not remove the backticks! -->

Patrol version

patrol: ^3.6.1

Patrol Doctor output

Patrol Doctor output
<!-- Replace this line with your logs. Do not remove the backticks! -->

Flutter Doctor output

Flutter Doctor output
Patrol doctor:
Patrol CLI version: 2.7.0
Flutter command: flutter 
  Flutter 3.19.5 • channel stable
Android: 
• Program adb found in /[PATH]/Library/Android/sdk/platform-tools/adb
• Env var $ANDROID_HOME set to /[PATH]/Library/Android/sdk
iOS / macOS: 
• Program xcodebuild found in /usr/bin/xcodebuild
• Program ideviceinstaller found in /opt/homebrew/bin/ideviceinstaller```

</details>

This was tested on a Pixel 7 only

Update: If I put this:
await $.waitUntilVisible($('LOGIN'), timeout: const Duration(seconds: 10));
above the top expect($('LOGIN'), findsOneWidget);. It works correctly.

I thought the pumpWidgetAndSettle() handled this so maybe I am just writing tests wrong?

Maybe there is something else rendered before login button is visible, like splash screen / auto log in page / some wrapper or something? I'm also waiting for first element on the sign in form before I proceed further with any tests.

Hi, I suppose settling ends before sign up form is being rendered. You could try to set longer duration in pumpWidgetAndSettle() or/and use await $(Key).waitUntilExists() and await $(Key).waitUntilVisible() instead of expect().

Without additional information, we can't resolve this issue. We're therefore reluctantly going to close it.
Feel free to open a new issue with all the required information provided, including a [minimal, reproducible sample]. Make sure to diligently fill out the issue template.
Thanks for your contribution.
[minimal, reproducible sample]: https://stackoverflow.com/help/minimal-reproducible-example

Without additional information, we can't resolve this issue. We're therefore reluctantly going to close it.
Feel free to open a new issue with all the required information provided, including a [minimal, reproducible sample]. Make sure to diligently fill out the issue template.
Thanks for your contribution.
[minimal, reproducible sample]: https://stackoverflow.com/help/minimal-reproducible-example

Without additional information, we can't resolve this issue. We're therefore reluctantly going to close it.
Feel free to open a new issue with all the required information provided, including a [minimal, reproducible sample]. Make sure to diligently fill out the issue template.
Thanks for your contribution.
[minimal, reproducible sample]: https://stackoverflow.com/help/minimal-reproducible-example

Without additional information, we can't resolve this issue. We're therefore reluctantly going to close it.
Feel free to open a new issue with all the required information provided, including a [minimal, reproducible sample]. Make sure to diligently fill out the issue template.
Thanks for your contribution.
[minimal, reproducible sample]: https://stackoverflow.com/help/minimal-reproducible-example

Without additional information, we can't resolve this issue. We're therefore reluctantly going to close it.
Feel free to open a new issue with all the required information provided, including a [minimal, reproducible sample]. Make sure to diligently fill out the issue template.
Thanks for your contribution.
[minimal, reproducible sample]: https://stackoverflow.com/help/minimal-reproducible-example

Without additional information, we can't resolve this issue. We're therefore reluctantly going to close it.
Feel free to open a new issue with all the required information provided, including a [minimal, reproducible sample]. Make sure to diligently fill out the issue template.
Thanks for your contribution.
[minimal, reproducible sample]: https://stackoverflow.com/help/minimal-reproducible-example

Without additional information, we can't resolve this issue. We're therefore reluctantly going to close it.
Feel free to open a new issue with all the required information provided, including a [minimal, reproducible sample]. Make sure to diligently fill out the issue template.
Thanks for your contribution.
[minimal, reproducible sample]: https://stackoverflow.com/help/minimal-reproducible-example

Without additional information, we can't resolve this issue. We're therefore reluctantly going to close it.
Feel free to open a new issue with all the required information provided, including a [minimal, reproducible sample]. Make sure to diligently fill out the issue template.
Thanks for your contribution.
[minimal, reproducible sample]: https://stackoverflow.com/help/minimal-reproducible-example

Without additional information, we can't resolve this issue. We're therefore reluctantly going to close it.
Feel free to open a new issue with all the required information provided, including a [minimal, reproducible sample]. Make sure to diligently fill out the issue template.
Thanks for your contribution.
[minimal, reproducible sample]: https://stackoverflow.com/help/minimal-reproducible-example

Without additional information, we can't resolve this issue. We're therefore reluctantly going to close it.
Feel free to open a new issue with all the required information provided, including a [minimal, reproducible sample]. Make sure to diligently fill out the issue template.
Thanks for your contribution.
[minimal, reproducible sample]: https://stackoverflow.com/help/minimal-reproducible-example

Without additional information, we can't resolve this issue. We're therefore reluctantly going to close it.
Feel free to open a new issue with all the required information provided, including a [minimal, reproducible sample]. Make sure to diligently fill out the issue template.
Thanks for your contribution.
[minimal, reproducible sample]: https://stackoverflow.com/help/minimal-reproducible-example

This issue has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar problem, please file a new issue. Make sure to follow the template and provide all the information necessary to reproduce the issue.