diff --git a/wallets/keplr/src/fixtureActions/index.ts b/wallets/keplr/src/fixtureActions/index.ts new file mode 100644 index 000000000..232e44caa --- /dev/null +++ b/wallets/keplr/src/fixtureActions/index.ts @@ -0,0 +1,2 @@ +export * from './getExtensionId' +export * from './prepareExtension' diff --git a/wallets/keplr/src/fixtureActions/persistLocalStorage.ts b/wallets/keplr/src/fixtureActions/persistLocalStorage.ts new file mode 100644 index 000000000..e24deb66d --- /dev/null +++ b/wallets/keplr/src/fixtureActions/persistLocalStorage.ts @@ -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() +} diff --git a/wallets/keplr/src/pages/LockPage/page.ts b/wallets/keplr/src/pages/LockPage/page.ts new file mode 100644 index 000000000..ce95f7c0f --- /dev/null +++ b/wallets/keplr/src/pages/LockPage/page.ts @@ -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) + } +} diff --git a/wallets/keplr/src/pages/LockPage/selectors/index.ts b/wallets/keplr/src/pages/LockPage/selectors/index.ts new file mode 100644 index 000000000..161762780 --- /dev/null +++ b/wallets/keplr/src/pages/LockPage/selectors/index.ts @@ -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"]', +}; diff --git a/wallets/keplr/src/pages/NotificationPage/page.ts b/wallets/keplr/src/pages/NotificationPage/page.ts new file mode 100644 index 000000000..ce95f7c0f --- /dev/null +++ b/wallets/keplr/src/pages/NotificationPage/page.ts @@ -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) + } +} diff --git a/wallets/keplr/src/pages/NotificationPage/selectors/index.ts b/wallets/keplr/src/pages/NotificationPage/selectors/index.ts new file mode 100644 index 000000000..e8581cf42 --- /dev/null +++ b/wallets/keplr/src/pages/NotificationPage/selectors/index.ts @@ -0,0 +1,3 @@ +export default { + approveButton: 'button[type="button"]', +}; \ No newline at end of file diff --git a/wallets/keplr/src/utils/selectors/createDataTestSelectors.ts b/wallets/keplr/src/utils/selectors/createDataTestSelectors.ts new file mode 100644 index 000000000..705c69420 --- /dev/null +++ b/wallets/keplr/src/utils/selectors/createDataTestSelectors.ts @@ -0,0 +1,7 @@ +export const createDataTestSelector = (dataTestId: string) => { + if (dataTestId.includes(' ')) { + throw new Error('[CreateDataTestSelector] dataTestId cannot contain spaces') + } + + return `[data-testid="${dataTestId}"]` +}