Skip to content

Commit

Permalink
add: localization to e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
parodyBit committed Oct 25, 2023
1 parent 9e57fee commit 852480a
Show file tree
Hide file tree
Showing 20 changed files with 223 additions and 182 deletions.
34 changes: 18 additions & 16 deletions integration_test/e2e_auth_preferences_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,47 @@ part of 'test_utils.dart';

Future<void> e2eAuthPreferencesTest(WidgetTester tester) async {
await initializeTest(tester);
AppLocalizations _localization =
AppLocalizations.of(navigatorKey.currentContext!)!;
await tester.pumpAndSettle();

/// Assess what is on the screen
walletsExist = isTextOnScreen("Unlock wallet");
bool biometricsActive = isTextOnScreen("CANCEL");
walletsExist = isTextOnScreen(_localization.unlockWallet);
bool biometricsActive = isTextOnScreen(_localization.cancel);

if (walletsExist && biometricsActive && Platform.isAndroid) {
await tapButton(tester, "CANCEL");
await tapButton(tester, _localization.cancel);
}
if (walletsExist) {
/// Login Screen
await enterText(tester, TextFormField, password);
await tapButton(tester, "Unlock wallet");
await tapButton(tester, _localization.unlockWallet);
} else {
/// Create or Import Wallet from xprv
await tapButton(tester, "Import wallet");
await tapButton(tester, "Import from Xprv key");
await tapButton(tester, _localization.importWalletLabel);
await tapButton(tester, _localization.importXprvLabel);

/// Wallet Security
await scrollUntilVisible(
tester, widgetByLabel("I will be careful, I promise!"));
tester, widgetByLabel(_localization.walletSecurityConfirmLabel));
await tapButton(tester, LabeledCheckbox);
await tapButton(tester, "Continue");
await tapButton(tester, _localization.continueLabel);

/// Enter node Xprv
await tapButton(tester, Select, index: 0);
await tapButton(tester, "Node");
await tapButton(tester, _localization.walletTypeNodeLabel);
await enterText(tester, TextField, nodeXprv);
await tapButton(tester, "Continue");
await tapButton(tester, _localization.continueLabel);

/// Enter Wallet Name
await enterText(tester, TextField, "Test Node");
await tapButton(tester, "Continue", delay: true);
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, "Continue");
await tapButton(tester, _localization.continueLabel);
}
}
await tester.pumpAndSettle();
Expand All @@ -56,22 +58,22 @@ Future<void> e2eAuthPreferencesTest(WidgetTester tester) async {
await tapButton(tester, Switch, index: 1);

// Show modal to verify password
expect(widgetByText('Enter your password'), findsWidgets);
expect(widgetByText(_localization.enterYourPassword), findsWidgets);

// Enter password for verification and continue
await enterText(tester, TextFormField, password);
await tapButton(tester, "Continue");
await tapButton(tester, _localization.continueLabel);
expect(tester.widget<Switch>(find.byType(Switch).at(1)).value, isFalse);

// Avoid switch to password authentication if password is not typed by the user
await tapButton(tester, Switch, index: 1);
expect(tester.widget<Switch>(find.byType(Switch).at(1)).value, isTrue);
await tapButton(tester, Switch, index: 1);
await tapButton(tester, "Close");
await tapButton(tester, _localization.close);
expect(tester.widget<Switch>(find.byType(Switch).at(1)).value, isTrue);
} else {
// Auth settings should not appear
expect(widgetByText('Enable login with biometrics'), findsNothing);
expect(widgetByText(_localization.enableLoginWithBiometrics), findsNothing);
}
await teardownTest();
}
35 changes: 19 additions & 16 deletions integration_test/e2e_export_xprv_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@ part of 'test_utils.dart';

Future<void> e2eExportXprvTest(WidgetTester tester) async {
await initializeTest(tester);
AppLocalizations _localization =
AppLocalizations.of(navigatorKey.currentContext!)!;

/// Assess what is on the screen
walletsExist = isTextOnScreen("Unlock wallet");
bool biometricsActive = isTextOnScreen("CANCEL");
walletsExist = isTextOnScreen(_localization.unlockWallet);
bool biometricsActive = isTextOnScreen(_localization.cancel);

/// Cancel the Biometrics popup for linux
if (walletsExist && biometricsActive && Platform.isAndroid) {
await tapButton(tester, "CANCEL");
await tapButton(tester, _localization.cancel);
}
if (walletsExist) {
/// Login Screen
await enterText(tester, TextFormField, password);
await tapButton(tester, "Unlock wallet");
await tapButton(tester, _localization.unlockWallet);

/// Dashboard
/// Tap on the first PaddedButton on the screen, which is the identicon
Expand All @@ -24,44 +26,45 @@ Future<void> e2eExportXprvTest(WidgetTester tester) async {
}

/// Create or Import Wallet
await tapButton(tester, "Import wallet");
await tapButton(tester, "Import from Xprv key");
await tapButton(tester, _localization.importWalletLabel);
await tapButton(tester, _localization.importXprvLabel);

/// Wallet Security
await scrollUntilVisible(
tester, widgetByLabel("I will be careful, I promise!"));
tester, widgetByLabel(_localization.walletSecurityConfirmLabel));
await tapButton(tester, LabeledCheckbox);
await tapButton(tester, "Continue");
await tapButton(tester, _localization.continueLabel);

/// Enter node Xprv
await tapButton(tester, Select, index: 0);
await tapButton(tester, "Node");
await tapButton(tester, _localization.walletTypeNodeLabel);
await enterText(tester, TextField, nodeXprv);
await tapButton(tester, "Continue");
await tapButton(tester, _localization.continueLabel);

/// Enter Wallet Name
await enterText(tester, TextField, "Test Wallet");
await tapButton(tester, "Continue");
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, "Continue");
await tapButton(tester, _localization.continueLabel);
}

await tester.pumpAndSettle();

await tapButton(tester, FontAwesomeIcons.gear);
await tapButton(tester, "Wallet");
await tapButton(tester, _localization.preferenceTabs('wallet'));

await tapButton(tester, "Export xprv");
await tapButton(tester, _localization.exportXprv);

// Scroll Save button into view
await scrollUntilVisible(tester, widgetByText("Copy Xprv").first,
await scrollUntilVisible(
tester, widgetByText(_localization.copyXprvLabel).first,
lastScroll: true);
await tester.pumpAndSettle();
await tapButton(tester, "Copy Xprv");
await tapButton(tester, _localization.copyXprvLabel);

ClipboardData? data = await Clipboard.getData('text/plain');

Expand Down
24 changes: 13 additions & 11 deletions integration_test/e2e_import_mnemonic_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ part of 'test_utils.dart';

Future<void> e2eImportMnemonicTest(WidgetTester tester) async {
await initializeTest(tester);
AppLocalizations _localization =
AppLocalizations.of(navigatorKey.currentContext!)!;

/// Assess what is on the screen
walletsExist = isTextOnScreen("Unlock wallet");
bool biometricsActive = isTextOnScreen("CANCEL");
walletsExist = isTextOnScreen(_localization.unlockWallet);
bool biometricsActive = isTextOnScreen(_localization.cancel);

/// Cancel the Biometrics popup for linux
if (walletsExist && biometricsActive && Platform.isAndroid) {
await tapButton(tester, "CANCEL");
await tapButton(tester, _localization.cancel);
}

if (walletsExist) {
/// Login Screen
await enterText(tester, TextFormField, password);
await tapButton(tester, "Unlock wallet");
await tapButton(tester, _localization.unlockWallet);

/// Dashboard
/// Tap on the first PaddedButton on the screen, which is the identicon
Expand All @@ -25,28 +27,28 @@ Future<void> e2eImportMnemonicTest(WidgetTester tester) async {
}

/// Create or Import Wallet
await tapButton(tester, "Import wallet");
await tapButton(tester, "Import from secret security phrase");
await tapButton(tester, _localization.importWalletLabel);
await tapButton(tester, _localization.importMnemonicLabel);

/// Wallet Security
await scrollUntilVisible(
tester, widgetByLabel("I will be careful, I promise!"));
tester, widgetByLabel(_localization.walletSecurityConfirmLabel));
await tapButton(tester, LabeledCheckbox);
await tapButton(tester, "Continue");
await tapButton(tester, _localization.continueLabel);

/// Enter Mnemonic
await enterText(tester, TextField, mnemonic);
await tapButton(tester, "Continue");
await tapButton(tester, _localization.continueLabel);

/// Enter Wallet Name
await enterText(tester, TextField, "Test Wallet");
await tapButton(tester, "Continue");
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, "Continue");
await tapButton(tester, _localization.continueLabel);
}

await tester.pumpAndSettle();
Expand Down
26 changes: 14 additions & 12 deletions integration_test/e2e_import_xprv_from_sheikah_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ part of 'test_utils.dart';

Future<void> e2eImportXprvFromSheikahTest(WidgetTester tester) async {
await initializeTest(tester);
AppLocalizations _localization =
AppLocalizations.of(navigatorKey.currentContext!)!;

/// Assess what is on the screen
walletsExist = isTextOnScreen("Unlock wallet");
bool biometricsActive = isTextOnScreen("CANCEL");
walletsExist = isTextOnScreen(_localization.unlockWallet);
bool biometricsActive = isTextOnScreen(_localization.cancel);

/// Cancel the Biometrics popup for linux
if (walletsExist && biometricsActive && Platform.isAndroid) {
await tapButton(tester, "CANCEL");
await tapButton(tester, _localization.cancel);
}

if (walletsExist) {
/// Login Screen
await enterText(tester, TextFormField, password);
await tapButton(tester, "Unlock wallet");
await tapButton(tester, _localization.unlockWallet);

/// Dashboard
/// Tap on the first PaddedButton on the screen, which is the identicon
Expand All @@ -25,33 +27,33 @@ Future<void> e2eImportXprvFromSheikahTest(WidgetTester tester) async {
}

/// Create or Import Wallet
await tapButton(tester, "Import wallet");
await tapButton(tester, "Import from Xprv key");
await tapButton(tester, _localization.importWalletLabel);
await tapButton(tester, _localization.importXprvLabel);

/// Wallet Security
await scrollUntilVisible(
tester, widgetByLabel("I will be careful, I promise!"));
tester, widgetByLabel(_localization.walletSecurityConfirmLabel));
await tapButton(tester, LabeledCheckbox);
await tapButton(tester, "Continue");
await tapButton(tester, _localization.continueLabel);

// Select Sheikah option
await tapButton(tester, Select, index: 0);
await tapButton(tester, "Sheikah");
await tapButton(tester, _localization.sheikah);

/// Enter Shiekah Compatible Encrypted Xprv
await enterText(tester, TextField, sheikahXprv, index: 0);
await enterText(tester, TextField, password, index: 1);
await tapButton(tester, "Continue");
await tapButton(tester, _localization.continueLabel);

/// Enter Wallet Name
await enterText(tester, TextField, "Test Wallet xprv from Sheikah");
await tapButton(tester, "Continue");
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, "Continue");
await tapButton(tester, _localization.continueLabel);
}

/// Get the currentWallet loaded in the dashboard
Expand Down
24 changes: 13 additions & 11 deletions integration_test/e2e_import_xprv_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ part of 'test_utils.dart';

Future<void> e2eImportXprvTest(WidgetTester tester) async {
await initializeTest(tester);
AppLocalizations _localization =
AppLocalizations.of(navigatorKey.currentContext!)!;

/// Assess what is on the screen
walletsExist = isTextOnScreen("Unlock wallet");
bool biometricsActive = isTextOnScreen("CANCEL");
walletsExist = isTextOnScreen(_localization.unlockWallet);
bool biometricsActive = isTextOnScreen(_localization.cancel);

/// Cancel the Biometrics popup for linux
if (walletsExist && biometricsActive && Platform.isAndroid) {
await tapButton(tester, "CANCEL");
await tapButton(tester, _localization.cancel);
}

if (walletsExist) {
/// Login Screen
await enterText(tester, TextFormField, password);
await tapButton(tester, "Unlock wallet");
await tapButton(tester, _localization.unlockWallet);

/// Dashboard
/// Tap on the first PaddedButton on the screen, which is the identicon
Expand All @@ -25,29 +27,29 @@ Future<void> e2eImportXprvTest(WidgetTester tester) async {
}

/// Create or Import Wallet
await tapButton(tester, "Import wallet");
await tapButton(tester, "Import from Xprv key");
await tapButton(tester, _localization.importWalletLabel);
await tapButton(tester, _localization.importXprvLabel);

/// Wallet Security
await scrollUntilVisible(
tester, widgetByLabel("I will be careful, I promise!"));
tester, widgetByLabel(_localization.walletSecurityConfirmLabel));
await tapButton(tester, LabeledCheckbox);
await tapButton(tester, "Continue");
await tapButton(tester, _localization.continueLabel);

/// Enter Mnemonic
await enterText(tester, TextField, mwwXprv, index: 0);
await enterText(tester, TextField, password, index: 1);
await tapButton(tester, "Continue");
await tapButton(tester, _localization.continueLabel);

/// Enter Wallet Name
await enterText(tester, TextField, "Test Wallet xprv");
await tapButton(tester, "Continue");
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, "Continue");
await tapButton(tester, _localization.continueLabel);
}

await tester.pumpAndSettle();
Expand Down
Loading

0 comments on commit 852480a

Please sign in to comment.