diff --git a/CHANGELOG.md b/CHANGELOG.md index 1644209..a304788 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # @tobelabs/chainwright +## 0.10.7 + +### Patch Changes + +- Fix CI flakiness for Keplr and Meteor + ## 0.10.6 ### Patch Changes diff --git a/package.json b/package.json index 309e53a..9ebb3e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chainwright", - "version": "0.10.6", + "version": "0.10.7", "description": "Playwright Web3 wallet testing framework for end-to-end dApp automation with MetaMask, Phantom, Solflare, Petra, Meteor, and Keplr", "type": "module", "license": "MIT", diff --git a/src/utils/wallets/get-popup-page-from-context.ts b/src/utils/wallets/get-popup-page-from-context.ts index 059733f..bcd58b8 100644 --- a/src/utils/wallets/get-popup-page-from-context.ts +++ b/src/utils/wallets/get-popup-page-from-context.ts @@ -19,7 +19,7 @@ export async function getPopupPageFromContext({ context, path, locator }: GetPop return !!popupPage; }, { - timeout: 60_000, + timeout: 90_000, }, ) .toBe(true); @@ -29,8 +29,10 @@ export async function getPopupPageFromContext({ context, path, locator }: GetPop .filter((_page) => _page.url().startsWith("chrome-extension://")) .map((p) => p.url()); throw new Error( - `Popup page with path "${path}" not found in context after 30s. ` + + [ + `Popup page with path "${path}" not found in context after 90s. `, `Pages in context: ${JSON.stringify(urls)}`, + ].join("\n"), ); } @@ -50,7 +52,7 @@ export async function getPopupPageFromContext({ context, path, locator }: GetPop } async function waitForStablePage(page: Page, locator: string) { - const TIMEOUT = 40_000; + const TIMEOUT = 45_000; await page.waitForLoadState("load", { timeout: TIMEOUT }); await page.waitForLoadState("domcontentloaded", { timeout: TIMEOUT }); diff --git a/src/wallets/keplr/actions/get-account-address.keplr.ts b/src/wallets/keplr/actions/get-account-address.keplr.ts index 4a5a8af..1814635 100644 --- a/src/wallets/keplr/actions/get-account-address.keplr.ts +++ b/src/wallets/keplr/actions/get-account-address.keplr.ts @@ -38,6 +38,7 @@ export async function getAccountAddress({ page, ...args }: GetAccountAddress) { await popoverSearchInput.fill(parsedData.chain); const _chains = popoverContainer.locator("div[cursor='pointer']", { hasText: parsedData.chain }); + await expect(_chains.first()).toBeVisible({ timeout: 60_000 }); const chains = await _chains.all(); let addressElement: Locator | undefined; diff --git a/src/wallets/keplr/utils.ts b/src/wallets/keplr/utils.ts index 30545d5..09e4bc5 100644 --- a/src/wallets/keplr/utils.ts +++ b/src/wallets/keplr/utils.ts @@ -42,7 +42,6 @@ export async function addWalletViaPrivateKey({ walletName, mode, chains, - actionType: "privateKey", }); } @@ -84,7 +83,6 @@ export async function addWalletViaSeedPhrase({ walletName, mode, chains, - actionType: "seedPhrase", }); } @@ -92,11 +90,10 @@ type AddAccountFlow = { page: Page; walletName: string; mode: AddAccount["mode"]; - actionType: "seedPhrase" | "privateKey"; chains: AddAccount["chains"]; }; -async function addAccountFlow({ page, walletName, mode, chains, actionType }: AddAccountFlow) { +async function addAccountFlow({ page, walletName, mode, chains }: AddAccountFlow) { const walletProfile = new KeplrProfile(); const PASSWORD = await getWalletPasswordFromCache("keplr"); @@ -118,18 +115,10 @@ async function addAccountFlow({ page, walletName, mode, chains, actionType }: Ad await nextButton.click(); const allNativeChains = page.locator("div:has-text('All Native Chains')").nth(-4); - const cosmosHubChain = page.locator( - `div[cursor='${actionType === "privateKey" ? "pointer" : "not-allowed"}']:has-text('Cosmos Hub')`, - ); const allNativeChainsCheckbox = await allNativeChains.locator("input[type='checkbox']").getAttribute("checked"); - const cosmosHubChainCheckbox = - actionType === "privateKey" - ? await cosmosHubChain.locator("input[type='checkbox']").getAttribute("checked") - : null; // Uncheck "All Native Chains" and "Cosmos Hub" if (allNativeChainsCheckbox !== null) await allNativeChains.click(); - if (cosmosHubChainCheckbox !== null) await cosmosHubChain.click(); const searchNetworkInput = page.locator(onboardingSelectors.searchNetworkInput); diff --git a/src/wallets/metamask/actions/connect-to-app.metamask.ts b/src/wallets/metamask/actions/connect-to-app.metamask.ts index 4f87550..d7f3ce0 100644 --- a/src/wallets/metamask/actions/connect-to-app.metamask.ts +++ b/src/wallets/metamask/actions/connect-to-app.metamask.ts @@ -52,7 +52,7 @@ export async function connectToApp(page: Page) { .catch(() => console.error("Notice dialog did not appear within the timeout period.")); const confirmButton = page.getByTestId("page-container-footer-next"); - await confirmButton.waitFor({ state: "visible", timeout: 25_000 }); + await confirmButton.waitFor({ state: "visible", timeout: 60_000 }); await confirmButton.click(); await page .waitForEvent("close", { diff --git a/src/wallets/meteor/actions/get-account-address.meteor.ts b/src/wallets/meteor/actions/get-account-address.meteor.ts index 398827e..8ed6e8d 100644 --- a/src/wallets/meteor/actions/get-account-address.meteor.ts +++ b/src/wallets/meteor/actions/get-account-address.meteor.ts @@ -7,10 +7,10 @@ export async function getAccountAddress(page: Page) { const copiedToast = page.locator(".chakra-toast").last(); await copyAddressButton.click(); - await copiedToast.waitFor({ state: "visible", timeout: 5_000 }); + await copiedToast.waitFor({ state: "visible", timeout: 10_000 }); const address = await page.evaluate(async () => await navigator.clipboard.readText()); - await copiedToast.waitFor({ state: "hidden", timeout: 5_000 }); + await copiedToast.waitFor({ state: "hidden", timeout: 15_000 }); return address; } diff --git a/src/wallets/solflare/actions/confirm-transaction.solflare.ts b/src/wallets/solflare/actions/confirm-transaction.solflare.ts index 6fd5315..31372c5 100644 --- a/src/wallets/solflare/actions/confirm-transaction.solflare.ts +++ b/src/wallets/solflare/actions/confirm-transaction.solflare.ts @@ -4,7 +4,7 @@ import { popupPageSelectors } from "../selectors/popup-page-selectors.solflare"; export async function confirmTransaction(page: Page) { const approveButton = page.getByTestId(popupPageSelectors.approveButton); const networkFeeSection = page.getByTestId("section-network-fee"); - await networkFeeSection.waitFor({ state: "attached", timeout: 15_000 }).catch(() => false); + await networkFeeSection.waitFor({ state: "attached", timeout: 45_000 }).catch(() => false); const infoBoxNetworkMismatch = page.getByTestId("info-box-network-mismatch"); const isInfoBoxNetworkMismatchVisible = await infoBoxNetworkMismatch.isVisible().catch(() => false);