Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Seroxdesign committed Jul 9, 2024
1 parent 769d933 commit 2327937
Show file tree
Hide file tree
Showing 33 changed files with 353 additions and 356 deletions.
16 changes: 7 additions & 9 deletions packages/cache/src/prepareExtension.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import download from 'download'
import unzipCrx from 'unzip-crx-3';
import unzipCrx from 'unzip-crx-3'
import { downloadFile, ensureCacheDirExists, unzipArchive } from '.'

interface ExtensionConfig {
Expand All @@ -26,8 +26,7 @@ export async function getExtensionConfig(name: string): Promise<ExtensionConfig>
{
name: 'Phantom',
version: 'phantom-chrome-latest',
downloadUrl:
'https://crx-backup.phantom.dev/latest.crx'
downloadUrl: 'https://crx-backup.phantom.dev/latest.crx'
}
]
}
Expand All @@ -47,13 +46,12 @@ export async function prepareExtension(extensionName: string) {
const outputPath = `${cacheDirPath}/latest`
downloadResult = await download(extensionConfig.downloadUrl, cacheDirPath, {
headers: {
Accept: 'application/octet-stream',
},
});
Accept: 'application/octet-stream'
}
})

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

The value assigned to downloadResult here is unused.
await unzipCrx('.cache-synpress/latest.crx', outputPath)
return outputPath
}
else {
} else {
downloadResult = await downloadFile({
url: extensionConfig.downloadUrl,
outputDir: cacheDirPath,
Expand All @@ -62,7 +60,7 @@ export async function prepareExtension(extensionName: string) {
const unzipResult = await unzipArchive({
archivePath: downloadResult.filePath
})

return unzipResult.outputPath
}
}
2 changes: 1 addition & 1 deletion packages/cache/src/unzip.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
declare module 'unzip-crx-3';
declare module 'unzip-crx-3'
2 changes: 1 addition & 1 deletion wallets/phantom/src/PhantomWallet.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
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'
import { ConfirmationPage } from './pages/ConfirmationPage/page'

export class PhantomWallet {
readonly lockPage: LockPage
Expand Down
2 changes: 1 addition & 1 deletion wallets/phantom/src/fixtureActions/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './getExtensionId'
export * from './getExtensionId'
2 changes: 1 addition & 1 deletion wallets/phantom/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './PhantomWallet'
export * from './utils'
export * from './fixtures/phantomFixtures'
export * from './fixtures/phantomFixtures'
12 changes: 6 additions & 6 deletions wallets/phantom/src/pages/ConfirmationPage/selectors/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const confirmationPage = '.confirmation-page';
const confirmationPageFooter = `${confirmationPage} .confirmation-footer`;
const confirmationPage = '.confirmation-page'
const confirmationPageFooter = `${confirmationPage} .confirmation-footer`
const footer = {
footer: confirmationPageFooter,
cancelButton: `${confirmationPageFooter} .btn-secondary`,
approveButton: `${confirmationPageFooter} .btn-primary`,
};
approveButton: `${confirmationPageFooter} .btn-primary`
}

export const confirmationPageElements = {
confirmationPage,
footer,
};
footer
}
8 changes: 4 additions & 4 deletions wallets/phantom/src/pages/HomePage/actions/changeAccount.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Page } from "@playwright/test";
import { homePageElements } from "../selectors";
import type { Page } from '@playwright/test'
import { homePageElements } from '../selectors'

export const changeAccount = async (page: Page, accountIndex = 1) => {
await page.waitForLoadState('domcontentloaded')
await page.click(homePageElements.settingsMenu.settingsMenuButton);
await page.click(homePageElements.settingsMenu.settingsMenuButton)
await page.click(homePageElements.accountMenu.accountButton(accountIndex))
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import type { Page } from "@playwright/test";
import { getNotificationPageAndWaitForLoad } from "../../../utils/getNotificationAndWaitForLoads";
import { homePageElements } from "../selectors";
import type { Page } from '@playwright/test'
import { getNotificationPageAndWaitForLoad } from '../../../utils/getNotificationAndWaitForLoads'
import { homePageElements } from '../selectors'

export const closePopupAndTooltips = async (page: Page, extensionId: string) => {
const notificationPage = await getNotificationPageAndWaitForLoad(page.context(), extensionId);
const notificationPage = await getNotificationPageAndWaitForLoad(page.context(), extensionId)
// note: this is required for fast execution of e2e tests to avoid flakiness
// otherwise popup may not be detected properly and not closed
const popupIsVisible = await notificationPage.locator(homePageElements.popup.container).isVisible()
const closeIsVisible = await notificationPage.locator(homePageElements.tippyTooltip.closeButton).isVisible()
const actionableMessageIsVisible = await notificationPage.locator(homePageElements.actionableMessage.closeButton).isVisible()
const actionableMessageIsVisible = await notificationPage
.locator(homePageElements.actionableMessage.closeButton)
.isVisible()
if (popupIsVisible) {
const popupBackground = await notificationPage.locator(homePageElements.popup.background)
const popupBackgroundBox = await popupBackground.boundingBox();
const popupBackgroundBox = await popupBackground.boundingBox()
await notificationPage.mouse.click(popupBackgroundBox?.x! + 1, popupBackgroundBox?.y! + 1)
}
if (closeIsVisible) {
await page.click(homePageElements.tippyTooltip.closeButton);
await page.click(homePageElements.tippyTooltip.closeButton)
}
if (actionableMessageIsVisible) {
await page.click(homePageElements.actionableMessage.closeButton)
}
return true;
}
return true
}
23 changes: 10 additions & 13 deletions wallets/phantom/src/pages/HomePage/actions/disconnectFromApp.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Page } from "@playwright/test";
import { getNotificationPageAndWaitForLoad } from "../../../utils/getNotificationAndWaitForLoads";
import { homePageElements } from "../selectors";
import type { Page } from '@playwright/test'
import { getNotificationPageAndWaitForLoad } from '../../../utils/getNotificationAndWaitForLoads'
import { homePageElements } from '../selectors'

export const disconnectFromApp = async (page: Page, extensionId: string) => {
const notificationPage = await getNotificationPageAndWaitForLoad(page.context(), extensionId)
Expand All @@ -10,19 +10,16 @@ export const disconnectFromApp = async (page: Page, extensionId: string) => {
await notificationPage.click(homePageElements.settingsMenu.trustedAppsRow)

const rowButtonLocator = await notificationPage.locator(homePageElements.connectedSites.rowButton)
const hasConnectedSite = await rowButtonLocator.isVisible();
const hasConnectedSite = await rowButtonLocator.isVisible()

let isDisconnected = false;
let isDisconnected = false
if (hasConnectedSite) {
await rowButtonLocator.click()
await notificationPage.click(homePageElements.connectedSites.trustedAppsRevokeButton)
isDisconnected = true
} else {
console.log('[disconnectWalletFromDapp] Wallet is not connected to a dapp, skipping...')
}
else {
console.log(
'[disconnectWalletFromDapp] Wallet is not connected to a dapp, skipping...',
);
}

return isDisconnected;
}

return isDisconnected
}
16 changes: 8 additions & 8 deletions wallets/phantom/src/pages/HomePage/actions/getWalletAddress.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import type { Page } from "@playwright/test";
import { getNotificationPageAndWaitForLoad } from "../../../utils/getNotificationAndWaitForLoads";
import { homePageElements } from "../selectors";
import type { Page } from '@playwright/test'
import { getNotificationPageAndWaitForLoad } from '../../../utils/getNotificationAndWaitForLoads'
import { homePageElements } from '../selectors'

export const getWalletAddress = async (page: Page, extensionId: string, chain = 'eth') => {
const notificationPage = await getNotificationPageAndWaitForLoad(page.context(), extensionId)
await notificationPage.hover(homePageElements.accountBar.title)

await new Promise(resolve => setTimeout(resolve, 100));
await new Promise((resolve) => setTimeout(resolve, 100))
await notificationPage.waitForLoadState('domcontentloaded')

if (chain === 'eth') {
await notificationPage.click(homePageElements.accountBar.ethRow);
await notificationPage.click(homePageElements.accountBar.ethRow)
} else if (chain === 'solana') {
await notificationPage.click(homePageElements.accountBar.solanaRow);
await notificationPage.click(homePageElements.accountBar.solanaRow)
}

const walletAddress = await notificationPage.evaluate('navigator.clipboard.readText()')
return walletAddress;
}
return walletAddress
}
2 changes: 1 addition & 1 deletion wallets/phantom/src/pages/HomePage/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './changeAccount'
export * from './closePopupAndTooltips'
export * from './getWalletAddress'
export * from './disconnectFromApp'
export * from './disconnectFromApp'
4 changes: 2 additions & 2 deletions wallets/phantom/src/pages/HomePage/page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Page } from '@playwright/test'
import { changeAccount, closePopupAndTooltips, disconnectFromApp, getWalletAddress } from './actions'
import { homePageElements } from './selectors'
import { changeAccount, getWalletAddress, closePopupAndTooltips, disconnectFromApp } from './actions'

export class HomePage {
static readonly selectors = homePageElements
Expand All @@ -16,7 +16,7 @@ export class HomePage {
return await changeAccount(this.page, accountIndex)
}

async getWalletAddress(extensionId: string, chainId: string){
async getWalletAddress(extensionId: string, chainId: string) {
return await getWalletAddress(this.page, extensionId, chainId)
}

Expand Down
Loading

0 comments on commit 2327937

Please sign in to comment.