|
| 1 | +import TestHelpers from '../../helpers'; |
| 2 | +import { FlaskBuildTests } from '../../tags'; |
| 3 | +import { loginToApp } from '../../viewHelper'; |
| 4 | +import FixtureBuilder from '../../fixtures/fixture-builder'; |
| 5 | +import { withFixtures } from '../../fixtures/fixture-helper'; |
| 6 | +import Assertions from '../../utils/Assertions'; |
| 7 | +import TabBarComponent from '../../pages/wallet/TabBarComponent'; |
| 8 | +import BrowserView from '../../pages/Browser/BrowserView'; |
| 9 | +import TestSnaps from '../../pages/Browser/TestSnaps'; |
| 10 | +import ConnectBottomSheet from '../../pages/Browser/ConnectBottomSheet'; |
| 11 | +import { mockEvents } from '../../api-mocking/mock-config/mock-events'; |
| 12 | +import RequestTypes from '../../pages/Browser/Confirmations/RequestTypes'; |
| 13 | + |
| 14 | +describe(FlaskBuildTests('Ethereum Provider Snap Tests'), () => { |
| 15 | + beforeAll(async () => { |
| 16 | + await TestHelpers.reverseServerPort(); |
| 17 | + }); |
| 18 | + |
| 19 | + beforeEach(() => { |
| 20 | + jest.setTimeout(150000); |
| 21 | + }); |
| 22 | + |
| 23 | + it('can use the Ethereum provider', async () => { |
| 24 | + await withFixtures( |
| 25 | + { |
| 26 | + fixture: new FixtureBuilder().withMultiSRPKeyringController().build(), |
| 27 | + restartDevice: true, |
| 28 | + testSpecificMock: { |
| 29 | + GET: [mockEvents.GET.remoteFeatureFlagsRedesignedConfirmationsFlask], |
| 30 | + }, |
| 31 | + }, |
| 32 | + async () => { |
| 33 | + await loginToApp(); |
| 34 | + |
| 35 | + // Navigate to test snaps URL once for all tests |
| 36 | + await TabBarComponent.tapBrowser(); |
| 37 | + await TestSnaps.navigateToTestSnap(); |
| 38 | + await TestHelpers.delay(3500); // Wait for page to load |
| 39 | + await Assertions.checkIfVisible(BrowserView.browserScreenID); |
| 40 | + |
| 41 | + await TestSnaps.installSnap('connectEthereumProviderButton'); |
| 42 | + |
| 43 | + await TestSnaps.tapButton('getChainIdButton'); |
| 44 | + await TestHelpers.delay(500); |
| 45 | + await TestSnaps.checkResultSpan('ethereumProviderResultSpan', '"0x1"'); |
| 46 | + |
| 47 | + await TestSnaps.tapButton('getAccountsButton'); |
| 48 | + await Assertions.checkIfVisible(ConnectBottomSheet.connectButton); |
| 49 | + await ConnectBottomSheet.tapConnectButton(); |
| 50 | + await TestHelpers.delay(500); |
| 51 | + await TestSnaps.checkResultSpanIncludes( |
| 52 | + 'ethereumProviderResultSpan', |
| 53 | + '"0x5cfe73b6021e818b776b421b1c4db2474086a7e1"', |
| 54 | + ); |
| 55 | + |
| 56 | + // Test `personal_sign`. |
| 57 | + await TestSnaps.fillMessage('personalSignMessageInput', 'foo'); |
| 58 | + await TestSnaps.tapButton('personalSignButton'); |
| 59 | + await Assertions.checkIfVisible(RequestTypes.PersonalSignRequest); |
| 60 | + await TestSnaps.approveNativeConfirmation(); |
| 61 | + await TestSnaps.checkResultSpan( |
| 62 | + 'personalSignResultSpan', |
| 63 | + '"0xf63c587cd42e7775e2e815a579f9744ea62944f263b3e69fad48535ba98a5ea107bc878088a99942733a59a89ef1d590eafdb467d59cf76564158d7e78351b751b"', |
| 64 | + ); |
| 65 | + |
| 66 | + // Test `eth_signTypedData_v4`. |
| 67 | + await TestSnaps.fillMessage('signTypedDataMessageInput', 'bar'); |
| 68 | + await TestSnaps.tapButton('signTypedDataButton'); |
| 69 | + await Assertions.checkIfVisible(RequestTypes.TypedSignRequest); |
| 70 | + await TestSnaps.approveNativeConfirmation(); |
| 71 | + await TestSnaps.checkResultSpan( |
| 72 | + 'signTypedDataResultSpan', |
| 73 | + '"0x7024dc071a7370eee444b2a3edc08d404dd03393694403cdca864653a7e8dd7c583419293d53602666cbe77faa8819fba04f8c57e95df2d4c0190968eece28021c"', |
| 74 | + ); |
| 75 | + |
| 76 | + // Check other networks. |
| 77 | + await TestSnaps.selectInDropdown('networkDropDown', 'Ethereum'); |
| 78 | + await TestSnaps.tapButton('getChainIdButton'); |
| 79 | + await TestHelpers.delay(500); |
| 80 | + await TestSnaps.checkResultSpan('ethereumProviderResultSpan', '"0x1"'); |
| 81 | + |
| 82 | + await TestSnaps.selectInDropdown('networkDropDown', 'Linea'); |
| 83 | + await TestSnaps.tapButton('getChainIdButton'); |
| 84 | + await TestHelpers.delay(500); |
| 85 | + await TestSnaps.checkResultSpan( |
| 86 | + 'ethereumProviderResultSpan', |
| 87 | + '"0xe708"', |
| 88 | + ); |
| 89 | + |
| 90 | + await TestSnaps.selectInDropdown('networkDropDown', 'Sepolia'); |
| 91 | + await TestSnaps.tapButton('getChainIdButton'); |
| 92 | + await TestHelpers.delay(500); |
| 93 | + await TestSnaps.checkResultSpan( |
| 94 | + 'ethereumProviderResultSpan', |
| 95 | + '"0xaa36a7"', |
| 96 | + ); |
| 97 | + }, |
| 98 | + ); |
| 99 | + }); |
| 100 | +}); |
0 commit comments