@coinbase/onchaintestkit
Version:
End-to-end testing toolkit for blockchain applications, powered by Playwright
53 lines (52 loc) • 2.41 kB
TypeScript
import type { Page } from "@playwright/test";
export declare enum NotificationPageType {
SpendingCap = "spending-cap",
Signature = "signature",
Transaction = "transaction",
RemoveSpendCap = "remove-spend-cap"
}
export declare class NotificationPage {
readonly page: Page;
private cachedNotificationPage;
constructor(page: Page);
/**
* Helper method to get notification page URL
*/
private getNotificationUrl;
/**
* Helper method to wait for notification page.
* Reuses the cached page from identifyNotificationType if still alive.
*
* Wraps waitForPage with a timeout so a hung lookup doesn't burn the
* entire 300s test timeout. waitForPage itself handles the TOCTOU race
* (event listener + polling), and action handlers now wait for page
* close so stale pages are no longer in context.pages().
*/
private getNotificationPage;
connectToDapp(extensionId: string): Promise<void>;
approveNewNetwork(extensionId: string): Promise<void>;
rejectNewNetwork(extensionId: string): Promise<void>;
approveSwitchNetwork(extensionId: string): Promise<void>;
rejectSwitchNetwork(extensionId: string): Promise<void>;
approveAddNetwork(extensionId: string): Promise<void>;
rejectAddNetwork(extensionId: string): Promise<void>;
/**
* Run an action on the notification page with a single retry.
* If the first attempt fails with "Target page, context or browser has been
* closed", waits 1 second for the stale page to detach, then looks for a
* fresh notification page directly in context.pages().
*
* The retry does NOT use waitForPage because its waitForEvent('page')
* fallback hangs forever — MetaMask reuses popups rather than opening
* new page events.
*/
private withRetry;
confirmTransaction(extensionId: string): Promise<void>;
rejectTransaction(extensionId: string): Promise<void>;
approveTokenPermission(extensionId: string): Promise<void>;
rejectTokenPermission(extensionId: string): Promise<void>;
confirmSpendingCapRemoval(extensionId: string): Promise<void>;
rejectSpendingCapRemoval(extensionId: string): Promise<void>;
addNewToken(extensionId: string): Promise<void>;
identifyNotificationType(extensionId: string, globalTimeout?: number, pollInterval?: number): Promise<NotificationPageType>;
}