-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[web] adding a test for e2e web testing. #2554
Conversation
de4c57f
to
5a85587
Compare
.cirrus.yml
Outdated
- cd web_installers/packages/web_drivers/ | ||
- pub get | ||
- dart lib/web_driver_installer.dart & | ||
- sleep 20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this more deterministic? Maybe look at the output of web_driver_installer and use that to decide when to call flutter drive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... Why is the previous command run in the background, though?
Wouldn't you be able to remove the sleep
if the &
at the end of dart lib/web_driver_installer.dart
was removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it should always run on the background. The code is installing (downloading over the web and extracting. It takes some time) the chrome driver. It also starts running it on port 4444
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh... maybe splitting the code in "the part that downloads and installs" (being synchronous) and the part that "starts the driver on port 444 in the background" could be split in two separate commands, that way you wouldn't need the sleep (maybe)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I can do is, I can only use web_driver installers for installing. and for launching I can use
chromedriver --port=4444 &
This can remove the need for sleep since it is starts instantly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that works, I think it's more deterministic than having the sleep there (imagine that installing takes 21 seconds for whatever reason)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ditman I sent you a PR to fix the webdriver command (flutter/web_installers#4)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nturgut just approved it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
app.main(); | ||
|
||
// Trigger a frame. | ||
await tester.pumpAndSettle(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to await expectLater
below instead of calling this?
I worry about littering tests with tester.pumpAndSettle()
, it seems kind of mysterious whether it's needed or not. In any case, I hope that WidgetTester
synchronization will help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
packages/e2e/CHANGELOG.md
Outdated
@@ -1,3 +1,7 @@ | |||
## 0.2.4+4 | |||
|
|||
* Add timeout to invokeMethod call, for tests do not use MethodChannel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Add timeout to invokeMethod call, for tests do not use MethodChannel. | |
* Fixed a hang that occurred on platforms that don't have a `MethodChannel` listener registered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
The chrome version flutter/plugins CI is using is 78. It was not supported in web_installers. I'll update web_installers and continue on the PR. Thanks for the comments. |
bfd8fb7
to
b8d4e22
Compare
…unning . use background_task to run it. use ENV for directory change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this approach will solve the build issue: collinjackson@7fa057d
@@ -0,0 +1,15 @@ | |||
@TestOn('browser') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a test file, you can remove this
import 'dart:io'; | ||
|
||
import 'package:flutter_driver/flutter_driver.dart'; | ||
import 'package:test/test.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a test file, you can remove this
That's a very nice trick @collinjackson |
ee48546
to
494c8d4
Compare
it didn't work unfortunately: https://cirrus-ci.com/task/6188264717549568 It still wants to compile each file and in case of example_e2e_web_test it is not able to. |
Actually it looks like the conditional import is working and the tests are running successfully on mobile. Your commit differs from my suggestion in that you left example_e2e_web_test.dart in place and that's where things are not working. You should delete it. See https://github.com/flutter/plugin_tools/blob/master/lib/src/drive_examples_command.dart#L52 |
May be I am missing something, but as far as I know if the file <test_name>_test.dart, does not exist we won't be able to use the following smoke test command: flutter drive -v --target=test_driver/example_e2e_web.dart -d web-server --release --browser-name=chrome My suggestions are: Let me know if these makes sense. |
This reverts commit 7cf24d6.
My current proposal is to remove example_e2e_web_test.dart and you'd have two options for running the web integration test:
As for moving the web tests to their own folder -- I am not sure about using folder names to determine the platform of tests. It's one thing for us to do this for our own CI, but plugin developers are going to mimic whatever we're doing here, and an approach based on directory structure baked into all our tools seems less flexible to me than a code solution. |
The code runs the tests only if there are under example folder, so if I add a new folder such as web_example or web_smoke it should be ok. The reason I don't want to remove example_e2e_web_test.dart is soon it would be very different than example_e2e_test.dart by content due to screenshots taken by the driver for web. In the original PR we added more functionality to the driver test: flutter/flutter#49833 For now I can go with the options you suggested but for the future we still need to reconsider differences between driver files. |
@@ -1,3 +1,7 @@ | |||
## 0.2.4+4 | |||
|
|||
* Fixed a hang that occurred on platforms that don't have a `MethodChannel` listener registered.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Fixed a hang that occurred on platforms that don't have a `MethodChannel` listener registered.. | |
* Fixed a hang that occurred on platforms that don't have a `MethodChannel` listener registered. |
* adding a test for e2e web testing. * chaning the changelog. updating pubspec.yaml version. fixing analyze * merging the changelog * addressing reviewer comments * fix format. addressing reviewer comments * try to run chromedriver on the backend * chrome driver is was running as the main task, preventing test from running . use background_task to run it. use ENV for directory change * change in scripts. remove list from backfround task. change argument of driver * removed background task. it wasn't using the same path * run web tests only on browser * add test on to the web driver test as well. drive-examples are still failing * fix the imports * trying reviever suggestion for drive_example compile errors * test _ imports * Revert "test _ imports" This reverts commit 7cf24d6. * removing the web_test driver file upon reviewers suggestion * format fix
* adding a test for e2e web testing. * chaning the changelog. updating pubspec.yaml version. fixing analyze * merging the changelog * addressing reviewer comments * fix format. addressing reviewer comments * try to run chromedriver on the backend * chrome driver is was running as the main task, preventing test from running . use background_task to run it. use ENV for directory change * change in scripts. remove list from backfround task. change argument of driver * removed background task. it wasn't using the same path * run web tests only on browser * add test on to the web driver test as well. drive-examples are still failing * fix the imports * trying reviever suggestion for drive_example compile errors * test _ imports * Revert "test _ imports" This reverts commit 7cf24d6. * removing the web_test driver file upon reviewers suggestion * format fix
Description
(1) Adding a timeout to e2e so any test that doesn't use the MethodChannel won't timeout.
(2) Adding a test for web use case, altering the existing tests.
(3) Altering the previous code not to use dart:io on web
(4) Changing the documentation for future users.
(5) Adding the test to CI
Related Issues
Fixes: flutter/flutter#50212
Fixes: flutter/flutter#50654
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?