| 1 | import 'package:flutter/foundation.dart'; |
| 2 | import 'package:flutter_test/flutter_test.dart'; |
| 3 | import 'package:integration_test/integration_test.dart'; |
| 4 | |
| 5 | import 'components/common_test_constants.dart'; |
| 6 | import 'components/common_test_flows.dart'; |
| 7 | import 'robots/auth_page_robot.dart'; |
| 8 | import 'robots/dashboard_page_robot.dart'; |
| 9 | import 'robots/exchange_confirm_page_robot.dart'; |
| 10 | import 'robots/exchange_page_robot.dart'; |
| 11 | import 'robots/exchange_trade_page_robot.dart'; |
| 12 | import 'package:cake_wallet/.secrets.g.dart' as secrets; |
| 13 | |
| 14 | void main() { |
| 15 | IntegrationTestWidgetsFlutterBinding.ensureInitialized(); |
| 16 | |
| 17 | DashboardPageRobot dashboardPageRobot; |
| 18 | ExchangePageRobot exchangePageRobot; |
| 19 | ExchangeConfirmPageRobot exchangeConfirmPageRobot; |
| 20 | AuthPageRobot authPageRobot; |
| 21 | ExchangeTradePageRobot exchangeTradePageRobot; |
| 22 | CommonTestFlows commonTestFlows; |
| 23 | |
| 24 | group('Startup Test', () { |
| 25 | testWidgets('Test for Exchange flow using Restore Wallet - Exchanging USDT(Sol) to SOL', |
| 26 | (tester) async { |
| 27 | authPageRobot = AuthPageRobot(tester); |
| 28 | exchangePageRobot = ExchangePageRobot(tester); |
| 29 | dashboardPageRobot = DashboardPageRobot(tester); |
| 30 | exchangeTradePageRobot = ExchangeTradePageRobot(tester); |
| 31 | exchangeConfirmPageRobot = ExchangeConfirmPageRobot(tester); |
| 32 | commonTestFlows = CommonTestFlows(tester); |
| 33 | |
| 34 | await commonTestFlows.startAppFlow(ValueKey('funds_exchange_test_app_key')); |
| 35 | |
| 36 | await commonTestFlows.welcomePageToRestoreWalletThroughSeedsFlow( |
| 37 | CommonTestConstants.testWalletType, |
| 38 | secrets.solanaTestWalletSeeds, |
| 39 | CommonTestConstants.pin, |
| 40 | ); |
| 41 | |
| 42 | // ----------- RestoreFromSeedOrKeys Page ------------- |
| 43 | await dashboardPageRobot.navigateToExchangePage(); |
| 44 | |
| 45 | // ----------- Exchange Page ------------- |
| 46 | await exchangePageRobot.isExchangePage(); |
| 47 | exchangePageRobot.hasResetButton(); |
| 48 | await exchangePageRobot.displayBothExchangeCards(); |
| 49 | exchangePageRobot.confirmRightComponentsDisplayOnDepositExchangeCards(); |
| 50 | exchangePageRobot.confirmRightComponentsDisplayOnReceiveExchangeCards(); |
| 51 | |
| 52 | await exchangePageRobot |
| 53 | .selectDepositCurrency(CommonTestConstants.exchangeTestDepositCurrency); |
| 54 | await exchangePageRobot |
| 55 | .selectReceiveCurrency(CommonTestConstants.exchangeTestReceiveCurrency); |
| 56 | |
| 57 | await exchangePageRobot.enterDepositAmount(CommonTestConstants.exchangeTestAmount); |
| 58 | await exchangePageRobot.enterDepositRefundAddress( |
| 59 | depositAddress: CommonTestConstants.testWalletAddress); |
| 60 | |
| 61 | await exchangePageRobot.enterReceiveAddress(CommonTestConstants.testWalletAddress); |
| 62 | |
| 63 | await exchangePageRobot.onExchangeButtonPressed(); |
| 64 | |
| 65 | await exchangePageRobot.handleErrors(CommonTestConstants.exchangeTestAmount); |
| 66 | |
| 67 | final onAuthPage = authPageRobot.onAuthPage(); |
| 68 | if (onAuthPage) { |
| 69 | await authPageRobot.enterPinCode(CommonTestConstants.pin); |
| 70 | } |
| 71 | |
| 72 | final onAuthPageDesktop = authPageRobot.onAuthPageDesktop(); |
| 73 | if (onAuthPageDesktop) { |
| 74 | await authPageRobot.enterPassword(CommonTestConstants.pin.join("")); |
| 75 | } |
| 76 | |
| 77 | // ----------- Exchange Confirm Page ------------- |
| 78 | await exchangeConfirmPageRobot.isExchangeConfirmPage(); |
| 79 | |
| 80 | exchangeConfirmPageRobot.confirmComponentsOfTradeDisplayProperly(); |
| 81 | await exchangeConfirmPageRobot.confirmCopyTradeIdToClipBoardWorksProperly(); |
| 82 | await exchangeConfirmPageRobot.onSavedTradeIdButtonPressed(); |
| 83 | |
| 84 | // ----------- Exchange Trade Page ------------- |
| 85 | await exchangeTradePageRobot.isExchangeTradePage(); |
| 86 | exchangeTradePageRobot.hasInformationDialog(); |
| 87 | await exchangeTradePageRobot.onGotItButtonPressed(); |
| 88 | |
| 89 | await exchangeTradePageRobot.onSendFromCakeButtonPressed(); |
| 90 | |
| 91 | await exchangeTradePageRobot.handleConfirmSendResult(); |
| 92 | |
| 93 | await exchangeTradePageRobot.onSendButtonOnConfirmSendingDialogPressed(); |
| 94 | }); |
| 95 | }); |
| 96 | } |