Skip to content

Commit

Permalink
debug cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSero committed Jun 19, 2024
1 parent af0855e commit d2c807c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 21 deletions.
6 changes: 3 additions & 3 deletions wallets/keplr/src/KeplrWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 5 additions & 11 deletions wallets/keplr/src/cypress/initKeplrWallet.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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() {
Expand All @@ -71,6 +66,5 @@ export function getKeplrWallet() {
}

if (keplrWallet) return keplrWallet

Check warning

Code scanning / CodeQL

Useless conditional Warning

This use of variable 'keplrWallet' always evaluates to true.
return null
// return new KeplrWallet(cypressPage)
return new KeplrWallet(cypressPage)
}
12 changes: 6 additions & 6 deletions wallets/keplr/src/cypress/setupTasks.ts
Original file line number Diff line number Diff line change
@@ -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
}
})
Expand Down
1 change: 0 additions & 1 deletion wallets/keplr/src/fixtures/keplrFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit d2c807c

Please sign in to comment.