diff --git a/src/constants.ts b/src/constants.ts index 79cdb5a3..4cb9d56c 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -3,12 +3,13 @@ import { getDappateerPath } from "./helpers/utils"; export const EXAMPLE_WEBSITE = "http://example.org"; -export const RECOMMENDED_METAMASK_VERSION = "v10.24.2"; +export const RECOMMENDED_METAMASK_VERSION = "v10.25.0"; export const DEFAULT_METAMASK_USERDATA = path.join( getDappateerPath(), "userData/chrome-mm" ); + export const DEFAULT_FLASK_USERDATA = path.join( getDappateerPath(), "userData/chrome-flask" diff --git a/src/helpers/actions.ts b/src/helpers/actions.ts index 83728b79..5f514973 100644 --- a/src/helpers/actions.ts +++ b/src/helpers/actions.ts @@ -17,6 +17,25 @@ export const clickOnSettingsSwitch = async ( await button.click(); }; +type Section = + | "General" + | "Advanced" + | "Contacts" + | "Snaps" + | "Security & privacy" + | "Alerts" + | "Networks" + | "Experimental" + | "About"; +export const openSettingsScreen = async ( + page: DappeteerPage, + section: Section = "General" +): Promise => { + await profileDropdownClick(page); + await clickOnElement(page, "Settings"); + await clickOnElement(page, section); +}; + export const openNetworkDropdown = async ( page: DappeteerPage ): Promise => { diff --git a/src/helpers/selectors.ts b/src/helpers/selectors.ts index b428520f..d400c65d 100644 --- a/src/helpers/selectors.ts +++ b/src/helpers/selectors.ts @@ -16,9 +16,19 @@ export const getElementByContent = ( export const getElementByTestId = ( page: DappeteerPage, - testId: string + testId: string, + options: { + visible?: boolean; + detached?: boolean; + hidden?: boolean; + timeout?: number; + } = {} ): Promise => - page.waitForSelector(`[data-testid="${testId}"]`); + page.waitForSelector(`[data-testid="${testId}"]`, { + timeout: 20000, + visible: true, + ...options, + }); export const getInputByLabel = ( page: DappeteerPage, @@ -91,7 +101,7 @@ export const getButton = async ( } ): Promise => { return await Promise.race([ - getElementByTestId(page, text), + getElementByTestId(page, text, options), getElementByContent(page, text, "button", options), ]); }; diff --git a/src/metamask/confirmTransaction.ts b/src/metamask/confirmTransaction.ts index 9cc4b08b..0a7bc065 100644 --- a/src/metamask/confirmTransaction.ts +++ b/src/metamask/confirmTransaction.ts @@ -1,7 +1,7 @@ import { TransactionOptions } from ".."; import { clickOnButton, - getElementByContent, + getElementByTestId, retry, typeOnInputField, waitForOverlay, @@ -10,8 +10,6 @@ import { DappeteerPage } from "../page"; import { GetSingedIn } from "./index"; -const MIN_GAS = 21000; - export const confirmTransaction = (page: DappeteerPage, getSingedIn: GetSingedIn) => async (options?: TransactionOptions): Promise => { @@ -25,41 +23,44 @@ export const confirmTransaction = await page.bringToFront(); await page.reload(); await waitForOverlay(page); - await getElementByContent(page, "Edit", "button", { + await getElementByTestId(page, "edit-gas-fee-button", { timeout: 500, - visible: false, }); }, 15); if (options) { - await clickOnButton(page, "Edit"); - await clickOnButton(page, "Edit suggested gas fee"); + await clickOnButton(page, "edit-gas-fee-button"); + await clickOnButton(page, "edit-gas-fee-item-custom"); //non EIP1559 networks don't have priority fee. TODO: run separate Ganache with older hardfork to test this - let priority = false; - if (options.priority) { - priority = await typeOnInputField( + if (options.priority) + await typeOnInputField( page, - "Max priority fee", + "Priority Fee", // priority-fee-input String(options.priority), true, true, true ); - } - if (options.gasLimit && options.gasLimit >= MIN_GAS) + if (options.gas) await typeOnInputField( page, - "Gas Limit", - String(options.gasLimit), + "Max base fee", // base-fee-input + String(options.priority), + true, + true, true ); - if (options.gas && options.gasLimit >= MIN_GAS) + if (options.gasLimit) { + await clickOnButton(page, "advanced-gas-fee-edit"); await typeOnInputField( page, - priority ? "Max fee" : "Gas Limit", - String(options.gasLimit), + "Gas limit", // gas-limit-input + String(options.priority), + true, + true, true ); + } await clickOnButton(page, "Save"); } diff --git a/src/setup/setupActions.ts b/src/setup/setupActions.ts index 5691f20b..ba6d367b 100644 --- a/src/setup/setupActions.ts +++ b/src/setup/setupActions.ts @@ -5,6 +5,7 @@ import { clickOnNavigationButton, clickOnSettingsSwitch, openNetworkDropdown, + openSettingsScreen, typeOnInputField, waitForOverlay, } from "../helpers"; @@ -19,6 +20,14 @@ export async function showTestNets(metaMaskPage: DappeteerPage): Promise { await clickOnLogo(metaMaskPage); } +export async function enableEthSign( + metaMaskPage: DappeteerPage +): Promise { + await openSettingsScreen(metaMaskPage, "Advanced"); + await clickOnSettingsSwitch(metaMaskPage, "Toggle eth_sign requests"); + await clickOnLogo(metaMaskPage); +} + export async function acceptTheRisks( metaMaskPage: DappeteerPage ): Promise { diff --git a/src/setup/setupMetaMask.ts b/src/setup/setupMetaMask.ts index aa292641..d6740e5a 100644 --- a/src/setup/setupMetaMask.ts +++ b/src/setup/setupMetaMask.ts @@ -9,6 +9,7 @@ import { closeNewModal, closePortfolioTooltip, closeWhatsNewModal, + enableEthSign, importAccount, showTestNets, } from "./setupActions"; @@ -25,6 +26,7 @@ const defaultMetaMaskSteps: Step[] = [ importAccount, closeNewModal, showTestNets, + enableEthSign, closeWhatsNewModal, closeWhatsNewModal, ]; @@ -33,6 +35,7 @@ const flaskMetaMaskSteps: Step[] = [ acceptTheRisks, importAccount, showTestNets, + enableEthSign, closePortfolioTooltip, closeWhatsNewModal, closeWhatsNewModal, diff --git a/test/basic.spec.ts b/test/basic.spec.ts index 34efe54c..324eac5b 100644 --- a/test/basic.spec.ts +++ b/test/basic.spec.ts @@ -124,10 +124,6 @@ describe("basic interactions", function () { }); it("should not add network", async function (this: TestContext) { - if (this.browser.isMetaMaskFlask()) { - this.skip(); - } - const addNetworkPromise = testPage.evaluate(addNetwork); await metaMask.rejectAddNetwork(); const res = await addNetworkPromise; @@ -135,10 +131,6 @@ describe("basic interactions", function () { }); it("should add network and switch", async function (this: TestContext) { - if (this.browser.isMetaMaskFlask()) { - this.skip(); - } - const addNetworkPromise = testPage.evaluate(addNetwork); await metaMask.acceptAddNetwork(); const res = await addNetworkPromise;