From 1cd667cf54bef37cf5ce780cf141fab558f35c97 Mon Sep 17 00:00:00 2001 From: Ugwuanyi TobeChukwu <39131739+amaify@users.noreply.github.com> Date: Wed, 22 Jul 2026 12:47:33 +0100 Subject: [PATCH 1/2] [Solflare] - Close the "what's new" modal during onboarding --- src/wallets/phantom/actions/onboard.phantom.ts | 7 +++---- src/wallets/phantom/phantom-fixture.ts | 7 +++---- src/wallets/phantom/utils.ts | 18 ++++-------------- .../solflare/actions/onboard.solflare.ts | 7 +++++++ src/wallets/solflare/solflare-fixture.ts | 7 +++---- src/wallets/solflare/utils.ts | 15 +++------------ 6 files changed, 23 insertions(+), 38 deletions(-) diff --git a/src/wallets/phantom/actions/onboard.phantom.ts b/src/wallets/phantom/actions/onboard.phantom.ts index 98d0e69..52f3448 100644 --- a/src/wallets/phantom/actions/onboard.phantom.ts +++ b/src/wallets/phantom/actions/onboard.phantom.ts @@ -199,14 +199,13 @@ export default async function onboard({ page, additionalAccounts, ...args }: Onb } if (additionalAccounts && additionalAccounts.length > 0) { - let cancelled = false; - const isCancelled = () => cancelled; + const autoCloseController = new AbortController(); - autoClosePhantomNotification(newPage, isCancelled).catch((error) => console.error({ error })); + autoClosePhantomNotification(newPage, autoCloseController.signal).catch((error) => console.error({ error })); for (const { accountName, chain, privateKey } of additionalAccounts) { await addAccount({ page: newPage, privateKey, accountName, chain }); - cancelled = true; + autoCloseController.abort(); } await switchAccount(newPage, args.accountName); diff --git a/src/wallets/phantom/phantom-fixture.ts b/src/wallets/phantom/phantom-fixture.ts index 13096da..45d265f 100644 --- a/src/wallets/phantom/phantom-fixture.ts +++ b/src/wallets/phantom/phantom-fixture.ts @@ -77,13 +77,12 @@ export const phantomFixture = ({ slowMo = 0, profileName }: WalletProfileFixture }, autoCloseNotification: [ async ({ context: _ }, use) => { - let cancelled = false; - const isCancelled = () => cancelled; - const runner = autoClosePhantomNotification(_phantomPage, isCancelled); + const autoCloseController = new AbortController(); + const runner = autoClosePhantomNotification(_phantomPage, autoCloseController.signal); await use(undefined); - cancelled = true; + autoCloseController.abort(); await runner.catch((error) => { console.error(`Auto close notification error: ${(error as Error).message}`); }); diff --git a/src/wallets/phantom/utils.ts b/src/wallets/phantom/utils.ts index 01d1240..e7404a7 100644 --- a/src/wallets/phantom/utils.ts +++ b/src/wallets/phantom/utils.ts @@ -1,33 +1,23 @@ import type { Page } from "@playwright/test"; import { sleep } from "@/utils/sleep"; -export async function autoClosePhantomNotification(page: Page, isCancelled: () => boolean) { +export async function autoClosePhantomNotification(page: Page, signal: AbortSignal) { const INTERVAL = 300; - let IS_POLLING_COMPLETE = false; - - while (!isCancelled()) { - const _isCancelled = isCancelled(); - - // Check if notification is closed - // If it's closed or cancelled, there's no need to check again - if (_isCancelled || IS_POLLING_COMPLETE || page.isClosed()) break; + while (!signal.aborted && !page.isClosed()) { try { const notificationPopupBackButton = page.locator("div[id='modal']").locator("div > svg").first(); const isNotificationButtonVisible = await notificationPopupBackButton.isVisible().catch(() => false); if (isNotificationButtonVisible) { await notificationPopupBackButton.click(); - IS_POLLING_COMPLETE = true; + return; } } catch (error) { - if (page.isClosed()) break; console.error("[autoClosePhantomNotification]: ", error); + if (page.isClosed()) return; } - // Check if polling is complete - if (_isCancelled || IS_POLLING_COMPLETE || page.isClosed()) break; - await sleep(INTERVAL); } } diff --git a/src/wallets/solflare/actions/onboard.solflare.ts b/src/wallets/solflare/actions/onboard.solflare.ts index db8cb40..9d50943 100644 --- a/src/wallets/solflare/actions/onboard.solflare.ts +++ b/src/wallets/solflare/actions/onboard.solflare.ts @@ -3,6 +3,7 @@ import type { Page } from "@playwright/test"; import { getWalletPasswordFromCache } from "@/utils/wallets/get-wallet-password-from-cache"; import { onboardingSelectors } from "../selectors/onboard-selectors.solflare"; import type { OnboardingArgs } from "../types"; +import { autoCloseSolflareNotification } from "../utils"; import { addAccount } from "./add-account.solflare"; import { renameAccount } from "./rename-account.solflare"; import { switchNetwork } from "./switch-network.solflare"; @@ -42,6 +43,10 @@ export async function onboard({ page, recoveryPhrase, network, walletName, addit const IAgreeButton = page.getByTestId(onboardingSelectors.IAgreeButton); await IAgreeButton.click(); + const autoCloseController = new AbortController(); + + autoCloseSolflareNotification(page, autoCloseController.signal).catch((error) => console.error({ error })); + if (walletName) { // "Main Wallet" is the default wallet name for the fist wallet in Solflare. await renameAccount({ page, currentAccountName: "Main Wallet", newAccountName: walletName }); @@ -56,5 +61,7 @@ export async function onboard({ page, recoveryPhrase, network, walletName, addit } } + autoCloseController.abort(); + console.info(styleText("greenBright", "✨ Solflare onboarding completed successfully", { validateStream: false })); } diff --git a/src/wallets/solflare/solflare-fixture.ts b/src/wallets/solflare/solflare-fixture.ts index df65257..f4dd93f 100644 --- a/src/wallets/solflare/solflare-fixture.ts +++ b/src/wallets/solflare/solflare-fixture.ts @@ -81,13 +81,12 @@ export const solflareFixture = ({ slowMo = 0, profileName }: WalletProfileFixtur }, autoCloseNotification: [ async ({ context: _ }, use) => { - let cancelled = false; - const isCancelled = () => cancelled; - const runner = autoCloseSolflareNotification(_solflarePage, isCancelled); + const autoCloseController = new AbortController(); + const runner = autoCloseSolflareNotification(_solflarePage, autoCloseController.signal); await use(undefined); - cancelled = true; + autoCloseController.abort(); await runner.catch((error) => { console.error(`Auto close notification error: ${(error as Error).message}`); }); diff --git a/src/wallets/solflare/utils.ts b/src/wallets/solflare/utils.ts index ae6822e..ed94685 100644 --- a/src/wallets/solflare/utils.ts +++ b/src/wallets/solflare/utils.ts @@ -1,17 +1,10 @@ import type { Page } from "@playwright/test"; import { sleep } from "@/utils/sleep"; -export async function autoCloseSolflareNotification(page: Page, isCancelled: () => boolean) { +export async function autoCloseSolflareNotification(page: Page, signal: AbortSignal) { const INTERVAL = 150; - let IS_POLLING_COMPLETE = false; - - while (!isCancelled()) { - const _isCancelled = isCancelled(); - - // Check if notification is closed - // If it's closed or cancelled, there's no need to check again - if (_isCancelled || IS_POLLING_COMPLETE || page.isClosed()) break; + while (!signal.aborted && !page.isClosed()) { try { const notificationPopupCloseButton = page .locator("div[role='dialog']") @@ -23,14 +16,12 @@ export async function autoCloseSolflareNotification(page: Page, isCancelled: () if (isNotificationPopupCloseButtonVisisble) { await notificationPopupCloseButton.click(); - IS_POLLING_COMPLETE = true; + return; } } catch (error) { console.error("[autoCloseSolflareNotification]: ", error); } - if (_isCancelled || IS_POLLING_COMPLETE || page.isClosed()) break; - await sleep(INTERVAL); } } From 89ae08fa51c5ad797f5e1fca4a683b9e36b65216 Mon Sep 17 00:00:00 2001 From: Ugwuanyi TobeChukwu <39131739+amaify@users.noreply.github.com> Date: Wed, 22 Jul 2026 12:50:19 +0100 Subject: [PATCH 2/2] Prepare for publishing --- CHANGELOG.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6309089..f832a38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # @tobelabs/chainwright +## 0.10.10 + +### Patch Changes + +- [Solflare] - Close the "What's new" modal popup during onboarding + ## 0.10.9 ### Patch Changes diff --git a/package.json b/package.json index da30ba9..502f3bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chainwright", - "version": "0.10.9", + "version": "0.10.10", "description": "Playwright Web3 wallet testing framework for end-to-end dApp automation with MetaMask, Phantom, Solflare, Petra, Meteor, and Keplr", "type": "module", "license": "MIT",