Skip to content

Commit

Permalink
fix: e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
parodyBit committed Oct 19, 2023
1 parent ee9856b commit ca2ff8c
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 195 deletions.
35 changes: 29 additions & 6 deletions integration_test/e2e_auth_preferences_test.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'test_utils.dart';
part of 'test_utils.dart';

Future<void> e2eAuthPreferencesTest(WidgetTester tester) async {
await initializeTest(tester);
Expand All @@ -20,7 +15,35 @@ Future<void> e2eAuthPreferencesTest(WidgetTester tester) async {
/// Login Screen
await enterText(tester, TextFormField, password);
await tapButton(tester, "Unlock wallet");
} else {
/// Create or Import Wallet from xprv
await tapButton(tester, "Import wallet");
await tapButton(tester, "Import from Xprv key");

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

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

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

await tapButton(tester, FontAwesomeIcons.gear);
// Check if it is desktop
Expand Down
25 changes: 10 additions & 15 deletions integration_test/e2e_export_xprv_test.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:my_wit_wallet/widgets/PaddedButton.dart';
import 'package:my_wit_wallet/widgets/labeled_checkbox.dart';
import 'package:my_wit_wallet/widgets/select.dart';
import 'test_utils.dart';

bool walletsExist = false;
String password = dotenv.env['PASSWORD'] ?? "password";
String nodeXprv = dotenv.env['NODE_XPRV'] ?? '';
part of 'test_utils.dart';

Future<void> e2eExportXprvTest(WidgetTester tester) async {
await initializeTest(tester);
Expand Down Expand Up @@ -57,6 +43,15 @@ Future<void> e2eExportXprvTest(WidgetTester tester) async {
await enterText(tester, TextField, "Test Wallet");
await tapButton(tester, "Continue");

/// 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 tester.pumpAndSettle();

await tapButton(tester, FontAwesomeIcons.gear);
await tapButton(tester, "Wallet");

Expand Down
25 changes: 8 additions & 17 deletions integration_test/e2e_import_mnemonic_test.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:my_wit_wallet/screens/dashboard/view/dashboard_screen.dart';
import 'package:my_wit_wallet/widgets/labeled_checkbox.dart';
import 'test_utils.dart';
import 'package:my_wit_wallet/widgets/PaddedButton.dart';
import 'package:my_wit_wallet/util/storage/database/wallet.dart';

bool walletsExist = false;
String password = dotenv.env['PASSWORD'] ?? "password";
String mnemonic = dotenv.env['MNEMONIC'] ??
"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
part of 'test_utils.dart';

Future<void> e2eImportMnemonicTest(WidgetTester tester) async {
await initializeTest(tester);
Expand Down Expand Up @@ -57,12 +42,18 @@ Future<void> e2eImportMnemonicTest(WidgetTester tester) async {
await enterText(tester, TextField, "Test Wallet");
await tapButton(tester, "Continue");

/// 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 tester.pumpAndSettle();

/// Get the currentWallet loaded in the dashboard
final DashboardScreenState dashboardScreenState =
tester.state(widgetByType(DashboardScreen));
dashboardScreenState.currentWallet!.printDebug();
Wallet? currentWallet = dashboardScreenState.currentWallet;

/// Verify the imported wallet and the current address
Expand Down
23 changes: 3 additions & 20 deletions integration_test/e2e_import_xprv_from_sheikah_test.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:my_wit_wallet/screens/dashboard/view/dashboard_screen.dart';
import 'package:my_wit_wallet/util/storage/database/wallet.dart';
import 'test_utils.dart';
import 'package:my_wit_wallet/widgets/PaddedButton.dart';
import 'package:my_wit_wallet/widgets/select.dart';
import 'package:my_wit_wallet/widgets/labeled_checkbox.dart';

bool walletsExist = false;
String password = dotenv.env['PASSWORD'] ?? "password";
String xprv = dotenv.env['XPRV'] ??
"xprv12qq5w546kss07l3kw5ag44epc79ya78fvqtnq2q775qx3p8trgqsur443m4cj98p3eaz0k7h7ncn58yccp5kkufkc6ylflctfcyzk45z8fup6tq4uavtv7fsmkg43mmuvddfk5fcx087jqy7x0wjw5j2zc82hupl0acmtgtntjmh34zk7ewg7qy2e8qj60pjs5y4szfzydfc0fern29nvzedra4c8pucgtgrpzgfr8d3vp0yjdn2y8qk2fdjeacvs76k9zely0p8vz7fyvn269y0ksu039hj";
part of 'test_utils.dart';

Future<void> e2eImportXprvFromSheikahTest(WidgetTester tester) async {
await initializeTest(tester);
Expand Down Expand Up @@ -54,8 +38,8 @@ Future<void> e2eImportXprvFromSheikahTest(WidgetTester tester) async {
await tapButton(tester, Select, index: 0);
await tapButton(tester, "Sheikah");

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

Expand All @@ -73,7 +57,6 @@ Future<void> e2eImportXprvFromSheikahTest(WidgetTester tester) async {
/// Get the currentWallet loaded in the dashboard
final DashboardScreenState dashboardScreenState =
tester.state(widgetByType(DashboardScreen));
dashboardScreenState.currentWallet!.printDebug();
Wallet? currentWallet = dashboardScreenState.currentWallet;

/// Verify the imported wallet and the current address
Expand Down
22 changes: 4 additions & 18 deletions integration_test/e2e_import_xprv_test.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:my_wit_wallet/screens/dashboard/view/dashboard_screen.dart';
import 'package:my_wit_wallet/util/storage/database/wallet.dart';
import 'test_utils.dart';
import 'package:my_wit_wallet/widgets/PaddedButton.dart';
import 'package:my_wit_wallet/widgets/labeled_checkbox.dart';

bool walletsExist = false;
String password = dotenv.env['PASSWORD'] ?? "password";
String xprv = dotenv.env['XPRV'] ??
"xprv1m9datmt8l4qyqa2nf7lxrw76vu3kyy63qndhtpjyezm7rjrlqrqjh23yks7zjwycud9k25g20rjqkl7uyfcvq6e246du73cl8hhcfa2xwm6cun5ma69jrtyyzjzm0nqwurwa8vg5pxhd9wxu2lgrpmwknsl3yk3t4qn5au4mnf33qpnk3gg7e093nkk0kqzhfkecg45jm0qsczellg6hll4nzuldckjvj6xku75gmhjc340jau26t634c98ke3a454mqjsxtvfs53f2464jfyhd605hqs0lu";
part of 'test_utils.dart';

Future<void> e2eImportXprvTest(WidgetTester tester) async {
await initializeTest(tester);
Expand Down Expand Up @@ -50,7 +35,7 @@ Future<void> e2eImportXprvTest(WidgetTester tester) async {
await tapButton(tester, "Continue");

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

Expand All @@ -65,10 +50,11 @@ Future<void> e2eImportXprvTest(WidgetTester tester) async {
await tapButton(tester, "Continue");
}

await tester.pumpAndSettle();

/// Get the currentWallet loaded in the dashboard
final DashboardScreenState dashboardScreenState =
tester.state(widgetByType(DashboardScreen));
dashboardScreenState.currentWallet!.printDebug();
Wallet? currentWallet = dashboardScreenState.currentWallet;

/// Verify the imported wallet and the current address
Expand Down
8 changes: 1 addition & 7 deletions integration_test/e2e_mnemonic_test.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:my_wit_wallet/screens/create_wallet/generate_mnemonic_card.dart';
import 'package:my_wit_wallet/widgets/PaddedButton.dart';
import 'package:my_wit_wallet/widgets/labeled_checkbox.dart';
import 'test_utils.dart';
part of 'test_utils.dart';

Future<void> e2eCreateMnemonicTest(WidgetTester tester) async {
await initializeTest(tester);
Expand Down
51 changes: 29 additions & 22 deletions integration_test/e2e_re_establish_wallet.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:my_wit_wallet/widgets/PaddedButton.dart';
import 'package:my_wit_wallet/widgets/labeled_checkbox.dart';
import 'test_utils.dart';
part of 'test_utils.dart';

Future<void> e2eReEstablishWallets(WidgetTester tester) async {
await initializeTest(tester);
Expand All @@ -22,29 +15,43 @@ Future<void> e2eReEstablishWallets(WidgetTester tester) async {
/// Login Screen
await enterText(tester, TextFormField, password);
await tapButton(tester, "Unlock wallet");
}
} else {
/// Create or Import Wallet from mnemonic
await tapButton(tester, "Import wallet");
await tapButton(tester, "Import from secret security phrase");

await tapButton(tester, FontAwesomeIcons.gear);
await tapButton(tester, 'Lock wallet');
/// Wallet Security
await scrollUntilVisible(
tester, widgetByLabel("I will be careful, I promise!"));
await tapButton(tester, LabeledCheckbox);
await tapButton(tester, "Continue");

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

/// Cancel the Biometrics popup for linux
if (walletsExist && biometricsActive) {
if (Platform.isAndroid) {
await tapButton(tester, "CANCEL");
/// Enter Wallet Name
await enterText(tester, TextField, "Test Wallet");
await tapButton(tester, "Continue");

/// 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 tester.pumpAndSettle();
}
await scrollUntilVisible(tester, find.byType(PaddedButton).at(0),
lastScroll: true);
await tester.pumpAndSettle();

await tapButton(tester, PaddedButton, index: 0);
await scrollUntilVisible(
tester, widgetByLabel("I will be careful, I promise!"));
await tapButton(tester, FontAwesomeIcons.gear);
await tapButton(tester, 'Lock wallet', delay: true, milliseconds: 1000);

await tapButton(tester, "Re-establish wallet",
delay: true, milliseconds: 1000);
await tapButton(tester, LabeledCheckbox);
await tapButton(tester, "Continue");
await tapButton(tester, "Re-establish");
await tapButton(tester, "Continue", index: 1);
await tapButton(tester, "Back", index: 0);
bool isStorageDeleted = isTextOnScreen('Create new wallet');
expect(isStorageDeleted, true);
}
57 changes: 35 additions & 22 deletions integration_test/e2e_show_node_stats.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:my_wit_wallet/screens/dashboard/view/dashboard_screen.dart';
import 'package:my_wit_wallet/util/storage/database/wallet.dart';
import 'package:my_wit_wallet/widgets/select.dart';
import 'test_utils.dart';
import 'package:my_wit_wallet/widgets/PaddedButton.dart';
import 'package:my_wit_wallet/widgets/labeled_checkbox.dart';

bool walletsExist = false;
String password = dotenv.env['PASSWORD'] ?? "password";
String nodeXprv = dotenv.env['NODE_XPRV'] ?? '';
part of 'test_utils.dart';

Future<void> e2eShowNodeStatsTest(WidgetTester tester) async {
await initializeTest(tester);
Expand All @@ -38,7 +23,34 @@ Future<void> e2eShowNodeStatsTest(WidgetTester tester) async {
await tapButton(tester, FontAwesomeIcons.circlePlus);
}

/// Create or Import Wallet from xprv
/// Create or Import Wallet from mnemonic
await tapButton(tester, "Import wallet");
await tapButton(tester, "Import from secret security phrase");

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

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

/// Enter Wallet Name
await enterText(tester, TextField, "Test Wallet");
await tapButton(tester, "Continue");

/// 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 tester.pumpAndSettle();
await tapButton(tester, PaddedButton, index: 0);
await tapButton(tester, FontAwesomeIcons.circlePlus);

await tapButton(tester, "Import wallet");
await tapButton(tester, "Import from Xprv key");

Expand All @@ -54,22 +66,23 @@ Future<void> e2eShowNodeStatsTest(WidgetTester tester) async {
await enterText(tester, TextField, nodeXprv);
await tapButton(tester, "Continue");

/// Enter Wallet Name
await enterText(tester, TextField, "Test Wallet");
/// Enter Node Name
await enterText(tester, TextField, "Test Node");
await tapButton(tester, "Continue");

await tester.pumpAndSettle();

/// Get the currentWallet loaded in the dashboard
final DashboardScreenState dashboardScreenState =
tester.state(widgetByType(DashboardScreen));
await expectLater(dashboardScreenState.currentWallet!.id, 'dae88d1f');
dashboardScreenState.currentWallet!.printDebug();
await expectLater(dashboardScreenState.currentWallet!.id, 'ce389a1a');
Wallet? currentWallet = dashboardScreenState.currentWallet;

await tester.pumpAndSettle();

/// Verify the imported wallet and the current address
expectLater(currentWallet!.masterAccount!.address,
"wit1zl7ty0lwr7atp5fu34azkgewhtfx2fl4wv69cw");
"wit1vzm7xrguwf5uzjx72l65stgj3npfn292tya50u");

await tapButton(tester, "Stats");

Expand Down
Loading

0 comments on commit ca2ff8c

Please sign in to comment.