Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(cat-voices): add automation for lace #1698

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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" }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const clickRestoreWalletButton = async (page: Page): Promise<void> => {
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
Expand All @@ -25,18 +25,22 @@ const clickRestoreWalletButton = async (page: Page): Promise<void> => {

// 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);
}
Expand All @@ -45,47 +49,67 @@ const clickRestoreWalletButton = async (page: Page): Promise<void> => {
};

/*
* 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<void> => {
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<void> => {
export const onboardLaceWallet = async (
page: Page,
walletConfig: WalletConfig
): Promise<void> => {
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<void> => {
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<void> => {
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);
}
await page.close();
};
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const getWalletPopup = async (
): Promise<Page> => {
if (browser.pages().length > 1) {
await triggerLocatorCLick.click();
await browser.pages()[0].waitForTimeout(2000);
await browser
.pages()
[browser.pages().length - 1].waitForLoadState("domcontentloaded");
Expand All @@ -85,6 +86,7 @@ const getWalletPopup = async (
browser.waitForEvent("page"),
triggerLocatorCLick.click(),
]);
await page.waitForLoadState("domcontentloaded");
return page;
}
};
Expand Down
Loading