Skip to content

Commit

Permalink
test(cat-voices): Adding account tests
Browse files Browse the repository at this point in the history
  • Loading branch information
emiride committed Jan 8, 2025
1 parent e275a81 commit 69d92c5
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 7 deletions.
44 changes: 44 additions & 0 deletions catalyst_voices/apps/voices/integration_test/account_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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($);
},
);
},
);
}
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 'account_test.dart' as account_test;
import 'app_test.dart' as app_test;
import 'onboarding_test.dart' as onboarding_test;

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

app_test.main();
onboarding_test.main();
account_test.main();
}
4 changes: 4 additions & 0 deletions catalyst_voices/apps/voices/integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ void main() async {
);

patrolWidgetTest(
tags: 'https://github.com/input-output-hk/catalyst-voices/issues/1473',
skip: true,
'guest - chooser - clicking on icons works correctly',
(PatrolTester $) async {
await $.pumpWidgetAndSettle(App(routerConfig: router));
Expand All @@ -60,6 +62,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
@@ -0,0 +1,19 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:patrol_finders/patrol_finders.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> 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 @@ -5,4 +5,5 @@ import 'package:flutter/material.dart';
class AppBarPage {
static const spacesDrawerButton = Key('DrawerButton');
static const getStartedBtn = Key('GetStartedButton');
static const accountPopupBtn = Key('AccountPopupButton');
}
18 changes: 11 additions & 7 deletions catalyst_voices/apps/voices/lib/pages/account/account_popup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import 'package:catalyst_voices_shared/catalyst_voices_shared.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

const _padding = 12.0;

class AccountPopup extends StatelessWidget {
final String avatarLetter;
final VoidCallback? onProfileKeychainTap;
Expand Down Expand Up @@ -38,6 +40,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 @@ -52,6 +55,7 @@ class AccountPopup extends StatelessWidget {
),
),
const PopupMenuItem(
key: Key('PopUpMenuMyAccount'),
height: 48,
padding: EdgeInsets.zero,
enabled: false,
Expand All @@ -61,6 +65,7 @@ class AccountPopup extends StatelessWidget {
PopupMenuItem(
padding: EdgeInsets.zero,
value: _MenuItemValue.profileAndKeychain,
key: const Key('PopUpMenuProfileAndKeychain'),
child: _MenuItem(
'Profile & Keychain',
VoicesAssets.icons.userCircle,
Expand All @@ -69,6 +74,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 Expand Up @@ -221,6 +227,11 @@ class _MenuItem extends StatelessWidget {
}
}

enum _MenuItemValue {
profileAndKeychain,
lock,
}

class _Section extends StatelessWidget {
final String text;

Expand Down Expand Up @@ -251,10 +262,3 @@ class _Section extends StatelessWidget {
);
}
}

const _padding = 12.0;

enum _MenuItemValue {
profileAndKeychain,
lock,
}
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 69d92c5

Please sign in to comment.