diff --git a/packages/cache/src/cli/cliEntrypoint.ts b/packages/cache/src/cli/cliEntrypoint.ts index b26bfe8e3..151b3a7fa 100644 --- a/packages/cache/src/cli/cliEntrypoint.ts +++ b/packages/cache/src/cli/cliEntrypoint.ts @@ -1,11 +1,11 @@ import os from 'node:os' import path from 'node:path' +import { WALLET_SETUP_DIR_NAME } from '@synthetixio/synpress-utils' +import { prepareExtension } from '@synthetixio/synpress-utils' import chalk from 'chalk' import { Command } from 'commander' import { rimraf } from 'rimraf' -import { WALLET_SETUP_DIR_NAME } from '@synthetixio/synpress-utils' import { createCache } from '../createCache' -import { prepareExtension } from '@synthetixio/synpress-utils' import { compileWalletSetupFunctions } from './compileWalletSetupFunctions' import { footer } from './footer' @@ -53,7 +53,6 @@ export const cliEntrypoint = async () => { console.log({ cacheDir: walletSetupDir, ...flags, headless: Boolean(process.env.HEADLESS) ?? false }, '\n') } - const extensionsToSetup = () => { const extensions = [] if (flags.keplr) { @@ -84,10 +83,10 @@ export const cliEntrypoint = async () => { console.log('extensions', extensionNames, 'walletSetupDir', walletSetupDir, 'flags', flags) const compiledWalletSetupDirPath = await compileWalletSetupFunctions(walletSetupDir, flags.debug) for (const extensionName of extensionNames) { - await createCache(compiledWalletSetupDirPath, () => prepareExtension(extensionName), flags.force); // Pass extensionName + await createCache(compiledWalletSetupDirPath, () => prepareExtension(extensionName), flags.force) // Pass extensionName } // TODO: We should be using `prepareExtension` function from the wallet itself! - + if (!flags.debug) { await rimraf(compiledWalletSetupDirPath) } diff --git a/packages/cache/src/cli/compileWalletSetupFunctions.ts b/packages/cache/src/cli/compileWalletSetupFunctions.ts index 8237dbb68..ed47a3df9 100644 --- a/packages/cache/src/cli/compileWalletSetupFunctions.ts +++ b/packages/cache/src/cli/compileWalletSetupFunctions.ts @@ -1,7 +1,7 @@ import path from 'node:path' +import { ensureCacheDirExists } from '@synthetixio/synpress-utils' import { glob } from 'glob' import { build } from 'tsup' -import { ensureCacheDirExists } from '@synthetixio/synpress-utils' import { FIXES_BANNER } from './compilationFixes' const OUT_DIR_NAME = 'wallet-setup-dist' diff --git a/packages/cache/src/synpress-utils.d.ts b/packages/cache/src/synpress-utils.d.ts index fc395992a..7b5c1bae0 100644 --- a/packages/cache/src/synpress-utils.d.ts +++ b/packages/cache/src/synpress-utils.d.ts @@ -1 +1 @@ -declare module '@synthetixio/synpress-utils' \ No newline at end of file +declare module '@synthetixio/synpress-utils' diff --git a/packages/cache/test/defineWalletSetup.test.ts b/packages/cache/test/defineWalletSetup.test.ts index 76a620b22..2fea17a36 100644 --- a/packages/cache/test/defineWalletSetup.test.ts +++ b/packages/cache/test/defineWalletSetup.test.ts @@ -1,5 +1,5 @@ -import { describe, expect, it } from 'vitest' import { defineWalletSetup } from '@synthetixio/synpress-utils' +import { describe, expect, it } from 'vitest' const PASSWORD = 'Quack Quack! 🦆' const EXPECTED_HASH = 'f9c5ea5bb2c3aac96ff4' diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 82e36644d..b411c51a9 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -17,6 +17,3 @@ export * from './utils/onDownloadProgress' export * from './utils/triggerCacheCreation' export * from './utils/waitForExtensionOnLoadPage' export * from './utils/removeTempContextDir' - - - diff --git a/packages/utils/src/prepareExtension.ts b/packages/utils/src/prepareExtension.ts index 523df0849..47546e3ea 100644 --- a/packages/utils/src/prepareExtension.ts +++ b/packages/utils/src/prepareExtension.ts @@ -1,47 +1,49 @@ import { downloadFile, ensureCacheDirExists, unzipArchive } from '.' interface ExtensionConfig { - name: string; - version: string; - downloadUrl: string; + name: string + version: string + downloadUrl: string } async function getExtensionConfig(name: string): Promise { const config = { - "extensions": [ + extensions: [ { - "name": "MetaMask", - "version": "11.9.1", - "downloadUrl": "https://github.com/MetaMask/metamask-extension/releases/download/v11.9.1/metamask-chrome-11.9.1.zip" + name: 'MetaMask', + version: '11.9.1', + downloadUrl: + 'https://github.com/MetaMask/metamask-extension/releases/download/v11.9.1/metamask-chrome-11.9.1.zip' }, { - "name": "Keplr", - "version": "0.12.102", - "downloadUrl": "https://github.com/chainapsis/keplr-wallet/releases/download/v0.12.102/keplr-extension-manifest-v2-v0.12.102.zip" + name: 'Keplr', + version: '0.12.102', + downloadUrl: + 'https://github.com/chainapsis/keplr-wallet/releases/download/v0.12.102/keplr-extension-manifest-v2-v0.12.102.zip' } ] } - const extension = config.extensions.find((ext: { name: string }) => ext.name === name); + const extension = config.extensions.find((ext: { name: string }) => ext.name === name) if (!extension) { - throw new Error(`Extension configuration not found for ${name}`); + throw new Error(`Extension configuration not found for ${name}`) } - return extension; + return extension } export async function prepareExtension(extensionName: string) { - const cacheDirPath = ensureCacheDirExists(); - const extensionConfig = await getExtensionConfig(extensionName); // Get config + const cacheDirPath = ensureCacheDirExists() + const extensionConfig = await getExtensionConfig(extensionName) // Get config const downloadResult = await downloadFile({ url: extensionConfig.downloadUrl, outputDir: cacheDirPath, fileName: `${extensionConfig.name.toLowerCase()}-chrome-${extensionConfig.version}.zip` - }); + }) const unzipResult = await unzipArchive({ archivePath: downloadResult.filePath - }); + }) - return unzipResult.outputPath; -} \ No newline at end of file + return unzipResult.outputPath +} diff --git a/release/src/index.ts b/release/src/index.ts index 882df1de7..b45c6f11b 100644 --- a/release/src/index.ts +++ b/release/src/index.ts @@ -1,7 +1,7 @@ import { EthereumWalletMock, ethereumWalletMockFixtures } from '@synthetixio/ethereum-wallet-mock' -import { defineWalletSetup } from '@synthetixio/synpress-utils' import { testWithSynpress } from '@synthetixio/synpress-core' import { MetaMask, getExtensionId, metaMaskFixtures } from '@synthetixio/synpress-metamask' +import { defineWalletSetup } from '@synthetixio/synpress-utils' export { // Framework fixtures diff --git a/wallets/keplr/src/KeplrWallet.ts b/wallets/keplr/src/KeplrWallet.ts index f9567a834..897afc03e 100644 --- a/wallets/keplr/src/KeplrWallet.ts +++ b/wallets/keplr/src/KeplrWallet.ts @@ -1,6 +1,6 @@ import { type BrowserContext, type Page } from '@playwright/test' -import { LockPage } from './pages/LockPage/page' import { HomePage } from './pages/HomePage/page' +import { LockPage } from './pages/LockPage/page' import { NotificationPage } from './pages/NotificationPage/page' export class KeplrWallet { @@ -12,7 +12,7 @@ export class KeplrWallet { readonly page: Page, readonly context?: BrowserContext, readonly password?: string, - readonly extensionId?: string | undefined, + readonly extensionId?: string | undefined ) { this.lockPage = new LockPage(page) this.homePage = new HomePage(page) @@ -20,20 +20,18 @@ export class KeplrWallet { } /** * Does initial setup for the wallet. - * + * * @param playwrightInstance. The playwright instance to use. * @param secretWordsOrPrivateKey. The secret words or private key to import. * @param password. The password to set. */ - async setupWallet( - { secretWordsOrPrivateKey, password }: { secretWordsOrPrivateKey: string; password: string }, - ) { + async setupWallet({ secretWordsOrPrivateKey, password }: { secretWordsOrPrivateKey: string; password: string }) { const wallet = await this.lockPage.importWallet(secretWordsOrPrivateKey, password) - return wallet; + return wallet } async getWalletAddress(wallet: string) { const walletAddress = await this.homePage.getWalletAddress(wallet) - return walletAddress; + return walletAddress } } diff --git a/wallets/keplr/src/cypress/index.ts b/wallets/keplr/src/cypress/index.ts index b06eeeeb6..c1cf1560a 100644 --- a/wallets/keplr/src/cypress/index.ts +++ b/wallets/keplr/src/cypress/index.ts @@ -1 +1 @@ -export { default as installSynpress } from './installSynpress' \ No newline at end of file +export { default as installSynpress } from './installSynpress' diff --git a/wallets/keplr/src/cypress/initKeplrWallet.ts b/wallets/keplr/src/cypress/initKeplrWallet.ts index 45fb219b2..cc520492a 100644 --- a/wallets/keplr/src/cypress/initKeplrWallet.ts +++ b/wallets/keplr/src/cypress/initKeplrWallet.ts @@ -1,7 +1,7 @@ import { type BrowserContext, type Page, chromium } from '@playwright/test' import { KeplrWallet } from '../KeplrWallet' -import { SEED_PHRASE, PASSWORD } from '../utils' +import { PASSWORD, SEED_PHRASE } from '../utils' import { MISSING_INIT, NO_CONTEXT, NO_PAGE } from './errors' let context: BrowserContext | undefined diff --git a/wallets/keplr/src/cypress/setupTasks.ts b/wallets/keplr/src/cypress/setupTasks.ts index 901126c20..42a0f015e 100644 --- a/wallets/keplr/src/cypress/setupTasks.ts +++ b/wallets/keplr/src/cypress/setupTasks.ts @@ -1,5 +1,5 @@ -import { PASSWORD, SEED_PHRASE } from "../utils" -import { getKeplrWallet } from "./initKeplrWallet" +import { PASSWORD, SEED_PHRASE } from '../utils' +import { getKeplrWallet } from './initKeplrWallet' export default function setupTasks(on: Cypress.PluginEvents) { on('task', { diff --git a/wallets/keplr/src/cypress/support/commands.ts b/wallets/keplr/src/cypress/support/commands.ts index 212bf091c..080ce4ca5 100644 --- a/wallets/keplr/src/cypress/support/commands.ts +++ b/wallets/keplr/src/cypress/support/commands.ts @@ -12,7 +12,7 @@ declare global { namespace Cypress { interface Chainable { - setupWallet({secretWordsOnPrivateKeys, password}: { secretWordsOnPrivateKeys: string, password: string }): any + setupWallet({ secretWordsOnPrivateKeys, password }: { secretWordsOnPrivateKeys: string; password: string }): Chainable } } } diff --git a/wallets/keplr/src/cypress/support/e2e.ts b/wallets/keplr/src/cypress/support/e2e.ts index aabeeb2d7..de6e9e568 100644 --- a/wallets/keplr/src/cypress/support/e2e.ts +++ b/wallets/keplr/src/cypress/support/e2e.ts @@ -18,4 +18,4 @@ import './commands' Cypress.on('uncaught:exception', () => { return false -}) \ No newline at end of file +}) diff --git a/wallets/keplr/src/fixtureActions/getExtensionId.ts b/wallets/keplr/src/fixtureActions/getExtensionId.ts index de7982cd5..aaa88cf3e 100644 --- a/wallets/keplr/src/fixtureActions/getExtensionId.ts +++ b/wallets/keplr/src/fixtureActions/getExtensionId.ts @@ -28,7 +28,7 @@ export async function getExtensionId(context: BrowserContext, extensionName: str const allExtensions = Extensions.parse(unparsedExtensions) const targetExtension = allExtensions.find( - (extension: any) => extension.name.toLowerCase() === extensionName.toLowerCase() + (extension: { name: string }) => extension.name.toLowerCase() === extensionName.toLowerCase() ) if (!targetExtension) { diff --git a/wallets/keplr/src/fixtureActions/index.ts b/wallets/keplr/src/fixtureActions/index.ts index 77a094411..525f21338 100644 --- a/wallets/keplr/src/fixtureActions/index.ts +++ b/wallets/keplr/src/fixtureActions/index.ts @@ -1 +1 @@ -export * from './getExtensionId' \ No newline at end of file +export * from './getExtensionId' diff --git a/wallets/keplr/src/fixtureActions/unlockForFixtures.ts b/wallets/keplr/src/fixtureActions/unlockForFixtures.ts index 5b0c07fc7..e4115d9e1 100644 --- a/wallets/keplr/src/fixtureActions/unlockForFixtures.ts +++ b/wallets/keplr/src/fixtureActions/unlockForFixtures.ts @@ -1,8 +1,8 @@ -import type { Page } from '@playwright/test'; +import type { Page } from '@playwright/test' import { LockPage } from '../pages/LockPage/page' export default async function unlockForFixtures(page: Page, password: string) { const lockpage = new LockPage(page) const wallet = await lockpage.unlock(password) - return wallet; -} \ No newline at end of file + return wallet +} diff --git a/wallets/keplr/src/fixtures/keplrFixtures.ts b/wallets/keplr/src/fixtures/keplrFixtures.ts index 5cff7bb1e..fac54fd41 100644 --- a/wallets/keplr/src/fixtures/keplrFixtures.ts +++ b/wallets/keplr/src/fixtures/keplrFixtures.ts @@ -2,19 +2,19 @@ import path from 'node:path' import { type Page, chromium } from '@playwright/test' import { test as base } from '@playwright/test' -import { KeplrWallet } from '../KeplrWallet' -import { PASSWORD } from '../utils' import { CACHE_DIR_NAME, createTempContextDir, defineWalletSetup, removeTempContextDir } from '@synthetixio/synpress-utils' +import { prepareExtension } from '@synthetixio/synpress-utils' import fs from 'fs-extra' -import { persistLocalStorage } from '../fixtureActions/persistLocalStorage' +import { KeplrWallet } from '../KeplrWallet' import { getExtensionId } from '../fixtureActions' -import { prepareExtension } from '@synthetixio/synpress-utils' +import { persistLocalStorage } from '../fixtureActions/persistLocalStorage' import unlockForFixtures from '../fixtureActions/unlockForFixtures' +import { PASSWORD } from '../utils' type KeplrFixtures = { _contextPath: string @@ -26,12 +26,11 @@ type KeplrFixtures = { let _keplrPage: Page export const keplrFixtures = (walletSetup: ReturnType, slowMo = 0) => { - console.log(walletSetup, 'ee') return base.extend({ _contextPath: async ({ browserName }, use, testInfo) => { const contextDir = await createTempContextDir(browserName, testInfo.testId) - + await use(contextDir) const error = await removeTempContextDir(contextDir) @@ -78,16 +77,15 @@ export const keplrFixtures = (walletSetup: ReturnType, const extensionId = await getExtensionId(context, 'Keplr') _keplrPage = context.pages()[0] as Page - + await _keplrPage.goto(`chrome-extension://${extensionId}/popup.html`) await unlockForFixtures(_keplrPage, PASSWORD) - + await use(context) - }, keplrPage: async ({ context: _ }, use) => { - await use(_keplrPage); + await use(_keplrPage) }, extensionId: async ({ context }, use) => { const extensionId = await getExtensionId(context, 'Keplr') @@ -103,6 +101,6 @@ export const keplrFixtures = (walletSetup: ReturnType, page: async ({ page }, use) => { await page.goto('https://wallet.keplr.app/') await use(page) - }, + } }) -} \ No newline at end of file +} diff --git a/wallets/keplr/src/pages/HomePage/actions/addNewTokensFound.ts b/wallets/keplr/src/pages/HomePage/actions/addNewTokensFound.ts index 4af732b6b..ad50ff474 100644 --- a/wallets/keplr/src/pages/HomePage/actions/addNewTokensFound.ts +++ b/wallets/keplr/src/pages/HomePage/actions/addNewTokensFound.ts @@ -1,12 +1,12 @@ -import type { Page } from "@playwright/test"; +import type { Page } from '@playwright/test' export const addNewTokensFound = async (page: Page, switchScreens = true) => { - console.log('addNewTokensFound', switchScreens, page); + console.log('addNewTokensFound', switchScreens, page) // if (switchScreens) { // module.exports.switchToKeplrIfNotActive(); // await module.exports.goToHome(); // } - + // await page.waitAndClickByText(homePageElements.newTokensFound); // await playwright.waitAndClickWithDelay( // homePageElements.selectAllTokensCheck, diff --git a/wallets/keplr/src/pages/HomePage/actions/getTokenAmount.ts b/wallets/keplr/src/pages/HomePage/actions/getTokenAmount.ts index b1ecae7f4..4341bede4 100644 --- a/wallets/keplr/src/pages/HomePage/actions/getTokenAmount.ts +++ b/wallets/keplr/src/pages/HomePage/actions/getTokenAmount.ts @@ -1,7 +1,7 @@ -import type { Page } from "@playwright/test"; +import type { Page } from '@playwright/test' export const getTokenAmount = async (page: Page, tokenName: string) => { - console.log('getTokenAmount', tokenName, page); + console.log('getTokenAmount', tokenName, page) // await module.exports.switchToKeplrIfNotActive(); // await module.exports.goToHome(); @@ -18,4 +18,4 @@ export const getTokenAmount = async (page: Page, tokenName: string) => { // const parsedTokenValue = Number(tokenValue.replace(/,/g, '')); // await playwright.switchToCypressWindow(); // return parsedTokenValue; -} \ No newline at end of file +} diff --git a/wallets/keplr/src/pages/HomePage/actions/getWalletAddress.ts b/wallets/keplr/src/pages/HomePage/actions/getWalletAddress.ts index 76f977d08..91de909bb 100644 --- a/wallets/keplr/src/pages/HomePage/actions/getWalletAddress.ts +++ b/wallets/keplr/src/pages/HomePage/actions/getWalletAddress.ts @@ -1,11 +1,11 @@ -import type { Page } from '@playwright/test'; -import { homePageElements } from '../selectors'; +import type { Page } from '@playwright/test' +import { homePageElements } from '../selectors' export const getWalletAddress = async (page: Page, wallet: string) => { - await page.waitForLoadState('domcontentloaded'); - await page.getByText(homePageElements.copyAddress).click(); - const chain = await page.waitForSelector(homePageElements.walletSelectors(wallet)); - await chain.click(); + await page.waitForLoadState('domcontentloaded') + await page.getByText(homePageElements.copyAddress).click() + const chain = await page.waitForSelector(homePageElements.walletSelectors(wallet)) + await chain.click() return 'no access to clipboard!' -} \ No newline at end of file +} diff --git a/wallets/keplr/src/pages/HomePage/actions/index.ts b/wallets/keplr/src/pages/HomePage/actions/index.ts index d13947b9a..4ae575b40 100644 --- a/wallets/keplr/src/pages/HomePage/actions/index.ts +++ b/wallets/keplr/src/pages/HomePage/actions/index.ts @@ -1,3 +1,3 @@ -export * from './addNewTokensFound'; -export * from './getWalletAddress'; -export * from './getTokenAmount'; \ No newline at end of file +export * from './addNewTokensFound' +export * from './getWalletAddress' +export * from './getTokenAmount' diff --git a/wallets/keplr/src/pages/HomePage/page.ts b/wallets/keplr/src/pages/HomePage/page.ts index 1a3864bd3..69a8b8d7e 100644 --- a/wallets/keplr/src/pages/HomePage/page.ts +++ b/wallets/keplr/src/pages/HomePage/page.ts @@ -1,6 +1,6 @@ import type { Page } from '@playwright/test' +import { addNewTokensFound, getTokenAmount, getWalletAddress } from './actions' import { homePageElements } from './selectors' -import { getTokenAmount, getWalletAddress, addNewTokensFound } from './actions' export class HomePage { static readonly selectors = homePageElements @@ -15,7 +15,7 @@ export class HomePage { async getTokenAmount() { return await getTokenAmount(this.page, 'token name') } - + async getWalletAddress(wallet: string) { return await getWalletAddress(this.page, wallet) } diff --git a/wallets/keplr/src/pages/HomePage/selectors/index.ts b/wallets/keplr/src/pages/HomePage/selectors/index.ts index b23ee90fc..b7f33080d 100644 --- a/wallets/keplr/src/pages/HomePage/selectors/index.ts +++ b/wallets/keplr/src/pages/HomePage/selectors/index.ts @@ -6,5 +6,5 @@ export const homePageElements = { addChainsButton: 'Add Chains', newTokensFoundSelector: 'text=new token(s) found', walletSelectors: (chainName: string) => `img[alt="${chainName}"]`, - copyAddress: 'Copy Address', -} \ No newline at end of file + copyAddress: 'Copy Address' +} diff --git a/wallets/keplr/src/pages/LockPage/actions/importWallet.ts b/wallets/keplr/src/pages/LockPage/actions/importWallet.ts index ce40255c4..acb0c2217 100644 --- a/wallets/keplr/src/pages/LockPage/actions/importWallet.ts +++ b/wallets/keplr/src/pages/LockPage/actions/importWallet.ts @@ -1,37 +1,36 @@ -import { onboardingElements } from "../selectors"; -import type { Page } from "@playwright/test"; +import type { Page } from '@playwright/test' +import { onboardingElements } from '../selectors' export async function importWallet(page: Page, secretWords: string, password: string) { - await page.waitForLoadState('domcontentloaded'); + await page.waitForLoadState('domcontentloaded') - const importButton = await page.getByText(onboardingElements.importRecoveryPhraseButton); + const importButton = await page.getByText(onboardingElements.importRecoveryPhraseButton) - await importButton.click(); - const useButton = await page.getByText(onboardingElements.useRecoveryPhraseButton); - await useButton.click(); - const phraseCount = await page.getByText(onboardingElements.phraseCount24); - await phraseCount.click(); - const wordsArray = secretWords.split(' '); - const inputFields = page.locator(onboardingElements.phraseInput); - const inputCount = await inputFields.count(); + await importButton.click() + const useButton = await page.getByText(onboardingElements.useRecoveryPhraseButton) + await useButton.click() + const phraseCount = await page.getByText(onboardingElements.phraseCount24) + await phraseCount.click() + const wordsArray = secretWords.split(' ') + const inputFields = page.locator(onboardingElements.phraseInput) + const inputCount = await inputFields.count() for (let i = 0; i < inputCount; i++) { - const inputField = inputFields.nth(i); - if (wordsArray[i]){ - await inputField.fill(wordsArray[i]!); + const inputField = inputFields.nth(i) + if (wordsArray[i]) { + await inputField.fill(wordsArray[i] || '') } } - const submitPhraseButton = await page.getByRole('button', { name: 'Import', exact: true }); - await submitPhraseButton.click(); - const walletInput = await page.locator(onboardingElements.walletInput); - await walletInput.fill(onboardingElements.walletName); - const passwordInput = await page.locator(onboardingElements.passwordInput); - await passwordInput.fill(password); - const confirmPasswordInput = await page.locator(onboardingElements.confirmPasswordInput); - await confirmPasswordInput.fill(password); - const submitWalletDataButton = await page.getByRole('button', { name: 'Next', exact: true }); - await submitWalletDataButton.click(); - const submitChainButton = await page.getByRole('button', { name: 'Save', exact: true }); - await submitChainButton.click(); - await page.close(); -} - + const submitPhraseButton = await page.getByRole('button', { name: 'Import', exact: true }) + await submitPhraseButton.click() + const walletInput = await page.locator(onboardingElements.walletInput) + await walletInput.fill(onboardingElements.walletName) + const passwordInput = await page.locator(onboardingElements.passwordInput) + await passwordInput.fill(password) + const confirmPasswordInput = await page.locator(onboardingElements.confirmPasswordInput) + await confirmPasswordInput.fill(password) + const submitWalletDataButton = await page.getByRole('button', { name: 'Next', exact: true }) + await submitWalletDataButton.click() + const submitChainButton = await page.getByRole('button', { name: 'Save', exact: true }) + await submitChainButton.click() + await page.close() +} diff --git a/wallets/keplr/src/pages/LockPage/actions/index.ts b/wallets/keplr/src/pages/LockPage/actions/index.ts index c2828e215..209e35f7e 100644 --- a/wallets/keplr/src/pages/LockPage/actions/index.ts +++ b/wallets/keplr/src/pages/LockPage/actions/index.ts @@ -1,2 +1,2 @@ -export * from './importWallet'; -export * from './unlockWallet'; \ No newline at end of file +export * from './importWallet' +export * from './unlockWallet' diff --git a/wallets/keplr/src/pages/LockPage/actions/unlockWallet.ts b/wallets/keplr/src/pages/LockPage/actions/unlockWallet.ts index f3432b2c2..6a558197a 100644 --- a/wallets/keplr/src/pages/LockPage/actions/unlockWallet.ts +++ b/wallets/keplr/src/pages/LockPage/actions/unlockWallet.ts @@ -1,11 +1,11 @@ -import { onboardingElements } from "../selectors"; -import type { Page } from "@playwright/test"; +import type { Page } from '@playwright/test' +import { onboardingElements } from '../selectors' export async function unlockWallet(page: Page, password: string) { - await page.waitForLoadState('domcontentloaded'); - const passwordField = page.locator(onboardingElements.unlockPasswordInput); - await passwordField.fill(password); - const button = await page.$(onboardingElements.unlockConfirmPasswordInput); - button?.click(); - return true; -} \ No newline at end of file + await page.waitForLoadState('domcontentloaded') + const passwordField = page.locator(onboardingElements.unlockPasswordInput) + await passwordField.fill(password) + const button = await page.$(onboardingElements.unlockConfirmPasswordInput) + button?.click() + return true +} diff --git a/wallets/keplr/src/pages/LockPage/page.ts b/wallets/keplr/src/pages/LockPage/page.ts index 57b0eb34f..fb0c3703a 100644 --- a/wallets/keplr/src/pages/LockPage/page.ts +++ b/wallets/keplr/src/pages/LockPage/page.ts @@ -1,7 +1,7 @@ import type { Page } from '@playwright/test' -import { onboardingElements } from './selectors' import { importWallet } from './actions' import { unlockWallet } from './actions' +import { onboardingElements } from './selectors' export class LockPage { static readonly selectors = onboardingElements diff --git a/wallets/keplr/src/pages/LockPage/selectors/index.ts b/wallets/keplr/src/pages/LockPage/selectors/index.ts index 319e6430c..50b18c789 100644 --- a/wallets/keplr/src/pages/LockPage/selectors/index.ts +++ b/wallets/keplr/src/pages/LockPage/selectors/index.ts @@ -22,5 +22,5 @@ export const onboardingElements = { submitChainButton: 'button[type="button"]', finishButton: 'button[type="button"]', textAreaSelector: 'textbox', - submitPhraseButton: '.sc-bZkfAO jGdbNJ', -}; + submitPhraseButton: '.sc-bZkfAO jGdbNJ' +} diff --git a/wallets/keplr/src/pages/NotificationPage/actions/acceptAccess.ts b/wallets/keplr/src/pages/NotificationPage/actions/acceptAccess.ts index d225ebf37..7816fa854 100644 --- a/wallets/keplr/src/pages/NotificationPage/actions/acceptAccess.ts +++ b/wallets/keplr/src/pages/NotificationPage/actions/acceptAccess.ts @@ -1,8 +1,7 @@ - -import { notificationPageElements } from '../selectors'; +import { notificationPageElements } from '../selectors' export const acceptAccess = async () => { - console.log('Accepting access in Keplr wallet', notificationPageElements); + console.log('Accepting access in Keplr wallet', notificationPageElements) // const notificationPage = await playwright.switchToKeplrNotification(); // await playwright.waitAndClick( // notificationPageElements.approveButton, diff --git a/wallets/keplr/src/pages/NotificationPage/actions/confirmAccess.ts b/wallets/keplr/src/pages/NotificationPage/actions/confirmAccess.ts index 9aa5b9586..458a05a3e 100644 --- a/wallets/keplr/src/pages/NotificationPage/actions/confirmAccess.ts +++ b/wallets/keplr/src/pages/NotificationPage/actions/confirmAccess.ts @@ -1,12 +1,12 @@ -import { notificationPageElements } from "../selectors"; +import { notificationPageElements } from '../selectors' export const confirmTransaction = async () => { console.log('Confirming transaction in Keplr wallet', notificationPageElements) - // const notificationPage = await playwright.switchToKeplrNotification(); - // await playwright.waitAndClick( - // notificationPageElements.approveButton, - // notificationPage, - // { waitForEvent: 'close' }, - // ); - return true; - } \ No newline at end of file + // const notificationPage = await playwright.switchToKeplrNotification(); + // await playwright.waitAndClick( + // notificationPageElements.approveButton, + // notificationPage, + // { waitForEvent: 'close' }, + // ); + return true +} diff --git a/wallets/keplr/src/pages/NotificationPage/actions/index.ts b/wallets/keplr/src/pages/NotificationPage/actions/index.ts index 0c7179ffc..5b7fd73fd 100644 --- a/wallets/keplr/src/pages/NotificationPage/actions/index.ts +++ b/wallets/keplr/src/pages/NotificationPage/actions/index.ts @@ -1,2 +1,2 @@ -export * from './acceptAccess'; -export * from './confirmAccess'; \ No newline at end of file +export * from './acceptAccess' +export * from './confirmAccess' diff --git a/wallets/keplr/src/pages/NotificationPage/page.ts b/wallets/keplr/src/pages/NotificationPage/page.ts index 1182e8090..9b5a42679 100644 --- a/wallets/keplr/src/pages/NotificationPage/page.ts +++ b/wallets/keplr/src/pages/NotificationPage/page.ts @@ -1,6 +1,6 @@ import type { Page } from '@playwright/test' +import { acceptAccess, confirmTransaction } from './actions' import { notificationPageElements } from './selectors' -import { confirmTransaction, acceptAccess } from './actions' export class NotificationPage { static readonly selectors = notificationPageElements diff --git a/wallets/keplr/src/pages/NotificationPage/selectors/index.ts b/wallets/keplr/src/pages/NotificationPage/selectors/index.ts index f247584b8..7918a53cb 100644 --- a/wallets/keplr/src/pages/NotificationPage/selectors/index.ts +++ b/wallets/keplr/src/pages/NotificationPage/selectors/index.ts @@ -1,5 +1,5 @@ export const notificationPageElements = { approveButton: 'button', copyAddress: 'Copy Address', - walletSelectors: (chainName: string) => `img[alt="${chainName}"]`, -}; \ No newline at end of file + walletSelectors: (chainName: string) => `img[alt="${chainName}"]` +} diff --git a/wallets/keplr/src/synpress-utils.d.ts b/wallets/keplr/src/synpress-utils.d.ts index fc395992a..7b5c1bae0 100644 --- a/wallets/keplr/src/synpress-utils.d.ts +++ b/wallets/keplr/src/synpress-utils.d.ts @@ -1 +1 @@ -declare module '@synthetixio/synpress-utils' \ No newline at end of file +declare module '@synthetixio/synpress-utils' diff --git a/wallets/keplr/src/utils/constants.ts b/wallets/keplr/src/utils/constants.ts index 037a560dc..041660dcc 100644 --- a/wallets/keplr/src/utils/constants.ts +++ b/wallets/keplr/src/utils/constants.ts @@ -1,5 +1,6 @@ -export const SEED_PHRASE = 'orbit bench unit task food shock brand bracket domain regular warfare company announce wheel grape trust sphere boy doctor half guard ritual three ecology' +export const SEED_PHRASE = + 'orbit bench unit task food shock brand bracket domain regular warfare company announce wheel grape trust sphere boy doctor half guard ritual three ecology' export const PASSWORD = 'Test1234' export const NO_CONTEXT = 'No context found' export const NO_PAGE = 'No page found' -export const MISSING_INIT = 'Keplr not initialized' \ No newline at end of file +export const MISSING_INIT = 'Keplr not initialized' diff --git a/wallets/keplr/src/utils/helpers.ts b/wallets/keplr/src/utils/helpers.ts index 071fd686f..ae7945734 100644 --- a/wallets/keplr/src/utils/helpers.ts +++ b/wallets/keplr/src/utils/helpers.ts @@ -1 +1 @@ -export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)) \ No newline at end of file +export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)) diff --git a/wallets/keplr/src/utils/index.ts b/wallets/keplr/src/utils/index.ts index 363c822da..f87cf0102 100644 --- a/wallets/keplr/src/utils/index.ts +++ b/wallets/keplr/src/utils/index.ts @@ -1 +1 @@ -export * from './constants' \ No newline at end of file +export * from './constants' diff --git a/wallets/keplr/test/cypress/setupAccount.cy.ts b/wallets/keplr/test/cypress/setupAccount.cy.ts index 1d5a8fed8..a57ca788d 100644 --- a/wallets/keplr/test/cypress/setupAccount.cy.ts +++ b/wallets/keplr/test/cypress/setupAccount.cy.ts @@ -1,7 +1,7 @@ -import { SEED_PHRASE, PASSWORD, KeplrWallet } from "../../src" +import { KeplrWallet, PASSWORD, SEED_PHRASE } from '../../src' it('should import a wallet', () => { cy.setupWallet({ secretWordsOnPrivateKeys: SEED_PHRASE, password: PASSWORD }).then((wallet: KeplrWallet) => { expect(wallet).to.be.true }) -}) \ No newline at end of file +}) diff --git a/wallets/keplr/test/synpress.ts b/wallets/keplr/test/synpress.ts index 81b23d386..8f66b7b05 100644 --- a/wallets/keplr/test/synpress.ts +++ b/wallets/keplr/test/synpress.ts @@ -1,5 +1,5 @@ -import { testWithSynpress } from "@synthetixio/synpress-core"; -import { keplrFixtures } from "../src"; -import connectedKeplrSetup from "./wallet-setup/connected-keplr.setup"; +import { testWithSynpress } from '@synthetixio/synpress-core' +import { keplrFixtures } from '../src' +import connectedKeplrSetup from './wallet-setup/connected-keplr.setup' -export default testWithSynpress(keplrFixtures(connectedKeplrSetup)) \ No newline at end of file +export default testWithSynpress(keplrFixtures(connectedKeplrSetup)) diff --git a/wallets/keplr/test/wallet-setup/connected-keplr-two.setup.ts b/wallets/keplr/test/wallet-setup/connected-keplr-two.setup.ts index 1035072fe..f7ab94f9b 100644 --- a/wallets/keplr/test/wallet-setup/connected-keplr-two.setup.ts +++ b/wallets/keplr/test/wallet-setup/connected-keplr-two.setup.ts @@ -1,9 +1,10 @@ -import { defineWalletSetup } from "@synthetixio/synpress-utils"; -import { KeplrWallet } from "../../src"; -import { getExtensionId } from "../../src/fixtureActions"; -import type { BrowserContext, Page } from "@playwright/test"; +import type { BrowserContext, Page } from '@playwright/test' +import { defineWalletSetup } from '@synthetixio/synpress-utils' +import { KeplrWallet } from '../../src' +import { getExtensionId } from '../../src/fixtureActions' -const SEED_PHRASE = 'orbit bench unit task food shock brand bracket domain regular warfare company announce wheel grape trust sphere boy doctor half guard ritual three ecology' +const SEED_PHRASE = + 'orbit bench unit task food shock brand bracket domain regular warfare company announce wheel grape trust sphere boy doctor half guard ritual three ecology' const PASSWORD = 'Test1234' const connectedKeplrSetup = defineWalletSetup(PASSWORD, async (context: BrowserContext, keplrPage: Page) => { @@ -11,10 +12,10 @@ const connectedKeplrSetup = defineWalletSetup(PASSWORD, async (context: BrowserC const keplr = new KeplrWallet(keplrPage, context, PASSWORD, extensionId) try { - await keplr.setupWallet({ secretWordsOrPrivateKey: SEED_PHRASE, password: PASSWORD}) + await keplr.setupWallet({ secretWordsOrPrivateKey: SEED_PHRASE, password: PASSWORD }) } catch (e) { console.log('Error setting up Keplr wallet:', e) } }) -export default connectedKeplrSetup \ No newline at end of file +export default connectedKeplrSetup diff --git a/wallets/keplr/test/wallet-setup/connected-keplr.setup.ts b/wallets/keplr/test/wallet-setup/connected-keplr.setup.ts index bbfbb9a67..38ee730ff 100644 --- a/wallets/keplr/test/wallet-setup/connected-keplr.setup.ts +++ b/wallets/keplr/test/wallet-setup/connected-keplr.setup.ts @@ -1,16 +1,17 @@ -import { defineWalletSetup } from "@synthetixio/synpress-utils"; -import { KeplrWallet } from "../../src"; -import { getExtensionId } from "../../src/fixtureActions"; -import type { BrowserContext, Page } from "@playwright/test"; +import type { BrowserContext, Page } from '@playwright/test' +import { defineWalletSetup } from '@synthetixio/synpress-utils' +import { KeplrWallet } from '../../src' +import { getExtensionId } from '../../src/fixtureActions' -const SEED_PHRASE = 'orbit bench unit task food shock brand bracket domain regular warfare company announce wheel grape trust sphere boy doctor half guard ritual three ecology' +const SEED_PHRASE = + 'orbit bench unit task food shock brand bracket domain regular warfare company announce wheel grape trust sphere boy doctor half guard ritual three ecology' const PASSWORD = 'Test1234' const connectedKeplrSetup = defineWalletSetup(PASSWORD, async (context: BrowserContext, keplrPage: Page) => { const extensionId = await getExtensionId(context, 'keplr') const keplr = new KeplrWallet(keplrPage, context, PASSWORD, extensionId) - await keplr.setupWallet({ secretWordsOrPrivateKey: SEED_PHRASE, password: PASSWORD}) + await keplr.setupWallet({ secretWordsOrPrivateKey: SEED_PHRASE, password: PASSWORD }) }) -export default connectedKeplrSetup \ No newline at end of file +export default connectedKeplrSetup diff --git a/wallets/metamask/src/fixtures/metaMaskFixtures.ts b/wallets/metamask/src/fixtures/metaMaskFixtures.ts index 725b28ed8..840e151ed 100644 --- a/wallets/metamask/src/fixtures/metaMaskFixtures.ts +++ b/wallets/metamask/src/fixtures/metaMaskFixtures.ts @@ -1,8 +1,7 @@ -import { MetaMask, getExtensionId, unlockForFixture } from '../../src' -import { prepareExtension } from '@synthetixio/synpress-utils' import path from 'node:path' import { type Page, chromium } from '@playwright/test' import { test as base } from '@playwright/test' +import { prepareExtension } from '@synthetixio/synpress-utils' import { CACHE_DIR_NAME, createTempContextDir, @@ -11,6 +10,7 @@ import { } from '@synthetixio/synpress-utils' import { type Anvil, type CreateAnvilOptions, createPool } from '@viem/anvil' import fs from 'fs-extra' +import { MetaMask, getExtensionId, unlockForFixture } from '../../src' import { persistLocalStorage } from '../fixture-actions/persistLocalStorage' type MetaMaskFixtures = { diff --git a/wallets/metamask/src/synpress-utils.d.ts b/wallets/metamask/src/synpress-utils.d.ts index fc395992a..7b5c1bae0 100644 --- a/wallets/metamask/src/synpress-utils.d.ts +++ b/wallets/metamask/src/synpress-utils.d.ts @@ -1 +1 @@ -declare module '@synthetixio/synpress-utils' \ No newline at end of file +declare module '@synthetixio/synpress-utils' diff --git a/wallets/metamask/test/e2e/importWallet.spec.ts b/wallets/metamask/test/e2e/importWallet.spec.ts index a7dfbf8f8..6b4e3dbcc 100644 --- a/wallets/metamask/test/e2e/importWallet.spec.ts +++ b/wallets/metamask/test/e2e/importWallet.spec.ts @@ -1,6 +1,6 @@ import { type Page, chromium, test as base } from '@playwright/test' -import { MetaMask } from '../../src' import { prepareExtension } from '@synthetixio/synpress-utils' +import { MetaMask } from '../../src' const SEED_PHRASE = 'test test test test test test test test test test test junk' const PASSWORD = 'Tester@1234' diff --git a/wallets/metamask/test/unit/prepareExtension.test.ts b/wallets/metamask/test/unit/prepareExtension.test.ts index 72dc0eb5a..736fb6394 100644 --- a/wallets/metamask/test/unit/prepareExtension.test.ts +++ b/wallets/metamask/test/unit/prepareExtension.test.ts @@ -1,6 +1,6 @@ import * as core from '@synthetixio/synpress-cache' -import { afterAll, afterEach, describe, expect, it, vi } from 'vitest' import { prepareExtension } from '@synthetixio/synpress-utils' +import { afterAll, afterEach, describe, expect, it, vi } from 'vitest' const DEFAULT_METAMASK_VERSION = '11.9.1' const EXTENSION_DOWNLOAD_URL = `https://github.com/MetaMask/metamask-extension/releases/download/v${DEFAULT_METAMASK_VERSION}/metamask-chrome-${DEFAULT_METAMASK_VERSION}.zip` diff --git a/wallets/metamask/test/wallet-setup/basic.setup.ts b/wallets/metamask/test/wallet-setup/basic.setup.ts index 6ab0d291f..e6b0e1bb0 100644 --- a/wallets/metamask/test/wallet-setup/basic.setup.ts +++ b/wallets/metamask/test/wallet-setup/basic.setup.ts @@ -1,6 +1,6 @@ +import type { BrowserContext, Page } from '@playwright/test' import { defineWalletSetup } from '@synthetixio/synpress-utils' import { MetaMask } from '../../src' -import type { BrowserContext, Page } from '@playwright/test' export const SEED_PHRASE = 'test test test test test test test test test test test junk' @@ -12,4 +12,4 @@ const basicSetup = defineWalletSetup(PASSWORD, async (context: BrowserContext, w await metamask.importWallet(SEED_PHRASE) }) -export default basicSetup \ No newline at end of file +export default basicSetup diff --git a/wallets/metamask/test/wallet-setup/connected.setup.ts b/wallets/metamask/test/wallet-setup/connected.setup.ts index ca87986e0..01bd56abd 100644 --- a/wallets/metamask/test/wallet-setup/connected.setup.ts +++ b/wallets/metamask/test/wallet-setup/connected.setup.ts @@ -1,6 +1,6 @@ +import type { BrowserContext, Page } from '@playwright/test' import { defineWalletSetup } from '@synthetixio/synpress-utils' import { MetaMask, getExtensionId } from '../../src' -import type { BrowserContext, Page } from '@playwright/test' const SEED_PHRASE = 'test test test test test test test test test test test junk' @@ -31,4 +31,4 @@ const connectedSetup = defineWalletSetup(PASSWORD, async (context: BrowserContex await page.close() }) -export default connectedSetup \ No newline at end of file +export default connectedSetup