diff --git a/catalyst_voices/packages/libs/catalyst_cardano/catalyst_cardano/wallet-automation/playwright.config.ts b/catalyst_voices/packages/libs/catalyst_cardano/catalyst_cardano/wallet-automation/playwright.config.ts index 6571ff0b0d6..597510a1d2b 100644 --- a/catalyst_voices/packages/libs/catalyst_cardano/catalyst_cardano/wallet-automation/playwright.config.ts +++ b/catalyst_voices/packages/libs/catalyst_cardano/catalyst_cardano/wallet-automation/playwright.config.ts @@ -8,14 +8,12 @@ export default defineConfig({ testDir: "./tests", fullyParallel: false, forbidOnly: !!process.env.CI, - retries: process.env.CI ? 2 : 1, - workers: process.env.CI ? 1 : 1, + retries: 3, + workers: 1, use: { baseURL: process.env.APP_URL || "http://localhost:8000", ignoreHTTPSErrors: true, screenshot: "only-on-failure", - trace: "on", - video: "on", }, reporter: [ ["junit", { outputFile: "/results/cardano-wallet.junit-report.xml" }], diff --git a/catalyst_voices/packages/libs/catalyst_cardano/catalyst_cardano/wallet-automation/tests/wallets.spec.ts b/catalyst_voices/packages/libs/catalyst_cardano/catalyst_cardano/wallet-automation/tests/wallets.spec.ts index 7867550c2b7..468300fdc5e 100644 --- a/catalyst_voices/packages/libs/catalyst_cardano/catalyst_cardano/wallet-automation/tests/wallets.spec.ts +++ b/catalyst_voices/packages/libs/catalyst_cardano/catalyst_cardano/wallet-automation/tests/wallets.spec.ts @@ -17,10 +17,6 @@ walletConfigs.forEach((walletConfig) => { walletConfig.extension.Name === "Yoroi", "https://github.com/input-output-hk/catalyst-voices/issues/753" ); - test.skip( - walletConfig.extension.Name === "Lace", - "https://github.com/input-output-hk/catalyst-voices/issues/1190" - ); test.skip( walletConfig.extension.Name === "Nufi", "https://github.com/input-output-hk/catalyst-voices/issues/1190" diff --git a/catalyst_voices/packages/libs/catalyst_cardano/catalyst_cardano/wallet-automation/utils/wallets/laceUtils.ts b/catalyst_voices/packages/libs/catalyst_cardano/catalyst_cardano/wallet-automation/utils/wallets/laceUtils.ts index 6611a80d5da..39318aab1fd 100644 --- a/catalyst_voices/packages/libs/catalyst_cardano/catalyst_cardano/wallet-automation/utils/wallets/laceUtils.ts +++ b/catalyst_voices/packages/libs/catalyst_cardano/catalyst_cardano/wallet-automation/utils/wallets/laceUtils.ts @@ -14,7 +14,7 @@ const clickRestoreWalletButton = async (page: Page): Promise => { try { // Wait for the restore wallet button to be visible and enabled const restoreWalletButton = page.locator(restoreWalletButtonSelector); - await restoreWalletButton.waitFor({ state: 'visible', timeout: 5000 }); + await restoreWalletButton.waitFor({ state: "visible", timeout: 5000 }); await expect(restoreWalletButton).toBeEnabled(); // Click the restore wallet button and wait for the next page to load @@ -25,18 +25,22 @@ const clickRestoreWalletButton = async (page: Page): Promise => { // Verify that the next page has loaded by checking for a unique element const nextPageElement = page.locator(nextPageSelector); - await nextPageElement.waitFor({ state: 'visible', timeout: 5000 }); + await nextPageElement.waitFor({ state: "visible", timeout: 5000 }); // If the next page is detected, exit the function - console.log('Successfully navigated to the next page.'); + console.log("Successfully navigated to the next page."); return; } catch (error) { if (attempt === maxAttempts) { // If it's the last attempt, rethrow the error - throw new Error(`Failed to click 'restore-wallet-button' after ${maxAttempts} attempts: ${error}`); + throw new Error( + `Failed to click 'restore-wallet-button' after ${maxAttempts} attempts: ${error}` + ); } else { // Log the attempt and retry - console.warn(`Attempt ${attempt} to click 'restore-wallet-button' failed. Retrying...`); + console.warn( + `Attempt ${attempt} to click 'restore-wallet-button' failed. Retrying...` + ); // Optionally, you can add a short delay before retrying await page.waitForTimeout(1000); } @@ -45,47 +49,67 @@ const clickRestoreWalletButton = async (page: Page): Promise => { }; /* - * This handles the situation where after clicking restore Lace sometimes leads directly to recovery phrase page - * and sometimes leads to a page where the user has to click on the recovery phrase button to get to the recovery phrase page - */ + * This handles the situation where after clicking restore Lace sometimes leads directly to recovery phrase page + * and sometimes leads to a page where the user has to click on the recovery phrase button to get to the recovery phrase page + */ const handleNextPage = async (page: Page): Promise => { - const title = await page.getByTestId('wallet-setup-step-title').textContent(); - if(title === 'Choose recovery method') { + const title = await page.getByTestId("wallet-setup-step-title").textContent(); + if (title === "Choose recovery method") { await page.locator('[data-testid="wallet-setup-step-btn-next"]').click(); } else { return; } -} +}; -export const onboardLaceWallet = async (page: Page, walletConfig: WalletConfig): Promise => { +export const onboardLaceWallet = async ( + page: Page, + walletConfig: WalletConfig +): Promise => { await page.locator('[data-testid="analytics-accept-button"]').click(); await clickRestoreWalletButton(page); await handleNextPage(page); - await page.getByTestId('recovery-phrase-15').click(); + await page.getByTestId("recovery-phrase-15").click(); const seedPhrase = walletConfig.seed; - for (let i = 0; i < seedPhrase.length; i++) { - const ftSeedPhraseSelector = `//*[@id="mnemonic-word-${i + 1}"]`; - await page.locator(ftSeedPhraseSelector).fill(seedPhrase[i]); - } - await page.getByRole('button', { name: 'Next' }).click(); - await page.getByTestId('wallet-name-input').fill(walletConfig.username); - await page.getByTestId('wallet-password-verification-input').fill(walletConfig.password); - await page.getByTestId('wallet-password-confirmation-input').fill(walletConfig.password); - await page.getByRole('button', { name: 'Open wallet' }).click(); + for (let i = 0; i < seedPhrase.length; i++) { + const ftSeedPhraseSelector = `//*[@id="mnemonic-word-${i + 1}"]`; + await page.locator(ftSeedPhraseSelector).fill(seedPhrase[i]); + } + await page.getByRole("button", { name: "Next" }).click(); + await page.getByTestId("wallet-name-input").fill(walletConfig.username); + await page + .getByTestId("wallet-password-verification-input") + .fill(walletConfig.password); + await page + .getByTestId("wallet-password-confirmation-input") + .fill(walletConfig.password); + await page.getByRole("button", { name: "Open wallet" }).click(); //Lace is very slow at loading - await page.getByTestId('profile-dropdown-trigger-menu').click({timeout: 300000}); - await page.getByTestId('header-menu').getByTestId('header-menu-network-choice-container').click(); - await page.getByTestId('header-menu').getByTestId('network-preprod-radio-button').click(); + await page + .getByTestId("profile-dropdown-trigger-menu") + .click({ timeout: 300000 }); + await page + .getByTestId("header-menu") + .getByTestId("header-menu-network-choice-container") + .click(); + await page + .getByTestId("header-menu") + .getByTestId("network-preprod-radio-button") + .click(); await page.waitForTimeout(4000); }; -export const signLaceData = async (page: Page, password: string, isCorrectPassword: boolean): Promise => { - await page.getByRole('button', { name: 'Confirm' }).click(); - await page.getByTestId('password-input').fill(password); - await page.getByRole('button', { name: 'Confirm' }).click(); +export const signLaceData = async ( + page: Page, + password: string, + isCorrectPassword: boolean +): Promise => { + await page.getByRole("button", { name: "Confirm" }).click(); + await page.getByTestId("password-input").fill(password); + await page.getByTestId("sign-transaction-confirm").click(); if (!isCorrectPassword) { - await page.getByRole('button', { name: 'Close' }).click(); + await page.close(); return; } await page.waitForTimeout(2000); - } \ No newline at end of file + await page.close(); +}; diff --git a/catalyst_voices/packages/libs/catalyst_cardano/catalyst_cardano/wallet-automation/utils/wallets/walletUtils.ts b/catalyst_voices/packages/libs/catalyst_cardano/catalyst_cardano/wallet-automation/utils/wallets/walletUtils.ts index 3b5638a9c45..d2601dd37da 100644 --- a/catalyst_voices/packages/libs/catalyst_cardano/catalyst_cardano/wallet-automation/utils/wallets/walletUtils.ts +++ b/catalyst_voices/packages/libs/catalyst_cardano/catalyst_cardano/wallet-automation/utils/wallets/walletUtils.ts @@ -76,6 +76,7 @@ const getWalletPopup = async ( ): Promise => { if (browser.pages().length > 1) { await triggerLocatorCLick.click(); + await browser.pages()[0].waitForTimeout(2000); await browser .pages() [browser.pages().length - 1].waitForLoadState("domcontentloaded"); @@ -85,6 +86,7 @@ const getWalletPopup = async ( browser.waitForEvent("page"), triggerLocatorCLick.click(), ]); + await page.waitForLoadState("domcontentloaded"); return page; } };