Skip to content

Commit

Permalink
phantom
Browse files Browse the repository at this point in the history
  • Loading branch information
Seroxdesign committed Jul 9, 2024
1 parent 2327937 commit 38e2cc4
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 51 deletions.
14 changes: 8 additions & 6 deletions wallets/phantom/src/PhantomWallet.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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.
Expand Down Expand Up @@ -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')
}
}
Empty file.
13 changes: 0 additions & 13 deletions wallets/phantom/src/pages/ConfirmationPage/page.ts

This file was deleted.

12 changes: 0 additions & 12 deletions wallets/phantom/src/pages/ConfirmationPage/selectors/index.ts

This file was deleted.

8 changes: 8 additions & 0 deletions wallets/phantom/src/pages/HomePage/actions/backToMain.ts
Original file line number Diff line number Diff line change
@@ -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)
}
2 changes: 2 additions & 0 deletions wallets/phantom/src/pages/HomePage/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ export * from './changeAccount'
export * from './closePopupAndTooltips'
export * from './getWalletAddress'
export * from './disconnectFromApp'
export * from './selectDefaultWallet'
export * from './backToMain'
15 changes: 15 additions & 0 deletions wallets/phantom/src/pages/HomePage/actions/selectDefaultWallet.ts
Original file line number Diff line number Diff line change
@@ -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)
}
10 changes: 9 additions & 1 deletion wallets/phantom/src/pages/HomePage/page.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion wallets/phantom/src/pages/NotificationPage/actions/lock.ts
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
7 changes: 7 additions & 0 deletions wallets/phantom/src/pages/NotificationPage/selectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ const signaturePageElements = {
}
}

export const settingsPageElements = {
buttons: {
lockWallet: '[data-testid="lock-menu-item"]'
}
}


const transactionPageElements = {
buttons: {
confirmTransaction: '[data-testid="primary-button"]',
Expand Down
Empty file.
13 changes: 0 additions & 13 deletions wallets/phantom/src/pages/SettingsPage/page.ts

This file was deleted.

5 changes: 0 additions & 5 deletions wallets/phantom/src/pages/SettingsPage/selectors/index.ts

This file was deleted.

0 comments on commit 38e2cc4

Please sign in to comment.