From 38e2cc4424f7c6e7c0bc36fe15b36dd73873581e Mon Sep 17 00:00:00 2001 From: Sero <69639595+Seroxdesign@users.noreply.github.com> Date: Tue, 9 Jul 2024 11:02:37 -0400 Subject: [PATCH] phantom --- wallets/phantom/src/PhantomWallet.ts | 14 ++++++++------ .../src/pages/ConfirmationPage/actions/index.ts | 0 .../phantom/src/pages/ConfirmationPage/page.ts | 13 ------------- .../src/pages/ConfirmationPage/selectors/index.ts | 12 ------------ .../src/pages/HomePage/actions/backToMain.ts | 8 ++++++++ .../phantom/src/pages/HomePage/actions/index.ts | 2 ++ .../pages/HomePage/actions/selectDefaultWallet.ts | 15 +++++++++++++++ wallets/phantom/src/pages/HomePage/page.ts | 10 +++++++++- .../src/pages/NotificationPage/actions/lock.ts | 2 +- .../src/pages/NotificationPage/selectors/index.ts | 7 +++++++ .../src/pages/SettingsPage/actions/index.ts | 0 wallets/phantom/src/pages/SettingsPage/page.ts | 13 ------------- .../src/pages/SettingsPage/selectors/index.ts | 5 ----- 13 files changed, 50 insertions(+), 51 deletions(-) delete mode 100644 wallets/phantom/src/pages/ConfirmationPage/actions/index.ts delete mode 100644 wallets/phantom/src/pages/ConfirmationPage/page.ts delete mode 100644 wallets/phantom/src/pages/ConfirmationPage/selectors/index.ts create mode 100644 wallets/phantom/src/pages/HomePage/actions/backToMain.ts create mode 100644 wallets/phantom/src/pages/HomePage/actions/selectDefaultWallet.ts delete mode 100644 wallets/phantom/src/pages/SettingsPage/actions/index.ts delete mode 100644 wallets/phantom/src/pages/SettingsPage/page.ts delete mode 100644 wallets/phantom/src/pages/SettingsPage/selectors/index.ts diff --git a/wallets/phantom/src/PhantomWallet.ts b/wallets/phantom/src/PhantomWallet.ts index 5d2b0145a..5aa2d7e4c 100644 --- a/wallets/phantom/src/PhantomWallet.ts +++ b/wallets/phantom/src/PhantomWallet.ts @@ -1,16 +1,12 @@ import { type BrowserContext, type Page } from '@playwright/test' -import { ConfirmationPage } from './pages/ConfirmationPage/page' import { HomePage } from './pages/HomePage/page' import { LockPage } from './pages/LockPage/page' import { NotificationPage } from './pages/NotificationPage/page' -import { SettingsPage } from './pages/SettingsPage/page' export class PhantomWallet { readonly lockPage: LockPage readonly homePage: HomePage readonly notificationPage: NotificationPage - readonly settingsPage: SettingsPage - readonly confirmationPage: ConfirmationPage constructor( readonly page: Page, @@ -21,8 +17,6 @@ export class PhantomWallet { this.lockPage = new LockPage(page) this.homePage = new HomePage(page) this.notificationPage = new NotificationPage(page) - this.settingsPage = new SettingsPage(page) - this.confirmationPage = new ConfirmationPage(page) } /** * Does initial setup for the wallet. @@ -86,4 +80,12 @@ export class PhantomWallet { async rejectTransaction() { await this.notificationPage.rejectTransaction(this.extensionId!) } + + async backToMain() { + await this.homePage.backToMain() + } + + async selectDefaultWallet() { + await this.homePage.selectDefaultWallet(this.extensionId!, 'phantom') + } } diff --git a/wallets/phantom/src/pages/ConfirmationPage/actions/index.ts b/wallets/phantom/src/pages/ConfirmationPage/actions/index.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/wallets/phantom/src/pages/ConfirmationPage/page.ts b/wallets/phantom/src/pages/ConfirmationPage/page.ts deleted file mode 100644 index 52c37d3ec..000000000 --- a/wallets/phantom/src/pages/ConfirmationPage/page.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { Page } from '@playwright/test' -import { confirmationPageElements } from './selectors' - -export class ConfirmationPage { - static readonly selectors = confirmationPageElements - readonly selectors = confirmationPageElements - - readonly page: Page - - constructor(page: Page) { - this.page = page - } -} diff --git a/wallets/phantom/src/pages/ConfirmationPage/selectors/index.ts b/wallets/phantom/src/pages/ConfirmationPage/selectors/index.ts deleted file mode 100644 index 106a1ef74..000000000 --- a/wallets/phantom/src/pages/ConfirmationPage/selectors/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -const confirmationPage = '.confirmation-page' -const confirmationPageFooter = `${confirmationPage} .confirmation-footer` -const footer = { - footer: confirmationPageFooter, - cancelButton: `${confirmationPageFooter} .btn-secondary`, - approveButton: `${confirmationPageFooter} .btn-primary` -} - -export const confirmationPageElements = { - confirmationPage, - footer -} diff --git a/wallets/phantom/src/pages/HomePage/actions/backToMain.ts b/wallets/phantom/src/pages/HomePage/actions/backToMain.ts new file mode 100644 index 000000000..d62dc88da --- /dev/null +++ b/wallets/phantom/src/pages/HomePage/actions/backToMain.ts @@ -0,0 +1,8 @@ +import type { Page } from '@playwright/test' +import { homePageElements } from '../selectors' + +export const backToMain = async (page: Page) => { + await page.waitForLoadState('domcontentloaded') + await page.click(homePageElements.connectedSites.trustedAppsBackButton) + await page.click(homePageElements.settingsMenu.settingsSidebarCloseButton) +} diff --git a/wallets/phantom/src/pages/HomePage/actions/index.ts b/wallets/phantom/src/pages/HomePage/actions/index.ts index 579f5447a..19d12e5c0 100644 --- a/wallets/phantom/src/pages/HomePage/actions/index.ts +++ b/wallets/phantom/src/pages/HomePage/actions/index.ts @@ -2,3 +2,5 @@ export * from './changeAccount' export * from './closePopupAndTooltips' export * from './getWalletAddress' export * from './disconnectFromApp' +export * from './selectDefaultWallet' +export * from './backToMain' \ No newline at end of file diff --git a/wallets/phantom/src/pages/HomePage/actions/selectDefaultWallet.ts b/wallets/phantom/src/pages/HomePage/actions/selectDefaultWallet.ts new file mode 100644 index 000000000..6deccf409 --- /dev/null +++ b/wallets/phantom/src/pages/HomePage/actions/selectDefaultWallet.ts @@ -0,0 +1,15 @@ +import type { Page } from '@playwright/test' +import { getNotificationPageAndWaitForLoad } from '../../../utils/getNotificationAndWaitForLoads' +import { homePageElements } from '../selectors' + +export const selectDefaultWallet = async (page: Page, extensionId: string, wallet: string) => { + console.log(wallet) + const notificationPage = await getNotificationPageAndWaitForLoad(page.context(), extensionId) + const walletSelector = homePageElements.defaultWallet['phantom'] + await notificationPage.click(homePageElements.settingsMenu.settingsMenuButton) + await notificationPage.click(homePageElements.settingsMenu.settingsSidebarButton) + await notificationPage.click(homePageElements.settingsMenu.settingsPreferencesButton) + await notificationPage.click(homePageElements.settingsMenu.defaultAppWalletRow) + await notificationPage.click(walletSelector) + await notificationPage.click(homePageElements.connectedSites.trustedAppsBackButton) +} diff --git a/wallets/phantom/src/pages/HomePage/page.ts b/wallets/phantom/src/pages/HomePage/page.ts index 1219a49ea..94eea1cbf 100644 --- a/wallets/phantom/src/pages/HomePage/page.ts +++ b/wallets/phantom/src/pages/HomePage/page.ts @@ -1,5 +1,5 @@ import type { Page } from '@playwright/test' -import { changeAccount, closePopupAndTooltips, disconnectFromApp, getWalletAddress } from './actions' +import { changeAccount, closePopupAndTooltips, disconnectFromApp, getWalletAddress, selectDefaultWallet, backToMain } from './actions' import { homePageElements } from './selectors' export class HomePage { @@ -27,4 +27,12 @@ export class HomePage { async disconnectFromApp(extensionId: string) { await disconnectFromApp(this.page, extensionId) } + + async selectDefaultWallet(extensionId: string, wallet: string) { + await selectDefaultWallet(this.page, extensionId, wallet) + } + + async backToMain() { + await backToMain(this.page) + } } diff --git a/wallets/phantom/src/pages/NotificationPage/actions/lock.ts b/wallets/phantom/src/pages/NotificationPage/actions/lock.ts index bac64ce15..90a1cc9a3 100644 --- a/wallets/phantom/src/pages/NotificationPage/actions/lock.ts +++ b/wallets/phantom/src/pages/NotificationPage/actions/lock.ts @@ -1,6 +1,6 @@ import type { Page } from '@playwright/test' import { closePopupAndTooltips } from '../../HomePage/actions/closePopupAndTooltips' -import { settingsPageElements } from '../../SettingsPage/selectors' +import { settingsPageElements } from '../selectors' import { notificationPageElements } from '../selectors' export const lock = async (page: Page, extensionId: string) => { diff --git a/wallets/phantom/src/pages/NotificationPage/selectors/index.ts b/wallets/phantom/src/pages/NotificationPage/selectors/index.ts index efdf02b16..5018c4154 100644 --- a/wallets/phantom/src/pages/NotificationPage/selectors/index.ts +++ b/wallets/phantom/src/pages/NotificationPage/selectors/index.ts @@ -174,6 +174,13 @@ const signaturePageElements = { } } +export const settingsPageElements = { + buttons: { + lockWallet: '[data-testid="lock-menu-item"]' + } +} + + const transactionPageElements = { buttons: { confirmTransaction: '[data-testid="primary-button"]', diff --git a/wallets/phantom/src/pages/SettingsPage/actions/index.ts b/wallets/phantom/src/pages/SettingsPage/actions/index.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/wallets/phantom/src/pages/SettingsPage/page.ts b/wallets/phantom/src/pages/SettingsPage/page.ts deleted file mode 100644 index 3809723cb..000000000 --- a/wallets/phantom/src/pages/SettingsPage/page.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { Page } from '@playwright/test' -import { settingsPageElements } from './selectors' - -export class SettingsPage { - static readonly selectors = settingsPageElements - readonly selectors = settingsPageElements - - readonly page: Page - - constructor(page: Page) { - this.page = page - } -} diff --git a/wallets/phantom/src/pages/SettingsPage/selectors/index.ts b/wallets/phantom/src/pages/SettingsPage/selectors/index.ts deleted file mode 100644 index 5a2c8da0c..000000000 --- a/wallets/phantom/src/pages/SettingsPage/selectors/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const settingsPageElements = { - buttons: { - lockWallet: '[data-testid="lock-menu-item"]' - } -}