-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add e2e for imported account being removed and then reimported (#…
…10380) <!-- 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** This PR adds an e2e that uses a fixture to start with the imported account present. The imported account is removed, and then imported again by private key. ## **Related issues** Fixes: [494](https://github.com/MetaMask/accounts-planning/issues/494) ## **Manual testing steps** 1. Go to this page... 2. 3. ## **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** - [x] 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). - [x] 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 - [x] 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
1 parent
35ae0b4
commit 234738a
Showing
5 changed files
with
138 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
import enContent from '../../locales/languages/en.json'; | ||
|
||
export const AccountListViewSelectorsIDs = { | ||
ACCOUNT_TYPE_LABEL: 'account-type-label', | ||
}; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export const AccountListViewSelectorsText = { | ||
REMOVE_IMPORTED_ACCOUNT: enContent.accounts.yes_remove_it, | ||
IMPORT_ACCOUNT: enContent.account_actions.import_account, | ||
CREATE_ACCOUNT: enContent.account_actions.add_new_account, | ||
ACCOUNT_TYPE_LABEL_TEXT: enContent.accounts.imported, | ||
}; |
72 changes: 72 additions & 0 deletions
72
e2e/specs/accounts/imported-account-remove-and-import.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
'use strict'; | ||
|
||
import { Regression } from '../../tags.js'; | ||
import TestHelpers from '../../helpers.js'; | ||
import FixtureBuilder from '../../fixtures/fixture-builder'; | ||
import { | ||
loadFixture, | ||
startFixtureServer, | ||
stopFixtureServer, | ||
} from '../../fixtures/fixture-helper'; | ||
import FixtureServer from '../../fixtures/fixture-server'; | ||
import { getFixturesServerPort } from '../../fixtures/utils'; | ||
import { loginToApp } from '../../viewHelper.js'; | ||
import WalletView from '../../pages/wallet/WalletView.js'; | ||
import AccountListView from '../../pages/AccountListView.js'; | ||
import ImportAccountView from '../../pages/ImportAccountView.js'; | ||
import Assertions from '../../utils/Assertions.js'; | ||
import { AccountListViewSelectorsText } from '../../selectors/AccountListView.selectors.js'; | ||
|
||
const fixtureServer = new FixtureServer(); | ||
// This key is for testing private key import only | ||
// It should NEVER hold any eth or token | ||
const TEST_PRIVATE_KEY = | ||
'cbfd798afcfd1fd8ecc48cbecb6dc7e876543395640b758a90e11d986e758ad1'; | ||
|
||
describe( | ||
Regression('removes and reimports an account using a private key'), | ||
() => { | ||
beforeAll(async () => { | ||
await TestHelpers.reverseServerPort(); | ||
const fixture = new FixtureBuilder() | ||
.withImportedAccountKeyringController() | ||
.build(); | ||
await startFixtureServer(fixtureServer); | ||
await loadFixture(fixtureServer, { fixture }); | ||
await device.launchApp({ | ||
launchArgs: { fixtureServerPort: `${getFixturesServerPort()}` }, | ||
}); | ||
await loginToApp(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await stopFixtureServer(fixtureServer); | ||
}); | ||
|
||
it('removes an imported account and imports it again using a private key', async () => { | ||
// Ensure imported account is present | ||
await WalletView.tapIdenticon(); | ||
await AccountListView.isVisible(); | ||
await AccountListView.checkAccountVisibilityAtIndex(1, true); | ||
|
||
// Remove the imported account | ||
await AccountListView.longPressImportedAccount(); | ||
await AccountListView.tapYesToRemoveImportedAccountAlertButton(); | ||
await AccountListView.checkAccountVisibilityAtIndex(1, false); | ||
await Assertions.checkIfNotVisible(AccountListView.accountTypeLabel()); | ||
|
||
// Import account again | ||
await AccountListView.tapAddAccountButton(); | ||
await AccountListView.tapImportAccountButton(); | ||
await ImportAccountView.isVisible(); | ||
await ImportAccountView.enterPrivateKey(TEST_PRIVATE_KEY); | ||
await ImportAccountView.isImportSuccessSreenVisible(); | ||
await ImportAccountView.tapCloseButtonOnImportSuccess(); | ||
await AccountListView.checkAccountVisibilityAtIndex(1, true); | ||
await Assertions.checkIfElementToHaveText( | ||
AccountListView.accountTypeLabel(), | ||
AccountListViewSelectorsText.ACCOUNT_TYPE_LABEL_TEXT, | ||
); | ||
}); | ||
}, | ||
); |