Skip to content

Commit faf5340

Browse files
test(3615): E2E to check the labels displaying the default account and chain (#12830)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** E2E to assert the permission summary is displaying the expected content after the user has connected with default account and chain. <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Related issues** Contributes to: MetaMask/MetaMask-planning#3615 ## **Manual testing steps** 1. `yarn watch:clean` 2. `yarn test:e2e:ios:debug:build` 3. `yarn test:e2e:ios:debug:run <path to test file>` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
1 parent 0157bb7 commit faf5340

File tree

5 files changed

+86
-1
lines changed

5 files changed

+86
-1
lines changed

app/components/UI/PermissionsSummary/PermissionsSummary.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,13 @@ const PermissionsSummary = ({
291291
</TextComponent>
292292
<View style={styles.permissionRequestAccountInfo}>
293293
<View style={styles.permissionRequestAccountName}>
294-
<TextComponent numberOfLines={1} ellipsizeMode="tail">
294+
<TextComponent
295+
testID={
296+
PermissionSummaryBottomSheetSelectorsIDs.ACCOUNT_PERMISSION_CONTAINER
297+
}
298+
numberOfLines={1}
299+
ellipsizeMode="tail"
300+
>
295301
<TextComponent variant={TextVariant.BodySM}>
296302
{getAccountLabel()}
297303
</TextComponent>

app/components/UI/PermissionsSummary/__snapshots__/PermissionsSummary.test.tsx.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ exports[`PermissionsSummary should render correctly 1`] = `
232232
"lineHeight": 22,
233233
}
234234
}
235+
testID="permission-summary-account-text"
235236
>
236237
<Text
237238
accessibilityRole="text"

e2e/pages/Browser/PermissionSummaryBottomSheet.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ class PermissionSummaryBottomSheet {
2323
);
2424
}
2525

26+
get ethereumMainnetText() {
27+
return Matchers.getElementByText(
28+
PermissionSummaryBottomSheetSelectorsText.ETHEREUM_MAINNET_LABEL,
29+
);
30+
}
31+
32+
get accountPermissionLabelContainer() {
33+
return Matchers.getElementByID(
34+
PermissionSummaryBottomSheetSelectorsIDs.ACCOUNT_PERMISSION_CONTAINER,
35+
);
36+
}
37+
2638
async swipeToDismissModal() {
2739
await Gestures.swipe(this.container, 'down', 'fast');
2840
}

e2e/selectors/Browser/PermissionSummaryBottomSheet.selectors.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ import enContent from '../../../locales/languages/en.json';
33
export const PermissionSummaryBottomSheetSelectorsIDs = {
44
CONTAINER: 'permission-summary-container',
55
NETWORK_PERMISSIONS_CONTAINER: 'permission-network-permissions-container',
6+
ACCOUNT_PERMISSION_CONTAINER: 'permission-summary-account-text',
67
};
78

89
export const PermissionSummaryBottomSheetSelectorsText = {
910
CONNECTED_ACCOUNTS_TEXT: enContent.accounts.connected_accounts_title,
1011
ADD_NETWORK_PERMISSION: enContent.permissions.title_add_network_permission,
12+
ETHEREUM_MAINNET_LABEL: 'Ethereum Main Network',
13+
ACCOUNT_ONE_LABEL: 'Account 1',
1114
};
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
'use strict';
2+
import TestHelpers from '../../helpers';
3+
import { SmokeMultiChainPermissions } from '../../tags';
4+
import Browser from '../../pages/Browser/BrowserView';
5+
import TabBarComponent from '../../pages/wallet/TabBarComponent';
6+
import ConnectedAccountsModal from '../../pages/Browser/ConnectedAccountsModal';
7+
import FixtureBuilder from '../../fixtures/fixture-builder';
8+
import { withFixtures } from '../../fixtures/fixture-helper';
9+
import { loginToApp } from '../../viewHelper';
10+
import Assertions from '../../utils/Assertions';
11+
import PermissionSummaryBottomSheet from '../../pages/Browser/PermissionSummaryBottomSheet';
12+
import { PermissionSummaryBottomSheetSelectorsText } from '../../selectors/Browser/PermissionSummaryBottomSheet.selectors';
13+
14+
describe(
15+
SmokeMultiChainPermissions('Permission System - Default Permissions'),
16+
() => {
17+
beforeAll(async () => {
18+
jest.setTimeout(150000);
19+
await TestHelpers.reverseServerPort();
20+
});
21+
22+
it('should display default account and chain permissions in permission summary', async () => {
23+
// Test setup with fixtures
24+
await withFixtures(
25+
{
26+
dapp: true,
27+
fixture: new FixtureBuilder()
28+
.withPermissionControllerConnectedToTestDapp()
29+
.withChainPermission() // Initialize with Ethereum mainnet only
30+
.build(),
31+
restartDevice: true,
32+
},
33+
async () => {
34+
// Step 1: Initial app setup
35+
await loginToApp();
36+
await TabBarComponent.tapBrowser();
37+
await Browser.navigateToTestDApp();
38+
39+
// Step 2: Navigate to permissions management
40+
await Browser.tapNetworkAvatarButtonOnBrowser();
41+
await ConnectedAccountsModal.tapManagePermissionsButton();
42+
43+
// Step 3: Verify account permissions
44+
const accountLabelElement =
45+
await PermissionSummaryBottomSheet.accountPermissionLabelContainer;
46+
const accountLabelAttributes =
47+
await accountLabelElement.getAttributes();
48+
const accountLabel = accountLabelAttributes.label;
49+
50+
await Assertions.checkIfTextMatches(
51+
accountLabel,
52+
PermissionSummaryBottomSheetSelectorsText.ACCOUNT_ONE_LABEL,
53+
);
54+
55+
// Step 4: Verify chain permissions
56+
await Assertions.checkIfVisible(
57+
PermissionSummaryBottomSheet.ethereumMainnetText,
58+
);
59+
},
60+
);
61+
});
62+
},
63+
);

0 commit comments

Comments
 (0)