diff --git a/examples/new-dawn/test/playwright/wallet-setup/connected.setup.ts b/examples/new-dawn/test/playwright/wallet-setup/connected.setup.ts index ac3a25f7c..adcb9128f 100644 --- a/examples/new-dawn/test/playwright/wallet-setup/connected.setup.ts +++ b/examples/new-dawn/test/playwright/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 '@synthetixio/synpress' +import { defineWalletSetup } from '@synthetixio/synpress-utils' const SEED_PHRASE = process.env.SEED_PHRASE const PASSWORD = process.env.WALLET_PASSWORD diff --git a/package.json b/package.json index 24392b9b3..06a21a631 100644 --- a/package.json +++ b/package.json @@ -15,10 +15,8 @@ "sort-package-json": "sort-package-json 'package.json' '{packages,wallets,examples}/*/package.json'", "sort-package-json:check": "sort-package-json 'package.json' '{packages,wallets,examples}/*/package.json' --check", "test": "turbo test", - "test:e2e:headful": "turbo test:e2e:headful --filter=@synthetixio/synpress-metamask --filter=@synthetixio/ethereum-wallet-mock", - "test:e2e:headful:keplr": "turbo test:e2e:headful --filter=@synthetixio/synpress-keplr", - "test:e2e:headless": "turbo test:e2e:headless --filter=@synthetixio/synpress-metamask --filter=@synthetixio/ethereum-wallet-mock", - "test:e2e:headless:keplr": "turbo test:e2e:headless --filter=@synthetixio/synpress-keplr", + "test:e2e:headful": "turbo test:e2e:headful --filter=@synthetixio/synpress-metamask --filter=@synthetixio/synpress-keplr --filter=@synthetixio/ethereum-wallet-mock", + "test:e2e:headless": "turbo test:e2e:headless --filter=@synthetixio/synpress-metamask --filter=@synthetixio/synpress-keplr --filter=@synthetixio/ethereum-wallet-mock", "update:deps": "ncu -u -ws --root" }, "lint-staged": { diff --git a/release/src/index.ts b/release/src/index.ts index 5660e1818..b45c6f11b 100644 --- a/release/src/index.ts +++ b/release/src/index.ts @@ -14,4 +14,4 @@ export { // Helpers defineWalletSetup, getExtensionId -} \ No newline at end of file +} diff --git a/wallets/keplr/cypress.config.ts b/wallets/keplr/cypress.config.ts deleted file mode 100644 index e57319d60..000000000 --- a/wallets/keplr/cypress.config.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { defineConfig } from 'cypress' -import { installSynpress } from './src/cypress' - -export default defineConfig({ - chromeWebSecurity: false, - e2e: { - baseUrl: 'http://localhost:9999', - specPattern: 'test/cypress/**/*.cy.{js,jsx,ts,tsx}', - supportFile: 'src/cypress/support/e2e.{js,jsx,ts,tsx}', - fixturesFolder: 'src/cypress/fixtures', - testIsolation: false, - async setupNodeEvents(on, config) { - return installSynpress(on, config) - } - } -}) diff --git a/wallets/keplr/package.json b/wallets/keplr/package.json index 2a5d7f133..0e4f261e5 100644 --- a/wallets/keplr/package.json +++ b/wallets/keplr/package.json @@ -23,7 +23,6 @@ "test:coverage": "vitest run --coverage", "test:e2e:headful": "playwright test", "test:e2e:headless": "HEADLESS=true playwright test", - "test:e2e:headless:cypress": "cypress run --headless --browser chrome", "test:e2e:headless:ui": "HEADLESS=true playwright test --ui", "test:watch": "vitest watch", "types:check": "tsc --noEmit" diff --git a/wallets/keplr/src/cypress/errors.ts b/wallets/keplr/src/cypress/errors.ts deleted file mode 100644 index 7d46bf925..000000000 --- a/wallets/keplr/src/cypress/errors.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const NO_CONTEXT = 'No browser context found. Connect Playwright first - connectPlaywright()' -export const NO_PAGE = 'No page found. Use getPage()' -export const MISSING_INIT = 'Keplr not initialized. Use initKeplrWallet()' diff --git a/wallets/keplr/src/cypress/index.ts b/wallets/keplr/src/cypress/index.ts deleted file mode 100644 index c1cf1560a..000000000 --- a/wallets/keplr/src/cypress/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as installSynpress } from './installSynpress' diff --git a/wallets/keplr/src/cypress/initKeplrWallet.ts b/wallets/keplr/src/cypress/initKeplrWallet.ts deleted file mode 100644 index a6631e5f5..000000000 --- a/wallets/keplr/src/cypress/initKeplrWallet.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { type BrowserContext, type Page, chromium } from '@playwright/test' - -import { KeplrWallet } from '../KeplrWallet' -import { PASSWORD, SEED_PHRASE } from '../utils' -import { MISSING_INIT, NO_CONTEXT, NO_PAGE } from './errors' - -let context: BrowserContext | undefined -let cypressPage: Page | undefined -let keplrWallet: KeplrWallet | undefined - -let keplrLoaded = false - -const getCypressPage = async () => { - if (!context) { - console.error(NO_CONTEXT) - return - } - - cypressPage = context.pages()[0] - - return cypressPage -} - -export async function connectPlaywrightToChrome(port: number) { - const debuggerDetails = await fetch(`http://127.0.0.1:${port}/json/version`) - - const debuggerDetailsConfig = (await debuggerDetails.json()) as { - webSocketDebuggerUrl: string - } - const browser = await chromium.connectOverCDP(debuggerDetailsConfig.webSocketDebuggerUrl) - context = browser.contexts()[0] - - return browser.isConnected() -} - -export async function initKeplrWallet(port: number) { - await connectPlaywrightToChrome(port) - - if (!context) { - console.error(NO_CONTEXT) - return - } - - await getCypressPage() - - if (!cypressPage) { - console.error(NO_PAGE) - return - } - - if (!keplrLoaded) { - await cypressPage.reload() - keplrLoaded = true - } - keplrWallet = new KeplrWallet(cypressPage) - await keplrWallet.setupWallet({ secretWordsOrPrivateKey: SEED_PHRASE, password: PASSWORD }) -} - -export function getKeplrWallet() { - if (!context || !cypressPage || !keplrWallet) { - console.error(MISSING_INIT) - return - } - if (keplrWallet) return keplrWallet - - return new KeplrWallet(cypressPage) -} diff --git a/wallets/keplr/src/cypress/installSynpress.ts b/wallets/keplr/src/cypress/installSynpress.ts deleted file mode 100644 index 7ea90bf97..000000000 --- a/wallets/keplr/src/cypress/installSynpress.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { ensureRdpPort } from '@synthetixio/synpress-core' - -import { initKeplrWallet } from './initKeplrWallet' -import setupTasks from './setupTasks' - -let port: number - -export default function installSynpress(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) { - const browsers = config.browsers.filter((b) => b.name === 'chrome') - if (browsers.length === 0) { - throw new Error('No Chrome browser found in the configuration') - } - - on('before:browser:launch', async (_, launchOptions) => { - // Enable debug mode to establish playwright connection - const args = Array.isArray(launchOptions) ? launchOptions : launchOptions.args - port = ensureRdpPort(args) - }) - - on('before:spec', async () => { - await initKeplrWallet(port) - }) - - setupTasks(on) - - return { - ...config, - browsers - } -} diff --git a/wallets/keplr/src/cypress/setupTasks.ts b/wallets/keplr/src/cypress/setupTasks.ts deleted file mode 100644 index 42a0f015e..000000000 --- a/wallets/keplr/src/cypress/setupTasks.ts +++ /dev/null @@ -1,14 +0,0 @@ -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({ secretWordsOrPrivateKey: SEED_PHRASE, password: PASSWORD }) - } - return true - } - }) -} diff --git a/wallets/keplr/src/cypress/support/commands.ts b/wallets/keplr/src/cypress/support/commands.ts deleted file mode 100644 index bfb24557b..000000000 --- a/wallets/keplr/src/cypress/support/commands.ts +++ /dev/null @@ -1,34 +0,0 @@ -/// -// *********************************************** -// This example commands.ts shows you how to -// create various custom commands and overwrite -// existing commands. -// -// For more comprehensive examples of custom -// commands please read more here: -// https://on.cypress.io/custom-commands -// *********************************************** - -declare global { - namespace Cypress { - interface Chainable { - setupWallet({ - secretWordsOnPrivateKeys, - password - }: { secretWordsOnPrivateKeys: string; password: string }): Chainable - setupPlaywrightContext(): Chainable - } - } -} - -Cypress.Commands.add('setupWallet', ({ secretWordsOnPrivateKeys, password }) => { - cy.task('setupWallet', { secretWordsOnPrivateKeys, password }) -}) - -Cypress.Commands.add('setupPlaywrightContext', () => { - cy.task('setupPlaywrightContext') -}) - -before(() => { - cy.setupPlaywrightContext() -}) diff --git a/wallets/keplr/src/cypress/support/e2e.ts b/wallets/keplr/src/cypress/support/e2e.ts deleted file mode 100644 index de6e9e568..000000000 --- a/wallets/keplr/src/cypress/support/e2e.ts +++ /dev/null @@ -1,21 +0,0 @@ -// *********************************************************** -// This example support/e2e.ts is processed and -// loaded automatically before your test files. -// -// This is a great place to put global configuration and -// behavior that modifies Cypress. -// -// You can change the location of this file or turn off -// automatically serving support files with the -// 'supportFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/configuration -// *********************************************************** - -// Import commands.js using ES2015 syntax: -import './commands' - -Cypress.on('uncaught:exception', () => { - return false -}) diff --git a/wallets/keplr/src/pages/NotificationPage/actions/acceptAccess.ts b/wallets/keplr/src/pages/NotificationPage/actions/acceptAccess.ts index 7193c3f20..8a0fd047c 100644 --- a/wallets/keplr/src/pages/NotificationPage/actions/acceptAccess.ts +++ b/wallets/keplr/src/pages/NotificationPage/actions/acceptAccess.ts @@ -5,7 +5,7 @@ import { notificationPageElements } from '../selectors' export const acceptAccess = async (page: Page) => { const extensionId = await getExtensionId(page.context(), 'keplr') - const notificationPage = await getNotificationPageAndWaitForLoad(context, extensionId) + const notificationPage = await getNotificationPageAndWaitForLoad(page.context(), extensionId) await notificationPage.waitForLoadState('domcontentloaded') await notificationPage.waitForSelector(notificationPageElements.approveButton) await notificationPage.click(notificationPageElements.approveButton) diff --git a/wallets/keplr/src/pages/NotificationPage/actions/rejectAccess.ts b/wallets/keplr/src/pages/NotificationPage/actions/rejectAccess.ts index fcd8cd7b9..b49a8c7ce 100644 --- a/wallets/keplr/src/pages/NotificationPage/actions/rejectAccess.ts +++ b/wallets/keplr/src/pages/NotificationPage/actions/rejectAccess.ts @@ -4,6 +4,6 @@ import { getExtensionId } from '../../../fixtureActions' export const rejectAccess = async (page: Page) => { const extensionId = await getExtensionId(page.context(), 'keplr') - const notificationPage = await getNotificationPageAndWaitForLoad(context, extensionId) + const notificationPage = await getNotificationPageAndWaitForLoad(page.context(), extensionId) await notificationPage.close() } diff --git a/wallets/keplr/test/cypress/setupAccount.cy.ts b/wallets/keplr/test/cypress/setupAccount.cy.ts deleted file mode 100644 index a57ca788d..000000000 --- a/wallets/keplr/test/cypress/setupAccount.cy.ts +++ /dev/null @@ -1,7 +0,0 @@ -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 - }) -})