Skip to content

Commit

Permalink
merge and import
Browse files Browse the repository at this point in the history
  • Loading branch information
Seroxdesign committed Jul 8, 2024
1 parent 802a7ee commit b6330f6
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 5 deletions.
2 changes: 1 addition & 1 deletion wallets/phantom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
32 changes: 32 additions & 0 deletions wallets/phantom/src/pages/LockPage/actions/createAccount.ts
Original file line number Diff line number Diff line change
@@ -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;
}
3 changes: 2 additions & 1 deletion wallets/phantom/src/pages/LockPage/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './importAccount'
export * from './importAccount'
export * from './createAccount'
6 changes: 5 additions & 1 deletion wallets/phantom/src/pages/LockPage/page.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)

Check failure

Code scanning / CodeQL

Invocation of non-function Error

Callee is not a function: it has type undefined.
}
}
5 changes: 3 additions & 2 deletions wallets/phantom/test/wallet-setup/import.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit b6330f6

Please sign in to comment.