Skip to content

Commit

Permalink
Merge pull request #215 from lidofinance/revive-exodus-wallet
Browse files Browse the repository at this point in the history
Revive exodus wallet
  • Loading branch information
jake4take authored Feb 6, 2025
2 parents affafba + 2ee82de commit fabd21d
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 47 deletions.
85 changes: 40 additions & 45 deletions packages/wallets/src/exodus/exodus.page.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
import { WalletConfig } from '../wallets.constants';
import { WalletPage } from '../wallet.page';
import { test, BrowserContext, Page } from '@playwright/test';
import { OnboardingPage } from './pages';

export class ExodusPage implements WalletPage {
page: Page | undefined;
onboardingPage: OnboardingPage;

constructor(
private browserContext: BrowserContext,
private extensionUrl: string,
public config: WalletConfig,
) {}

/** Init all page objects Classes included to wallet */
async initLocators() {
this.onboardingPage = new OnboardingPage(this.page, this.config);
}

/** Navigate to home page of OXK Wallet extension:
* - open the wallet extension
* - unlock extension (if needed)
*/
async navigate() {
await test.step('Navigate to exodus', async () => {
this.page = await this.browserContext.newPage();
await this.initLocators();
await this.page.goto(
this.extensionUrl + this.config.COMMON.EXTENSION_START_PATH,
);
Expand All @@ -23,19 +35,17 @@ export class ExodusPage implements WalletPage {
});
}

/** Checks the wallet is set correctly and starts the wallet setup as the first time (if needed) */
async setup() {
await test.step('Setup', async () => {
await test.step('Setup wallet', async () => {
await this.navigate();
if (!this.page) throw "Page isn't ready";
const firstTime =
(await this.page.locator('text=I Have A Wallet').count()) > 0;
if (firstTime) await this.firstTimeSetup();
await this.onboardingPage.firstTimeSetup();
});
}

/** Unlock wallet*/
async unlock() {
await test.step('Unlock', async () => {
if (!this.page) throw "Page isn't ready";
await test.step('Unlock wallet', async () => {
if (
(await this.page
.locator('input[placeholder="Enter password"]')
Expand All @@ -50,56 +60,41 @@ export class ExodusPage implements WalletPage {
});
}

async firstTimeSetup() {
await test.step('First time setup', async () => {
if (!this.page) throw "Page isn't ready";
await this.page.click('text=I Have A Wallet');
await this.page.fill('input[type="text"]', this.config.SECRET_PHRASE);
await this.page.click(':nth-match(:text("Restore"), 2)');
await this.page.fill(
"input[placeholder='Enter a unique password']",
this.config.PASSWORD,
);
await this.page.click('text=Next');
await this.page.fill(
"input[placeholder='Enter your password again']",
this.config.PASSWORD,
);
await this.page.click('text=Restore');
await this.page.waitForSelector('text=Continue');
});
}

/** Click `Connect` button on the transaction `page` */
async connectWallet(page: Page) {
await test.step('Connect wallet', async () => {
await page.waitForTimeout(5000);
await page.click(':nth-match(:text("Connect"), 3)');
await page.close();
const connectWalletBtn = page.getByText('Connect').nth(2);
// the connect button is disabled by default, and it will be enabled after hover with awaiting
await connectWalletBtn.hover();
await page.waitForTimeout(2000);
await connectWalletBtn.click();
});
}

/** Click `Confirm` button on the transaction `page` */
async confirmTx(page: Page) {
await test.step('Confirm TX', async () => {
await page.click('text=Confirm');
await page.getByText('Confirm').click();
});
}

// eslint-disable-next-line
async signTx(page: Page) {}
async signTx() {
throw new Error('Method not implemented.');
}

// eslint-disable-next-line
async importKey(key: string) {}
async importKey() {
throw new Error('Method not implemented.');
}

async addNetwork(
networkName: string, // eslint-disable-line
networkUrl: string, // eslint-disable-line
chainId: number, // eslint-disable-line
tokenSymbol: string, // eslint-disable-line
) {} // eslint-disable-line
async addNetwork() {
throw new Error('Method not implemented.');
}

// eslint-disable-next-line
async assertTxAmount(page: Page, expectedAmount: string) {}
async assertTxAmount() {
throw new Error('Method not implemented.');
}

// eslint-disable-next-line
async assertReceiptAddress(page: Page, expectedAddress: string) {}
async assertReceiptAddress() {
throw new Error('Method not implemented.');
}
}
1 change: 1 addition & 0 deletions packages/wallets/src/exodus/pages/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './onboarding.page';
59 changes: 59 additions & 0 deletions packages/wallets/src/exodus/pages/onboarding.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Locator, Page, test } from '@playwright/test';
import { WalletConfig } from '../../wallets.constants';

export class OnboardingPage {
page: Page;
iHaveWalletBtn: Locator;
restoreWalletBtn: Locator;
walletPassword: Locator;
repeatWalletPassword: Locator;
nextButton: Locator;
finishOnboardingBtn: Locator;

constructor(page: Page, public config: WalletConfig) {
this.page = page;
this.iHaveWalletBtn = this.page.getByTestId(
'exodusmovement.exodus:id/button-already-have-a-wallet',
);
this.restoreWalletBtn = this.page.getByTestId(
'exodusmovement.exodus:id/button-restore',
);
this.walletPassword = this.page.getByTestId(
'exodusmovement.exodus:id/field-new-password',
);
this.repeatWalletPassword = this.page.getByTestId(
'exodusmovement.exodus:id/input-type-password-again',
);
this.nextButton = this.page.getByTestId(
'exodusmovement.exodus:id/button-next',
);
this.finishOnboardingBtn = this.page.getByTestId(
'exodusmovement.exodus:id/button-get-started',
);
}

async firstTimeSetup() {
if ((await this.iHaveWalletBtn.count()) === 0) return;

await test.step('First time setup', async () => {
await this.iHaveWalletBtn.click();

await test.step('Fill the seed phrase', async () => {
await this.page.fill('input[type="text"]', this.config.SECRET_PHRASE);
await this.restoreWalletBtn.click();
});

await test.step('Setup wallet password', async () => {
await this.walletPassword.fill(this.config.PASSWORD);
await this.nextButton.click();
await this.repeatWalletPassword.fill(this.config.PASSWORD);
await this.nextButton.click();
});

await this.finishOnboardingBtn.waitFor({
state: 'visible',
timeout: 30000,
});
});
}
}
2 changes: 1 addition & 1 deletion packages/wallets/src/okx/okx.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export class OkxPage implements WalletPage {
await this.page.close();
}

/** Click `Confirm` button on the transaction `page` */
/** Click `Connect` button on the transaction `page` */
async connectWallet(page: Page) {
await test.step('Connect OKX wallet', async () => {
const operationPage = new WalletOperations(page);
Expand Down
2 changes: 1 addition & 1 deletion wallets-testing/test/widgets/ethereum.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test.describe('Ethereum', () => {
await browserService.connectWallet();
});

test.skip(`Exodus connect`, async () => {
test(`Exodus connect`, async () => {
await browserService.setup(EXODUS_COMMON_CONFIG, ETHEREUM_WIDGET_CONFIG);
await browserService.connectWallet();
});
Expand Down

0 comments on commit fabd21d

Please sign in to comment.