Skip to content

Commit

Permalink
test(cat-voices): Adding account tests (#1491)
Browse files Browse the repository at this point in the history
  • Loading branch information
emiride authored Jan 13, 2025
1 parent a40efb5 commit 53a4ddb
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 0 deletions.
2 changes: 2 additions & 0 deletions catalyst_voices/apps/voices/integration_test/all_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -14,4 +15,5 @@ void main() async {

app_test.main();
onboarding_test.main();
account_test.main();
}
Original file line number Diff line number Diff line change
@@ -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<void> 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<void> accountDropdownLooksAsExpected(
PatrolTester $,
) async {
expect($(popUpMenuAccountHeader), findsOneWidget);
expect($(popUpMenuMyAccount), findsOneWidget);
expect($(popUpMenuProfileAndKeychain), findsOneWidget);
expect($(popUpMenuLock), findsOneWidget);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Original file line number Diff line number Diff line change
@@ -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($);
},
);
},
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class SessionStateHeader extends StatelessWidget {
avatarLetter: account?.acronym ?? '',
onLockAccountTap: () => _onLockAccount(context),
onProfileKeychainTap: () => _onSeeProfile(context),
key: const Key('AccountPopupButton'),
),
};
},
Expand Down

0 comments on commit 53a4ddb

Please sign in to comment.