diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index 37655f0d5..8285d00ce 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -81,7 +81,11 @@ jobs: uses: actions/checkout@v4 - name: Create .env - run: cp ./.env.example ./.env + run: | + cp ./.env.example ./.env + echo "DELAY=100" >> .env + echo "INIT_E2E_DELAY_IN_SECONDS=10" >> .env + echo "DELETE_TEST_STORAGE=true" >> .env - name: Setup Flutter uses: subosito/flutter-action@v2 @@ -100,11 +104,18 @@ jobs: - name: Flutter Doctor run: flutter doctor - - name: Run unit tests - run: flutter test - + # - name: Run unit tests + # run: flutter test - name: Run E2E tests - run: xvfb-run flutter test integration_test/main.dart -d linux -r github + run: xvfb-run --auto-servernum flutter test integration_test/main.dart -d linux -r github + + - name: Upload images as artifacts + if: always() + uses: actions/upload-artifact@v4 + with: + name: screenshots + path: screenshots/*.png + - name: Binary run: flutter build linux --release diff --git a/integration_test/e2e_auth_preferences_test.dart b/integration_test/e2e_auth_preferences_test.dart index a26aa79ec..92b031a28 100644 --- a/integration_test/e2e_auth_preferences_test.dart +++ b/integration_test/e2e_auth_preferences_test.dart @@ -6,45 +6,30 @@ Future e2eAuthPreferencesTest(WidgetTester tester) async { AppLocalizations.of(navigatorKey.currentContext!)!; await tester.pumpAndSettle(); - /// Assess what is on the screen - walletsExist = isTextOnScreen(_localization.unlockWallet); - bool biometricsActive = isTextOnScreen(_localization.cancel); + /// Create or Import Wallet from xprv + await tapButton(tester, _localization.importWalletLabel); + await tapButton(tester, _localization.importXprvLabel); - if (walletsExist && biometricsActive && Platform.isAndroid) { - await tapButton(tester, _localization.cancel); - } - if (walletsExist) { - /// Login Screen - await enterText(tester, TextFormField, password); - await tapButton(tester, _localization.unlockWallet); - } else { - /// Create or Import Wallet from xprv - await tapButton(tester, _localization.importWalletLabel); - await tapButton(tester, _localization.importXprvLabel); - - /// Wallet Security - await scrollUntilVisible( - tester, widgetByLabel(_localization.walletSecurityConfirmLabel)); - await tapButton(tester, LabeledCheckbox); - await tapButton(tester, _localization.continueLabel); + /// Wallet Security + await scrollUntilVisible( + tester, widgetByLabel(_localization.walletSecurityConfirmLabel)); + await tapButton(tester, LabeledCheckbox); + await tapButton(tester, _localization.continueLabel); - /// Enter node Xprv - await tapButton(tester, Select, index: 0); - await tapButton(tester, _localization.walletTypeNodeLabel); - await enterText(tester, TextField, nodeXprv); - await tapButton(tester, _localization.continueLabel); + /// Enter node Xprv + await tapButton(tester, Select, index: 0); + await tapButton(tester, _localization.walletTypeNodeLabel); + await enterText(tester, TextField, nodeXprv); + await tapButton(tester, _localization.continueLabel); - /// Enter Wallet Name - await enterText(tester, TextField, "Test Node"); - await tapButton(tester, _localization.continueLabel, delay: true); + /// Enter Wallet Name + await enterText(tester, TextField, "Test Node"); + await tapButton(tester, _localization.continueLabel, delay: true); - /// If the wallet database does not exist we need to enter the password. - if (!walletsExist) { - await enterText(tester, TextFormField, password, index: 0); - await enterText(tester, TextFormField, password, index: 1); - await tapButton(tester, _localization.continueLabel); - } - } + /// Enter the password + await enterText(tester, TextFormField, password, index: 0); + await enterText(tester, TextFormField, password, index: 1); + await tapButton(tester, _localization.continueLabel); await tester.pumpAndSettle(); await tapButton(tester, FontAwesomeIcons.gear); diff --git a/integration_test/e2e_export_hd_xprv_test.dart b/integration_test/e2e_export_hd_xprv_test.dart index 1e6c8b1db..e69f02b5d 100644 --- a/integration_test/e2e_export_hd_xprv_test.dart +++ b/integration_test/e2e_export_hd_xprv_test.dart @@ -8,23 +8,6 @@ Future e2eExportHdXprvTest(WidgetTester tester) async { /// Assess what is on the screen walletsExist = isTextOnScreen(_localization.unlockWallet); - bool biometricsActive = isTextOnScreen(_localization.cancel); - - /// Cancel the Biometrics popup for linux - if (walletsExist && biometricsActive && Platform.isAndroid) { - await tapButton(tester, _localization.cancel); - } - if (walletsExist) { - /// Login Screen - await enterText(tester, TextFormField, password); - await tapButton(tester, _localization.unlockWallet); - - /// Dashboard - /// Tap on the first PaddedButton on the screen, which is the identicon - /// and brings up the wallet list. - await tapButton(tester, PaddedButton, index: 0); - await tapButton(tester, FontAwesomeIcons.circlePlus); - } /// Create or Import Wallet await tapButton(tester, _localization.importWalletLabel); @@ -46,11 +29,9 @@ Future e2eExportHdXprvTest(WidgetTester tester) async { await tapButton(tester, _localization.continueLabel); /// If the wallet database does not exist we need to enter the password. - if (!walletsExist) { - await enterText(tester, TextFormField, password, index: 0); - await enterText(tester, TextFormField, password, index: 1); - await tapButton(tester, _localization.continueLabel); - } + await enterText(tester, TextFormField, password, index: 0); + await enterText(tester, TextFormField, password, index: 1); + await tapButton(tester, _localization.continueLabel); await tester.pumpAndSettle(); @@ -83,14 +64,14 @@ Future e2eExportHdXprvTest(WidgetTester tester) async { await tapButton(tester, _localization.generateXprv); - // Scroll Save button into view + /// Scroll Save button into view await scrollUntilVisible( tester, widgetByText(_localization.copyXprvLabel).first, lastScroll: true); await tester.pumpAndSettle(); await tapButton(tester, _localization.copyXprvLabel); - // Data from the copied xprv + /// Data from the copied xprv ClipboardData? data = await Clipboard.getData('text/plain'); /// Dashboard @@ -103,6 +84,9 @@ Future e2eExportHdXprvTest(WidgetTester tester) async { await tapButton(tester, _localization.importWalletLabel); await tapButton(tester, _localization.importXprvLabel); + /// Wait until popover disappears + await Future.delayed(Duration(seconds: 7)); + /// Wallet Security await scrollUntilVisible( tester, widgetByLabel(_localization.walletSecurityConfirmLabel)); diff --git a/integration_test/e2e_export_node_xprv_test.dart b/integration_test/e2e_export_node_xprv_test.dart index 66cc25253..63c89e073 100644 --- a/integration_test/e2e_export_node_xprv_test.dart +++ b/integration_test/e2e_export_node_xprv_test.dart @@ -5,26 +5,6 @@ Future e2eExportXprvTest(WidgetTester tester) async { AppLocalizations _localization = AppLocalizations.of(navigatorKey.currentContext!)!; - /// Assess what is on the screen - walletsExist = isTextOnScreen(_localization.unlockWallet); - bool biometricsActive = isTextOnScreen(_localization.cancel); - - /// Cancel the Biometrics popup for linux - if (walletsExist && biometricsActive && Platform.isAndroid) { - await tapButton(tester, _localization.cancel); - } - if (walletsExist) { - /// Login Screen - await enterText(tester, TextFormField, password); - await tapButton(tester, _localization.unlockWallet); - - /// Dashboard - /// Tap on the first PaddedButton on the screen, which is the identicon - /// and brings up the wallet list. - await tapButton(tester, PaddedButton, index: 0); - await tapButton(tester, FontAwesomeIcons.circlePlus); - } - /// Create or Import Wallet await tapButton(tester, _localization.importWalletLabel); await tapButton(tester, _localization.importXprvLabel); @@ -45,12 +25,10 @@ Future e2eExportXprvTest(WidgetTester tester) async { await enterText(tester, TextField, "Test Wallet"); await tapButton(tester, _localization.continueLabel); - /// If the wallet database does not exist we need to enter the password. - if (!walletsExist) { - await enterText(tester, TextFormField, password, index: 0); - await enterText(tester, TextFormField, password, index: 1); - await tapButton(tester, _localization.continueLabel); - } + /// Enter the password + await enterText(tester, TextFormField, password, index: 0); + await enterText(tester, TextFormField, password, index: 1); + await tapButton(tester, _localization.continueLabel); await tester.pumpAndSettle(); diff --git a/integration_test/e2e_import_mnemonic_test.dart b/integration_test/e2e_import_mnemonic_test.dart index 8ca3b09f3..8fd91f331 100644 --- a/integration_test/e2e_import_mnemonic_test.dart +++ b/integration_test/e2e_import_mnemonic_test.dart @@ -5,27 +5,6 @@ Future e2eImportMnemonicTest(WidgetTester tester) async { AppLocalizations _localization = AppLocalizations.of(navigatorKey.currentContext!)!; - /// Assess what is on the screen - walletsExist = isTextOnScreen(_localization.unlockWallet); - bool biometricsActive = isTextOnScreen(_localization.cancel); - - /// Cancel the Biometrics popup for linux - if (walletsExist && biometricsActive && Platform.isAndroid) { - await tapButton(tester, _localization.cancel); - } - - if (walletsExist) { - /// Login Screen - await enterText(tester, TextFormField, password); - await tapButton(tester, _localization.unlockWallet); - - /// Dashboard - /// Tap on the first PaddedButton on the screen, which is the identicon - /// and brings up the wallet list. - await tapButton(tester, PaddedButton, index: 0); - await tapButton(tester, FontAwesomeIcons.circlePlus); - } - /// Create or Import Wallet await tapButton(tester, _localization.importWalletLabel); await tapButton(tester, _localization.importMnemonicLabel); @@ -44,12 +23,10 @@ Future e2eImportMnemonicTest(WidgetTester tester) async { await enterText(tester, TextField, "Test Wallet"); await tapButton(tester, _localization.continueLabel); - /// If the wallet database does not exist we need to enter the password. - if (!walletsExist) { - await enterText(tester, TextFormField, password, index: 0); - await enterText(tester, TextFormField, password, index: 1); - await tapButton(tester, _localization.continueLabel); - } + /// Enter the password + await enterText(tester, TextFormField, password, index: 0); + await enterText(tester, TextFormField, password, index: 1); + await tapButton(tester, _localization.continueLabel); await tester.pumpAndSettle(); diff --git a/integration_test/e2e_import_xprv_from_sheikah_test.dart b/integration_test/e2e_import_xprv_from_sheikah_test.dart index 3920623b3..a0879c6af 100644 --- a/integration_test/e2e_import_xprv_from_sheikah_test.dart +++ b/integration_test/e2e_import_xprv_from_sheikah_test.dart @@ -5,27 +5,6 @@ Future e2eImportXprvFromSheikahTest(WidgetTester tester) async { AppLocalizations _localization = AppLocalizations.of(navigatorKey.currentContext!)!; - /// Assess what is on the screen - walletsExist = isTextOnScreen(_localization.unlockWallet); - bool biometricsActive = isTextOnScreen(_localization.cancel); - - /// Cancel the Biometrics popup for linux - if (walletsExist && biometricsActive && Platform.isAndroid) { - await tapButton(tester, _localization.cancel); - } - - if (walletsExist) { - /// Login Screen - await enterText(tester, TextFormField, password); - await tapButton(tester, _localization.unlockWallet); - - /// Dashboard - /// Tap on the first PaddedButton on the screen, which is the identicon - /// and brings up the wallet list. - await tapButton(tester, PaddedButton, index: 0); - await tapButton(tester, FontAwesomeIcons.circlePlus); - } - /// Create or Import Wallet await tapButton(tester, _localization.importWalletLabel); await tapButton(tester, _localization.importXprvLabel); @@ -49,12 +28,10 @@ Future e2eImportXprvFromSheikahTest(WidgetTester tester) async { await enterText(tester, TextField, "Test Wallet xprv from Sheikah"); await tapButton(tester, _localization.continueLabel); - /// If the wallet database does not exist we need to enter the password. - if (!walletsExist) { - await enterText(tester, TextFormField, password, index: 0); - await enterText(tester, TextFormField, password, index: 1); - await tapButton(tester, _localization.continueLabel); - } + /// Enter the password + await enterText(tester, TextFormField, password, index: 0); + await enterText(tester, TextFormField, password, index: 1); + await tapButton(tester, _localization.continueLabel); /// Get the currentWallet loaded in the dashboard final DashboardScreenState dashboardScreenState = diff --git a/integration_test/e2e_import_xprv_test.dart b/integration_test/e2e_import_xprv_test.dart index e18f1c4c6..86338c9ab 100644 --- a/integration_test/e2e_import_xprv_test.dart +++ b/integration_test/e2e_import_xprv_test.dart @@ -5,27 +5,6 @@ Future e2eImportXprvTest(WidgetTester tester) async { AppLocalizations _localization = AppLocalizations.of(navigatorKey.currentContext!)!; - /// Assess what is on the screen - walletsExist = isTextOnScreen(_localization.unlockWallet); - bool biometricsActive = isTextOnScreen(_localization.cancel); - - /// Cancel the Biometrics popup for linux - if (walletsExist && biometricsActive && Platform.isAndroid) { - await tapButton(tester, _localization.cancel); - } - - if (walletsExist) { - /// Login Screen - await enterText(tester, TextFormField, password); - await tapButton(tester, _localization.unlockWallet); - - /// Dashboard - /// Tap on the first PaddedButton on the screen, which is the identicon - /// and brings up the wallet list. - await tapButton(tester, PaddedButton, index: 0); - await tapButton(tester, FontAwesomeIcons.circlePlus); - } - /// Create or Import Wallet await tapButton(tester, _localization.importWalletLabel); await tapButton(tester, _localization.importXprvLabel); @@ -45,12 +24,10 @@ Future e2eImportXprvTest(WidgetTester tester) async { await enterText(tester, TextField, "Test Wallet xprv"); await tapButton(tester, _localization.continueLabel); - /// If the wallet database does not exist we need to enter the password. - if (!walletsExist) { - await enterText(tester, TextFormField, password, index: 0); - await enterText(tester, TextFormField, password, index: 1); - await tapButton(tester, _localization.continueLabel); - } + /// Enter the password + await enterText(tester, TextFormField, password, index: 0); + await enterText(tester, TextFormField, password, index: 1); + await tapButton(tester, _localization.continueLabel); await tester.pumpAndSettle(); diff --git a/integration_test/e2e_mnemonic_test.dart b/integration_test/e2e_mnemonic_test.dart index 1482ea57d..f2bc72206 100644 --- a/integration_test/e2e_mnemonic_test.dart +++ b/integration_test/e2e_mnemonic_test.dart @@ -5,26 +5,6 @@ Future e2eCreateMnemonicTest(WidgetTester tester) async { AppLocalizations _localization = AppLocalizations.of(navigatorKey.currentContext!)!; - /// Assess what is on the screen - walletsExist = isTextOnScreen(_localization.unlockWallet); - bool biometricsActive = isTextOnScreen(_localization.cancel); - - /// Cancel the Biometrics popup - if (walletsExist && biometricsActive && Platform.isAndroid) { - await tapButton(tester, _localization.cancel); - } - if (walletsExist) { - /// Login Screen - await enterText(tester, TextFormField, password); - await tapButton(tester, _localization.unlockWallet); - - /// Dashboard - /// Tap on the first PaddedButton on the screen, which is the identicon - /// and brings up the wallet list. - await tapButton(tester, PaddedButton, index: 0); - await tapButton(tester, FontAwesomeIcons.circlePlus); - } - /// Create or Import Wallet await tapButton(tester, _localization.createNewWalletLabel); @@ -48,11 +28,9 @@ Future e2eCreateMnemonicTest(WidgetTester tester) async { await enterText(tester, TextField, "Test Wallet"); await tapButton(tester, _localization.continueLabel); - /// If the wallet database does not exist we need to enter the password. - if (!walletsExist) { - await enterText(tester, TextFormField, password, index: 0); - await enterText(tester, TextFormField, password, index: 1); - await tapButton(tester, _localization.continueLabel); - } + /// Enter the password + await enterText(tester, TextFormField, password, index: 0); + await enterText(tester, TextFormField, password, index: 1); + await tapButton(tester, _localization.continueLabel); await teardownTest(); } diff --git a/integration_test/e2e_re_establish_wallet.dart b/integration_test/e2e_re_establish_wallet.dart index 0b230e19e..57ec39007 100644 --- a/integration_test/e2e_re_establish_wallet.dart +++ b/integration_test/e2e_re_establish_wallet.dart @@ -6,44 +6,29 @@ Future e2eReEstablishWallets(WidgetTester tester) async { AppLocalizations.of(navigatorKey.currentContext!)!; await tester.pumpAndSettle(); - /// Assess what is on the screen - walletsExist = isTextOnScreen(_localization.unlockWallet); - bool biometricsActive = isTextOnScreen(_localization.cancel); + /// Create or Import Wallet from mnemonic + await tapButton(tester, _localization.importWalletLabel); + await tapButton(tester, _localization.importMnemonicLabel); - if (walletsExist && biometricsActive && Platform.isAndroid) { - await tapButton(tester, _localization.cancel); - } - if (walletsExist) { - /// Login Screen - await enterText(tester, TextFormField, password); - await tapButton(tester, _localization.unlockWallet); - } else { - /// Create or Import Wallet from mnemonic - await tapButton(tester, _localization.importWalletLabel); - await tapButton(tester, _localization.importMnemonicLabel); - - /// Wallet Security - await scrollUntilVisible( - tester, widgetByLabel(_localization.walletSecurityConfirmLabel)); - await tapButton(tester, LabeledCheckbox); - await tapButton(tester, _localization.continueLabel); + /// Wallet Security + await scrollUntilVisible( + tester, widgetByLabel(_localization.walletSecurityConfirmLabel)); + await tapButton(tester, LabeledCheckbox); + await tapButton(tester, _localization.continueLabel); - /// Enter Mnemonic - await enterText(tester, TextField, mnemonic); - await tapButton(tester, _localization.continueLabel); + /// Enter Mnemonic + await enterText(tester, TextField, mnemonic); + await tapButton(tester, _localization.continueLabel); - /// Enter Wallet Name - await enterText(tester, TextField, "Test Wallet"); - await tapButton(tester, _localization.continueLabel); + /// Enter Wallet Name + await enterText(tester, TextField, "Test Wallet"); + await tapButton(tester, _localization.continueLabel); - /// If the wallet database does not exist we need to enter the password. - if (!walletsExist) { - await enterText(tester, TextFormField, password, index: 0); - await enterText(tester, TextFormField, password, index: 1); - await tapButton(tester, _localization.continueLabel); - } - await tester.pumpAndSettle(); - } + /// Enter the password + await enterText(tester, TextFormField, password, index: 0); + await enterText(tester, TextFormField, password, index: 1); + await tapButton(tester, _localization.continueLabel); + await tester.pumpAndSettle(); await tapButton(tester, FontAwesomeIcons.gear); await scrollUntilVisible( @@ -67,6 +52,8 @@ Future e2eReEstablishWallets(WidgetTester tester) async { await tapButton(tester, LabeledCheckbox); await tapButton(tester, _localization.continueLabel); await tapButton(tester, _localization.reestablish); + // Wait until is deleted + await tester.pumpAndSettle(Duration(seconds: 2)); await tapButton(tester, _localization.continueLabel, index: 1); expect(widgetByText(_localization.createNewWalletLabel), findsOneWidget); await teardownTest(); diff --git a/integration_test/e2e_show_node_stats.dart b/integration_test/e2e_show_node_stats.dart index 732a96107..bbf8db772 100644 --- a/integration_test/e2e_show_node_stats.dart +++ b/integration_test/e2e_show_node_stats.dart @@ -5,26 +5,6 @@ Future e2eShowNodeStatsTest(WidgetTester tester) async { AppLocalizations _localization = AppLocalizations.of(navigatorKey.currentContext!)!; - /// Assess what is on the screen - walletsExist = isTextOnScreen(_localization.unlockWallet); - bool biometricsActive = isTextOnScreen(_localization.cancel); - - /// Cancel the Biometrics popup for linux - if (walletsExist && biometricsActive && Platform.isAndroid) { - await tapButton(tester, _localization.cancel); - } - if (walletsExist) { - /// Login Screen - await enterText(tester, TextFormField, password); - await tapButton(tester, _localization.unlockWallet); - - /// Dashboard - /// Tap on the first PaddedButton on the screen, which is the identicon - /// and brings up the wallet list. - await tapButton(tester, PaddedButton, index: 0); - await tapButton(tester, FontAwesomeIcons.circlePlus); - } - /// Create or Import Wallet from mnemonic await tapButton(tester, _localization.importWalletLabel); await tapButton(tester, _localization.importMnemonicLabel); @@ -43,12 +23,10 @@ Future e2eShowNodeStatsTest(WidgetTester tester) async { await enterText(tester, TextField, "Test Wallet"); await tapButton(tester, _localization.continueLabel); - /// If the wallet database does not exist we need to enter the password. - if (!walletsExist) { - await enterText(tester, TextFormField, password, index: 0); - await enterText(tester, TextFormField, password, index: 1); - await tapButton(tester, _localization.continueLabel); - } + /// Enter the password + await enterText(tester, TextFormField, password, index: 0); + await enterText(tester, TextFormField, password, index: 1); + await tapButton(tester, _localization.continueLabel); await tester.pumpAndSettle(); await tapButton(tester, PaddedButton, index: 0); await tapButton(tester, FontAwesomeIcons.circlePlus); diff --git a/integration_test/e2e_sign_message_test.dart b/integration_test/e2e_sign_message_test.dart index 07cb00257..724860b21 100644 --- a/integration_test/e2e_sign_message_test.dart +++ b/integration_test/e2e_sign_message_test.dart @@ -5,26 +5,6 @@ Future e2eSignMessageTest(WidgetTester tester) async { AppLocalizations _localization = AppLocalizations.of(navigatorKey.currentContext!)!; - /// Assess what is on the screen - walletsExist = isTextOnScreen(_localization.unlockWallet); - bool biometricsActive = isTextOnScreen(_localization.cancel); - - /// Cancel the Biometrics popup for linux - if (walletsExist && biometricsActive && Platform.isAndroid) { - await tapButton(tester, _localization.cancel); - } - if (walletsExist) { - /// Login Screen - await enterText(tester, TextFormField, password); - await tapButton(tester, _localization.unlockWallet); - - /// Dashboard - /// Tap on the first PaddedButton on the screen, which is the identicon - /// and brings up the wallet list. - await tapButton(tester, PaddedButton, index: 0); - await tapButton(tester, FontAwesomeIcons.circlePlus); - } - /// Create or Import Wallet await tapButton(tester, _localization.importWalletLabel); await tapButton(tester, _localization.importXprvLabel); @@ -45,12 +25,10 @@ Future e2eSignMessageTest(WidgetTester tester) async { await enterText(tester, TextField, "Test Wallet"); await tapButton(tester, _localization.continueLabel); - /// If the wallet database does not exist we need to enter the password. - if (!walletsExist) { - await enterText(tester, TextFormField, password, index: 0); - await enterText(tester, TextFormField, password, index: 1); - await tapButton(tester, _localization.continueLabel); - } + /// Enter the password + await enterText(tester, TextFormField, password, index: 0); + await enterText(tester, TextFormField, password, index: 1); + await tapButton(tester, _localization.continueLabel); await tester.pumpAndSettle(); @@ -71,31 +49,20 @@ Future e2eSignMessageTest(WidgetTester tester) async { await tapButton(tester, _localization.signMessage); - // Select second address in the list - await tapButton(tester, Select, index: 0); - await tapButton(tester, "wit1vzm7xrguwf5uzjx72l65stgj3npfn292tya50u", - index: 2); - /// Enter Message to sign - await enterText(tester, TextField, _localization.messageToBeSigned); + await enterText(tester, TextField, "myWitWallet"); + // Scroll Sign message button into view - await scrollUntilVisible(tester, widgetByText(_localization.signMessage).last, + await scrollUntilVisible(tester, find.text(_localization.signMessage), lastScroll: true); - await tapButton(tester, _localization.signMessage); - if (Platform.isIOS || Platform.isAndroid) { - // Show modal to verify password - expect(widgetByText(_localization.enterYourPassword), findsWidgets); - - // Enter password for verification and continue - await enterText(tester, TextFormField, password); - await tapButton(tester, _localization.continueLabel); - } + await tapButton(tester, _localization.signMessage); // Scroll Copy JSON button into view await scrollUntilVisible(tester, widgetByText(_localization.copyJson).first, lastScroll: true); - await tester.pumpAndSettle(); + + // Scroll Copy JSON button into view await tapButton(tester, _localization.copyJson); ClipboardData? data = await Clipboard.getData('text/plain'); diff --git a/integration_test/e2e_stake_unstake.dart b/integration_test/e2e_stake_unstake.dart index ff6df17ce..52d910745 100644 --- a/integration_test/e2e_stake_unstake.dart +++ b/integration_test/e2e_stake_unstake.dart @@ -6,53 +6,36 @@ Future e2eStakeUnstakeTest(WidgetTester tester) async { AppLocalizations.of(navigatorKey.currentContext!)!; await tester.pumpAndSettle(); - /// Assess what is on the screen - walletsExist = isTextOnScreen(_localization.unlockWallet); - bool biometricsActive = isTextOnScreen(_localization.cancel); - - if (walletsExist && biometricsActive && Platform.isAndroid) { - await tapButton(tester, _localization.cancel); - } - if (walletsExist) { - /// Login Screen - await enterText(tester, TextFormField, password); - await tapButton(tester, _localization.unlockWallet); - } else { - /// Create or Import Wallet from xprv - await tapButton(tester, _localization.importWalletLabel); - await tapButton(tester, _localization.importXprvLabel); - - /// Wallet Security - await scrollUntilVisible( - tester, widgetByLabel(_localization.walletSecurityConfirmLabel)); - await tapButton(tester, LabeledCheckbox); - await tapButton(tester, _localization.continueLabel); - - /// Enter node Xprv - await tapButton(tester, Select, index: 0); - await tapButton(tester, _localization.walletTypeNodeLabel); - await enterText(tester, TextField, nodeXprv); - await tapButton(tester, _localization.continueLabel); - - /// Enter Wallet Name - await enterText(tester, TextField, "Test Node"); - await tapButton(tester, _localization.continueLabel, delay: true); - - /// If the wallet database does not exist we need to enter the password. - if (!walletsExist) { - await enterText(tester, TextFormField, password, index: 0); - await enterText(tester, TextFormField, password, index: 1); - await tapButton(tester, _localization.continueLabel); - } - } + /// Create or Import Wallet from xprv + await tapButton(tester, _localization.importWalletLabel); + await tapButton(tester, _localization.importXprvLabel); + + /// Wallet Security + await scrollUntilVisible( + tester, widgetByLabel(_localization.walletSecurityConfirmLabel)); + await tapButton(tester, LabeledCheckbox); + await tapButton(tester, _localization.continueLabel); + + /// Enter node Xprv + await tapButton(tester, Select, index: 0); + await tapButton(tester, _localization.walletTypeNodeLabel); + await enterText(tester, TextField, nodeXprv); + await tapButton(tester, _localization.continueLabel); + + /// Enter Wallet Name + await enterText(tester, TextField, "Test Node"); + await tapButton(tester, _localization.continueLabel, delay: true); + + await enterText(tester, TextFormField, password, index: 0); + await enterText(tester, TextFormField, password, index: 1); + await tapButton(tester, _localization.continueLabel); await tester.pumpAndSettle(); await tapButton(tester, localization.stakeUnstake, semantics: true); await tapButton(tester, localization.stake); expect(widgetByText(localization.stake), findsOneWidget); await tapButton(tester, localization.stakeUnstake, semantics: true); await tapButton(tester, localization.unstake); - expect(widgetByText(localization.stake), findsNothing); - expect(widgetByText(localization.unstake), findsOneWidget); + expect(widgetByText(localization.emptyStakeTitle), findsOneWidget); await teardownTest(); } diff --git a/integration_test/e2e_update_theme_test.dart b/integration_test/e2e_update_theme_test.dart index 54ffd5e4f..221c47242 100644 --- a/integration_test/e2e_update_theme_test.dart +++ b/integration_test/e2e_update_theme_test.dart @@ -6,45 +6,30 @@ Future e2eUpdateThemeColorTest(WidgetTester tester) async { AppLocalizations.of(navigatorKey.currentContext!)!; await tester.pumpAndSettle(); - /// Assess what is on the screen - walletsExist = isTextOnScreen(_localization.unlockWallet); - bool biometricsActive = isTextOnScreen(_localization.cancel); - - if (walletsExist && biometricsActive && Platform.isAndroid) { - await tapButton(tester, _localization.cancel); - } - if (walletsExist) { - /// Login Screen - await enterText(tester, TextFormField, password); - await tapButton(tester, _localization.unlockWallet); - } else { - /// Create or Import Wallet from xprv - await tapButton(tester, _localization.importWalletLabel); - await tapButton(tester, _localization.importXprvLabel); - - /// Wallet Security - await scrollUntilVisible( - tester, widgetByLabel(_localization.walletSecurityConfirmLabel)); - await tapButton(tester, LabeledCheckbox); - await tapButton(tester, _localization.continueLabel); - - /// Enter node Xprv - await tapButton(tester, Select, index: 0); - await tapButton(tester, _localization.walletTypeNodeLabel); - await enterText(tester, TextField, nodeXprv); - await tapButton(tester, _localization.continueLabel); - - /// Enter Wallet Name - await enterText(tester, TextField, "Test Node"); - await tapButton(tester, _localization.continueLabel, delay: true); - - /// If the wallet database does not exist we need to enter the password. - if (!walletsExist) { - await enterText(tester, TextFormField, password, index: 0); - await enterText(tester, TextFormField, password, index: 1); - await tapButton(tester, _localization.continueLabel); - } - } + /// Create or Import Wallet from xprv + await tapButton(tester, _localization.importWalletLabel); + await tapButton(tester, _localization.importXprvLabel); + + /// Wallet Security + await scrollUntilVisible( + tester, widgetByLabel(_localization.walletSecurityConfirmLabel)); + await tapButton(tester, LabeledCheckbox); + await tapButton(tester, _localization.continueLabel); + + /// Enter node Xprv + await tapButton(tester, Select, index: 0); + await tapButton(tester, _localization.walletTypeNodeLabel); + await enterText(tester, TextField, nodeXprv); + await tapButton(tester, _localization.continueLabel); + + /// Enter Wallet Name + await enterText(tester, TextField, "Test Node"); + await tapButton(tester, _localization.continueLabel, delay: true); + + /// Enter the password + await enterText(tester, TextFormField, password, index: 0); + await enterText(tester, TextFormField, password, index: 1); + await tapButton(tester, _localization.continueLabel); await tester.pumpAndSettle(); await tapButton(tester, FontAwesomeIcons.gear); if (tester.widget(find.byType(Switch).at(0)).value == false) { diff --git a/integration_test/e2e_update_wallet_test.dart b/integration_test/e2e_update_wallet_test.dart index 7d8b09547..9d996246b 100644 --- a/integration_test/e2e_update_wallet_test.dart +++ b/integration_test/e2e_update_wallet_test.dart @@ -5,26 +5,6 @@ Future e2eUpdateCurrentWalletTest(WidgetTester tester) async { AppLocalizations _localization = AppLocalizations.of(navigatorKey.currentContext!)!; - /// Assess what is on the screen - walletsExist = isTextOnScreen(_localization.unlockWallet); - bool biometricsActive = isTextOnScreen(_localization.cancel); - - /// Cancel the Biometrics popup for linux - if (walletsExist && biometricsActive && Platform.isAndroid) { - await tapButton(tester, _localization.cancel); - } - if (walletsExist) { - /// Login Screen - await enterText(tester, TextFormField, password); - await tapButton(tester, _localization.unlockWallet); - - /// Dashboard - /// Tap on the first PaddedButton on the screen, which is the identicon - /// and brings up the wallet list. - await tapButton(tester, PaddedButton, index: 0); - await tapButton(tester, FontAwesomeIcons.circlePlus); - } - /// Create or Import Wallet from xprv await tapButton(tester, _localization.importWalletLabel); await tapButton(tester, _localization.importXprvLabel); @@ -45,12 +25,10 @@ Future e2eUpdateCurrentWalletTest(WidgetTester tester) async { await enterText(tester, TextField, "Test Node"); await tapButton(tester, _localization.continueLabel, delay: true); - /// If the wallet database does not exist we need to enter the password. - if (!walletsExist) { - await enterText(tester, TextFormField, password, index: 0); - await enterText(tester, TextFormField, password, index: 1); - await tapButton(tester, _localization.continueLabel); - } + /// Enter the password + await enterText(tester, TextFormField, password, index: 0); + await enterText(tester, TextFormField, password, index: 1); + await tapButton(tester, _localization.continueLabel); await tester.pumpAndSettle(); /// Get the currentWallet loaded in the dashboard diff --git a/integration_test/main.dart b/integration_test/main.dart index 9191976d0..9ef64ff47 100644 --- a/integration_test/main.dart +++ b/integration_test/main.dart @@ -8,20 +8,18 @@ void main() async { group("End To End Mnemonic Tests", () { testWidgets("Create Mnemonic Test", e2eCreateMnemonicTest); - testWidgets("Import Mnemonic Test", e2eImportMnemonicTest, skip: true); - testWidgets("Import Xprv Test", e2eImportXprvTest, skip: true); - testWidgets("Export Node Xprv Test", e2eExportXprvTest, skip: true); - testWidgets("Export Hd Xprv Test", e2eExportHdXprvTest, skip: true); - testWidgets("Sign message Test", e2eSignMessageTest, skip: true); - testWidgets('Update current wallet', e2eUpdateCurrentWalletTest, - skip: true); - testWidgets("Auth preferences Test", e2eAuthPreferencesTest, skip: true); - testWidgets("Show node stats Test", e2eShowNodeStatsTest, skip: true); - testWidgets("Re-establish wallets", e2eReEstablishWallets, skip: true); - testWidgets("Import Xprv From Sheikah Test", e2eImportXprvFromSheikahTest, - skip: true); - testWidgets("Update theme color", e2eUpdateThemeColorTest, skip: true); + testWidgets("Import Mnemonic Test", e2eImportMnemonicTest); + testWidgets("Import Xprv Test", e2eImportXprvTest); + testWidgets("Export Node Xprv Test", e2eExportXprvTest); + testWidgets("Export Hd Xprv Test", e2eExportHdXprvTest); + testWidgets("Sign message Test", e2eSignMessageTest); + testWidgets('Update current wallet', e2eUpdateCurrentWalletTest); + testWidgets("Auth preferences Test", e2eAuthPreferencesTest); + testWidgets("Show node stats Test", e2eShowNodeStatsTest); + testWidgets("Re-establish wallets", e2eReEstablishWallets); + testWidgets("Import Xprv From Sheikah Test", e2eImportXprvFromSheikahTest); + testWidgets("Update theme color", e2eUpdateThemeColorTest); testWidgets( - "Go to stake and unstake transaction view", e2eStakeUnstakeTest, skip: true); + "Go to stake and unstake transaction view", e2eStakeUnstakeTest); }); } diff --git a/integration_test/test_utils.dart b/integration_test/test_utils.dart index d38ad564a..541d9adde 100644 --- a/integration_test/test_utils.dart +++ b/integration_test/test_utils.dart @@ -1,7 +1,8 @@ import 'dart:io'; +import 'dart:ui' as ui; import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; - import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -232,13 +233,70 @@ Future teardownTest() async { ApiDatabase apiDatabase = Locator.instance(); if (globals.testingActive) { if (globals.testingDeleteStorage) { - await apiDatabase.deleteAllWallets(); - await apiDatabase.openDatabase(); - globals.firstRun = false; + bool isDeleted = await apiDatabase.deleteAllWallets(); + if (isDeleted) { + await apiDatabase.openDatabase(); + globals.firstRun = false; + } } await apiDatabase.lockDatabase(); } + await Future.delayed(Duration(seconds: 4)); return true; } bool isTextOnScreen(String text) => find.text(text).hasFound; + +/// Originally published on: https://gist.github.com/stevenosse/b191d56cb4b75ed8012c3d04c1d80448 +extension TestScreenshotUtil on WidgetTester { + Future takeScreenshot({required String name}) async { + final liveElement = binding.renderViewElement!; + + late final Uint8List bytes; + await binding.runAsync(() async { + final image = await _captureImage(liveElement); + final byteData = await image.toByteData(format: ui.ImageByteFormat.png); + if (byteData == null) { + return 'Could not take screenshot'; + } + bytes = byteData.buffer.asUint8List(); + image.dispose(); + }); + + final directory = Directory('./screenshots'); + if (!directory.existsSync()) { + directory.createSync(); + } + final file = File('./screenshots/$name.png'); + file.writeAsBytesSync(bytes); + } + + Future _captureImage(Element element) async { + assert(element.renderObject != null); + RenderObject renderObject = element.renderObject!; + while (!renderObject.isRepaintBoundary) { + // ignore: unnecessary_cast + renderObject = renderObject.parent! as RenderObject; + } + assert(!renderObject.debugNeedsPaint); + + final OffsetLayer layer = renderObject.debugLayer! as OffsetLayer; + final ui.Image image = await layer.toImage(renderObject.paintBounds); + + if (element.renderObject is RenderBox) { + final expectedSize = (element.renderObject as RenderBox?)!.size; + if (expectedSize.width != image.width || + expectedSize.height != image.height) { + // ignore: avoid_print + print( + 'Warning: The screenshot captured of ${element.toStringShort()} is ' + 'larger (${image.width}, ${image.height}) than ' + '${element.toStringShort()} (${expectedSize.width}, ${expectedSize.height}) itself.\n' + 'Wrap the ${element.toStringShort()} in a RepaintBoundary to be able to capture only that layer. ', + ); + } + } + + return image; + } +} diff --git a/lib/bloc/explorer/explorer_bloc.dart b/lib/bloc/explorer/explorer_bloc.dart index 659893748..9d7f01b1d 100644 --- a/lib/bloc/explorer/explorer_bloc.dart +++ b/lib/bloc/explorer/explorer_bloc.dart @@ -170,7 +170,7 @@ class ExplorerBloc extends Bloc { if (errorMessage.runtimeType == ExplorerException) { errorMessage = (errorMessage as ExplorerException).message; } - add(SyncErrorEvent(ExplorerStatus.error, errorMessage)); + add(SyncErrorEvent(ExplorerStatus.error, '${errorMessage}')); } Future _syncSingleAccount( diff --git a/macos/Podfile.lock b/macos/Podfile.lock index b1a9fa964..8914c60c7 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -49,11 +49,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 local_auth_darwin: 66e40372f1c29f383a314c738c7446e2f7fdadc3 -<<<<<<< HEAD - mobile_scanner: d12930b68bf502497f78b8b5182aeccfaa1e04f6 -======= mobile_scanner: 1efac1e53c294b24e3bb55bcc7f4deee0233a86b ->>>>>>> 8f2d04cd (chore: update deps) path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38 shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78