-
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat(metamask): Add support for adding new accounts (#1023)
- Loading branch information
1 parent
82f9e1f
commit 8cb0df5
Showing
6 changed files
with
59 additions
and
0 deletions.
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
18 changes: 18 additions & 0 deletions
18
wallets/metamask/src/pages/HomePage/actions/addNewAccount.ts
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,18 @@ | ||
import type { Page } from '@playwright/test' | ||
import Selectors from '../selectors' | ||
|
||
export async function addNewAccount(page: Page, accountName: string) { | ||
// TODO: Use zod to validate this. | ||
if (accountName.length === 0) { | ||
throw new Error('[AddNewAccount] Account name cannot be an empty string') | ||
} | ||
|
||
await page.locator(Selectors.accountMenu.accountButton).click() | ||
|
||
await page.locator(Selectors.accountMenu.addAccountMenu.addAccountButton).click() | ||
await page.locator(Selectors.accountMenu.addAccountMenu.addNewAccountButton).click() | ||
|
||
await page.locator(Selectors.accountMenu.addAccountMenu.addNewAccountMenu.accountNameInput).fill(accountName) | ||
|
||
await page.locator(Selectors.accountMenu.addAccountMenu.addNewAccountMenu.createButton).click() | ||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { testWithSynpress } from 'fixtures' | ||
import { MetaMask, unlockForFixture } from '../../../src' | ||
|
||
import basicSetup from '../wallet-setup/basic.setup' | ||
|
||
const test = testWithSynpress(basicSetup, unlockForFixture) | ||
|
||
const { expect } = test | ||
|
||
test('should add a new account with specified name', async ({ context, metamaskPage }) => { | ||
const metamask = new MetaMask(context, metamaskPage, basicSetup.walletPassword) | ||
|
||
const accountName = 'Test Account' | ||
await metamask.addNewAccount(accountName) | ||
|
||
await expect(metamaskPage.locator(metamask.homePage.selectors.accountMenu.accountButton)).toHaveText(accountName) | ||
}) | ||
|
||
test('should throw an error if an empty account name is passed', async ({ context, metamaskPage }) => { | ||
const metamask = new MetaMask(context, metamaskPage, basicSetup.walletPassword) | ||
|
||
await expect(metamask.addNewAccount('')).rejects.toThrowError( | ||
'[AddNewAccount] Account name cannot be an empty string' | ||
) | ||
}) |