Skip to content

Commit

Permalink
test: add Ethereum sign in e2e (#12737)
Browse files Browse the repository at this point in the history
## **Description**

This PR is within the scope of the Quality Quest.

We're including an e2e test case to check the sign in with Ethereum
feature.

**Test steps:**
Given I am on the test dapp
When I tap on the Sign in with ethereum button
Then the Signature form should appear
When I tap cancel
Then the signature form should disappear
When I tap on the Sign in with ethereum button
And I tap Sign
Then the signature form should disappear
_And the signature result should not be empty_ ← This step is pending
and will be done in the future.

## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**


### **Before**


### **After**


## **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
C-Ivan authored Dec 18, 2024
1 parent e335f05 commit 9054f70
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
11 changes: 11 additions & 0 deletions e2e/pages/Browser/TestDApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ class TestDApp {
TestDappSelectorsWebIDs.SIGN_TYPE_DATA_V4,
);
}
get ethereumSignButton() {
return Matchers.getElementByWebID(
BrowserViewSelectorsIDs.BROWSER_WEBVIEW_ID,
TestDappSelectorsWebIDs.ETHEREUM_SIGN,
);
}
// This taps on the transfer tokens button under the "SEND TOKENS section"
get nftTransferFromTokensButton() {
return Matchers.getElementByWebID(
Expand Down Expand Up @@ -124,6 +130,11 @@ class TestDApp {
async tapTypedV4SignButton() {
await this.tapButton(this.signTypedDataV4Button);
}

async tapEthereumSignButton() {
await this.tapButton(this.ethereumSignButton);
}

async tapERC20TransferButton() {
await this.tapButton(this.erc20TransferTokensButton);
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/selectors/Browser/TestDapp.selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export const TestDappSelectorsWebIDs = {
SIGN_TYPE_DATA: 'signTypedData',
SIGN_TYPE_DATA_V3: 'signTypedDataV3',
SIGN_TYPE_DATA_V4: 'signTypedDataV4',
SIWE: 'siwe',
ETHEREUM_SIGN: 'siwe',
ADD_TOKENS_TO_WALLET_BUTTON: 'watchAssets',
};
51 changes: 51 additions & 0 deletions e2e/specs/confirmations/signatures/ethereum-sign.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use strict';
import Browser from '../../../pages/Browser/BrowserView';
import TabBarComponent from '../../../pages/wallet/TabBarComponent';
import { loginToApp } from '../../../viewHelper';
import SigningBottomSheet from '../../../pages/Browser/SigningBottomSheet';
import TestDApp from '../../../pages/Browser/TestDApp';
import FixtureBuilder from '../../../fixtures/fixture-builder';
import {
withFixtures,
defaultGanacheOptions,
} from '../../../fixtures/fixture-helper';
import { SmokeConfirmations } from '../../../tags';
import TestHelpers from '../../../helpers';
import Assertions from '../../../utils/Assertions';

describe(SmokeConfirmations('Ethereum Sign'), () => {
beforeAll(async () => {
jest.setTimeout(2500000);
await TestHelpers.reverseServerPort();
});

it('Sign in with Ethereum', async () => {
await withFixtures(
{
dapp: true,
fixture: new FixtureBuilder()
.withGanacheNetwork()
.withPermissionControllerConnectedToTestDapp()
.build(),
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
},
async () => {
await loginToApp();

await TabBarComponent.tapBrowser();
await Browser.navigateToTestDApp();

await TestDApp.tapEthereumSignButton();
await Assertions.checkIfVisible(SigningBottomSheet.personalRequest);
await SigningBottomSheet.tapCancelButton();
await Assertions.checkIfNotVisible(SigningBottomSheet.personalRequest);

await TestDApp.tapEthereumSignButton();
await Assertions.checkIfVisible(SigningBottomSheet.personalRequest);
await SigningBottomSheet.tapSignButton();
await Assertions.checkIfNotVisible(SigningBottomSheet.personalRequest);
},
);
});
});

0 comments on commit 9054f70

Please sign in to comment.