From 9054f70aaa9968c9d1bbc0a88c14b40c52747e74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n?= Date: Wed, 18 Dec 2024 14:07:13 +0100 Subject: [PATCH] test: add Ethereum sign in e2e (#12737) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **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. --- e2e/pages/Browser/TestDApp.js | 11 ++++ e2e/selectors/Browser/TestDapp.selectors.js | 2 +- .../signatures/ethereum-sign.spec.js | 51 +++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 e2e/specs/confirmations/signatures/ethereum-sign.spec.js diff --git a/e2e/pages/Browser/TestDApp.js b/e2e/pages/Browser/TestDApp.js index 56f846e6942..cdf89c571f8 100644 --- a/e2e/pages/Browser/TestDApp.js +++ b/e2e/pages/Browser/TestDApp.js @@ -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( @@ -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); } diff --git a/e2e/selectors/Browser/TestDapp.selectors.js b/e2e/selectors/Browser/TestDapp.selectors.js index 8b2649767ab..0f2b7cad254 100644 --- a/e2e/selectors/Browser/TestDapp.selectors.js +++ b/e2e/selectors/Browser/TestDapp.selectors.js @@ -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', }; diff --git a/e2e/specs/confirmations/signatures/ethereum-sign.spec.js b/e2e/specs/confirmations/signatures/ethereum-sign.spec.js new file mode 100644 index 00000000000..4be24f172ca --- /dev/null +++ b/e2e/specs/confirmations/signatures/ethereum-sign.spec.js @@ -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); + }, + ); + }); +});