diff --git a/catalyst_voices/integration_test/Earthfile b/catalyst_voices/integration_test/Earthfile new file mode 100644 index 00000000000..295b34c3e23 --- /dev/null +++ b/catalyst_voices/integration_test/Earthfile @@ -0,0 +1,48 @@ +VERSION 0.8 + +IMPORT ../ AS catalyst-voices + +integration-test-web: + FROM catalyst-voices+build-web + ARG TARGETARCH + ARG browser + LET driver_port = 4444 + + IF [ $browser = "chrome" ] + LET driver = "chromedriver" + END + + IF [ $browser = "firefox" ] + LET driver = "geckodriver" + END + # Commenting out Edge tests as they are failing due to: + # https://github.com/flutter/flutter/issues/76213 + # https://github.com/flutter/flutter/issues/142021 + # IF [ $browser = "edge" && $TARGETARCH = "amd64" ]] + # LET driver = "msedgedriver" + # END + RUN ($driver --port=$driver_port > $driver.log &) && \ + sleep 5 && \ + flutter drive --driver=test_driver/integration_tests.dart \ + --target=integration_test/app_test.dart \ + -d web-server --browser-name=$browser --driver-port=$driver_port \ + # https://github.com/flutter/flutter/issues/154727 + --web-browser-flag=--disable-web-security \ + --web-browser-flag=--disable-gpu \ + --web-browser-flag=--headless=old \ + --web-browser-flag=--disable-search-engine-choice-screen \ + --profile || echo fail > fail + WAIT + SAVE ARTIFACT $driver.log AS LOCAL $driver.log + END + IF [ -f fail ] + RUN --no-cache echo ""$browser" integration test failed" && \ + echo "Printing "$driver" logs..." && \ + cat $driver.log && \ + exit 1 + END + +test-web-all: + BUILD +integration-test-web \ + --browser=chrome \ + --browser=firefox diff --git a/catalyst_voices/integration_test/app_test.dart b/catalyst_voices/integration_test/app_test.dart index c2774be7e4e..9c9bad35d45 100644 --- a/catalyst_voices/integration_test/app_test.dart +++ b/catalyst_voices/integration_test/app_test.dart @@ -6,18 +6,15 @@ import 'package:integration_test/integration_test.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - group('end-to-end test', () { + group('End to end tests', () { testWidgets('run app', (tester) async { final args = await bootstrap(); await tester.pumpWidget(App(routerConfig: args.routerConfig)); // let the application load await tester.pump(const Duration(seconds: 5)); - // pump and settle every 100ms to simulate almost production-like FPS await tester.pumpAndSettle(const Duration(milliseconds: 100)); - - // wait 10s until the test is finished - await Future.delayed(const Duration(seconds: 10)); + expect(find.text('Coming'), findsOneWidget); }); }); } diff --git a/catalyst_voices/integration_test/blueprint.cue b/catalyst_voices/integration_test/blueprint.cue new file mode 100644 index 00000000000..7ae3331f1be --- /dev/null +++ b/catalyst_voices/integration_test/blueprint.cue @@ -0,0 +1,2 @@ +version: "1.0.0" +project: name: "voices-integration-tests" diff --git a/catalyst_voices/integration_test/main.dart b/catalyst_voices/integration_test/main.dart deleted file mode 100644 index 680a863c6ac..00000000000 --- a/catalyst_voices/integration_test/main.dart +++ /dev/null @@ -1,5 +0,0 @@ -import './scenarios/login_scenario.dart' as login_scenario; - -void main() { - login_scenario.main(); -} diff --git a/catalyst_voices/integration_test/scenarios/login_scenario.dart b/catalyst_voices/integration_test/scenarios/login_scenario.dart deleted file mode 100644 index 12c88e0dd42..00000000000 --- a/catalyst_voices/integration_test/scenarios/login_scenario.dart +++ /dev/null @@ -1,36 +0,0 @@ -import 'package:catalyst_voices/configs/main_dev.dart' as app; -import 'package:flutter_test/flutter_test.dart'; -import 'package:integration_test/integration_test.dart'; - -import 'robots/login_robot.dart'; - -void main() { - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - LoginRobot loginRobot; - - group('Login', () { - testWidgets('shows error message when login information is missing', - (tester) async { - loginRobot = await _configure(tester); - - await loginRobot.enterEmail('Not Valid'); - await loginRobot.tapLoginButton(); - await loginRobot.checkInvalidCredentialsMessageIsShown(); - }); - - testWidgets('authenticates a user with an email and password', - (tester) async { - loginRobot = await _configure(tester); - - await loginRobot.enterEmail('mail@example.com'); - await loginRobot.enterPassword('MyPass123'); - await loginRobot.tapLoginButton(); - }); - }); -} - -Future _configure(WidgetTester tester) async { - app.main(); - await tester.pumpAndSettle(); - return LoginRobot(widgetTester: tester); -} diff --git a/catalyst_voices/integration_test/scenarios/robots/login_robot.dart b/catalyst_voices/integration_test/scenarios/robots/login_robot.dart deleted file mode 100644 index 4adc1488064..00000000000 --- a/catalyst_voices/integration_test/scenarios/robots/login_robot.dart +++ /dev/null @@ -1,46 +0,0 @@ -import 'package:catalyst_voices/pages/login/login.dart'; -import 'package:catalyst_voices/pages/login/login_email_text_filed.dart'; -import 'package:catalyst_voices/pages/login/login_password_text_field.dart'; -import 'package:flutter_test/flutter_test.dart'; - -final class LoginRobot { - final WidgetTester widgetTester; - - const LoginRobot({ - required this.widgetTester, - }); - - Future checkInvalidCredentialsMessageIsShown() async { - final loginErrorSnackbar = find.byKey(LoginForm.loginErrorSnackbarKey); - expect(loginErrorSnackbar, findsOneWidget); - await widgetTester.pump(); - } - - Future enterEmail(String email) async { - final emailTextField = find.byKey(LoginEmailTextFiled.emailInputKey); - expect(emailTextField, findsOneWidget); - await widgetTester.enterText(emailTextField, email); - await widgetTester.pump(); - } - - Future enterPassword(String password) async { - final passwordTextField = find.byKey( - LoginPasswordTextField.passwordInputKey, - ); - expect(passwordTextField, findsOneWidget); - await widgetTester.enterText(passwordTextField, password); - await widgetTester.pump(); - } - - Future tapLoginButton() async { - final loginButton = find.byKey(LoginInButton.loginButtonKey); - expect(loginButton, findsOneWidget); - await widgetTester.tap(loginButton); - await widgetTester.pump(); - } - - void verifyLoginScreenIsShown() { - final loginScreen = find.byKey(LoginForm.loginFormKey); - expect(loginScreen, findsOneWidget); - } -} diff --git a/catalyst_voices/test_driver/Earthfile b/catalyst_voices/test_driver/Earthfile deleted file mode 100644 index 092d407d314..00000000000 --- a/catalyst_voices/test_driver/Earthfile +++ /dev/null @@ -1,43 +0,0 @@ -# TODO(minikin): Temporary disabled until we have useful integration tests. - -# IMPORT ../ AS catalyst-voices - -# integration-test-web: -# FROM catalyst-voices+build-web -# ARG TARGETARCH -# ARG browser -# LET driver_port = 4444 - -# IF [ $browser = "chrome" ] -# LET driver = "chromedriver" -# END - -# IF [ $browser = "firefox" ] -# LET driver = "geckodriver" -# END -# # Commenting out Edge tests as they are failing due to: -# # https://github.com/flutter/flutter/issues/76213 -# # https://github.com/flutter/flutter/issues/142021 -# #IF [ $browser = "edge" && $TARGETARCH = "amd64" ]] -# # LET driver = "msedgedriver" -# #END -# RUN ($driver --port=$driver_port > $driver.log &) && \ -# flutter drive --driver=test_driver/integration_tests.dart \ -# --target=integration_test/main.dart \ -# --flavor development -d web-server --profile \ -# --browser-name=$browser --driver-port=$driver_port || echo fail > fail -# # Using WAIT instead of TRY because TRY/CATCH/FINALLY does not (currently) support expanding args for SAVE ARTIFACT paths -# WAIT -# SAVE ARTIFACT $driver.log AS LOCAL $driver.log -# END -# IF [ -f fail ] -# RUN echo ""$browser" integration test failed" && \ -# echo "Printing "$driver" logs..." && \ -# cat $driver.log && \ -# exit 1 -# END - -# test-web-all: -# BUILD +integration-test-web \ -# --browser=chrome \ -# --browser=firefox