From 1e1de78daa7dc029e78f44ed7c18046a18f85ab2 Mon Sep 17 00:00:00 2001 From: Janusz Janus Date: Tue, 31 Dec 2024 10:00:53 +0100 Subject: [PATCH] test(cat-voices): Add running all test files (#1449) --- .../voices/integration_test/all_test.dart | 17 ++ .../voices/integration_test/app_test.dart | 172 +++++++++--------- .../integration_test/onboarding_test.dart | 45 ++--- 3 files changed, 127 insertions(+), 107 deletions(-) create mode 100644 catalyst_voices/apps/voices/integration_test/all_test.dart diff --git a/catalyst_voices/apps/voices/integration_test/all_test.dart b/catalyst_voices/apps/voices/integration_test/all_test.dart new file mode 100644 index 00000000000..550f5872a25 --- /dev/null +++ b/catalyst_voices/apps/voices/integration_test/all_test.dart @@ -0,0 +1,17 @@ +import 'package:catalyst_voices/configs/bootstrap.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; + +import 'app_test.dart' as app_test; +import 'onboarding_test.dart' as onboarding_test; + +void main() async { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + setUpAll(() async { + await bootstrap(router: buildAppRouter()); + }); + + app_test.main(); + onboarding_test.main(); +} diff --git a/catalyst_voices/apps/voices/integration_test/app_test.dart b/catalyst_voices/apps/voices/integration_test/app_test.dart index ac46b881135..e2d34b294dd 100644 --- a/catalyst_voices/apps/voices/integration_test/app_test.dart +++ b/catalyst_voices/apps/voices/integration_test/app_test.dart @@ -4,7 +4,6 @@ import 'package:catalyst_voices/routes/routes.dart'; import 'package:catalyst_voices_models/catalyst_voices_models.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:go_router/go_router.dart'; -import 'package:integration_test/integration_test.dart'; import 'package:patrol_finders/patrol_finders.dart'; import 'pageobject/app_bar_page.dart'; @@ -13,12 +12,10 @@ import 'pageobject/spaces_drawer_page.dart'; import 'utils/selector_utils.dart'; void main() async { - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); late final GoRouter router; setUpAll(() async { router = buildAppRouter(); - await bootstrap(router: router); }); setUp(() async { @@ -30,96 +27,101 @@ void main() async { await restartDependencies(); }); - patrolWidgetTest( - 'Spaces drawer - visitor - no drawer button', - (PatrolTester $) async { - await $.pumpWidgetAndSettle(App(routerConfig: router)); - await $(OverallSpacesPage.visitorShortcutBtn) - .tap(settleTimeout: const Duration(seconds: 10)); - expect($(AppBarPage.spacesDrawerButton).exists, false); - }, - ); + group( + 'Spaces drawer -', + () { + patrolWidgetTest( + 'visitor - no drawer button', + (PatrolTester $) async { + await $.pumpWidgetAndSettle(App(routerConfig: router)); + await $(OverallSpacesPage.visitorShortcutBtn) + .tap(settleTimeout: const Duration(seconds: 10)); + expect($(AppBarPage.spacesDrawerButton).exists, false); + }, + ); - patrolWidgetTest( - 'Spaces drawer - guest - chooser - clicking on icons works correctly', - (PatrolTester $) async { - await $.pumpWidgetAndSettle(App(routerConfig: router)); - await $(OverallSpacesPage.guestShortcutBtn) - .tap(settleTimeout: const Duration(seconds: 10)); - await $(AppBarPage.spacesDrawerButton).waitUntilVisible().tap(); - SpacesDrawerPage.commonElementsLookAsExpected($); + patrolWidgetTest( + 'guest - chooser - clicking on icons works correctly', + (PatrolTester $) async { + await $.pumpWidgetAndSettle(App(routerConfig: router)); + await $(OverallSpacesPage.guestShortcutBtn) + .tap(settleTimeout: const Duration(seconds: 10)); + await $(AppBarPage.spacesDrawerButton).waitUntilVisible().tap(); + SpacesDrawerPage.commonElementsLookAsExpected($); - // iterate thru spaces by clicking on spaces icons directly - for (final space in Space.values) { - await $(SpacesDrawerPage.chooserItem(space)).tap(); - await SpacesDrawerPage.guestLooksAsExpected($, space); - } - SelectorUtils.isDisabled($, $(SpacesDrawerPage.chooserNextBtn)); - }, - ); + // iterate thru spaces by clicking on spaces icons directly + for (final space in Space.values) { + await $(SpacesDrawerPage.chooserItem(space)).tap(); + await SpacesDrawerPage.guestLooksAsExpected($, space); + } + SelectorUtils.isDisabled($, $(SpacesDrawerPage.chooserNextBtn)); + }, + ); - patrolWidgetTest( - 'Spaces drawer - guest - chooser - next,previous buttons work correctly', - (PatrolTester $) async { - await $.pumpWidgetAndSettle(App(routerConfig: router)); - await $(OverallSpacesPage.guestShortcutBtn) - .tap(settleTimeout: const Duration(seconds: 10)); - await $(AppBarPage.spacesDrawerButton).waitUntilVisible().tap(); + patrolWidgetTest( + 'guest - chooser - next,previous buttons work correctly', + (PatrolTester $) async { + await $.pumpWidgetAndSettle(App(routerConfig: router)); + await $(OverallSpacesPage.guestShortcutBtn) + .tap(settleTimeout: const Duration(seconds: 10)); + await $(AppBarPage.spacesDrawerButton).waitUntilVisible().tap(); - // iterate thru spaces by clicking next - for (final space in Space.values) { - await SpacesDrawerPage.guestLooksAsExpected($, space); - await $(SpacesDrawerPage.chooserNextBtn).tap(); - SelectorUtils.isEnabled($, $(SpacesDrawerPage.chooserPrevBtn)); - } - SelectorUtils.isDisabled($, $(SpacesDrawerPage.chooserNextBtn)); + // iterate thru spaces by clicking next + for (final space in Space.values) { + await SpacesDrawerPage.guestLooksAsExpected($, space); + await $(SpacesDrawerPage.chooserNextBtn).tap(); + SelectorUtils.isEnabled($, $(SpacesDrawerPage.chooserPrevBtn)); + } + SelectorUtils.isDisabled($, $(SpacesDrawerPage.chooserNextBtn)); - // iterate thru spaces by clicking previous - for (final space in Space.values.reversed) { - await SpacesDrawerPage.guestLooksAsExpected($, space); - await $(SpacesDrawerPage.chooserPrevBtn).tap(); - SelectorUtils.isEnabled($, $(SpacesDrawerPage.chooserNextBtn)); - } - SelectorUtils.isDisabled($, $(SpacesDrawerPage.chooserPrevBtn)); - }, - ); + // iterate thru spaces by clicking previous + for (final space in Space.values.reversed) { + await SpacesDrawerPage.guestLooksAsExpected($, space); + await $(SpacesDrawerPage.chooserPrevBtn).tap(); + SelectorUtils.isEnabled($, $(SpacesDrawerPage.chooserNextBtn)); + } + SelectorUtils.isDisabled($, $(SpacesDrawerPage.chooserPrevBtn)); + }, + ); - patrolWidgetTest( - 'Spaces drawer - user - chooser - clicking on icons works correctly', - (PatrolTester $) async { - await $.pumpWidgetAndSettle(App(routerConfig: router)); - await $(OverallSpacesPage.userShortcutBtn) - .tap(settleTimeout: const Duration(seconds: 10)); - await $(AppBarPage.spacesDrawerButton).waitUntilVisible().tap(); - SpacesDrawerPage.commonElementsLookAsExpected($); - for (final space in Space.values) { - await $(SpacesDrawerPage.chooserItem(space)).tap(); - await SpacesDrawerPage.userLooksAsExpected($, space); - } - }, - ); + patrolWidgetTest( + 'user - chooser - clicking on icons works correctly', + (PatrolTester $) async { + await $.pumpWidgetAndSettle(App(routerConfig: router)); + await $(OverallSpacesPage.userShortcutBtn) + .tap(settleTimeout: const Duration(seconds: 10)); + await $(AppBarPage.spacesDrawerButton).waitUntilVisible().tap(); + SpacesDrawerPage.commonElementsLookAsExpected($); + for (final space in Space.values) { + await $(SpacesDrawerPage.chooserItem(space)).tap(); + await SpacesDrawerPage.userLooksAsExpected($, space); + } + }, + ); - patrolWidgetTest( - 'Spaces drawer - guest - chooser - all spaces button works', - (PatrolTester $) async { - await $.pumpWidgetAndSettle(App(routerConfig: router)); - await $(OverallSpacesPage.guestShortcutBtn) - .tap(settleTimeout: const Duration(seconds: 10)); - await $(AppBarPage.spacesDrawerButton).waitUntilVisible().tap(); - await $(SpacesDrawerPage.allSpacesBtn).tap(); - expect($(OverallSpacesPage.spacesListView), findsOneWidget); - }, - ); + patrolWidgetTest( + 'guest - chooser - all spaces button works', + (PatrolTester $) async { + await $.pumpWidgetAndSettle(App(routerConfig: router)); + await $(OverallSpacesPage.guestShortcutBtn) + .tap(settleTimeout: const Duration(seconds: 10)); + await $(AppBarPage.spacesDrawerButton).waitUntilVisible().tap(); + await $(SpacesDrawerPage.allSpacesBtn).tap(); + expect($(OverallSpacesPage.spacesListView), findsOneWidget); + }, + ); - patrolWidgetTest( - 'Spaces drawer - user - chooser - all spaces button works', - (PatrolTester $) async { - await $.pumpWidgetAndSettle(App(routerConfig: router)); - await $(OverallSpacesPage.userShortcutBtn) - .tap(settleTimeout: const Duration(seconds: 10)); - await $(AppBarPage.spacesDrawerButton).waitUntilVisible().tap(); - await $(SpacesDrawerPage.allSpacesBtn).tap(); - expect($(OverallSpacesPage.spacesListView), findsOneWidget); + patrolWidgetTest( + 'user - chooser - all spaces button works', + (PatrolTester $) async { + await $.pumpWidgetAndSettle(App(routerConfig: router)); + await $(OverallSpacesPage.userShortcutBtn) + .tap(settleTimeout: const Duration(seconds: 10)); + await $(AppBarPage.spacesDrawerButton).waitUntilVisible().tap(); + await $(SpacesDrawerPage.allSpacesBtn).tap(); + expect($(OverallSpacesPage.spacesListView), findsOneWidget); + }, + ); }, ); } diff --git a/catalyst_voices/apps/voices/integration_test/onboarding_test.dart b/catalyst_voices/apps/voices/integration_test/onboarding_test.dart index cacc46c9da0..af666e9739c 100644 --- a/catalyst_voices/apps/voices/integration_test/onboarding_test.dart +++ b/catalyst_voices/apps/voices/integration_test/onboarding_test.dart @@ -4,19 +4,17 @@ import 'package:catalyst_voices/routes/routes.dart'; import 'package:catalyst_voices_models/catalyst_voices_models.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:go_router/go_router.dart'; -import 'package:integration_test/integration_test.dart'; import 'package:patrol_finders/patrol_finders.dart'; import 'pageobject/app_bar_page.dart'; import 'pageobject/onboarding_page.dart'; +import 'pageobject/overall_spaces_page.dart'; void main() async { - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); late final GoRouter router; setUpAll(() async { router = buildAppRouter(); - await bootstrap(router: router); }); setUp(() async { @@ -28,24 +26,27 @@ void main() async { await restartDependencies(); }); - patrolWidgetTest( - 'Onboarding - visitor - get started button works', - (PatrolTester $) async { - await $.pumpWidgetAndSettle(App(routerConfig: router)); - await $(AppBarPage.getStartedBtn) - .tap(settleTimeout: const Duration(seconds: 10)); - expect($(OnboardingPage.registrationInfoPanel), findsOneWidget); - expect($(OnboardingPage.registrationDetailsPanel), findsOneWidget); - }, - ); + group('Onboarding -', () { + patrolWidgetTest( + 'visitor - get started button works', + (PatrolTester $) async { + await $.pumpWidgetAndSettle(App(routerConfig: router)); + await $(OverallSpacesPage.visitorShortcutBtn) + .tap(settleTimeout: const Duration(seconds: 10)); + await $(AppBarPage.getStartedBtn).tap(); + expect($(OnboardingPage.registrationInfoPanel), findsOneWidget); + expect($(OnboardingPage.registrationDetailsPanel), findsOneWidget); + }, + ); - patrolWidgetTest( - 'Onboarding - visitor - get started screen looks as expected', - (PatrolTester $) async { - await $.pumpWidgetAndSettle(App(routerConfig: router)); - await $(AppBarPage.getStartedBtn) - .tap(settleTimeout: const Duration(seconds: 10)); - await OnboardingPage.getStartedScreenLooksAsExpected($); - }, - ); + patrolWidgetTest( + 'visitor - get started screen looks as expected', + (PatrolTester $) async { + await $.pumpWidgetAndSettle(App(routerConfig: router)); + await $(AppBarPage.getStartedBtn) + .tap(settleTimeout: const Duration(seconds: 10)); + await OnboardingPage.getStartedScreenLooksAsExpected($); + }, + ); + }); }