Skip to content

Commit c5722e4

Browse files
authored
Add PDSN redesigned confirmation e2e (#16179)
This PR adds basic PDSN dApp transfer confirmation. https://github.com/user-attachments/assets/ea09bbe0-674e-44f7-aac9-b8bdc7d7d162
1 parent a6ad3e1 commit c5722e4

File tree

2 files changed

+111
-0
lines changed

2 files changed

+111
-0
lines changed

e2e/selectors/Browser/TestDapp.selectors.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export const TestDappSelectorsWebIDs = {
2+
CHAIN_ID_TEXT: 'chainId',
23
TEST_DAPP_FOX_LOGO: 'mm-logo',
34
TEST_DAPP_HEADING_TITLE: 'logo-text',
45
APPROVE_ERC_20_TOKENS_BUTTON_ID: 'approveTokens',
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
'use strict';
2+
import { mockEvents } from '../../../api-mocking/mock-config/mock-events.js';
3+
import FixtureBuilder from '../../../fixtures/fixture-builder';
4+
import {
5+
withFixtures,
6+
defaultGanacheOptions,
7+
} from '../../../fixtures/fixture-helper';
8+
import { buildPermissions } from '../../../fixtures/utils';
9+
import TestHelpers from '../../../helpers';
10+
import Browser from '../../../pages/Browser/BrowserView';
11+
import ConfirmationFooterActions from '../../../pages/Browser/Confirmations/FooterActions';
12+
import ConfirmationUITypes from '../../../pages/Browser/Confirmations/ConfirmationUITypes';
13+
import TestDApp from '../../../pages/Browser/TestDApp';
14+
import NetworkEducationModal from '../../../pages/Network/NetworkEducationModal';
15+
import NetworkListModal from '../../../pages/Network/NetworkListModal';
16+
import TabBarComponent from '../../../pages/wallet/TabBarComponent';
17+
import WalletView from '../../../pages/wallet/WalletView';
18+
import { BrowserViewSelectorsIDs } from '../../../selectors/Browser/BrowserView.selectors';
19+
import { TestDappSelectorsWebIDs } from '../../../selectors/Browser/TestDapp.selectors';
20+
import { SmokeConfirmationsRedesigned } from '../../../tags';
21+
import Assertions from '../../../utils/Assertions';
22+
import Matchers from '../../../utils/Matchers';
23+
import { loginToApp } from '../../../viewHelper';
24+
25+
const LOCAL_CHAIN_ID = '0x539';
26+
const LOCAL_CHAIN_NAME = 'Localhost';
27+
28+
async function checkChainIdInTestDapp(assertedChainId) {
29+
const chainIdElement = await Matchers.getElementByWebID(
30+
BrowserViewSelectorsIDs.BROWSER_WEBVIEW_ID,
31+
TestDappSelectorsWebIDs.CHAIN_ID_TEXT,
32+
);
33+
const chainIdText = await chainIdElement.getText();
34+
await Assertions.checkIfTextMatches(chainIdText, assertedChainId);
35+
}
36+
37+
async function changeNetworkFromNetworkListModal(networkName) {
38+
await TabBarComponent.tapWallet();
39+
await WalletView.tapNetworksButtonOnNavBar();
40+
await NetworkListModal.changeNetworkTo(networkName);
41+
await device.disableSynchronization();
42+
await NetworkEducationModal.tapGotItButton();
43+
await device.enableSynchronization();
44+
}
45+
46+
describe(SmokeConfirmationsRedesigned('Per Dapp Selected Network'), () => {
47+
const testSpecificMock = {
48+
GET: [mockEvents.GET.remoteFeatureFlagsRedesignedConfirmations],
49+
};
50+
51+
beforeAll(async () => {
52+
jest.setTimeout(15000);
53+
await TestHelpers.reverseServerPort();
54+
});
55+
56+
it('submits a transaction to a dApp selected network', async () => {
57+
await withFixtures(
58+
{
59+
dapp: true,
60+
fixture: new FixtureBuilder()
61+
.withGanacheNetwork()
62+
.withPermissionControllerConnectedToTestDapp(
63+
buildPermissions([LOCAL_CHAIN_ID]),
64+
)
65+
.build(),
66+
ganacheOptions: defaultGanacheOptions,
67+
restartDevice: true,
68+
testSpecificMock,
69+
},
70+
async () => {
71+
await loginToApp();
72+
await TabBarComponent.tapBrowser();
73+
await Browser.navigateToTestDApp();
74+
await Browser.waitForBrowserPageToLoad();
75+
76+
// Make sure the dapp is connected to the predefined network in configuration (LOCAL_CHAIN_ID)
77+
// by checking chainId text in the test dapp
78+
await checkChainIdInTestDapp(LOCAL_CHAIN_ID);
79+
80+
// Change the network to Ethereum Main Network in app
81+
await changeNetworkFromNetworkListModal('Ethereum Main Network');
82+
83+
await TabBarComponent.tapBrowser();
84+
// Assert the dapp is still connected the previously selected network (LOCAL_CHAIN_ID)
85+
await checkChainIdInTestDapp(LOCAL_CHAIN_ID);
86+
87+
// Now do a transaction
88+
await TestDApp.tapSendEIP1559Button();
89+
90+
// Wait for the confirmation modal to appear
91+
await Assertions.checkIfVisible(
92+
ConfirmationUITypes.ModalConfirmationContainer,
93+
);
94+
95+
// Assert the transaction is happening on the correct network
96+
await Assertions.checkIfTextIsDisplayed(LOCAL_CHAIN_NAME);
97+
98+
// Accept confirmation
99+
await ConfirmationFooterActions.tapConfirmButton();
100+
101+
// Change the network to Localhost in app
102+
await changeNetworkFromNetworkListModal(LOCAL_CHAIN_NAME);
103+
104+
// Check activity tab
105+
await TabBarComponent.tapActivity();
106+
await Assertions.checkIfTextIsDisplayed('Confirmed');
107+
},
108+
);
109+
});
110+
});

0 commit comments

Comments
 (0)