Skip to content
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @tobelabs/chainwright

## 0.10.7

### Patch Changes

- Fix CI flakiness for Keplr and Meteor

## 0.10.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 5 additions & 3 deletions src/utils/wallets/get-popup-page-from-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function getPopupPageFromContext({ context, path, locator }: GetPop
return !!popupPage;
},
{
timeout: 60_000,
timeout: 90_000,
},
)
.toBe(true);
Expand All @@ -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"),
);
}

Expand All @@ -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 });

Expand Down
1 change: 1 addition & 0 deletions src/wallets/keplr/actions/get-account-address.keplr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 1 addition & 12 deletions src/wallets/keplr/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export async function addWalletViaPrivateKey({
walletName,
mode,
chains,
actionType: "privateKey",
});
}

Expand Down Expand Up @@ -84,19 +83,17 @@ export async function addWalletViaSeedPhrase({
walletName,
mode,
chains,
actionType: "seedPhrase",
});
}

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");

Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/wallets/metamask/actions/connect-to-app.metamask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down
4 changes: 2 additions & 2 deletions src/wallets/meteor/actions/get-account-address.meteor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down