Skip to content

Commit

Permalink
test(3615): E2E to check the labels displaying the default account an…
Browse files Browse the repository at this point in the history
…d 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.
  • Loading branch information
EtherWizard33 authored Jan 15, 2025
1 parent 0157bb7 commit faf5340
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/components/UI/PermissionsSummary/PermissionsSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,13 @@ const PermissionsSummary = ({
</TextComponent>
<View style={styles.permissionRequestAccountInfo}>
<View style={styles.permissionRequestAccountName}>
<TextComponent numberOfLines={1} ellipsizeMode="tail">
<TextComponent
testID={
PermissionSummaryBottomSheetSelectorsIDs.ACCOUNT_PERMISSION_CONTAINER
}
numberOfLines={1}
ellipsizeMode="tail"
>
<TextComponent variant={TextVariant.BodySM}>
{getAccountLabel()}
</TextComponent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ exports[`PermissionsSummary should render correctly 1`] = `
"lineHeight": 22,
}
}
testID="permission-summary-account-text"
>
<Text
accessibilityRole="text"
Expand Down
12 changes: 12 additions & 0 deletions e2e/pages/Browser/PermissionSummaryBottomSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ class PermissionSummaryBottomSheet {
);
}

get ethereumMainnetText() {
return Matchers.getElementByText(
PermissionSummaryBottomSheetSelectorsText.ETHEREUM_MAINNET_LABEL,
);
}

get accountPermissionLabelContainer() {
return Matchers.getElementByID(
PermissionSummaryBottomSheetSelectorsIDs.ACCOUNT_PERMISSION_CONTAINER,
);
}

async swipeToDismissModal() {
await Gestures.swipe(this.container, 'down', 'fast');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import enContent from '../../../locales/languages/en.json';
export const PermissionSummaryBottomSheetSelectorsIDs = {
CONTAINER: 'permission-summary-container',
NETWORK_PERMISSIONS_CONTAINER: 'permission-network-permissions-container',
ACCOUNT_PERMISSION_CONTAINER: 'permission-summary-account-text',
};

export const PermissionSummaryBottomSheetSelectorsText = {
CONNECTED_ACCOUNTS_TEXT: enContent.accounts.connected_accounts_title,
ADD_NETWORK_PERMISSION: enContent.permissions.title_add_network_permission,
ETHEREUM_MAINNET_LABEL: 'Ethereum Main Network',
ACCOUNT_ONE_LABEL: 'Account 1',
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
'use strict';
import TestHelpers from '../../helpers';
import { SmokeMultiChainPermissions } from '../../tags';
import Browser from '../../pages/Browser/BrowserView';
import TabBarComponent from '../../pages/wallet/TabBarComponent';
import ConnectedAccountsModal from '../../pages/Browser/ConnectedAccountsModal';
import FixtureBuilder from '../../fixtures/fixture-builder';
import { withFixtures } from '../../fixtures/fixture-helper';
import { loginToApp } from '../../viewHelper';
import Assertions from '../../utils/Assertions';
import PermissionSummaryBottomSheet from '../../pages/Browser/PermissionSummaryBottomSheet';
import { PermissionSummaryBottomSheetSelectorsText } from '../../selectors/Browser/PermissionSummaryBottomSheet.selectors';

describe(
SmokeMultiChainPermissions('Permission System - Default Permissions'),
() => {
beforeAll(async () => {
jest.setTimeout(150000);
await TestHelpers.reverseServerPort();
});

it('should display default account and chain permissions in permission summary', async () => {
// Test setup with fixtures
await withFixtures(
{
dapp: true,
fixture: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.withChainPermission() // Initialize with Ethereum mainnet only
.build(),
restartDevice: true,
},
async () => {
// Step 1: Initial app setup
await loginToApp();
await TabBarComponent.tapBrowser();
await Browser.navigateToTestDApp();

// Step 2: Navigate to permissions management
await Browser.tapNetworkAvatarButtonOnBrowser();
await ConnectedAccountsModal.tapManagePermissionsButton();

// Step 3: Verify account permissions
const accountLabelElement =
await PermissionSummaryBottomSheet.accountPermissionLabelContainer;
const accountLabelAttributes =
await accountLabelElement.getAttributes();
const accountLabel = accountLabelAttributes.label;

await Assertions.checkIfTextMatches(
accountLabel,
PermissionSummaryBottomSheetSelectorsText.ACCOUNT_ONE_LABEL,
);

// Step 4: Verify chain permissions
await Assertions.checkIfVisible(
PermissionSummaryBottomSheet.ethereumMainnetText,
);
},
);
});
},
);

0 comments on commit faf5340

Please sign in to comment.