Skip to content

Commit

Permalink
Merge pull request #13 from argentlabs/WW-143
Browse files Browse the repository at this point in the history
chore: update e2e tests
  • Loading branch information
bluecco authored Dec 11, 2024
2 parents 649dbba + b5f3a44 commit 1dc4406
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 36 deletions.
33 changes: 18 additions & 15 deletions e2e/src/webwallet/page-objects/Dapps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
])

Expand All @@ -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()
}

Expand All @@ -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")
Expand All @@ -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(),
Expand All @@ -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()
}
}
36 changes: 36 additions & 0 deletions e2e/src/webwallet/specs/network.spec.ts
Original file line number Diff line number Diff line change
@@ -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",
})
})
})
18 changes: 18 additions & 0 deletions e2e/src/webwallet/specs/token.spec.ts
Original file line number Diff line number Diff line change
@@ -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()
})
})
16 changes: 9 additions & 7 deletions src/components/sections/ERC20/AddToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@ const AddToken = () => {
return null
}

const handleAddToken = async () => {
try {
await walletRequest.requestAsync()
} catch {
alert("Not implemented")
}
}

return (
<SectionLayout sectionTitle="Add Token" icon={<AddTokenIcon />}>
<div className="flex w-1/2 justify-start">
<Button
className="w-full"
onClick={async () => {
await walletRequest.requestAsync()
}}
hideChevron
>
<Button className="w-full" onClick={handleAddToken} hideChevron>
Add Token
</Button>
</div>
Expand Down
16 changes: 9 additions & 7 deletions src/components/sections/Network/AddNetwork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ const AddNetwork = () => {
},
})

const handleAddNetwork = async () => {
try {
await walletRequest.requestAsync()
} catch {
alert("Not implemented")
}
}

return (
<div className="flex w-full justify-start">
<Button
className="w-full"
onClick={async () => {
await walletRequest.requestAsync()
}}
hideChevron
>
<Button className="w-full" onClick={handleAddNetwork} hideChevron>
Add Network
</Button>
</div>
Expand Down
16 changes: 9 additions & 7 deletions src/components/sections/Network/ChangeNetwork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ const ChangeNetwork = () => {
},
})

const handleChangeNetwork = async () => {
try {
await walletRequest.requestAsync()
} catch {
alert("Not implemented")
}
}

return (
<div className="flex w-full justify-start">
<Button
className="w-full"
onClick={async () => {
await walletRequest.requestAsync()
}}
hideChevron
>
<Button className="w-full" onClick={handleChangeNetwork} hideChevron>
Change Network
</Button>
</div>
Expand Down

0 comments on commit 1dc4406

Please sign in to comment.