2024-09-22 02:46:51 +00:00
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
|
|
|
import 'package:cake_wallet/src/screens/dashboard/dashboard_page.dart';
|
2024-11-07 14:46:08 +00:00
|
|
|
import 'package:cake_wallet/src/screens/dashboard/pages/balance_page.dart';
|
2024-09-22 02:46:51 +00:00
|
|
|
import 'package:cw_core/wallet_type.dart';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
|
|
|
|
import '../components/common_test_cases.dart';
|
2024-11-07 14:46:08 +00:00
|
|
|
import 'dashboard_menu_widget_robot.dart';
|
2024-09-22 02:46:51 +00:00
|
|
|
|
|
|
|
class DashboardPageRobot {
|
2024-11-07 14:46:08 +00:00
|
|
|
DashboardPageRobot(this.tester)
|
|
|
|
: commonTestCases = CommonTestCases(tester),
|
|
|
|
dashboardMenuWidgetRobot = DashboardMenuWidgetRobot(tester);
|
2024-09-22 02:46:51 +00:00
|
|
|
|
|
|
|
final WidgetTester tester;
|
2024-11-07 14:46:08 +00:00
|
|
|
final DashboardMenuWidgetRobot dashboardMenuWidgetRobot;
|
2024-09-22 02:46:51 +00:00
|
|
|
late CommonTestCases commonTestCases;
|
|
|
|
|
|
|
|
Future<void> isDashboardPage() async {
|
|
|
|
await commonTestCases.isSpecificPage<DashboardPage>();
|
|
|
|
}
|
|
|
|
|
2024-11-07 14:46:08 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2024-09-22 02:46:51 +00:00
|
|
|
void confirmServiceUpdateButtonDisplays() {
|
|
|
|
commonTestCases.hasValueKey('dashboard_page_services_update_button_key');
|
|
|
|
}
|
|
|
|
|
|
|
|
void confirmSyncIndicatorButtonDisplays() {
|
|
|
|
commonTestCases.hasValueKey('dashboard_page_sync_indicator_button_key');
|
|
|
|
}
|
|
|
|
|
|
|
|
void confirmMenuButtonDisplays() {
|
|
|
|
commonTestCases.hasValueKey('dashboard_page_wallet_menu_button_key');
|
|
|
|
}
|
|
|
|
|
2024-11-07 14:46:08 +00:00
|
|
|
Future<void> confirmRightCryptoAssetTitleDisplaysPerPageView(
|
|
|
|
WalletType type, {
|
|
|
|
bool isHaven = false,
|
|
|
|
}) async {
|
2024-09-22 02:46:51 +00:00
|
|
|
//Balance Page
|
2024-11-07 14:46:08 +00:00
|
|
|
await confirmWalletTypeIsDisplayedCorrectly(type, isHaven: isHaven);
|
2024-09-22 02:46:51 +00:00
|
|
|
|
|
|
|
// Swipe to Cake features Page
|
2024-11-07 14:46:08 +00:00
|
|
|
await swipeDashboardTab(false);
|
2024-09-22 02:46:51 +00:00
|
|
|
commonTestCases.hasText('Cake ${S.current.features}');
|
|
|
|
|
|
|
|
// Swipe back to balance
|
2024-11-07 14:46:08 +00:00
|
|
|
await swipeDashboardTab(true);
|
2024-09-22 02:46:51 +00:00
|
|
|
|
|
|
|
// Swipe to Transactions Page
|
2024-11-07 14:46:08 +00:00
|
|
|
await swipeDashboardTab(true);
|
2024-09-22 02:46:51 +00:00
|
|
|
commonTestCases.hasText(S.current.transactions);
|
|
|
|
|
|
|
|
// Swipe back to balance
|
2024-11-07 14:46:08 +00:00
|
|
|
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();
|
2024-09-22 02:46:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> navigateToBuyPage() async {
|
|
|
|
await commonTestCases.tapItemByKey('dashboard_page_${S.current.buy}_action_button_key');
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> navigateToSendPage() async {
|
|
|
|
await commonTestCases.tapItemByKey('dashboard_page_${S.current.send}_action_button_key');
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> navigateToSellPage() async {
|
|
|
|
await commonTestCases.tapItemByKey('dashboard_page_${S.current.sell}_action_button_key');
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> navigateToReceivePage() async {
|
|
|
|
await commonTestCases.tapItemByKey('dashboard_page_${S.current.receive}_action_button_key');
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> navigateToExchangePage() async {
|
|
|
|
await commonTestCases.tapItemByKey('dashboard_page_${S.current.exchange}_action_button_key');
|
|
|
|
}
|
|
|
|
}
|