From d2c807c4797f36641e733a394b81314fbe54d1d3 Mon Sep 17 00:00:00 2001 From: Sero <69639595+Seroxdesign@users.noreply.github.com> Date: Wed, 19 Jun 2024 04:14:25 -0400 Subject: [PATCH] debug cypress --- wallets/keplr/src/KeplrWallet.ts | 6 +++--- wallets/keplr/src/cypress/initKeplrWallet.ts | 16 +++++----------- wallets/keplr/src/cypress/setupTasks.ts | 12 ++++++------ wallets/keplr/src/fixtures/keplrFixtures.ts | 1 - 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/wallets/keplr/src/KeplrWallet.ts b/wallets/keplr/src/KeplrWallet.ts index 021d18b86..abefb94b8 100644 --- a/wallets/keplr/src/KeplrWallet.ts +++ b/wallets/keplr/src/KeplrWallet.ts @@ -10,9 +10,9 @@ export class KeplrWallet { constructor( readonly page: Page, - readonly context: BrowserContext, - readonly password: string, - readonly extensionId: string | undefined, + readonly context?: BrowserContext, + readonly password?: string, + readonly extensionId?: string | undefined, ) { this.lockPage = new LockPage(page) this.homePage = new HomePage(page) diff --git a/wallets/keplr/src/cypress/initKeplrWallet.ts b/wallets/keplr/src/cypress/initKeplrWallet.ts index b2ee19ab8..45fb219b2 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 { SEED_PHRASE, PASSWORD } from '../utils' import { MISSING_INIT, NO_CONTEXT, NO_PAGE } from './errors' let context: BrowserContext | undefined @@ -50,18 +50,13 @@ export async function initKeplrWallet(port: number) { return } - // await context.addInitScript({ - // content: `${readFileSync(web3MockPath, 'utf-8')}\n(${mockEthereum.toString()})();` - // }) - - // As we want to refresh the page after mocking the ethereum object if (!keplrLoaded) { await cypressPage.reload() keplrLoaded = true } - return {} - // keplrWallet = new KeplrWallet(cypressPage) - // await keplrWallet.setupWallet(null, { secretWordsOrPrivateKey: SEED_PHRASE, password: PASSWORD }) + + keplrWallet = new KeplrWallet(cypressPage) + await keplrWallet.setupWallet({ secretWordsOrPrivateKey: SEED_PHRASE, password: PASSWORD }) } export function getKeplrWallet() { @@ -71,6 +66,5 @@ export function getKeplrWallet() { } if (keplrWallet) return keplrWallet - return null - // return new KeplrWallet(cypressPage) + return new KeplrWallet(cypressPage) } diff --git a/wallets/keplr/src/cypress/setupTasks.ts b/wallets/keplr/src/cypress/setupTasks.ts index bf8c549ea..901126c20 100644 --- a/wallets/keplr/src/cypress/setupTasks.ts +++ b/wallets/keplr/src/cypress/setupTasks.ts @@ -1,13 +1,13 @@ -// 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', { importWallet: async function () { - // const keplrWallet = getKeplrWallet() - // if (keplrWallet) { - // await keplrWallet.setupWallet(null, { secretWordsOrPrivateKey: SEED_PHRASE, password: PASSWORD }) - // } + const keplrWallet = getKeplrWallet() + if (keplrWallet) { + await keplrWallet.setupWallet({ secretWordsOrPrivateKey: SEED_PHRASE, password: PASSWORD }) + } return true } }) diff --git a/wallets/keplr/src/fixtures/keplrFixtures.ts b/wallets/keplr/src/fixtures/keplrFixtures.ts index 442803dbb..744ddf441 100644 --- a/wallets/keplr/src/fixtures/keplrFixtures.ts +++ b/wallets/keplr/src/fixtures/keplrFixtures.ts @@ -13,7 +13,6 @@ import { import fs from 'fs-extra' import { persistLocalStorage } from '../fixtureActions/persistLocalStorage' import { getExtensionId } from '../fixtureActions' -//import unlockForFixtures from '../fixtureActions/unlockForFixtures' import { prepareExtension } from '@synthetixio/synpress-utils' type KeplrFixtures = {