|
| 1 | +import { Mockttp } from 'mockttp'; |
| 2 | + |
| 3 | +import { CHAIN_IDS } from '../../../../shared/constants/network'; |
| 4 | +import ActivityListPage from '../../page-objects/pages/home/activity-list'; |
| 5 | +import FixtureBuilder from '../../fixture-builder'; |
| 6 | +import HomePage from '../../page-objects/pages/home/homepage'; |
| 7 | +import SendPage from '../../page-objects/pages/send/send-page'; |
| 8 | +import SendTokenConfirmPage from '../../page-objects/pages/send/send-token-confirmation-page'; |
| 9 | +import { Driver } from '../../webdriver/driver'; |
| 10 | +import { WINDOW_TITLES, withFixtures } from '../../helpers'; |
| 11 | +import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; |
| 12 | +import { mockLookupSnap } from '../../mock-response-data/snaps/snap-binary-mocks'; |
| 13 | +import { openTestSnapClickButtonAndInstall } from '../../page-objects/flows/install-test-snap.flow'; |
| 14 | +import { mockSendRedesignFeatureFlag } from './common'; |
| 15 | + |
| 16 | +describe('Send ETH', function () { |
| 17 | + it('it should be possible to send ETH', async function () { |
| 18 | + await withFixtures( |
| 19 | + { |
| 20 | + fixtures: new FixtureBuilder().build(), |
| 21 | + title: this.test?.fullTitle(), |
| 22 | + testSpecificMock: mockSendRedesignFeatureFlag, |
| 23 | + }, |
| 24 | + async ({ driver }: { driver: Driver }) => { |
| 25 | + await loginWithBalanceValidation(driver); |
| 26 | + |
| 27 | + const homePage = new HomePage(driver); |
| 28 | + const sendPage = new SendPage(driver); |
| 29 | + const sendTokenConfirmationPage = new SendTokenConfirmPage(driver); |
| 30 | + const activityListPage = new ActivityListPage(driver); |
| 31 | + |
| 32 | + await homePage.startSendFlow(); |
| 33 | + |
| 34 | + await sendPage.selectToken('0x539', 'ETH'); |
| 35 | + await sendPage.fillRecipient( |
| 36 | + '0x2f318C334780961FB129D2a6c30D0763d9a5C970', |
| 37 | + ); |
| 38 | + await sendPage.fillAmount('1000'); |
| 39 | + await sendPage.checkInsufficientFundsError(); |
| 40 | + await sendPage.pressOnAmountInput('BACK_SPACE'); |
| 41 | + await sendPage.pressOnAmountInput('BACK_SPACE'); |
| 42 | + await sendPage.pressOnAmountInput('BACK_SPACE'); |
| 43 | + await sendPage.pressContinueButton(); |
| 44 | + |
| 45 | + await sendTokenConfirmationPage.clickOnConfirm(); |
| 46 | + await activityListPage.checkTransactionActivityByText('Sent'); |
| 47 | + await activityListPage.checkCompletedTxNumberDisplayedInActivity(1); |
| 48 | + await activityListPage.checkTxAmountInActivity('-1 ETH'); |
| 49 | + }, |
| 50 | + ); |
| 51 | + }); |
| 52 | + |
| 53 | + it('it should be possible to send Max ETH', async function () { |
| 54 | + await withFixtures( |
| 55 | + { |
| 56 | + fixtures: new FixtureBuilder().build(), |
| 57 | + title: this.test?.fullTitle(), |
| 58 | + testSpecificMock: mockSendRedesignFeatureFlag, |
| 59 | + }, |
| 60 | + async ({ driver }: { driver: Driver }) => { |
| 61 | + await loginWithBalanceValidation(driver); |
| 62 | + |
| 63 | + const homePage = new HomePage(driver); |
| 64 | + const sendPage = new SendPage(driver); |
| 65 | + const sendTokenConfirmationPage = new SendTokenConfirmPage(driver); |
| 66 | + const activityListPage = new ActivityListPage(driver); |
| 67 | + |
| 68 | + await homePage.startSendFlow(); |
| 69 | + |
| 70 | + await sendPage.createMaxSendRequest({ |
| 71 | + chainId: '0x539', |
| 72 | + symbol: 'ETH', |
| 73 | + recipientAddress: '0x2f318C334780961FB129D2a6c30D0763d9a5C970', |
| 74 | + }); |
| 75 | + |
| 76 | + await sendTokenConfirmationPage.clickOnConfirm(); |
| 77 | + await activityListPage.checkTransactionActivityByText('Sent'); |
| 78 | + await activityListPage.checkCompletedTxNumberDisplayedInActivity(1); |
| 79 | + }, |
| 80 | + ); |
| 81 | + }); |
| 82 | + |
| 83 | + it('it should be possible to send to address book entry', async function () { |
| 84 | + await withFixtures( |
| 85 | + { |
| 86 | + fixtures: new FixtureBuilder() |
| 87 | + .withAddressBookController({ |
| 88 | + addressBook: { |
| 89 | + '0x539': { |
| 90 | + '0x2f318C334780961FB129D2a6c30D0763d9a5C970': { |
| 91 | + address: '0x2f318C334780961FB129D2a6c30D0763d9a5C970', |
| 92 | + chainId: '0x539', |
| 93 | + isEns: false, |
| 94 | + memo: '', |
| 95 | + name: 'Test Name 1', |
| 96 | + }, |
| 97 | + }, |
| 98 | + }, |
| 99 | + }) |
| 100 | + .build(), |
| 101 | + title: this.test?.fullTitle(), |
| 102 | + testSpecificMock: mockSendRedesignFeatureFlag, |
| 103 | + }, |
| 104 | + async ({ driver }) => { |
| 105 | + await loginWithBalanceValidation(driver); |
| 106 | + |
| 107 | + const homePage = new HomePage(driver); |
| 108 | + const sendPage = new SendPage(driver); |
| 109 | + const sendTokenConfirmationPage = new SendTokenConfirmPage(driver); |
| 110 | + const activityListPage = new ActivityListPage(driver); |
| 111 | + |
| 112 | + await homePage.startSendFlow(); |
| 113 | + |
| 114 | + await sendPage.selectToken('0x539', 'ETH'); |
| 115 | + await sendPage.selectAccountFromRecipientModal('Test Name 1'); |
| 116 | + await sendPage.fillAmount('1'); |
| 117 | + await sendPage.pressContinueButton(); |
| 118 | + |
| 119 | + await sendTokenConfirmationPage.clickOnConfirm(); |
| 120 | + await activityListPage.checkTransactionActivityByText('Sent'); |
| 121 | + await activityListPage.checkCompletedTxNumberDisplayedInActivity(1); |
| 122 | + await activityListPage.checkTxAmountInActivity('-1 ETH'); |
| 123 | + }, |
| 124 | + ); |
| 125 | + }); |
| 126 | + |
| 127 | + it('it should be possible to resolve name lookup address', async function () { |
| 128 | + await withFixtures( |
| 129 | + { |
| 130 | + fixtures: new FixtureBuilder({ |
| 131 | + inputChainId: CHAIN_IDS.MAINNET, |
| 132 | + }).build(), |
| 133 | + title: this.test?.fullTitle(), |
| 134 | + testSpecificMock: (mockServer: Mockttp) => { |
| 135 | + mockSendRedesignFeatureFlag(mockServer); |
| 136 | + mockLookupSnap(mockServer); |
| 137 | + }, |
| 138 | + }, |
| 139 | + async ({ driver }) => { |
| 140 | + await loginWithBalanceValidation(driver); |
| 141 | + |
| 142 | + await openTestSnapClickButtonAndInstall( |
| 143 | + driver, |
| 144 | + 'connectNameLookUpButton', |
| 145 | + ); |
| 146 | + await driver.switchToWindowWithTitle( |
| 147 | + WINDOW_TITLES.ExtensionInFullScreenView, |
| 148 | + ); |
| 149 | + |
| 150 | + const homePage = new HomePage(driver); |
| 151 | + const sendPage = new SendPage(driver); |
| 152 | + |
| 153 | + await homePage.startSendFlow(); |
| 154 | + |
| 155 | + await sendPage.selectToken('0x1', 'ETH'); |
| 156 | + await sendPage.fillRecipient('test.eth'); |
| 157 | + |
| 158 | + await driver.findElement({ text: '0xc0ffe...54979' }); |
| 159 | + }, |
| 160 | + ); |
| 161 | + }); |
| 162 | +}); |
0 commit comments