-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🏗️ chore(metamask): Add core
MetaMask
class (#984)
- Loading branch information
1 parent
461ca58
commit 46b9047
Showing
40 changed files
with
210 additions
and
170 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,5 +1,2 @@ | ||
export * from './prepareExtension' | ||
export * from './pages' | ||
export * from './actions' | ||
export * from './selectors' | ||
export * from './utils/getExtensionId' | ||
export * from './metamask' | ||
export * from './fixture-actions/unlockForFixture' |
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,35 @@ | ||
import type { BrowserContext, Page } from '@playwright/test' | ||
import { CrashPage, HomePage, LockPage, NotificationPage, OnboardingPage } from './pages' | ||
|
||
export class MetaMask { | ||
crashPage: CrashPage | ||
onboardingPage: OnboardingPage | ||
lockPage: LockPage | ||
homePage: HomePage | ||
notificationPage: NotificationPage | ||
|
||
constructor(readonly context: BrowserContext, readonly page: Page, readonly password: string) { | ||
this.crashPage = new CrashPage() | ||
|
||
this.onboardingPage = new OnboardingPage(page) | ||
this.lockPage = new LockPage(page) | ||
this.homePage = new HomePage(page) | ||
this.notificationPage = new NotificationPage(page) | ||
} | ||
|
||
async importWallet(seedPhrase: string) { | ||
await this.onboardingPage.importWallet(seedPhrase, this.password) | ||
} | ||
|
||
async connectToDapp(extensionId: string) { | ||
await this.notificationPage.connectToDapp(extensionId) | ||
} | ||
|
||
async lock() { | ||
await this.homePage.lock() | ||
} | ||
|
||
async unlock() { | ||
await this.lockPage.unlock(this.password) | ||
} | ||
} |
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,6 @@ | ||
import Selectors from './selectors' | ||
|
||
export class CrashPage { | ||
static readonly selectors = Selectors | ||
readonly selectors = Selectors | ||
} |
2 changes: 1 addition & 1 deletion
2
...ets/metamask/src/selectors/crash/index.ts → ...sk/src/pages/CrashPage/selectors/index.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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
const container = 'section.error-page' | ||
|
||
export const CrashPageSelectors = { | ||
export default { | ||
header: `${container} > .error-page__header`, | ||
errors: `${container} > .error-page__details li` | ||
} |
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 @@ | ||
export * from './lock' |
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,7 @@ | ||
import type { Page } from '@playwright/test' | ||
import Selectors from '../selectors' | ||
|
||
export async function lock(page: Page) { | ||
await page.locator(Selectors.accountMenu.accountMenuButton).click() | ||
await page.locator(Selectors.accountMenu.lockButton).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { Page } from '@playwright/test' | ||
import { lock } from './actions' | ||
import Selectors from './selectors' | ||
|
||
export class HomePage { | ||
static readonly selectors = Selectors | ||
readonly selectors = Selectors | ||
|
||
readonly page: Page | ||
|
||
constructor(page: Page) { | ||
this.page = page | ||
} | ||
|
||
async lock() { | ||
await lock(this.page) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...s/metamask/src/selectors/main/homePage.ts → ...ask/src/pages/HomePage/selectors/index.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
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 @@ | ||
export * from './unlock' |
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,10 @@ | ||
import type { Page } from '@playwright/test' | ||
import { waitForSpinnerToVanish } from '../../../utils/waitForSpinnerToVanish' | ||
import Selectors from '../selectors' | ||
|
||
export async function unlock(page: Page, password: string) { | ||
await page.locator(Selectors.passwordInput).fill(password) | ||
await page.locator(Selectors.submitButton).click() | ||
|
||
await waitForSpinnerToVanish(page) | ||
} |
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 { unlock } from './actions' | ||
import Selectors from './selectors' | ||
|
||
export class LockPage { | ||
static readonly selectors = Selectors | ||
readonly selectors = Selectors | ||
|
||
readonly page: Page | ||
|
||
constructor(page: Page) { | ||
this.page = page | ||
} | ||
|
||
async unlock(password: string) { | ||
await unlock(this.page, password) | ||
} | ||
} |
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,6 @@ | ||
import { createDataTestSelector } from '../../../utils/selectors/createDataTestSelector' | ||
|
||
export default { | ||
passwordInput: createDataTestSelector('unlock-password'), | ||
submitButton: createDataTestSelector('unlock-submit') | ||
} |
2 changes: 1 addition & 1 deletion
2
...ets/metamask/src/actions/connectToDapp.ts → ...NotificationPage/actions/connectToDapp.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
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 @@ | ||
export * from './connectToDapp' |
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,14 @@ | ||
import type { Page } from '@playwright/test' | ||
import { connectToDapp } from './actions' | ||
|
||
export class NotificationPage { | ||
readonly page: Page | ||
|
||
constructor(page: Page) { | ||
this.page = page | ||
} | ||
|
||
async connectToDapp(extensionId: string) { | ||
await connectToDapp(this.page.context(), extensionId) | ||
} | ||
} |
File renamed without changes.
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 @@ | ||
export * from './getNotificationPage' |
4 changes: 2 additions & 2 deletions
4
wallets/metamask/src/pages/OnboardingPage/actions/helpers/confirmSecretRecoveryPhrase.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
4 changes: 2 additions & 2 deletions
4
wallets/metamask/src/pages/OnboardingPage/actions/helpers/createPassword.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
17 changes: 6 additions & 11 deletions
17
wallets/metamask/src/pages/OnboardingPage/actions/importWallet.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 |
---|---|---|
@@ -1,23 +1,18 @@ | ||
import type { Page } from '@playwright/test' | ||
import { | ||
AnalyticsPageSelectors, | ||
GetStartedPageSelectors, | ||
PinExtensionPageSelectors, | ||
WalletCreationSuccessPageSelectors | ||
} from '../selectors' | ||
import Selectors from '../selectors' | ||
import { confirmSecretRecoveryPhrase, createPassword } from './helpers' | ||
|
||
export async function importWallet(page: Page, seedPhrase: string, password: string) { | ||
await page.locator(GetStartedPageSelectors.importWallet).click() | ||
await page.locator(Selectors.GetStartedPageSelectors.importWallet).click() | ||
|
||
await page.locator(AnalyticsPageSelectors.optOut).click() | ||
await page.locator(Selectors.AnalyticsPageSelectors.optOut).click() | ||
|
||
// Secret Recovery Phrase Page | ||
await confirmSecretRecoveryPhrase(page, seedPhrase) | ||
await createPassword(page, password) | ||
|
||
await page.locator(WalletCreationSuccessPageSelectors.confirmButton).click() | ||
await page.locator(Selectors.WalletCreationSuccessPageSelectors.confirmButton).click() | ||
|
||
await page.locator(PinExtensionPageSelectors.nextButton).click() | ||
await page.locator(PinExtensionPageSelectors.confirmButton).click() | ||
await page.locator(Selectors.PinExtensionPageSelectors.nextButton).click() | ||
await page.locator(Selectors.PinExtensionPageSelectors.confirmButton).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
export * from './OnboardingPage/page' | ||
export * from './CrashPage/page' | ||
export * from './LockPage/page' | ||
export * from './HomePage/page' | ||
export * from './NotificationPage/page' |
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,4 +1 @@ | ||
export * from './unlocking' | ||
export * from './loading' | ||
export * from './crash' | ||
export * from './main' |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.