From b5f3a4422efafedbeae45474857a49bb020ee6c6 Mon Sep 17 00:00:00 2001 From: bluecco Date: Wed, 11 Dec 2024 16:30:29 +0100 Subject: [PATCH] chore: update e2e tests --- e2e/src/webwallet/page-objects/Dapps.ts | 33 +++++++++-------- e2e/src/webwallet/specs/network.spec.ts | 36 +++++++++++++++++++ e2e/src/webwallet/specs/token.spec.ts | 18 ++++++++++ src/components/sections/ERC20/AddToken.tsx | 16 +++++---- .../sections/Network/AddNetwork.tsx | 16 +++++---- .../sections/Network/ChangeNetwork.tsx | 16 +++++---- 6 files changed, 99 insertions(+), 36 deletions(-) create mode 100644 e2e/src/webwallet/specs/network.spec.ts create mode 100644 e2e/src/webwallet/specs/token.spec.ts diff --git a/e2e/src/webwallet/page-objects/Dapps.ts b/e2e/src/webwallet/page-objects/Dapps.ts index 24d08a0..a070b84 100644 --- a/e2e/src/webwallet/page-objects/Dapps.ts +++ b/e2e/src/webwallet/page-objects/Dapps.ts @@ -66,12 +66,10 @@ export default class Dapps extends Navigation { } // password submit - console.log("password submit") await popup.locator('button[type="submit"]').click() await Promise.all([ popup.waitForURL("**/connect?**"), - popup.waitForLoadState("networkidle"), popup.waitForTimeout(5000), // additional safety delay if needed ]) @@ -80,7 +78,6 @@ export default class Dapps extends Navigation { // check if connect page is showed by checking buttons if (count > 0) { - console.log("connect to dapp submit") await popup.locator('button[type="submit"]').click() } @@ -100,31 +97,24 @@ export default class Dapps extends Navigation { async sendERC20transaction({ type }: { type: "ERC20" | "Multicall" }) { const popupPromise = this.dApp.waitForEvent("popup") const dialogPromise = this.dApp.waitForEvent("dialog") - console.log("Sending ERC20 transaction") await this.dApp.locator('button :text-is("Transactions")').click() const [, popup] = await Promise.all([ this.dApp.locator(`button :text-is("Send ${type}")`).click(), popupPromise, ]) - console.log("Sending ERC20 transaction: send clicked") await expect(popup.getByText("Review transaction")).toBeVisible() - console.log("Sending ERC20 transaction: review transaction visible") await expect(popup.getByText("Confirm")).toBeVisible() - console.log("Sending ERC20 transaction: confirm visible") const [, dialog] = await Promise.all([ popup.getByText("Confirm").click(), dialogPromise, ]) - console.log("Sending ERC20 transaction: confirm clicked") - console.log("Signing message: wait for dialog") expect(dialog.message()).toContain("Transaction sent") await dialog.accept() } async signMessage() { - console.log("Signing message") const popupPromise = this.dApp.waitForEvent("popup") await this.dApp.locator('button :text-is("Signing")').click() await this.dApp.locator("[name=short-text]").fill("some message to sign") @@ -134,14 +124,9 @@ export default class Dapps extends Navigation { ]) await expect(popup.getByText("Sign Message")).toBeVisible() - console.log("Signing message: sign message visible") await expect(popup.getByText("Confirm")).toBeVisible() - console.log("Signing message: confirm visible") await popup.getByText("Confirm").click({ timeout: 30000, force: true }) - console.log("Signing message: confirm clicked") - //await popup.waitForEvent("close", { timeout: 10000 }) - console.log("Signing message: wait for ui") await Promise.all([ expect(this.dApp.getByText("Signer", { exact: true })).toBeVisible(), expect(this.dApp.getByText("Cosigner", { exact: true })).toBeVisible(), @@ -151,4 +136,22 @@ export default class Dapps extends Navigation { expect(this.dApp.locator("[name=cosigner_s]")).toBeVisible(), ]) } + + async network({ type }: { type: "Add" | "Change" }) { + const dialogPromise = this.dApp.waitForEvent("dialog") + await this.dApp.locator('button :text-is("Network")').click() + await this.dApp.locator(`button :text-is("${type} Network")`).click() + const dialog = await dialogPromise + expect(dialog.message()).toContain("Not implemented") + await dialog.accept() + } + + async addToken() { + const dialogPromise = this.dApp.waitForEvent("dialog") + await this.dApp.locator('button :text-is("ERC20")').click() + await this.dApp.locator(`button :text-is("Add Token")`).click() + const dialog = await dialogPromise + expect(dialog.message()).toContain("Not implemented") + await dialog.accept() + } } diff --git a/e2e/src/webwallet/specs/network.spec.ts b/e2e/src/webwallet/specs/network.spec.ts new file mode 100644 index 0000000..b6711ea --- /dev/null +++ b/e2e/src/webwallet/specs/network.spec.ts @@ -0,0 +1,36 @@ +import test from "../test" +import config from "../config" + +test.describe(`Network`, () => { + test(`not implemented while calling Add Network`, async ({ + webWallet, + dApp, + }) => { + await webWallet.dapps.requestConnectionFromDapp({ + dApp, + credentials: config.validLogin, + newAccount: false, + useStarknetKitModal: true, + }) + + await webWallet.dapps.network({ + type: "Add", + }) + }) + + test(`not implemented while calling Change Network`, async ({ + webWallet, + dApp, + }) => { + await webWallet.dapps.requestConnectionFromDapp({ + dApp, + credentials: config.validLogin, + newAccount: false, + useStarknetKitModal: false, + }) + + await webWallet.dapps.network({ + type: "Change", + }) + }) +}) diff --git a/e2e/src/webwallet/specs/token.spec.ts b/e2e/src/webwallet/specs/token.spec.ts new file mode 100644 index 0000000..f18e3ca --- /dev/null +++ b/e2e/src/webwallet/specs/token.spec.ts @@ -0,0 +1,18 @@ +import test from "../test" +import config from "../config" + +test.describe(`Token`, () => { + test(`not implemented while calling Add Token`, async ({ + webWallet, + dApp, + }) => { + await webWallet.dapps.requestConnectionFromDapp({ + dApp, + credentials: config.validLogin, + newAccount: false, + useStarknetKitModal: true, + }) + + await webWallet.dapps.addToken() + }) +}) diff --git a/src/components/sections/ERC20/AddToken.tsx b/src/components/sections/ERC20/AddToken.tsx index 1fbdb1e..9fcf90e 100644 --- a/src/components/sections/ERC20/AddToken.tsx +++ b/src/components/sections/ERC20/AddToken.tsx @@ -24,16 +24,18 @@ const AddToken = () => { return null } + const handleAddToken = async () => { + try { + await walletRequest.requestAsync() + } catch { + alert("Not implemented") + } + } + return ( }>
-
diff --git a/src/components/sections/Network/AddNetwork.tsx b/src/components/sections/Network/AddNetwork.tsx index 1b59973..08768b7 100644 --- a/src/components/sections/Network/AddNetwork.tsx +++ b/src/components/sections/Network/AddNetwork.tsx @@ -23,15 +23,17 @@ const AddNetwork = () => { }, }) + const handleAddNetwork = async () => { + try { + await walletRequest.requestAsync() + } catch { + alert("Not implemented") + } + } + return (
-
diff --git a/src/components/sections/Network/ChangeNetwork.tsx b/src/components/sections/Network/ChangeNetwork.tsx index 028a034..3b24b5b 100644 --- a/src/components/sections/Network/ChangeNetwork.tsx +++ b/src/components/sections/Network/ChangeNetwork.tsx @@ -15,15 +15,17 @@ const ChangeNetwork = () => { }, }) + const handleChangeNetwork = async () => { + try { + await walletRequest.requestAsync() + } catch { + alert("Not implemented") + } + } + return (
-