From b6330f60cba9a0d9a8683d5573133ba18d38f102 Mon Sep 17 00:00:00 2001 From: Sero <69639595+Seroxdesign@users.noreply.github.com> Date: Mon, 8 Jul 2024 06:03:35 -0400 Subject: [PATCH] merge and import --- wallets/phantom/package.json | 2 +- .../pages/LockPage/actions/createAccount.ts | 32 +++++++++++++++++++ .../src/pages/LockPage/actions/index.ts | 3 +- wallets/phantom/src/pages/LockPage/page.ts | 6 +++- .../phantom/test/wallet-setup/import.setup.ts | 5 +-- 5 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 wallets/phantom/src/pages/LockPage/actions/createAccount.ts diff --git a/wallets/phantom/package.json b/wallets/phantom/package.json index 265aafa75..4c537c047 100644 --- a/wallets/phantom/package.json +++ b/wallets/phantom/package.json @@ -15,7 +15,7 @@ ], "scripts": { "build": "pnpm run clean && pnpm run build:dist && pnpm run build:types", - "build:cache": "synpress-cache test/wallet-setup --phantom --debug", + "build:cache": "synpress-cache test/wallet-setup --phantom --debug --force --phantom", "build:dist": "tsup --tsconfig tsconfig.build.json", "build:types": "tsc --emitDeclarationOnly --project tsconfig.build.json", "clean": "rimraf dist types", diff --git a/wallets/phantom/src/pages/LockPage/actions/createAccount.ts b/wallets/phantom/src/pages/LockPage/actions/createAccount.ts new file mode 100644 index 000000000..ac82a3293 --- /dev/null +++ b/wallets/phantom/src/pages/LockPage/actions/createAccount.ts @@ -0,0 +1,32 @@ +import type { Page } from '@playwright/test' +import { lockPageElements } from "../selectors"; + +export const importWallet = async (page: Page, secretWords: string, password: string) => { + await page.click(lockPageElements.firstTimeFlowPageElements.importWalletButton) + await page.click(lockPageElements.firstTimeFlowPageElements.importRecoveryPhraseButton) + + for (const [index, word] of secretWords.split(' ').entries()) { + const inputField = await page.locator(lockPageElements.firstTimeFlowImportPageElements.secretWordsInput(index)) + await inputField.fill(word) + } + await page.click(lockPageElements.firstTimeFlowImportPageElements.confirmWordsButton) + + await page.waitForLoadState('domcontentloaded') + + await page.click(lockPageElements.firstTimeFlowImportPageElements.confirmWordsButton) + + const walletInput = await page.locator(lockPageElements.firstTimeFlowImportPageElements.passwordInput) + await walletInput.fill(password) + + const confirmWalletInput = await page.locator(lockPageElements.firstTimeFlowImportPageElements.confirmPasswordInput) + await confirmWalletInput.fill(password) + + const checkbox = await page.locator(lockPageElements.firstTimeFlowImportPageElements.termsCheckbox) + await checkbox.click() + + await page.click(lockPageElements.firstTimeFlowImportPageElements.continueAfterPasswordButton) + + await page.click(lockPageElements.firstTimeFlowImportPageElements.getStartedButton); + + return true; +} \ No newline at end of file diff --git a/wallets/phantom/src/pages/LockPage/actions/index.ts b/wallets/phantom/src/pages/LockPage/actions/index.ts index 4aaa3d5e9..5fa3aef98 100644 --- a/wallets/phantom/src/pages/LockPage/actions/index.ts +++ b/wallets/phantom/src/pages/LockPage/actions/index.ts @@ -1 +1,2 @@ -export * from './importAccount' \ No newline at end of file +export * from './importAccount' +export * from './createAccount' \ No newline at end of file diff --git a/wallets/phantom/src/pages/LockPage/page.ts b/wallets/phantom/src/pages/LockPage/page.ts index 829a0adfc..a2e5cfc16 100644 --- a/wallets/phantom/src/pages/LockPage/page.ts +++ b/wallets/phantom/src/pages/LockPage/page.ts @@ -1,6 +1,6 @@ import type { Page } from '@playwright/test' import { lockPageElements } from './selectors' -import { importWallet } from './actions' +import { importWallet, createAccount } from './actions' export class LockPage { static readonly selectors = lockPageElements @@ -15,4 +15,8 @@ export class LockPage { async importWallet(secretWords: string, password: string) { await importWallet(this.page, secretWords, password) } + + async createWallet(password: string) { + await createAccount(this.page, password) + } } diff --git a/wallets/phantom/test/wallet-setup/import.setup.ts b/wallets/phantom/test/wallet-setup/import.setup.ts index 6e9692000..610882a3a 100644 --- a/wallets/phantom/test/wallet-setup/import.setup.ts +++ b/wallets/phantom/test/wallet-setup/import.setup.ts @@ -3,14 +3,15 @@ import { defineWalletSetup } from '@synthetixio/synpress-cache' import { PhantomWallet } from '../../src' import { getExtensionId } from '../../src/fixtureActions' -const PASSWORD = 'Test1234' +const PASSWORD = '12345678' +const SECRET_WORDS = 'miss lock clip bicycle once road marble stay stereo bar change home' const importPhantomWallet = defineWalletSetup(PASSWORD, async (context: BrowserContext, phantomPage: Page) => { const extensionId = await getExtensionId(context, 'phantom') const phantom = new PhantomWallet(phantomPage, context, PASSWORD, extensionId) try { - await phantom.importWallet({ secretWords: '', password: PASSWORD }) + await phantom.importWallet({ secretWords: SECRET_WORDS, password: PASSWORD }) } catch (e) { console.log('Error creating Keplr wallet:', e) }