@coinbase/onchaintestkit
Version:
End-to-end testing toolkit for blockchain applications, powered by Playwright
24 lines (23 loc) • 916 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.transaction = 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 confirmTransaction = async (notificationPage) => {
await notificationPage.getByRole("button", { name: "Confirm" }).click();
await waitForPageClose(notificationPage);
};
const rejectTransaction = async (notificationPage) => {
await notificationPage.getByRole("button", { name: "Cancel" }).click();
await waitForPageClose(notificationPage);
};
exports.transaction = {
confirm: confirmTransaction,
reject: rejectTransaction,
};