From 884afd91f5a9fc7cc9a063e6101c7b8c5469e38b Mon Sep 17 00:00:00 2001 From: Feodor Fitsner Date: Wed, 22 Oct 2025 14:20:31 -0700 Subject: [PATCH] Add integration test and update dependencies Introduced an integration test in app_test.dart for end-to-end testing. Updated pubspec.yaml to switch serious_python to the main branch and added integration_test and flet_integration_test to dev_dependencies. --- .../integration_test/app_test.dart | 55 +++++++++++++++++++ {{cookiecutter.out_dir}}/pubspec.yaml | 9 ++- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 {{cookiecutter.out_dir}}/integration_test/app_test.dart diff --git a/{{cookiecutter.out_dir}}/integration_test/app_test.dart b/{{cookiecutter.out_dir}}/integration_test/app_test.dart new file mode 100644 index 0000000..cfdf7aa --- /dev/null +++ b/{{cookiecutter.out_dir}}/integration_test/app_test.dart @@ -0,0 +1,55 @@ +import 'package:flet_integration_test/flet_integration_test.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; + +import 'package:{{ cookiecutter.project_name }}/main.dart' as app; + +void main() { + final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + group('end-to-end test', () { + testWidgets('test app', (tester) async { + const testerServerUrl = String.fromEnvironment('FLET_TEST_SERVER_URL'); + late FlutterWidgetTester widgetTester; + + if (testerServerUrl.isNotEmpty) { + debugPrint('Connecting to remote tester at $testerServerUrl'); + widgetTester = await RemoteWidgetTester.connect( + tester: tester, + binding: binding, + serverUri: Uri.parse(testerServerUrl), + ); + } else { + widgetTester = FlutterWidgetTester(tester, binding); + } + + app.tester = widgetTester; + + final args = []; + + const fletTestAppUrl = String.fromEnvironment('FLET_TEST_APP_URL'); + if (fletTestAppUrl.isNotEmpty) { + args.add(fletTestAppUrl); + } + + const fletTestPidFile = String.fromEnvironment('FLET_TEST_PID_FILE_PATH'); + if (fletTestPidFile.isNotEmpty) { + args.add(fletTestPidFile); + } + + const fletTestAssetsDir = String.fromEnvironment('FLET_TEST_ASSETS_DIR'); + if (fletTestAssetsDir.isNotEmpty) { + args.add(fletTestAssetsDir); + } + + app.main(args); + + await Future.delayed(const Duration(milliseconds: 500)); + await widgetTester.pump(duration: const Duration(seconds: 1)); + await widgetTester + .pumpAndSettle(duration: const Duration(milliseconds: 100)); + await widgetTester.waitForTeardown(); + }); + }); +} diff --git a/{{cookiecutter.out_dir}}/pubspec.yaml b/{{cookiecutter.out_dir}}/pubspec.yaml index 3d346fd..236b14d 100644 --- a/{{cookiecutter.out_dir}}/pubspec.yaml +++ b/{{cookiecutter.out_dir}}/pubspec.yaml @@ -32,7 +32,7 @@ dependency_overrides: serious_python: git: url: https://github.com/flet-dev/serious-python.git - ref: android-16k + ref: main path: src/serious_python wakelock_plus: ^1.2.10 @@ -56,6 +56,13 @@ dev_dependencies: flutter_launcher_icons: ^0.14.1 flutter_native_splash: ^2.4.1 flutter_lints: ^2.0.0 + integration_test: + sdk: flutter + flet_integration_test: + git: + url: https://github.com/flet-dev/flet.git + ref: v1-flet-test + path: packages/flet_integration_test flutter: