From 53a4ddbe1065b327b5a0e303f31b07d479aaed1d Mon Sep 17 00:00:00 2001 From: Emir Hodzic Date: Mon, 13 Jan 2025 12:47:40 +0100 Subject: [PATCH] test(cat-voices): Adding account tests (#1491) --- .../voices/integration_test/all_test.dart | 2 + .../pageobject/account_dropdown_page.dart | 45 +++++++++++++++++++ .../pageobject/app_bar_page.dart | 1 + .../integration_test/suites/account_test.dart | 45 +++++++++++++++++++ .../integration_test/suites/app_test.dart | 4 ++ .../lib/pages/account/account_popup.dart | 4 ++ .../app_bar/session/session_state_header.dart | 1 + 7 files changed, 102 insertions(+) create mode 100644 catalyst_voices/apps/voices/integration_test/pageobject/account_dropdown_page.dart create mode 100644 catalyst_voices/apps/voices/integration_test/suites/account_test.dart diff --git a/catalyst_voices/apps/voices/integration_test/all_test.dart b/catalyst_voices/apps/voices/integration_test/all_test.dart index ea42d30f7bc..a87f2cfee63 100644 --- a/catalyst_voices/apps/voices/integration_test/all_test.dart +++ b/catalyst_voices/apps/voices/integration_test/all_test.dart @@ -2,6 +2,7 @@ import 'package:catalyst_voices/configs/bootstrap.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; +import 'suites/account_test.dart' as account_test; import 'suites/app_test.dart' as app_test; import 'suites/onboarding_test.dart' as onboarding_test; @@ -14,4 +15,5 @@ void main() async { app_test.main(); onboarding_test.main(); + account_test.main(); } diff --git a/catalyst_voices/apps/voices/integration_test/pageobject/account_dropdown_page.dart b/catalyst_voices/apps/voices/integration_test/pageobject/account_dropdown_page.dart new file mode 100644 index 00000000000..9cee212d044 --- /dev/null +++ b/catalyst_voices/apps/voices/integration_test/pageobject/account_dropdown_page.dart @@ -0,0 +1,45 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:patrol_finders/patrol_finders.dart'; + +import '../utils/translations_utils.dart'; + +class AccountDropdownPage { + static const popUpMenuAccountHeader = Key('PopUpMenuAccountHeader'); + static const popUpMenuMyAccount = Key('PopUpMenuMyAccount'); + static const popUpMenuProfileAndKeychain = Key('PopUpMenuProfileAndKeychain'); + static const popUpMenuLock = Key('PopUpMenuLockAccount'); + + static Future accountDropdownContainsSpecificData( + PatrolTester $, + ) async { + expect( + $(popUpMenuAccountHeader).$(Expanded).$(Text).text?.isNotEmpty, + true, + reason: 'The wallet name should not be an empty string.', + ); + expect( + $(popUpMenuAccountHeader).$(Expanded).$(Text).at(1).text?.contains('₳'), + true, + reason: 'The account balance should contain the symbol ₳.', + ); + expect( + $(popUpMenuMyAccount).$(Text).text, + T.get('My account'), + ); + expect( + $(popUpMenuProfileAndKeychain).$(Text).text, + T.get('Profile & Keychain'), + ); + expect($(popUpMenuLock).$(Text).text, T.get('Lock account')); + } + + static Future accountDropdownLooksAsExpected( + PatrolTester $, + ) async { + expect($(popUpMenuAccountHeader), findsOneWidget); + expect($(popUpMenuMyAccount), findsOneWidget); + expect($(popUpMenuProfileAndKeychain), findsOneWidget); + expect($(popUpMenuLock), findsOneWidget); + } +} diff --git a/catalyst_voices/apps/voices/integration_test/pageobject/app_bar_page.dart b/catalyst_voices/apps/voices/integration_test/pageobject/app_bar_page.dart index 7c24a975f07..b8c17783f4e 100644 --- a/catalyst_voices/apps/voices/integration_test/pageobject/app_bar_page.dart +++ b/catalyst_voices/apps/voices/integration_test/pageobject/app_bar_page.dart @@ -3,4 +3,5 @@ import 'package:flutter/material.dart'; class AppBarPage { static const spacesDrawerButton = Key('DrawerButton'); static const getStartedBtn = Key('GetStartedButton'); + static const accountPopupBtn = Key('AccountPopupButton'); } diff --git a/catalyst_voices/apps/voices/integration_test/suites/account_test.dart b/catalyst_voices/apps/voices/integration_test/suites/account_test.dart new file mode 100644 index 00000000000..6bae0391148 --- /dev/null +++ b/catalyst_voices/apps/voices/integration_test/suites/account_test.dart @@ -0,0 +1,45 @@ +import 'package:catalyst_voices/app/view/app.dart'; +import 'package:catalyst_voices/configs/bootstrap.dart'; +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:patrol_finders/patrol_finders.dart'; + +import '../pageobject/account_dropdown_page.dart'; +import '../pageobject/app_bar_page.dart'; +import '../pageobject/overall_spaces_page.dart'; + +void main() async { + late final GoRouter router; + + setUpAll(() async { + router = buildAppRouter(); + }); + + setUp(() async { + await registerDependencies(config: const AppConfig()); + router.go(const DiscoveryRoute().location); + }); + + tearDown(() async { + await restartDependencies(); + }); + + group( + 'Account dropdown -', + () { + patrolWidgetTest( + 'user - Account dropdown button opens account dropdown', + (PatrolTester $) async { + await $.pumpWidgetAndSettle(App(routerConfig: router)); + await $(OverallSpacesPage.userShortcutBtn) + .tap(settleTimeout: const Duration(seconds: 10)); + await $(AppBarPage.accountPopupBtn).tap(); + await AccountDropdownPage.accountDropdownLooksAsExpected($); + await AccountDropdownPage.accountDropdownContainsSpecificData($); + }, + ); + }, + ); +} diff --git a/catalyst_voices/apps/voices/integration_test/suites/app_test.dart b/catalyst_voices/apps/voices/integration_test/suites/app_test.dart index 0a790864aa5..11d0f9a6d30 100644 --- a/catalyst_voices/apps/voices/integration_test/suites/app_test.dart +++ b/catalyst_voices/apps/voices/integration_test/suites/app_test.dart @@ -41,6 +41,8 @@ void main() async { patrolWidgetTest( 'guest - chooser - clicking on icons works correctly', + tags: 'https://github.com/input-output-hk/catalyst-voices/issues/1473', + skip: true, (PatrolTester $) async { await $.pumpWidgetAndSettle(App(routerConfig: router)); await $(OverallSpacesPage.guestShortcutBtn) @@ -58,6 +60,8 @@ void main() async { ); patrolWidgetTest( + tags: 'https://github.com/input-output-hk/catalyst-voices/issues/1473', + skip: true, 'guest - chooser - next,previous buttons work correctly', (PatrolTester $) async { await $.pumpWidgetAndSettle(App(routerConfig: router)); diff --git a/catalyst_voices/apps/voices/lib/pages/account/account_popup.dart b/catalyst_voices/apps/voices/lib/pages/account/account_popup.dart index 8288221a1d8..93e9057d5fb 100644 --- a/catalyst_voices/apps/voices/lib/pages/account/account_popup.dart +++ b/catalyst_voices/apps/voices/lib/pages/account/account_popup.dart @@ -38,6 +38,7 @@ class AccountPopup extends StatelessWidget { padding: EdgeInsets.zero, enabled: false, value: null, + key: const Key('PopUpMenuAccountHeader'), child: _Header( accountLetter: avatarLetter, walletName: 'Wallet name', @@ -56,11 +57,13 @@ class AccountPopup extends StatelessWidget { padding: EdgeInsets.zero, enabled: false, value: null, + key: Key('PopUpMenuMyAccount'), child: _Section('My account'), ), PopupMenuItem( padding: EdgeInsets.zero, value: _MenuItemValue.profileAndKeychain, + key: const Key('PopUpMenuProfileAndKeychain'), child: _MenuItem( 'Profile & Keychain', VoicesAssets.icons.userCircle, @@ -69,6 +72,7 @@ class AccountPopup extends StatelessWidget { PopupMenuItem( padding: EdgeInsets.zero, value: _MenuItemValue.lock, + key: const Key('PopUpMenuLockAccount'), child: _MenuItem( 'Lock account', VoicesAssets.icons.lockClosed, diff --git a/catalyst_voices/apps/voices/lib/widgets/app_bar/session/session_state_header.dart b/catalyst_voices/apps/voices/lib/widgets/app_bar/session/session_state_header.dart index 5aec9ba1c4c..5a5e896186f 100644 --- a/catalyst_voices/apps/voices/lib/widgets/app_bar/session/session_state_header.dart +++ b/catalyst_voices/apps/voices/lib/widgets/app_bar/session/session_state_header.dart @@ -23,6 +23,7 @@ class SessionStateHeader extends StatelessWidget { avatarLetter: account?.acronym ?? '', onLockAccountTap: () => _onLockAccount(context), onProfileKeychainTap: () => _onSeeProfile(context), + key: const Key('AccountPopupButton'), ), }; },