UNPKG

@coinbase/onchaintestkit

Version:

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

35 lines (34 loc) 1.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addNetwork = addNetwork; const handlePopups_1 = require("../actions/handlePopups"); async function addNetwork(page, network) { const { name, rpcUrl, chainId, symbol, blockExplorerUrl } = network; console.log(`Adding network "${name}" with RPC URL: ${rpcUrl}`); await page.locator('[data-testid="network-display"]').click(); // click "Add a custom network" button await page.getByRole("button", { name: "Add a custom network" }).click(); // fill the network name input with id="networkName" await page.locator("#networkName").fill(name); // fill chain id input with id="chainId" await page.locator("#chainId").fill(chainId.toString()); // fill currency symbol input with id="nativeCurrency" await page.locator("#nativeCurrency").fill(symbol); // click the default rpc url dropdown button - label="Default RPC URL" await page.getByLabel("Default RPC URL").click(); // click "Add RPC URL" button await page.getByRole("button", { name: "Add RPC URL" }).click(); // fill rpc url input with id="rpcUrl" await page.locator("#rpcUrl").fill(rpcUrl); // fill rpc name input with id="rpcName" await page.locator("#rpcName").fill(name); // click "Add URL" button await page.getByRole("button", { name: "Add URL" }).click(); if (blockExplorerUrl) { await page.locator("#blockExplorerUrl").fill(blockExplorerUrl); } // click "Save" button await page.getByRole("button", { name: "Save" }).click(); await (0, handlePopups_1.closePopup)(page, handlePopups_1.popupConfigs.networkAdded); await (0, handlePopups_1.closePopup)(page, handlePopups_1.popupConfigs.networkInfo); }