Skip to content

Commit

Permalink
copy
Browse files Browse the repository at this point in the history
  • Loading branch information
Seroxdesign committed Jun 19, 2024
1 parent 834d458 commit b18ed70
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 69 deletions.
4 changes: 2 additions & 2 deletions wallets/keplr/src/KeplrWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export class KeplrWallet {
return wallet;
}

async getWalletAddress() {
const walletAddress = await this.homePage.getWalletAddress()
async getWalletAddress(wallet: string) {
const walletAddress = await this.homePage.getWalletAddress(wallet)
return walletAddress;
}
}
1 change: 1 addition & 0 deletions wallets/keplr/src/fixtures/keplrFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const keplrFixtures = (walletSetup: ReturnType<typeof defineWalletSetup>,
_keplrPage = context.pages()[0] as Page

await _keplrPage.goto(`chrome-extension://${extensionId}/popup.html`)

await unlockForFixtures(_keplrPage, PASSWORD)

await use(context)
Expand Down
16 changes: 7 additions & 9 deletions wallets/keplr/src/pages/HomePage/actions/getWalletAddress.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import type { Page } from '@playwright/test';
import { homePageElements } from '../selectors';

export const getWalletAddress = async (page: Page) => {
export const getWalletAddress = async (page: Page, wallet: string) => {
await page.waitForLoadState('domcontentloaded');
const newTokensFoundSelector = await page.waitForSelector(homePageElements.newTokensFoundSelector);
if (newTokensFoundSelector) {
await page.waitForSelector(homePageElements.newTokensFoundSelector);
}
await page.waitForSelector(homePageElements.copyAddress);
const walletAddress = await page.click(homePageElements.copyAddress);
console.log('Wallet address copied', walletAddress);
return walletAddress;
await page.getByText(homePageElements.copyAddress).click();
const chain = await page.waitForSelector(homePageElements.walletSelectors(wallet));
chain.click();
await page.context().grantPermissions(['clipboard-read', 'clipboard-write']);
const clipboardText = await page.evaluate(() => navigator.clipboard.readText());
return clipboardText;
}
4 changes: 2 additions & 2 deletions wallets/keplr/src/pages/HomePage/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class HomePage {
return await getTokenAmount(this.page, 'token name')
}

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

async addNewTokensFound() {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions wallets/keplr/src/pages/HomePage/selectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export const homePageElements = {
newTokensFound: 'new token(s) found',
addChainsButton: 'Add Chains',
newTokensFoundSelector: 'text=new token(s) found',
walletSelectors: (chainName: string) => `img[alt="${chainName}"]`,
copyAddress: 'Copy Address',
}
2 changes: 1 addition & 1 deletion wallets/keplr/src/pages/LockPage/selectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const onboardingElements = {
useRecoveryPhraseButton: 'Use recovery phrase or private key',
createNewRecoveryPhraseButton: 'Create new recovery phrase',
showMyPhraseButton: 'I understood. Show my phrase.',
copyToClipboardButton: 'Copy to clipboard',
copyToClipboardButton: 'Copy Address',
nextButton: 'Next',
focusedInput: 'input:focus',
phrasePrivateKey: 'Private key',
Expand Down
6 changes: 5 additions & 1 deletion wallets/keplr/test/playwright/getAddress.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import synpress from '../synpress'

const test = synpress

const { expect } = test

// test('should import wallet', async ({ keplr }) => {
// try {
// await keplr.setupWallet({ secretWordsOrPrivateKey: SEED_PHRASE, password: PASSWORD })
Expand All @@ -13,7 +15,9 @@ const test = synpress

test('should create address', async ({ keplr }) => {
try {
await keplr.getWalletAddress()
const address = await keplr.getWalletAddress('Cosmos Hub')
console.log('Address:', address)
expect(address).toContain('cosmos')
} catch (error) {
console.error('Error:', error)
}
Expand Down

0 comments on commit b18ed70

Please sign in to comment.