Skip to content

Commit

Permalink
selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSero committed Jun 13, 2024
1 parent 0ec44d3 commit 97091d6
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 0 deletions.
2 changes: 2 additions & 0 deletions wallets/keplr/src/fixtureActions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './getExtensionId'
export * from './prepareExtension'
24 changes: 24 additions & 0 deletions wallets/keplr/src/fixtureActions/persistLocalStorage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { BrowserContext } from '@playwright/test'

export async function persistLocalStorage(
origins: {
origin: string
localStorage: { name: string; value: string }[]
}[],
context: BrowserContext
) {
const newPage = await context.newPage()

for (const { origin, localStorage } of origins) {
const frame = newPage.mainFrame()
await frame.goto(origin)

await frame.evaluate((localStorageData) => {
localStorageData.forEach(({ name, value }) => {
window.localStorage.setItem(name, value)
})
}, localStorage)
}

await newPage.close()
}
18 changes: 18 additions & 0 deletions wallets/keplr/src/pages/LockPage/page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { Page } from '@playwright/test'
import { unlock } from './actions'
import Selectors from './selectors'

export class LockPage {
static readonly selectors = Selectors
readonly selectors = Selectors

readonly page: Page

constructor(page: Page) {
this.page = page
}

async unlock(password: string) {
await unlock(this.page, password)
}
}
17 changes: 17 additions & 0 deletions wallets/keplr/src/pages/LockPage/selectors/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default {
createWalletButton: 'Create a new wallet',
importRecoveryPhraseButton: 'Import existing recovery phrase',
useRecoveryPhraseButton: 'Use recovery phrase or private key',
phraseCount24: '24 words',
walletName: 'My wallet',
phraseSelectChain: 'Select Chains',
phraseAccountCreated: 'Account Created!',
walletInput: 'input[name="name"]:focus',
passwordInput: 'input[name="password"]',
confirmPasswordInput: 'input[name="confirmPassword"]',
submitWalletDataButton: 'button[type="submit"]',
submitChainButton: 'button[type="button"]',
finishButton: 'button[type="button"]',
textAreaSelector: 'textbox',
submitPhraseButton: 'button[type="submit"]',
};
18 changes: 18 additions & 0 deletions wallets/keplr/src/pages/NotificationPage/page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { Page } from '@playwright/test'
import { unlock } from './actions'
import Selectors from './selectors'

export class LockPage {
static readonly selectors = Selectors
readonly selectors = Selectors

readonly page: Page

constructor(page: Page) {
this.page = page
}

async unlock(password: string) {
await unlock(this.page, password)
}
}
3 changes: 3 additions & 0 deletions wallets/keplr/src/pages/NotificationPage/selectors/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
approveButton: 'button[type="button"]',
};
7 changes: 7 additions & 0 deletions wallets/keplr/src/utils/selectors/createDataTestSelectors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const createDataTestSelector = (dataTestId: string) => {
if (dataTestId.includes(' ')) {
throw new Error('[CreateDataTestSelector] dataTestId cannot contain spaces')
}

return `[data-testid="${dataTestId}"]`
}

0 comments on commit 97091d6

Please sign in to comment.