UNPKG

@coinbase/onchaintestkit

Version:

End-to-end testing toolkit for blockchain applications, powered by Playwright

24 lines (23 loc) 944 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.approvePermission = void 0; // Poll until the page is closed (or timeout). This prevents the next // waitForPage call from finding this stale page in context.pages(). async function waitForPageClose(page, timeout = 5000) { const deadline = Date.now() + timeout; while (Date.now() < deadline && !page.isClosed()) { await new Promise(r => setTimeout(r, 200)); } } const approveTokenPermission = async (notificationPage) => { await notificationPage.getByRole("button", { name: "Confirm" }).click(); await waitForPageClose(notificationPage); }; const rejectTokenPermission = async (notificationPage) => { await notificationPage.getByRole("button", { name: "Reject" }).click(); await waitForPageClose(notificationPage); }; exports.approvePermission = { approve: approveTokenPermission, reject: rejectTokenPermission, };