Skip to content

Commit

Permalink
test: fix failing tests
Browse files Browse the repository at this point in the history
Co-authored-by: gabaldon <[email protected]>
  • Loading branch information
Tommytrg and gabaldon committed Aug 12, 2024
1 parent c2496a0 commit 25a9e7b
Show file tree
Hide file tree
Showing 18 changed files with 226 additions and 429 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
55 changes: 20 additions & 35 deletions integration_test/e2e_auth_preferences_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,30 @@ Future<void> 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);
Expand Down
32 changes: 8 additions & 24 deletions integration_test/e2e_export_hd_xprv_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,6 @@ Future<void> 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);
Expand All @@ -46,11 +29,9 @@ Future<void> 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();

Expand Down Expand Up @@ -83,14 +64,14 @@ Future<void> 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
Expand All @@ -103,6 +84,9 @@ Future<void> 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));
Expand Down
30 changes: 4 additions & 26 deletions integration_test/e2e_export_node_xprv_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,6 @@ Future<void> 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);
Expand All @@ -45,12 +25,10 @@ Future<void> 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();

Expand Down
31 changes: 4 additions & 27 deletions integration_test/e2e_import_mnemonic_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,6 @@ Future<void> 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);
Expand All @@ -44,12 +23,10 @@ Future<void> 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();

Expand Down
31 changes: 4 additions & 27 deletions integration_test/e2e_import_xprv_from_sheikah_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,6 @@ Future<void> 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);
Expand All @@ -49,12 +28,10 @@ Future<void> 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 =
Expand Down
31 changes: 4 additions & 27 deletions integration_test/e2e_import_xprv_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,6 @@ Future<void> 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);
Expand All @@ -45,12 +24,10 @@ Future<void> 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();

Expand Down
30 changes: 4 additions & 26 deletions integration_test/e2e_mnemonic_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,6 @@ Future<void> 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);

Expand All @@ -48,11 +28,9 @@ Future<void> 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();
}
Loading

0 comments on commit 25a9e7b

Please sign in to comment.