Automated Integration Tests Flows (#1686)

* feat: Integration tests setup and tests for Disclaimer, Welcome and Setup Pin Code pages

* feat: Integration test flow from start to restoring a wallet successfully done

* test: Dashboard view test and linking to flow

* feat: Testing the Exchange flow section, selecting sending and receiving currencies

* test: Successfully create an exchange section

* feat: Implement flow up to sending section

* test: Complete Exchange flow

* fix dependency issue

* test: Final cleanups

* feat: Add CI to run automated integration tests withan android emulator

* feat: Adjust Automated integration test CI to run on ubuntu 20.04-a

* fix: Move integration test CI into PR test build CI

* ci: Add automated test ci which is a streamlined replica of pr test build ci

* ci: Re-add step to access branch name

* ci: Add KVM

* ci: Add filepath to trigger the test run from

* ci: Add required key

* ci: Add required key

* ci: Add missing secret key

* ci: Add missing secret key

* ci: Add nano secrets to workflow

* ci: Switch step to free space on runner

* ci: Remove timeout from workflow

* ci: Confirm impact that removing copy_monero_deps would have on entire workflow time

* ci: Update CI and temporarily remove cache related to emulator

* ci: Remove dynamic java version

* ci: Temporarily switch CI

* ci: Switch to 11.x jdk

* ci: Temporarily switch CI

* ci: Revert ubuntu version

* ci: Add more api levels

* ci: Add more target options

* ci: Settled on stable emulator matrix options

* ci: Add more target options

* ci: Modify flow

* ci: Streamline api levels to 28 and 29

* ci: One more trial

* ci: Switch to flutter drive

* ci: Reduce options

* ci: Remove haven from test

* ci: Check for solana in list

* ci: Adjust amounts and currencies for exchange flow

* ci: Set write response on failure to true

* ci: Split ci to funds and non funds related tests

* test: Test for Send flow scenario and minor restructuring for test folders and files

* chore: cleanup

* ci: Pause CI for now

* ci: Pause CI for now

* ci: Pause CI for now

* test: Restore wallets integration automated tests

* Fix: Add keys back to currency amount textfield widget

* fix: Switch variable name

* fix: remove automation for now

* tests: Automated tests for Create wallets flow

* tests: Further optimize common flows

* tests: Add missing await for call

* tests: Confirm Seeds Display Properly WIP

* tests: Confirm Seeds Display Correctly Automated Tests

* fix: Add missing pubspec params for bitcoin and bitcoin_cash

* feat: Automated Tests for Transaction History Flow

* fix: Add missing pubspec parameter

* feat: Automated Integration Tests for Transaction History flow

* test: Updating send page robot and also syncing branch with main

* test: Modifying tests to flow with wallet grouping implementation

* fix: Issue with transaction history test

* fix: Modifications to the PR and add automated confirmation for checking that all wallet types are restored or created correctly

* test: Attempting automation for testing

* fix: Issue from merge conflicts

* test: Remove automation of test in this PR

---------

Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
This commit is contained in:
David Adegoke 2024-11-07 15:46:08 +01:00 committed by GitHub
parent 48457fdd6d
commit 0fcfd76afd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
84 changed files with 2716 additions and 745 deletions

View file

@ -10,10 +10,16 @@ class CommonTestCases {
hasType<T>();
}
Future<void> tapItemByKey(String key, {bool shouldPumpAndSettle = true}) async {
Future<void> tapItemByKey(
String key, {
bool shouldPumpAndSettle = true,
int pumpDuration = 100,
}) async {
final widget = find.byKey(ValueKey(key));
await tester.tap(widget);
shouldPumpAndSettle ? await tester.pumpAndSettle() : await tester.pump();
shouldPumpAndSettle
? await tester.pumpAndSettle(Duration(milliseconds: pumpDuration))
: await tester.pump();
}
Future<void> tapItemByFinder(Finder finder, {bool shouldPumpAndSettle = true}) async {
@ -31,6 +37,11 @@ class CommonTestCases {
expect(typeWidget, findsOneWidget);
}
bool isKeyPresent(String key) {
final typeWidget = find.byKey(ValueKey(key));
return typeWidget.tryEvaluate();
}
void hasValueKey(String key) {
final typeWidget = find.byKey(ValueKey(key));
expect(typeWidget, findsOneWidget);
@ -53,33 +64,86 @@ class CommonTestCases {
await tester.pumpAndSettle();
}
Future<void> scrollUntilVisible(String childKey, String parentScrollableKey,
{double delta = 300}) async {
final scrollableWidget = find.descendant(
of: find.byKey(Key(parentScrollableKey)),
Future<void> dragUntilVisible(String childKey, String parentKey) async {
await tester.pumpAndSettle();
final itemFinder = find.byKey(ValueKey(childKey));
final listFinder = find.byKey(ValueKey(parentKey));
// Check if the widget is already in the widget tree
if (tester.any(itemFinder)) {
// Widget is already built and in the tree
tester.printToConsole('Child is already present');
return;
}
// We can adjust this as needed
final maxScrolls = 200;
int scrolls = 0;
bool found = false;
// We start by scrolling down
bool scrollDown = true;
// Flag to check if we've already reversed direction
bool reversedDirection = false;
// Find the Scrollable associated with the Parent Ad
final scrollableFinder = find.descendant(
of: listFinder,
matching: find.byType(Scrollable),
);
final isAlreadyVisibile = isWidgetVisible(find.byKey(ValueKey(childKey)));
if (isAlreadyVisibile) return;
await tester.scrollUntilVisible(
find.byKey(ValueKey(childKey)),
delta,
scrollable: scrollableWidget,
// Ensure that the Scrollable is found
expect(
scrollableFinder,
findsOneWidget,
reason: 'Scrollable descendant of the Parent Widget not found.',
);
}
bool isWidgetVisible(Finder finder) {
try {
final Element element = finder.evaluate().single;
final RenderBox renderBox = element.renderObject as RenderBox;
return renderBox.paintBounds
.shift(renderBox.localToGlobal(Offset.zero))
.overlaps(tester.binding.renderViews.first.paintBounds);
} catch (e) {
return false;
// Get the initial scroll position
final scrollableState = tester.state<ScrollableState>(scrollableFinder);
double previousScrollPosition = scrollableState.position.pixels;
while (!found && scrolls < maxScrolls) {
tester.printToConsole('Scrolling ${scrollDown ? 'down' : 'up'}, attempt $scrolls');
// Perform the drag in the current direction
await tester.drag(
scrollableFinder,
scrollDown ? const Offset(0, -100) : const Offset(0, 100),
);
await tester.pumpAndSettle();
scrolls++;
// Update the scroll position after the drag
final currentScrollPosition = scrollableState.position.pixels;
if (currentScrollPosition == previousScrollPosition) {
// Cannot scroll further in this direction
if (reversedDirection) {
// We've already tried both directions
tester.printToConsole('Cannot scroll further in both directions. Widget not found.');
break;
} else {
// Reverse the scroll direction
scrollDown = !scrollDown;
reversedDirection = true;
tester.printToConsole('Reached the end, reversing direction');
}
} else {
// Continue scrolling in the current direction
previousScrollPosition = currentScrollPosition;
}
// Check if the widget is now in the widget tree
found = tester.any(itemFinder);
}
if (!found) {
tester.printToConsole('Widget not found after scrolling in both directions.');
return;
}
}
@ -91,6 +155,15 @@ class CommonTestCases {
await tester.pumpAndSettle();
}
void findWidgetViaDescendant({
required FinderBase<Element> of,
required FinderBase<Element> matching,
}) {
final textWidget = find.descendant(of: of, matching: matching);
expect(textWidget, findsOneWidget);
}
Future<void> defaultSleepTime({int seconds = 2}) async =>
await Future.delayed(Duration(seconds: seconds));
}

View file

@ -9,5 +9,5 @@ class CommonTestConstants {
static final String testWalletName = 'Integrated Testing Wallet';
static final CryptoCurrency testReceiveCurrency = CryptoCurrency.sol;
static final CryptoCurrency testDepositCurrency = CryptoCurrency.usdtSol;
static final String testWalletAddress = 'An2Y2fsUYKfYvN1zF89GAqR1e6GUMBg3qA83Y5ZWDf8L';
static final String testWalletAddress = '5v9gTW1yWPffhnbNKuvtL2frevAf4HpBMw8oYnfqUjhm';
}

View file

@ -1,41 +1,65 @@
import 'package:flutter/foundation.dart';
import 'package:cake_wallet/entities/seed_type.dart';
import 'package:cake_wallet/reactions/bip39_wallet_utils.dart';
import 'package:cake_wallet/wallet_types.g.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:cake_wallet/.secrets.g.dart' as secrets;
import 'package:cake_wallet/main.dart' as app;
import '../robots/dashboard_page_robot.dart';
import '../robots/disclaimer_page_robot.dart';
import '../robots/new_wallet_page_robot.dart';
import '../robots/new_wallet_type_page_robot.dart';
import '../robots/pre_seed_page_robot.dart';
import '../robots/restore_from_seed_or_key_robot.dart';
import '../robots/restore_options_page_robot.dart';
import '../robots/setup_pin_code_robot.dart';
import '../robots/wallet_group_description_page_robot.dart';
import '../robots/wallet_list_page_robot.dart';
import '../robots/wallet_seed_page_robot.dart';
import '../robots/welcome_page_robot.dart';
import 'common_test_cases.dart';
import 'package:cake_wallet/.secrets.g.dart' as secrets;
import 'common_test_constants.dart';
class CommonTestFlows {
CommonTestFlows(this._tester)
: _commonTestCases = CommonTestCases(_tester),
_welcomePageRobot = WelcomePageRobot(_tester),
_preSeedPageRobot = PreSeedPageRobot(_tester),
_setupPinCodeRobot = SetupPinCodeRobot(_tester),
_dashboardPageRobot = DashboardPageRobot(_tester),
_newWalletPageRobot = NewWalletPageRobot(_tester),
_disclaimerPageRobot = DisclaimerPageRobot(_tester),
_walletSeedPageRobot = WalletSeedPageRobot(_tester),
_walletListPageRobot = WalletListPageRobot(_tester),
_newWalletTypePageRobot = NewWalletTypePageRobot(_tester),
_restoreOptionsPageRobot = RestoreOptionsPageRobot(_tester),
_restoreFromSeedOrKeysPageRobot = RestoreFromSeedOrKeysPageRobot(_tester);
_restoreFromSeedOrKeysPageRobot = RestoreFromSeedOrKeysPageRobot(_tester),
_walletGroupDescriptionPageRobot = WalletGroupDescriptionPageRobot(_tester);
final WidgetTester _tester;
final CommonTestCases _commonTestCases;
final WelcomePageRobot _welcomePageRobot;
final PreSeedPageRobot _preSeedPageRobot;
final SetupPinCodeRobot _setupPinCodeRobot;
final NewWalletPageRobot _newWalletPageRobot;
final DashboardPageRobot _dashboardPageRobot;
final DisclaimerPageRobot _disclaimerPageRobot;
final WalletSeedPageRobot _walletSeedPageRobot;
final WalletListPageRobot _walletListPageRobot;
final NewWalletTypePageRobot _newWalletTypePageRobot;
final RestoreOptionsPageRobot _restoreOptionsPageRobot;
final RestoreFromSeedOrKeysPageRobot _restoreFromSeedOrKeysPageRobot;
final WalletGroupDescriptionPageRobot _walletGroupDescriptionPageRobot;
//* ========== Handles flow to start the app afresh and accept disclaimer =============
Future<void> startAppFlow(Key key) async {
await app.main(topLevelKey: ValueKey('send_flow_test_app_key'));
await _tester.pumpAndSettle();
// --------- Disclaimer Page ------------
@ -46,56 +70,275 @@ class CommonTestFlows {
await _disclaimerPageRobot.tapAcceptButton();
}
Future<void> restoreWalletThroughSeedsFlow() async {
await _welcomeToRestoreFromSeedsPath();
await _restoreFromSeeds();
//* ========== Handles flow from welcome to creating a new wallet ===============
Future<void> welcomePageToCreateNewWalletFlow(
WalletType walletTypeToCreate,
List<int> walletPin,
) async {
await _welcomeToCreateWalletPath(walletTypeToCreate, walletPin);
await _generateNewWalletDetails();
await _confirmPreSeedInfo();
await _confirmWalletDetails();
}
Future<void> restoreWalletThroughKeysFlow() async {
await _welcomeToRestoreFromSeedsPath();
//* ========== Handles flow from welcome to restoring wallet from seeds ===============
Future<void> welcomePageToRestoreWalletThroughSeedsFlow(
WalletType walletTypeToRestore,
String walletSeed,
List<int> walletPin,
) async {
await _welcomeToRestoreFromSeedsOrKeysPath(walletTypeToRestore, walletPin);
await _restoreFromSeeds(walletTypeToRestore, walletSeed);
}
//* ========== Handles flow from welcome to restoring wallet from keys ===============
Future<void> welcomePageToRestoreWalletThroughKeysFlow(
WalletType walletTypeToRestore,
List<int> walletPin,
) async {
await _welcomeToRestoreFromSeedsOrKeysPath(walletTypeToRestore, walletPin);
await _restoreFromKeys();
}
Future<void> _welcomeToRestoreFromSeedsPath() async {
// --------- Welcome Page ---------------
await _welcomePageRobot.navigateToRestoreWalletPage();
//* ========== Handles switching to wallet list or menu from dashboard ===============
Future<void> switchToWalletMenuFromDashboardPage() async {
_tester.printToConsole('Switching to Wallet Menu');
await _dashboardPageRobot.openDrawerMenu();
// ----------- Restore Options Page -----------
// Route to restore from seeds page to continue flow
await _restoreOptionsPageRobot.navigateToRestoreFromSeedsPage();
await _dashboardPageRobot.dashboardMenuWidgetRobot.navigateToWalletMenu();
}
void confirmAllAvailableWalletTypeIconsDisplayCorrectly() {
for (var walletType in availableWalletTypes) {
final imageUrl = walletTypeToCryptoCurrency(walletType).iconPath;
final walletIconFinder = find.image(
Image.asset(
imageUrl!,
width: 32,
height: 32,
).image,
);
expect(walletIconFinder, findsAny);
}
}
//* ========== Handles creating new wallet flow from wallet list/menu ===============
Future<void> createNewWalletFromWalletMenu(WalletType walletTypeToCreate) async {
_tester.printToConsole('Creating ${walletTypeToCreate.name} Wallet');
await _walletListPageRobot.navigateToCreateNewWalletPage();
await _commonTestCases.defaultSleepTime();
await _selectWalletTypeForWallet(walletTypeToCreate);
await _commonTestCases.defaultSleepTime();
// ---- Wallet Group/New Seed Implementation Comes here
await _walletGroupDescriptionPageFlow(true, walletTypeToCreate);
await _generateNewWalletDetails();
await _confirmPreSeedInfo();
await _confirmWalletDetails();
await _commonTestCases.defaultSleepTime();
}
Future<void> _walletGroupDescriptionPageFlow(bool isNewSeed, WalletType walletType) async {
if (!isBIP39Wallet(walletType)) return;
await _walletGroupDescriptionPageRobot.isWalletGroupDescriptionPage();
if (isNewSeed) {
await _walletGroupDescriptionPageRobot.navigateToCreateNewSeedPage();
} else {
await _walletGroupDescriptionPageRobot.navigateToChooseWalletGroup();
}
}
//* ========== Handles restore wallet flow from wallet list/menu ===============
Future<void> restoreWalletFromWalletMenu(WalletType walletType, String walletSeed) async {
_tester.printToConsole('Restoring ${walletType.name} Wallet');
await _walletListPageRobot.navigateToRestoreWalletOptionsPage();
await _commonTestCases.defaultSleepTime();
await _restoreOptionsPageRobot.navigateToRestoreFromSeedsOrKeysPage();
await _commonTestCases.defaultSleepTime();
await _selectWalletTypeForWallet(walletType);
await _commonTestCases.defaultSleepTime();
await _restoreFromSeeds(walletType, walletSeed);
await _commonTestCases.defaultSleepTime();
}
//* ========== Handles setting up pin code for wallet on first install ===============
Future<void> setupPinCodeForWallet(List<int> pin) async {
// ----------- SetupPinCode Page -------------
// Confirm initial defaults - Widgets to be displayed etc
await _setupPinCodeRobot.isSetupPinCodePage();
await _setupPinCodeRobot.enterPinCode(CommonTestConstants.pin, true);
await _setupPinCodeRobot.enterPinCode(CommonTestConstants.pin, false);
await _setupPinCodeRobot.enterPinCode(pin);
await _setupPinCodeRobot.enterPinCode(pin);
await _setupPinCodeRobot.tapSuccessButton();
}
Future<void> _welcomeToCreateWalletPath(
WalletType walletTypeToCreate,
List<int> pin,
) async {
await _welcomePageRobot.navigateToCreateNewWalletPage();
await setupPinCodeForWallet(pin);
await _selectWalletTypeForWallet(walletTypeToCreate);
}
Future<void> _welcomeToRestoreFromSeedsOrKeysPath(
WalletType walletTypeToRestore,
List<int> pin,
) async {
await _welcomePageRobot.navigateToRestoreWalletPage();
await _restoreOptionsPageRobot.navigateToRestoreFromSeedsOrKeysPage();
await setupPinCodeForWallet(pin);
await _selectWalletTypeForWallet(walletTypeToRestore);
}
//* ============ Handles New Wallet Type Page ==================
Future<void> _selectWalletTypeForWallet(WalletType type) async {
// ----------- NewWalletType Page -------------
// Confirm scroll behaviour works properly
await _newWalletTypePageRobot
.findParticularWalletTypeInScrollableList(CommonTestConstants.testWalletType);
await _newWalletTypePageRobot.findParticularWalletTypeInScrollableList(type);
// Select a wallet and route to next page
await _newWalletTypePageRobot.selectWalletType(CommonTestConstants.testWalletType);
await _newWalletTypePageRobot.selectWalletType(type);
await _newWalletTypePageRobot.onNextButtonPressed();
}
Future<void> _restoreFromSeeds() async {
//* ============ Handles New Wallet Page ==================
Future<void> _generateNewWalletDetails() async {
await _newWalletPageRobot.isNewWalletPage();
await _newWalletPageRobot.generateWalletName();
await _newWalletPageRobot.onNextButtonPressed();
}
//* ============ Handles Pre Seed Page =====================
Future<void> _confirmPreSeedInfo() async {
await _preSeedPageRobot.isPreSeedPage();
await _preSeedPageRobot.onConfirmButtonPressed();
}
//* ============ Handles Wallet Seed Page ==================
Future<void> _confirmWalletDetails() async {
await _walletSeedPageRobot.isWalletSeedPage();
_walletSeedPageRobot.confirmWalletDetailsDisplayCorrectly();
_walletSeedPageRobot.confirmWalletSeedReminderDisplays();
await _walletSeedPageRobot.onCopySeedsButtonPressed();
await _walletSeedPageRobot.onNextButtonPressed();
await _walletSeedPageRobot.onConfirmButtonOnSeedAlertDialogPressed();
}
//* Main Restore Actions - On the RestoreFromSeed/Keys Page - Restore from Seeds Action
Future<void> _restoreFromSeeds(WalletType type, String walletSeed) async {
// ----------- RestoreFromSeedOrKeys Page -------------
await _restoreFromSeedOrKeysPageRobot.enterWalletNameText(CommonTestConstants.testWalletName);
await _restoreFromSeedOrKeysPageRobot.enterSeedPhraseForWalletRestore(secrets.solanaTestWalletSeeds);
await _restoreFromSeedOrKeysPageRobot.selectWalletNameFromAvailableOptions();
await _restoreFromSeedOrKeysPageRobot.enterSeedPhraseForWalletRestore(walletSeed);
final numberOfWords = walletSeed.split(' ').length;
if (numberOfWords == 25 && (type == WalletType.monero)) {
await _restoreFromSeedOrKeysPageRobot
.chooseSeedTypeForMoneroOrWowneroWallets(MoneroSeedType.legacy);
// Using a constant value of 2831400 for the blockheight as its the restore blockheight for our testing wallet
await _restoreFromSeedOrKeysPageRobot
.enterBlockHeightForWalletRestore(secrets.moneroTestWalletBlockHeight);
}
await _restoreFromSeedOrKeysPageRobot.onRestoreWalletButtonPressed();
}
//* Main Restore Actions - On the RestoreFromSeed/Keys Page - Restore from Keys Action
Future<void> _restoreFromKeys() async {
await _commonTestCases.swipePage();
await _commonTestCases.defaultSleepTime();
await _restoreFromSeedOrKeysPageRobot.enterWalletNameText(CommonTestConstants.testWalletName);
await _restoreFromSeedOrKeysPageRobot.selectWalletNameFromAvailableOptions(
isSeedFormEntry: false,
);
await _restoreFromSeedOrKeysPageRobot.enterSeedPhraseForWalletRestore('');
await _restoreFromSeedOrKeysPageRobot.onRestoreWalletButtonPressed();
}
//* ====== Utility Function to get test wallet seeds for each wallet type ========
String getWalletSeedsByWalletType(WalletType walletType) {
switch (walletType) {
case WalletType.monero:
return secrets.moneroTestWalletSeeds;
case WalletType.bitcoin:
return secrets.bitcoinTestWalletSeeds;
case WalletType.ethereum:
return secrets.ethereumTestWalletSeeds;
case WalletType.litecoin:
return secrets.litecoinTestWalletSeeds;
case WalletType.bitcoinCash:
return secrets.bitcoinCashTestWalletSeeds;
case WalletType.polygon:
return secrets.polygonTestWalletSeeds;
case WalletType.solana:
return secrets.solanaTestWalletSeeds;
case WalletType.tron:
return secrets.tronTestWalletSeeds;
case WalletType.nano:
return secrets.nanoTestWalletSeeds;
case WalletType.wownero:
return secrets.wowneroTestWalletSeeds;
default:
return '';
}
}
//* ====== Utility Function to get test receive address for each wallet type ========
String getReceiveAddressByWalletType(WalletType walletType) {
switch (walletType) {
case WalletType.monero:
return secrets.moneroTestWalletReceiveAddress;
case WalletType.bitcoin:
return secrets.bitcoinTestWalletReceiveAddress;
case WalletType.ethereum:
return secrets.ethereumTestWalletReceiveAddress;
case WalletType.litecoin:
return secrets.litecoinTestWalletReceiveAddress;
case WalletType.bitcoinCash:
return secrets.bitcoinCashTestWalletReceiveAddress;
case WalletType.polygon:
return secrets.polygonTestWalletReceiveAddress;
case WalletType.solana:
return secrets.solanaTestWalletReceiveAddress;
case WalletType.tron:
return secrets.tronTestWalletReceiveAddress;
case WalletType.nano:
return secrets.nanoTestWalletReceiveAddress;
case WalletType.wownero:
return secrets.wowneroTestWalletReceiveAddress;
default:
return '';
}
}
}

View file

@ -9,6 +9,7 @@ import 'robots/dashboard_page_robot.dart';
import 'robots/exchange_confirm_page_robot.dart';
import 'robots/exchange_page_robot.dart';
import 'robots/exchange_trade_page_robot.dart';
import 'package:cake_wallet/.secrets.g.dart' as secrets;
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
@ -32,7 +33,11 @@ void main() {
await commonTestFlows.startAppFlow(ValueKey('funds_exchange_test_app_key'));
await commonTestFlows.restoreWalletThroughSeedsFlow();
await commonTestFlows.welcomePageToRestoreWalletThroughSeedsFlow(
CommonTestConstants.testWalletType,
secrets.solanaTestWalletSeeds,
CommonTestConstants.pin,
);
// ----------- RestoreFromSeedOrKeys Page -------------
await dashboardPageRobot.navigateToExchangePage();
@ -59,7 +64,7 @@ void main() {
final onAuthPage = authPageRobot.onAuthPage();
if (onAuthPage) {
await authPageRobot.enterPinCode(CommonTestConstants.pin, false);
await authPageRobot.enterPinCode(CommonTestConstants.pin);
}
// ----------- Exchange Confirm Page -------------

View file

@ -0,0 +1,39 @@
import 'package:cake_wallet/src/screens/dashboard/widgets/menu_widget.dart';
import 'package:flutter_test/flutter_test.dart';
import '../components/common_test_cases.dart';
class DashboardMenuWidgetRobot {
DashboardMenuWidgetRobot(this.tester) : commonTestCases = CommonTestCases(tester);
final WidgetTester tester;
late CommonTestCases commonTestCases;
Future<void> hasMenuWidget() async {
commonTestCases.hasType<MenuWidget>();
}
void displaysTheCorrectWalletNameAndSubName() {
final menuWidgetState = tester.state<MenuWidgetState>(find.byType(MenuWidget));
final walletName = menuWidgetState.widget.dashboardViewModel.name;
commonTestCases.hasText(walletName);
final walletSubName = menuWidgetState.widget.dashboardViewModel.subname;
if (walletSubName.isNotEmpty) {
commonTestCases.hasText(walletSubName);
}
}
Future<void> navigateToWalletMenu() async {
await commonTestCases.tapItemByKey('dashboard_page_menu_widget_wallet_menu_button_key');
await commonTestCases.defaultSleepTime();
}
Future<void> navigateToSecurityAndBackupPage() async {
await commonTestCases.tapItemByKey(
'dashboard_page_menu_widget_security_and_backup_button_key',
);
await commonTestCases.defaultSleepTime();
}
}

View file

@ -1,20 +1,44 @@
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/dashboard/dashboard_page.dart';
import 'package:cake_wallet/src/screens/dashboard/pages/balance_page.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:flutter_test/flutter_test.dart';
import '../components/common_test_cases.dart';
import 'dashboard_menu_widget_robot.dart';
class DashboardPageRobot {
DashboardPageRobot(this.tester) : commonTestCases = CommonTestCases(tester);
DashboardPageRobot(this.tester)
: commonTestCases = CommonTestCases(tester),
dashboardMenuWidgetRobot = DashboardMenuWidgetRobot(tester);
final WidgetTester tester;
final DashboardMenuWidgetRobot dashboardMenuWidgetRobot;
late CommonTestCases commonTestCases;
Future<void> isDashboardPage() async {
await commonTestCases.isSpecificPage<DashboardPage>();
}
Future<void> confirmWalletTypeIsDisplayedCorrectly(
WalletType type, {
bool isHaven = false,
}) async {
final cryptoBalanceWidget =
tester.widget<CryptoBalanceWidget>(find.byType(CryptoBalanceWidget));
final hasAccounts = cryptoBalanceWidget.dashboardViewModel.balanceViewModel.hasAccounts;
if (hasAccounts) {
final walletName = cryptoBalanceWidget.dashboardViewModel.name;
commonTestCases.hasText(walletName);
} else {
final walletName = walletTypeToString(type);
final assetName = isHaven ? '$walletName Assets' : walletName;
commonTestCases.hasText(assetName);
}
await commonTestCases.defaultSleepTime(seconds: 5);
}
void confirmServiceUpdateButtonDisplays() {
commonTestCases.hasValueKey('dashboard_page_services_update_button_key');
}
@ -27,30 +51,40 @@ class DashboardPageRobot {
commonTestCases.hasValueKey('dashboard_page_wallet_menu_button_key');
}
Future<void> confirmRightCryptoAssetTitleDisplaysPerPageView(WalletType type,
{bool isHaven = false}) async {
Future<void> confirmRightCryptoAssetTitleDisplaysPerPageView(
WalletType type, {
bool isHaven = false,
}) async {
//Balance Page
final walletName = walletTypeToString(type);
final assetName = isHaven ? '$walletName Assets' : walletName;
commonTestCases.hasText(assetName);
await confirmWalletTypeIsDisplayedCorrectly(type, isHaven: isHaven);
// Swipe to Cake features Page
await commonTestCases.swipeByPageKey(key: 'dashboard_page_view_key', swipeRight: false);
await commonTestCases.defaultSleepTime();
await swipeDashboardTab(false);
commonTestCases.hasText('Cake ${S.current.features}');
// Swipe back to balance
await commonTestCases.swipeByPageKey(key: 'dashboard_page_view_key');
await commonTestCases.defaultSleepTime();
await swipeDashboardTab(true);
// Swipe to Transactions Page
await commonTestCases.swipeByPageKey(key: 'dashboard_page_view_key');
await commonTestCases.defaultSleepTime();
await swipeDashboardTab(true);
commonTestCases.hasText(S.current.transactions);
// Swipe back to balance
await commonTestCases.swipeByPageKey(key: 'dashboard_page_view_key', swipeRight: false);
await commonTestCases.defaultSleepTime(seconds: 5);
await swipeDashboardTab(false);
await commonTestCases.defaultSleepTime(seconds: 3);
}
Future<void> swipeDashboardTab(bool swipeRight) async {
await commonTestCases.swipeByPageKey(
key: 'dashboard_page_view_key',
swipeRight: swipeRight,
);
await commonTestCases.defaultSleepTime();
}
Future<void> openDrawerMenu() async {
await commonTestCases.tapItemByKey('dashboard_page_wallet_menu_button_key');
await commonTestCases.defaultSleepTime();
}
Future<void> navigateToBuyPage() async {

View file

@ -123,7 +123,7 @@ class ExchangePageRobot {
return;
}
await commonTestCases.scrollUntilVisible(
await commonTestCases.dragUntilVisible(
'picker_items_index_${depositCurrency.name}_button_key',
'picker_scrollbar_key',
);
@ -149,7 +149,7 @@ class ExchangePageRobot {
return;
}
await commonTestCases.scrollUntilVisible(
await commonTestCases.dragUntilVisible(
'picker_items_index_${receiveCurrency.name}_button_key',
'picker_scrollbar_key',
);

View file

@ -0,0 +1,35 @@
import 'package:cake_wallet/src/screens/new_wallet/new_wallet_page.dart';
import 'package:flutter_test/flutter_test.dart';
import '../components/common_test_cases.dart';
class NewWalletPageRobot {
NewWalletPageRobot(this.tester) : commonTestCases = CommonTestCases(tester);
final WidgetTester tester;
late CommonTestCases commonTestCases;
Future<void> isNewWalletPage() async {
await commonTestCases.isSpecificPage<NewWalletPage>();
}
Future<void> enterWalletName(String walletName) async {
await commonTestCases.enterText(
walletName,
'new_wallet_page_wallet_name_textformfield_key',
);
await commonTestCases.defaultSleepTime();
}
Future<void> generateWalletName() async {
await commonTestCases.tapItemByKey(
'new_wallet_page_wallet_name_textformfield_generate_name_button_key',
);
await commonTestCases.defaultSleepTime();
}
Future<void> onNextButtonPressed() async {
await commonTestCases.tapItemByKey('new_wallet_page_confirm_button_key');
await commonTestCases.defaultSleepTime();
}
}

View file

@ -24,13 +24,12 @@ class PinCodeWidgetRobot {
commonTestCases.hasValueKey('pin_code_button_0_key');
}
Future<void> pushPinButton(int index) async {
await commonTestCases.tapItemByKey('pin_code_button_${index}_key');
}
Future<void> enterPinCode(List<int> pinCode, bool isFirstEntry) async {
Future<void> enterPinCode(List<int> pinCode, {int pumpDuration = 100}) async {
for (int pin in pinCode) {
await pushPinButton(pin);
await commonTestCases.tapItemByKey(
'pin_code_button_${pin}_key',
pumpDuration: pumpDuration,
);
}
await commonTestCases.defaultSleepTime();

View file

@ -0,0 +1,20 @@
import 'package:cake_wallet/src/screens/seed/pre_seed_page.dart';
import 'package:flutter_test/flutter_test.dart';
import '../components/common_test_cases.dart';
class PreSeedPageRobot {
PreSeedPageRobot(this.tester) : commonTestCases = CommonTestCases(tester);
final WidgetTester tester;
late CommonTestCases commonTestCases;
Future<void> isPreSeedPage() async {
await commonTestCases.isSpecificPage<PreSeedPage>();
}
Future<void> onConfirmButtonPressed() async {
await commonTestCases.tapItemByKey('pre_seed_page_button_key');
await commonTestCases.defaultSleepTime();
}
}

View file

@ -1,3 +1,4 @@
import 'package:cake_wallet/entities/seed_type.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/restore/wallet_restore_page.dart';
import 'package:cake_wallet/src/widgets/validable_annotated_editable_text.dart';
@ -70,6 +71,22 @@ class RestoreFromSeedOrKeysPageRobot {
await tester.pumpAndSettle();
}
Future<void> enterBlockHeightForWalletRestore(String blockHeight) async {
await commonTestCases.enterText(
blockHeight,
'wallet_restore_from_seed_blockheight_textfield_key',
);
await tester.pumpAndSettle();
}
Future<void> chooseSeedTypeForMoneroOrWowneroWallets(MoneroSeedType selectedType) async {
await commonTestCases.tapItemByKey('wallet_restore_from_seed_seedtype_picker_button_key');
await commonTestCases.defaultSleepTime();
await commonTestCases.tapItemByKey('picker_items_index_${selectedType.title}_button_key');
}
Future<void> onPasteSeedPhraseButtonPressed() async {
await commonTestCases.tapItemByKey('wallet_restore_from_seed_wallet_seeds_paste_button_key');
}

View file

@ -14,14 +14,14 @@ class RestoreOptionsPageRobot {
}
void hasRestoreOptionsButton() {
commonTestCases.hasValueKey('restore_options_from_seeds_button_key');
commonTestCases.hasValueKey('restore_options_from_seeds_or_keys_button_key');
commonTestCases.hasValueKey('restore_options_from_backup_button_key');
commonTestCases.hasValueKey('restore_options_from_hardware_wallet_button_key');
commonTestCases.hasValueKey('restore_options_from_qr_button_key');
}
Future<void> navigateToRestoreFromSeedsPage() async {
await commonTestCases.tapItemByKey('restore_options_from_seeds_button_key');
Future<void> navigateToRestoreFromSeedsOrKeysPage() async {
await commonTestCases.tapItemByKey('restore_options_from_seeds_or_keys_button_key');
await commonTestCases.defaultSleepTime();
}

View file

@ -0,0 +1,24 @@
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/settings/security_backup_page.dart';
import 'package:flutter_test/flutter_test.dart';
import '../components/common_test_cases.dart';
class SecurityAndBackupPageRobot {
SecurityAndBackupPageRobot(this.tester) : commonTestCases = CommonTestCases(tester);
final WidgetTester tester;
final CommonTestCases commonTestCases;
Future<void> isSecurityAndBackupPage() async {
await commonTestCases.isSpecificPage<SecurityBackupPage>();
}
void hasTitle() {
commonTestCases.hasText(S.current.security_and_backup);
}
Future<void> navigateToShowKeysPage() async {
await commonTestCases.tapItemByKey('security_backup_page_show_keys_button_key');
}
}

View file

@ -84,7 +84,7 @@ class SendPageRobot {
return;
}
await commonTestCases.scrollUntilVisible(
await commonTestCases.dragUntilVisible(
'picker_items_index_${receiveCurrency.name}_button_key',
'picker_scrollbar_key',
);
@ -117,7 +117,7 @@ class SendPageRobot {
return;
}
await commonTestCases.scrollUntilVisible(
await commonTestCases.dragUntilVisible(
'picker_items_index_${priority.title}_button_key',
'picker_scrollbar_key',
);
@ -198,7 +198,7 @@ class SendPageRobot {
tester.printToConsole('Starting inner _handleAuth loop checks');
try {
await authPageRobot.enterPinCode(CommonTestConstants.pin, false);
await authPageRobot.enterPinCode(CommonTestConstants.pin, pumpDuration: 500);
tester.printToConsole('Auth done');
await tester.pump();
@ -213,6 +213,7 @@ class SendPageRobot {
}
Future<void> handleSendResult() async {
await tester.pump();
tester.printToConsole('Inside handle function');
bool hasError = false;
@ -287,6 +288,8 @@ class SendPageRobot {
// Loop to wait for the operation to commit transaction
await _waitForCommitTransactionCompletion();
await tester.pump();
await commonTestCases.defaultSleepTime(seconds: 4);
} else {
await commonTestCases.defaultSleepTime();

View file

@ -0,0 +1,286 @@
import 'dart:async';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/dashboard/pages/transactions_page.dart';
import 'package:cake_wallet/utils/date_formatter.dart';
import 'package:cake_wallet/view_model/dashboard/action_list_item.dart';
import 'package:cake_wallet/view_model/dashboard/anonpay_transaction_list_item.dart';
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
import 'package:cake_wallet/view_model/dashboard/date_section_item.dart';
import 'package:cake_wallet/view_model/dashboard/order_list_item.dart';
import 'package:cake_wallet/view_model/dashboard/trade_list_item.dart';
import 'package:cake_wallet/view_model/dashboard/transaction_list_item.dart';
import 'package:cw_core/crypto_currency.dart';
import 'package:cw_core/sync_status.dart';
import 'package:cw_core/transaction_direction.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:intl/intl.dart';
import '../components/common_test_cases.dart';
class TransactionsPageRobot {
TransactionsPageRobot(this.tester) : commonTestCases = CommonTestCases(tester);
final WidgetTester tester;
late CommonTestCases commonTestCases;
Future<void> isTransactionsPage() async {
await commonTestCases.isSpecificPage<TransactionsPage>();
}
Future<void> confirmTransactionsPageConstantsDisplayProperly() async {
await commonTestCases.defaultSleepTime();
final transactionsPage = tester.widget<TransactionsPage>(find.byType(TransactionsPage));
final dashboardViewModel = transactionsPage.dashboardViewModel;
if (dashboardViewModel.status is SyncingSyncStatus) {
commonTestCases.hasValueKey('transactions_page_syncing_alert_card_key');
commonTestCases.hasText(S.current.syncing_wallet_alert_title);
commonTestCases.hasText(S.current.syncing_wallet_alert_content);
}
commonTestCases.hasValueKey('transactions_page_header_row_key');
commonTestCases.hasText(S.current.transactions);
commonTestCases.hasValueKey('transactions_page_header_row_transaction_filter_button_key');
}
Future<void> confirmTransactionHistoryListDisplaysCorrectly(bool hasTxHistoryWhileSyncing) async {
// Retrieve the TransactionsPage widget and its DashboardViewModel
final transactionsPage = tester.widget<TransactionsPage>(find.byType(TransactionsPage));
final dashboardViewModel = transactionsPage.dashboardViewModel;
// Define a timeout to prevent infinite loops
// Putting at one hour for cases like monero that takes time to sync
final timeout = Duration(hours: 1);
final pollingInterval = Duration(seconds: 2);
final endTime = DateTime.now().add(timeout);
while (DateTime.now().isBefore(endTime)) {
final isSynced = dashboardViewModel.status is SyncedSyncStatus;
final itemsLoaded = dashboardViewModel.items.isNotEmpty;
// Perform item checks if items are loaded
if (itemsLoaded) {
await _performItemChecks(dashboardViewModel);
} else {
// Verify placeholder when items are not loaded
_verifyPlaceholder();
}
// Determine if we should exit the loop
if (_shouldExitLoop(hasTxHistoryWhileSyncing, isSynced, itemsLoaded)) {
break;
}
// Pump the UI and wait for the next polling interval
await tester.pump(pollingInterval);
}
// After the loop, verify that both status is synced and items are loaded
if (!_isFinalStateValid(dashboardViewModel)) {
throw TimeoutException('Dashboard did not sync and load items within the allotted time.');
}
}
bool _shouldExitLoop(bool hasTxHistoryWhileSyncing, bool isSynced, bool itemsLoaded) {
if (hasTxHistoryWhileSyncing) {
// When hasTxHistoryWhileSyncing is true, exit when status is synced
return isSynced;
} else {
// When hasTxHistoryWhileSyncing is false, exit when status is synced and items are loaded
return isSynced && itemsLoaded;
}
}
void _verifyPlaceholder() {
commonTestCases.hasValueKey('transactions_page_placeholder_transactions_text_key');
commonTestCases.hasText(S.current.placeholder_transactions);
}
bool _isFinalStateValid(DashboardViewModel dashboardViewModel) {
final isSynced = dashboardViewModel.status is SyncedSyncStatus;
final itemsLoaded = dashboardViewModel.items.isNotEmpty;
return isSynced && itemsLoaded;
}
Future<void> _performItemChecks(DashboardViewModel dashboardViewModel) async {
List<ActionListItem> items = dashboardViewModel.items;
for (var item in items) {
final keyId = (item.key as ValueKey<String>).value;
tester.printToConsole('\n');
tester.printToConsole(keyId);
await commonTestCases.dragUntilVisible(keyId, 'transactions_page_list_view_builder_key');
await tester.pump();
final isWidgetVisible = tester.any(find.byKey(ValueKey(keyId)));
if (!isWidgetVisible) {
tester.printToConsole('Moving to next visible item on list');
continue;
}
;
await tester.pump();
if (item is DateSectionItem) {
await _verifyDateSectionItem(item);
} else if (item is TransactionListItem) {
tester.printToConsole(item.formattedTitle);
tester.printToConsole(item.formattedFiatAmount);
tester.printToConsole('\n');
await _verifyTransactionListItemDisplay(item, dashboardViewModel);
} else if (item is AnonpayTransactionListItem) {
await _verifyAnonpayTransactionListItemDisplay(item);
} else if (item is TradeListItem) {
await _verifyTradeListItemDisplay(item);
} else if (item is OrderListItem) {
await _verifyOrderListItemDisplay(item);
}
}
}
Future<void> _verifyDateSectionItem(DateSectionItem item) async {
final title = DateFormatter.convertDateTimeToReadableString(item.date);
tester.printToConsole(title);
await tester.pump();
commonTestCases.findWidgetViaDescendant(
of: find.byKey(item.key),
matching: find.text(title),
);
}
Future<void> _verifyTransactionListItemDisplay(
TransactionListItem item,
DashboardViewModel dashboardViewModel,
) async {
final keyId =
'${dashboardViewModel.type.name}_transaction_history_item_${item.transaction.id}_key';
if (item.hasTokens && item.assetOfTransaction == null) return;
//* ==============Confirm it has the right key for this item ========
commonTestCases.hasValueKey(keyId);
//* ======Confirm it displays the properly formatted amount==========
commonTestCases.findWidgetViaDescendant(
of: find.byKey(ValueKey(keyId)),
matching: find.text(item.formattedCryptoAmount),
);
//* ======Confirm it displays the properly formatted title===========
final transactionType = dashboardViewModel.getTransactionType(item.transaction);
final title = item.formattedTitle + item.formattedStatus + transactionType;
commonTestCases.findWidgetViaDescendant(
of: find.byKey(ValueKey(keyId)),
matching: find.text(title),
);
//* ======Confirm it displays the properly formatted date============
final formattedDate = DateFormat('HH:mm').format(item.transaction.date);
commonTestCases.findWidgetViaDescendant(
of: find.byKey(ValueKey(keyId)),
matching: find.text(formattedDate),
);
//* ======Confirm it displays the properly formatted fiat amount=====
final formattedFiatAmount =
dashboardViewModel.balanceViewModel.isFiatDisabled ? '' : item.formattedFiatAmount;
if (formattedFiatAmount.isNotEmpty) {
commonTestCases.findWidgetViaDescendant(
of: find.byKey(ValueKey(keyId)),
matching: find.text(formattedFiatAmount),
);
}
//* ======Confirm it displays the right image based on the transaction direction=====
final imageToUse = item.transaction.direction == TransactionDirection.incoming
? 'assets/images/down_arrow.png'
: 'assets/images/up_arrow.png';
find.widgetWithImage(Container, AssetImage(imageToUse));
}
Future<void> _verifyAnonpayTransactionListItemDisplay(AnonpayTransactionListItem item) async {
final keyId = 'anonpay_invoice_transaction_list_item_${item.transaction.invoiceId}_key';
//* ==============Confirm it has the right key for this item ========
commonTestCases.hasValueKey(keyId);
//* ==============Confirm it displays the correct provider =========================
commonTestCases.hasText(item.transaction.provider);
//* ===========Confirm it displays the properly formatted amount with currency ========
final currency = item.transaction.fiatAmount != null
? item.transaction.fiatEquiv ?? ''
: CryptoCurrency.fromFullName(item.transaction.coinTo).name.toUpperCase();
final amount =
item.transaction.fiatAmount?.toString() ?? (item.transaction.amountTo?.toString() ?? '');
final amountCurrencyText = amount + ' ' + currency;
commonTestCases.hasText(amountCurrencyText);
//* ======Confirm it displays the properly formatted date=================
final formattedDate = DateFormat('HH:mm').format(item.transaction.createdAt);
commonTestCases.hasText(formattedDate);
//* ===============Confirm it displays the right image====================
find.widgetWithImage(ClipRRect, AssetImage('assets/images/trocador.png'));
}
Future<void> _verifyTradeListItemDisplay(TradeListItem item) async {
final keyId = 'trade_list_item_${item.trade.id}_key';
//* ==============Confirm it has the right key for this item ========
commonTestCases.hasValueKey(keyId);
//* ==============Confirm it displays the correct provider =========================
final conversionFlow = '${item.trade.from.toString()}${item.trade.to.toString()}';
commonTestCases.hasText(conversionFlow);
//* ===========Confirm it displays the properly formatted amount with its crypto tag ========
final amountCryptoText = item.tradeFormattedAmount + ' ' + item.trade.from.toString();
commonTestCases.hasText(amountCryptoText);
//* ======Confirm it displays the properly formatted date=================
final createdAtFormattedDate =
item.trade.createdAt != null ? DateFormat('HH:mm').format(item.trade.createdAt!) : null;
if (createdAtFormattedDate != null) {
commonTestCases.hasText(createdAtFormattedDate);
}
//* ===============Confirm it displays the right image====================
commonTestCases.hasValueKey(item.trade.provider.image);
}
Future<void> _verifyOrderListItemDisplay(OrderListItem item) async {
final keyId = 'order_list_item_${item.order.id}_key';
//* ==============Confirm it has the right key for this item ========
commonTestCases.hasValueKey(keyId);
//* ==============Confirm it displays the correct provider =========================
final orderFlow = '${item.order.from!}${item.order.to}';
commonTestCases.hasText(orderFlow);
//* ===========Confirm it displays the properly formatted amount with its crypto tag ========
final amountCryptoText = item.orderFormattedAmount + ' ' + item.order.to!;
commonTestCases.hasText(amountCryptoText);
//* ======Confirm it displays the properly formatted date=================
final createdAtFormattedDate = DateFormat('HH:mm').format(item.order.createdAt);
commonTestCases.hasText(createdAtFormattedDate);
}
}

View file

@ -0,0 +1,32 @@
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/new_wallet/wallet_group_description_page.dart';
import 'package:flutter_test/flutter_test.dart';
import '../components/common_test_cases.dart';
class WalletGroupDescriptionPageRobot {
WalletGroupDescriptionPageRobot(this.tester) : commonTestCases = CommonTestCases(tester);
final WidgetTester tester;
final CommonTestCases commonTestCases;
Future<void> isWalletGroupDescriptionPage() async {
await commonTestCases.isSpecificPage<WalletGroupDescriptionPage>();
}
void hasTitle() {
commonTestCases.hasText(S.current.wallet_group);
}
Future<void> navigateToCreateNewSeedPage() async {
await commonTestCases.tapItemByKey(
'wallet_group_description_page_create_new_seed_button_key',
);
}
Future<void> navigateToChooseWalletGroup() async {
await commonTestCases.tapItemByKey(
'wallet_group_description_page_choose_wallet_group_button_key',
);
}
}

View file

@ -0,0 +1,162 @@
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/reactions/wallet_connect.dart';
import 'package:cake_wallet/src/screens/wallet_keys/wallet_keys_page.dart';
import 'package:cake_wallet/store/app_store.dart';
import 'package:cw_core/monero_wallet_keys.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:cw_monero/monero_wallet.dart';
import 'package:cw_wownero/wownero_wallet.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:polyseed/polyseed.dart';
import '../components/common_test_cases.dart';
class WalletKeysAndSeedPageRobot {
WalletKeysAndSeedPageRobot(this.tester) : commonTestCases = CommonTestCases(tester);
final WidgetTester tester;
final CommonTestCases commonTestCases;
Future<void> isWalletKeysAndSeedPage() async {
await commonTestCases.isSpecificPage<WalletKeysPage>();
}
void hasTitle() {
final walletKeysPage = tester.widget<WalletKeysPage>(find.byType(WalletKeysPage));
final walletKeysViewModel = walletKeysPage.walletKeysViewModel;
commonTestCases.hasText(walletKeysViewModel.title);
}
void hasShareWarning() {
commonTestCases.hasText(S.current.do_not_share_warning_text.toUpperCase());
}
Future<void> confirmWalletCredentials(WalletType walletType) async {
final walletKeysPage = tester.widget<WalletKeysPage>(find.byType(WalletKeysPage));
final walletKeysViewModel = walletKeysPage.walletKeysViewModel;
final appStore = walletKeysViewModel.appStore;
final walletName = walletType.name;
bool hasSeed = appStore.wallet!.seed != null;
bool hasHexSeed = appStore.wallet!.hexSeed != null;
bool hasPrivateKey = appStore.wallet!.privateKey != null;
if (walletType == WalletType.monero) {
final moneroWallet = appStore.wallet as MoneroWallet;
final lang = PolyseedLang.getByPhrase(moneroWallet.seed);
final legacySeed = moneroWallet.seedLegacy(lang.nameEnglish);
_confirmMoneroWalletCredentials(
appStore,
walletName,
moneroWallet.seed,
legacySeed,
);
}
if (walletType == WalletType.wownero) {
final wowneroWallet = appStore.wallet as WowneroWallet;
final lang = PolyseedLang.getByPhrase(wowneroWallet.seed);
final legacySeed = wowneroWallet.seedLegacy(lang.nameEnglish);
_confirmMoneroWalletCredentials(
appStore,
walletName,
wowneroWallet.seed,
legacySeed,
);
}
if (walletType == WalletType.bitcoin ||
walletType == WalletType.litecoin ||
walletType == WalletType.bitcoinCash) {
commonTestCases.hasText(appStore.wallet!.seed!);
tester.printToConsole('$walletName wallet has seeds properly displayed');
}
if (isEVMCompatibleChain(walletType) ||
walletType == WalletType.solana ||
walletType == WalletType.tron) {
if (hasSeed) {
commonTestCases.hasText(appStore.wallet!.seed!);
tester.printToConsole('$walletName wallet has seeds properly displayed');
}
if (hasPrivateKey) {
commonTestCases.hasText(appStore.wallet!.privateKey!);
tester.printToConsole('$walletName wallet has private key properly displayed');
}
}
if (walletType == WalletType.nano || walletType == WalletType.banano) {
if (hasSeed) {
commonTestCases.hasText(appStore.wallet!.seed!);
tester.printToConsole('$walletName wallet has seeds properly displayed');
}
if (hasHexSeed) {
commonTestCases.hasText(appStore.wallet!.hexSeed!);
tester.printToConsole('$walletName wallet has hexSeed properly displayed');
}
if (hasPrivateKey) {
commonTestCases.hasText(appStore.wallet!.privateKey!);
tester.printToConsole('$walletName wallet has private key properly displayed');
}
}
await commonTestCases.defaultSleepTime(seconds: 5);
}
void _confirmMoneroWalletCredentials(
AppStore appStore,
String walletName,
String seed,
String legacySeed,
) {
final keys = appStore.wallet!.keys as MoneroWalletKeys;
final hasPublicSpendKey = commonTestCases.isKeyPresent(
'${walletName}_wallet_public_spend_key_item_key',
);
final hasPrivateSpendKey = commonTestCases.isKeyPresent(
'${walletName}_wallet_private_spend_key_item_key',
);
final hasPublicViewKey = commonTestCases.isKeyPresent(
'${walletName}_wallet_public_view_key_item_key',
);
final hasPrivateViewKey = commonTestCases.isKeyPresent(
'${walletName}_wallet_private_view_key_item_key',
);
final hasSeeds = seed.isNotEmpty;
final hasSeedLegacy = Polyseed.isValidSeed(seed);
if (hasPublicSpendKey) {
commonTestCases.hasText(keys.publicSpendKey);
tester.printToConsole('$walletName wallet has public spend key properly displayed');
}
if (hasPrivateSpendKey) {
commonTestCases.hasText(keys.privateSpendKey);
tester.printToConsole('$walletName wallet has private spend key properly displayed');
}
if (hasPublicViewKey) {
commonTestCases.hasText(keys.publicViewKey);
tester.printToConsole('$walletName wallet has public view key properly displayed');
}
if (hasPrivateViewKey) {
commonTestCases.hasText(keys.privateViewKey);
tester.printToConsole('$walletName wallet has private view key properly displayed');
}
if (hasSeeds) {
commonTestCases.hasText(seed);
tester.printToConsole('$walletName wallet has seeds properly displayed');
}
if (hasSeedLegacy) {
commonTestCases.hasText(legacySeed);
tester.printToConsole('$walletName wallet has legacy seeds properly displayed');
}
}
Future<void> backToDashboard() async {
tester.printToConsole('Going back to dashboard from credentials page');
await commonTestCases.goBack();
await commonTestCases.goBack();
}
}

View file

@ -0,0 +1,27 @@
import 'package:cake_wallet/generated/i18n.dart';
import 'package:flutter_test/flutter_test.dart';
import '../components/common_test_cases.dart';
class WalletListPageRobot {
WalletListPageRobot(this.tester) : commonTestCases = CommonTestCases(tester);
final WidgetTester tester;
late CommonTestCases commonTestCases;
Future<void> isWalletListPage() async {
await commonTestCases.isSpecificPage<WalletListPageRobot>();
}
void displaysCorrectTitle() {
commonTestCases.hasText(S.current.wallets);
}
Future<void> navigateToCreateNewWalletPage() async {
commonTestCases.tapItemByKey('wallet_list_page_create_new_wallet_button_key');
}
Future<void> navigateToRestoreWalletOptionsPage() async {
commonTestCases.tapItemByKey('wallet_list_page_restore_wallet_button_key');
}
}

View file

@ -0,0 +1,57 @@
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/seed/wallet_seed_page.dart';
import 'package:flutter_test/flutter_test.dart';
import '../components/common_test_cases.dart';
class WalletSeedPageRobot {
WalletSeedPageRobot(this.tester) : commonTestCases = CommonTestCases(tester);
final WidgetTester tester;
late CommonTestCases commonTestCases;
Future<void> isWalletSeedPage() async {
await commonTestCases.isSpecificPage<WalletSeedPage>();
}
Future<void> onNextButtonPressed() async {
await commonTestCases.tapItemByKey('wallet_seed_page_next_button_key');
await commonTestCases.defaultSleepTime();
}
Future<void> onConfirmButtonOnSeedAlertDialogPressed() async {
await commonTestCases.tapItemByKey('wallet_seed_page_seed_alert_confirm_button_key');
await commonTestCases.defaultSleepTime();
}
Future<void> onBackButtonOnSeedAlertDialogPressed() async {
await commonTestCases.tapItemByKey('wallet_seed_page_seed_alert_back_button_key');
await commonTestCases.defaultSleepTime();
}
void confirmWalletDetailsDisplayCorrectly() {
final walletSeedPage = tester.widget<WalletSeedPage>(find.byType(WalletSeedPage));
final walletSeedViewModel = walletSeedPage.walletSeedViewModel;
final walletName = walletSeedViewModel.name;
final walletSeeds = walletSeedViewModel.seed;
commonTestCases.hasText(walletName);
commonTestCases.hasText(walletSeeds);
}
void confirmWalletSeedReminderDisplays() {
commonTestCases.hasText(S.current.seed_reminder);
}
Future<void> onSaveSeedsButtonPressed() async {
await commonTestCases.tapItemByKey('wallet_seed_page_save_seeds_button_key');
await commonTestCases.defaultSleepTime();
}
Future<void> onCopySeedsButtonPressed() async {
await commonTestCases.tapItemByKey('wallet_seed_page_copy_seeds_button_key');
await commonTestCases.defaultSleepTime();
}
}

View file

@ -0,0 +1,107 @@
import 'package:cake_wallet/wallet_types.g.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import '../components/common_test_constants.dart';
import '../components/common_test_flows.dart';
import '../robots/auth_page_robot.dart';
import '../robots/dashboard_page_robot.dart';
import '../robots/security_and_backup_page_robot.dart';
import '../robots/wallet_keys_robot.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
AuthPageRobot authPageRobot;
CommonTestFlows commonTestFlows;
DashboardPageRobot dashboardPageRobot;
WalletKeysAndSeedPageRobot walletKeysAndSeedPageRobot;
SecurityAndBackupPageRobot securityAndBackupPageRobot;
testWidgets(
'Confirm if the seeds display properly',
(tester) async {
authPageRobot = AuthPageRobot(tester);
commonTestFlows = CommonTestFlows(tester);
dashboardPageRobot = DashboardPageRobot(tester);
walletKeysAndSeedPageRobot = WalletKeysAndSeedPageRobot(tester);
securityAndBackupPageRobot = SecurityAndBackupPageRobot(tester);
// Start the app
await commonTestFlows.startAppFlow(
ValueKey('confirm_creds_display_correctly_flow_app_key'),
);
await commonTestFlows.welcomePageToCreateNewWalletFlow(
WalletType.solana,
CommonTestConstants.pin,
);
await dashboardPageRobot.confirmWalletTypeIsDisplayedCorrectly(WalletType.solana);
await _confirmSeedsFlowForWalletType(
WalletType.solana,
authPageRobot,
dashboardPageRobot,
securityAndBackupPageRobot,
walletKeysAndSeedPageRobot,
tester,
);
// Do the same for other available wallet types
for (var walletType in availableWalletTypes) {
if (walletType == WalletType.solana) {
continue;
}
await commonTestFlows.switchToWalletMenuFromDashboardPage();
await commonTestFlows.createNewWalletFromWalletMenu(walletType);
await dashboardPageRobot.confirmWalletTypeIsDisplayedCorrectly(walletType);
await _confirmSeedsFlowForWalletType(
walletType,
authPageRobot,
dashboardPageRobot,
securityAndBackupPageRobot,
walletKeysAndSeedPageRobot,
tester,
);
}
await Future.delayed(Duration(seconds: 15));
},
);
}
Future<void> _confirmSeedsFlowForWalletType(
WalletType walletType,
AuthPageRobot authPageRobot,
DashboardPageRobot dashboardPageRobot,
SecurityAndBackupPageRobot securityAndBackupPageRobot,
WalletKeysAndSeedPageRobot walletKeysAndSeedPageRobot,
WidgetTester tester,
) async {
await dashboardPageRobot.openDrawerMenu();
await dashboardPageRobot.dashboardMenuWidgetRobot.navigateToSecurityAndBackupPage();
await securityAndBackupPageRobot.navigateToShowKeysPage();
final onAuthPage = authPageRobot.onAuthPage();
if (onAuthPage) {
await authPageRobot.enterPinCode(CommonTestConstants.pin);
}
await tester.pumpAndSettle();
await walletKeysAndSeedPageRobot.isWalletKeysAndSeedPage();
walletKeysAndSeedPageRobot.hasTitle();
walletKeysAndSeedPageRobot.hasShareWarning();
walletKeysAndSeedPageRobot.confirmWalletCredentials(walletType);
await walletKeysAndSeedPageRobot.backToDashboard();
}

View file

@ -0,0 +1,57 @@
import 'package:cake_wallet/wallet_types.g.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import '../components/common_test_constants.dart';
import '../components/common_test_flows.dart';
import '../robots/dashboard_page_robot.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
CommonTestFlows commonTestFlows;
DashboardPageRobot dashboardPageRobot;
testWidgets(
'Create Wallet Flow',
(tester) async {
commonTestFlows = CommonTestFlows(tester);
dashboardPageRobot = DashboardPageRobot(tester);
// Start the app
await commonTestFlows.startAppFlow(
ValueKey('create_wallets_through_seeds_test_app_key'),
);
await commonTestFlows.welcomePageToCreateNewWalletFlow(
WalletType.solana,
CommonTestConstants.pin,
);
// Confirm it actually restores a solana wallet
await dashboardPageRobot.confirmWalletTypeIsDisplayedCorrectly(WalletType.solana);
// Do the same for other available wallet types
for (var walletType in availableWalletTypes) {
if (walletType == WalletType.solana) {
continue;
}
await commonTestFlows.switchToWalletMenuFromDashboardPage();
await commonTestFlows.createNewWalletFromWalletMenu(walletType);
await dashboardPageRobot.confirmWalletTypeIsDisplayedCorrectly(walletType);
}
// Goes to the wallet menu and provides a confirmation that all the wallets were correctly restored
await commonTestFlows.switchToWalletMenuFromDashboardPage();
commonTestFlows.confirmAllAvailableWalletTypeIconsDisplayCorrectly();
await Future.delayed(Duration(seconds: 5));
},
);
}

View file

@ -9,6 +9,7 @@ import '../robots/dashboard_page_robot.dart';
import '../robots/exchange_confirm_page_robot.dart';
import '../robots/exchange_page_robot.dart';
import '../robots/exchange_trade_page_robot.dart';
import 'package:cake_wallet/.secrets.g.dart' as secrets;
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
@ -20,40 +21,42 @@ void main() {
ExchangeTradePageRobot exchangeTradePageRobot;
ExchangeConfirmPageRobot exchangeConfirmPageRobot;
group('Exchange Flow Tests', () {
testWidgets('Exchange flow', (tester) async {
authPageRobot = AuthPageRobot(tester);
commonTestFlows = CommonTestFlows(tester);
exchangePageRobot = ExchangePageRobot(tester);
dashboardPageRobot = DashboardPageRobot(tester);
exchangeTradePageRobot = ExchangeTradePageRobot(tester);
exchangeConfirmPageRobot = ExchangeConfirmPageRobot(tester);
testWidgets('Exchange flow', (tester) async {
authPageRobot = AuthPageRobot(tester);
commonTestFlows = CommonTestFlows(tester);
exchangePageRobot = ExchangePageRobot(tester);
dashboardPageRobot = DashboardPageRobot(tester);
exchangeTradePageRobot = ExchangeTradePageRobot(tester);
exchangeConfirmPageRobot = ExchangeConfirmPageRobot(tester);
await commonTestFlows.startAppFlow(ValueKey('exchange_app_test_key'));
await commonTestFlows.restoreWalletThroughSeedsFlow();
await dashboardPageRobot.navigateToExchangePage();
await commonTestFlows.startAppFlow(ValueKey('exchange_app_test_key'));
await commonTestFlows.welcomePageToRestoreWalletThroughSeedsFlow(
CommonTestConstants.testWalletType,
secrets.solanaTestWalletSeeds,
CommonTestConstants.pin,
);
await dashboardPageRobot.navigateToExchangePage();
// ----------- Exchange Page -------------
await exchangePageRobot.selectDepositCurrency(CommonTestConstants.testDepositCurrency);
await exchangePageRobot.selectReceiveCurrency(CommonTestConstants.testReceiveCurrency);
// ----------- Exchange Page -------------
await exchangePageRobot.selectDepositCurrency(CommonTestConstants.testDepositCurrency);
await exchangePageRobot.selectReceiveCurrency(CommonTestConstants.testReceiveCurrency);
await exchangePageRobot.enterDepositAmount(CommonTestConstants.exchangeTestAmount);
await exchangePageRobot.enterDepositRefundAddress(
depositAddress: CommonTestConstants.testWalletAddress,
);
await exchangePageRobot.enterReceiveAddress(CommonTestConstants.testWalletAddress);
await exchangePageRobot.onExchangeButtonPressed();
await exchangePageRobot.enterDepositAmount(CommonTestConstants.exchangeTestAmount);
await exchangePageRobot.enterDepositRefundAddress(
depositAddress: CommonTestConstants.testWalletAddress,
);
await exchangePageRobot.enterReceiveAddress(CommonTestConstants.testWalletAddress);
await exchangePageRobot.handleErrors(CommonTestConstants.exchangeTestAmount);
await exchangePageRobot.onExchangeButtonPressed();
final onAuthPage = authPageRobot.onAuthPage();
if (onAuthPage) {
await authPageRobot.enterPinCode(CommonTestConstants.pin, false);
}
await exchangePageRobot.handleErrors(CommonTestConstants.exchangeTestAmount);
await exchangeConfirmPageRobot.onSavedTradeIdButtonPressed();
await exchangeTradePageRobot.onGotItButtonPressed();
});
final onAuthPage = authPageRobot.onAuthPage();
if (onAuthPage) {
await authPageRobot.enterPinCode(CommonTestConstants.pin);
}
await exchangeConfirmPageRobot.onSavedTradeIdButtonPressed();
await exchangeTradePageRobot.onGotItButtonPressed();
});
}

View file

@ -0,0 +1,63 @@
import 'package:cake_wallet/wallet_types.g.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import '../components/common_test_constants.dart';
import '../components/common_test_flows.dart';
import '../robots/dashboard_page_robot.dart';
import 'package:cake_wallet/.secrets.g.dart' as secrets;
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
CommonTestFlows commonTestFlows;
DashboardPageRobot dashboardPageRobot;
testWidgets(
'Restoring Wallets Through Seeds',
(tester) async {
commonTestFlows = CommonTestFlows(tester);
dashboardPageRobot = DashboardPageRobot(tester);
// Start the app
await commonTestFlows.startAppFlow(
ValueKey('restore_wallets_through_seeds_test_app_key'),
);
// Restore the first wallet type: Solana
await commonTestFlows.welcomePageToRestoreWalletThroughSeedsFlow(
WalletType.solana,
secrets.solanaTestWalletSeeds,
CommonTestConstants.pin,
);
// Confirm it actually restores a solana wallet
await dashboardPageRobot.confirmWalletTypeIsDisplayedCorrectly(WalletType.solana);
// Do the same for other available wallet types
for (var walletType in availableWalletTypes) {
if (walletType == WalletType.solana) {
continue;
}
await commonTestFlows.switchToWalletMenuFromDashboardPage();
await commonTestFlows.restoreWalletFromWalletMenu(
walletType,
commonTestFlows.getWalletSeedsByWalletType(walletType),
);
await dashboardPageRobot.confirmWalletTypeIsDisplayedCorrectly(walletType);
}
// Goes to the wallet menu and provides a visual confirmation that all the wallets were correctly restored
await commonTestFlows.switchToWalletMenuFromDashboardPage();
commonTestFlows.confirmAllAvailableWalletTypeIconsDisplayCorrectly();
await Future.delayed(Duration(seconds: 5));
},
);
}

View file

@ -6,6 +6,7 @@ import '../components/common_test_constants.dart';
import '../components/common_test_flows.dart';
import '../robots/dashboard_page_robot.dart';
import '../robots/send_page_robot.dart';
import 'package:cake_wallet/.secrets.g.dart' as secrets;
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
@ -14,28 +15,30 @@ void main() {
CommonTestFlows commonTestFlows;
DashboardPageRobot dashboardPageRobot;
group('Send Flow Tests', () {
testWidgets('Send flow', (tester) async {
commonTestFlows = CommonTestFlows(tester);
sendPageRobot = SendPageRobot(tester: tester);
dashboardPageRobot = DashboardPageRobot(tester);
testWidgets('Send flow', (tester) async {
commonTestFlows = CommonTestFlows(tester);
sendPageRobot = SendPageRobot(tester: tester);
dashboardPageRobot = DashboardPageRobot(tester);
await commonTestFlows.startAppFlow(ValueKey('send_test_app_key'));
await commonTestFlows.restoreWalletThroughSeedsFlow();
await dashboardPageRobot.navigateToSendPage();
await commonTestFlows.startAppFlow(ValueKey('send_test_app_key'));
await commonTestFlows.welcomePageToRestoreWalletThroughSeedsFlow(
CommonTestConstants.testWalletType,
secrets.solanaTestWalletSeeds,
CommonTestConstants.pin,
);
await dashboardPageRobot.navigateToSendPage();
await sendPageRobot.enterReceiveAddress(CommonTestConstants.testWalletAddress);
await sendPageRobot.selectReceiveCurrency(CommonTestConstants.testReceiveCurrency);
await sendPageRobot.enterAmount(CommonTestConstants.sendTestAmount);
await sendPageRobot.selectTransactionPriority();
await sendPageRobot.enterReceiveAddress(CommonTestConstants.testWalletAddress);
await sendPageRobot.selectReceiveCurrency(CommonTestConstants.testReceiveCurrency);
await sendPageRobot.enterAmount(CommonTestConstants.sendTestAmount);
await sendPageRobot.selectTransactionPriority();
await sendPageRobot.onSendButtonPressed();
await sendPageRobot.onSendButtonPressed();
await sendPageRobot.handleSendResult();
await sendPageRobot.handleSendResult();
await sendPageRobot.onSendButtonOnConfirmSendingDialogPressed();
await sendPageRobot.onSendButtonOnConfirmSendingDialogPressed();
await sendPageRobot.onSentDialogPopUp();
});
await sendPageRobot.onSentDialogPopUp();
});
}

View file

@ -0,0 +1,70 @@
import 'package:cw_core/wallet_type.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import '../components/common_test_constants.dart';
import '../components/common_test_flows.dart';
import '../robots/dashboard_page_robot.dart';
import '../robots/transactions_page_robot.dart';
import 'package:cake_wallet/.secrets.g.dart' as secrets;
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
CommonTestFlows commonTestFlows;
DashboardPageRobot dashboardPageRobot;
TransactionsPageRobot transactionsPageRobot;
/// Two Test Scenarios
/// - Fully Synchronizes and display the transaction history either immediately or few seconds after fully synchronizing
/// - Displays the transaction history progressively as synchronizing happens
testWidgets('Transaction history flow', (tester) async {
commonTestFlows = CommonTestFlows(tester);
dashboardPageRobot = DashboardPageRobot(tester);
transactionsPageRobot = TransactionsPageRobot(tester);
await commonTestFlows.startAppFlow(
ValueKey('confirm_creds_display_correctly_flow_app_key'),
);
/// Test Scenario 1 - Displays transaction history list after fully synchronizing.
///
/// For Solana/Tron WalletTypes.
await commonTestFlows.welcomePageToRestoreWalletThroughSeedsFlow(
WalletType.solana,
secrets.solanaTestWalletSeeds,
CommonTestConstants.pin,
);
await dashboardPageRobot.confirmWalletTypeIsDisplayedCorrectly(WalletType.solana);
await dashboardPageRobot.swipeDashboardTab(true);
await transactionsPageRobot.isTransactionsPage();
await transactionsPageRobot.confirmTransactionsPageConstantsDisplayProperly();
await transactionsPageRobot.confirmTransactionHistoryListDisplaysCorrectly(false);
/// Test Scenario 2 - Displays transaction history list while synchronizing.
///
/// For bitcoin/Monero/Wownero WalletTypes.
await commonTestFlows.switchToWalletMenuFromDashboardPage();
await commonTestFlows.restoreWalletFromWalletMenu(
WalletType.bitcoin,
secrets.bitcoinTestWalletSeeds,
);
await dashboardPageRobot.confirmWalletTypeIsDisplayedCorrectly(WalletType.bitcoin);
await dashboardPageRobot.swipeDashboardTab(true);
await transactionsPageRobot.isTransactionsPage();
await transactionsPageRobot.confirmTransactionsPageConstantsDisplayProperly();
await transactionsPageRobot.confirmTransactionHistoryListDisplaysCorrectly(true);
});
}