dev
dart 122 lines 3.94 KB
Raw
1 import 'package:cake_wallet/wallet_types.g.dart';
2 import 'package:cw_core/wallet_type.dart';
3 import 'package:flutter/foundation.dart';
4 import 'package:flutter/material.dart';
5 import 'package:flutter_test/flutter_test.dart';
6 import 'package:integration_test/integration_test.dart';
7
8 import '../components/common_test_constants.dart';
9 import '../components/common_test_flows.dart';
10 import '../robots/auth_page_robot.dart';
11 import '../robots/dashboard_page_robot.dart';
12 import '../robots/security_and_backup_page_robot.dart';
13 import '../robots/wallet_keys_robot.dart';
14
15 void main() {
16 IntegrationTestWidgetsFlutterBinding.ensureInitialized();
17
18 AuthPageRobot authPageRobot;
19 CommonTestFlows commonTestFlows;
20 DashboardPageRobot dashboardPageRobot;
21 WalletKeysAndSeedPageRobot walletKeysAndSeedPageRobot;
22 SecurityAndBackupPageRobot securityAndBackupPageRobot;
23
24 testWidgets(
25 'Confirm if the seeds display properly',
26 (tester) async {
27 // Store the original FlutterError.onError handler
28 final originalOnError = FlutterError.onError;
29
30 FlutterError.onError = (FlutterErrorDetails details) {
31 debugPrint('FlutterError caught: ${details.exception}');
32 };
33
34 try {
35 authPageRobot = AuthPageRobot(tester);
36 commonTestFlows = CommonTestFlows(tester);
37 dashboardPageRobot = DashboardPageRobot(tester);
38 walletKeysAndSeedPageRobot = WalletKeysAndSeedPageRobot(tester);
39 securityAndBackupPageRobot = SecurityAndBackupPageRobot(tester);
40
41 await commonTestFlows.startAppFlow(
42 ValueKey('confirm_creds_display_correctly_flow_app_key'),
43 );
44
45 await commonTestFlows.welcomePageToCreateNewWalletFlow(
46 WalletType.solana,
47 CommonTestConstants.pin,
48 );
49
50 await dashboardPageRobot.confirmWalletTypeIsDisplayedCorrectly(WalletType.solana);
51
52 await _confirmSeedsFlowForWalletType(
53 WalletType.solana,
54 authPageRobot,
55 dashboardPageRobot,
56 securityAndBackupPageRobot,
57 walletKeysAndSeedPageRobot,
58 tester,
59 );
60
61 // Do the same for other available wallet types
62 for (var walletType in availableWalletTypes) {
63 if (walletType == WalletType.solana) {
64 continue;
65 }
66
67 await dashboardPageRobot.navigateToWalletsListPage(isDrawer: true);
68
69 await commonTestFlows.createNewWalletFromWalletMenu(walletType);
70
71 await dashboardPageRobot.confirmWalletTypeIsDisplayedCorrectly(walletType);
72
73 await _confirmSeedsFlowForWalletType(
74 walletType,
75 authPageRobot,
76 dashboardPageRobot,
77 securityAndBackupPageRobot,
78 walletKeysAndSeedPageRobot,
79 tester,
80 );
81 }
82
83 await Future.delayed(Duration(seconds: 15));
84 } finally {
85 FlutterError.onError = originalOnError;
86 }
87 },
88 );
89 }
90
91 Future<void> _confirmSeedsFlowForWalletType(
92 WalletType walletType,
93 AuthPageRobot authPageRobot,
94 DashboardPageRobot dashboardPageRobot,
95 SecurityAndBackupPageRobot securityAndBackupPageRobot,
96 WalletKeysAndSeedPageRobot walletKeysAndSeedPageRobot,
97 WidgetTester tester,
98 ) async {
99 await dashboardPageRobot.openDrawerMenu();
100 await dashboardPageRobot.dashboardMenuWidgetRobot.navigateToSecurityAndBackupPage();
101
102 await securityAndBackupPageRobot.navigateToShowKeysPage();
103
104 final onAuthPage = authPageRobot.onAuthPage();
105 if (onAuthPage) {
106 await authPageRobot.enterPinCode(CommonTestConstants.pin);
107 }
108
109 final onAuthPageDesktop = authPageRobot.onAuthPageDesktop();
110 if (onAuthPageDesktop) {
111 await authPageRobot.enterPassword(CommonTestConstants.pin.join(""));
112 }
113 await tester.pumpAndSettle();
114
115 await walletKeysAndSeedPageRobot.isWalletKeysAndSeedPage();
116 walletKeysAndSeedPageRobot.hasTitle();
117 walletKeysAndSeedPageRobot.hasShareWarning();
118
119 await walletKeysAndSeedPageRobot.confirmWalletCredentials(walletType);
120
121 await walletKeysAndSeedPageRobot.backToDashboard();
122 }