-
Notifications
You must be signed in to change notification settings - Fork 394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flip updated dApp connections flag #3492
Changes from 8 commits
76d8172
70f5d89
2ae0359
60ed423
9e3fb5b
c82f7b4
95fac2e
2578d1f
c9fc250
0c940fb
93cdbc7
220a0b8
31287cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,94 @@ | ||
import { test } from "./utils" | ||
import { test, expect } from "./utils" | ||
|
||
test("dapp connect", async ({ page, context, walletPageHelper }) => { | ||
await walletPageHelper.onboarding.addReadOnlyAccount("testertesting.eth") | ||
test.describe("dApp Connections", () => { | ||
test("should display an informational popup for Taho as default on first connection", async ({ | ||
context, | ||
walletPageHelper, | ||
}) => { | ||
await walletPageHelper.onboarding.addReadOnlyAccount("testertesting.eth") | ||
|
||
const dappPage = await context.newPage() | ||
await dappPage.goto("https://swap.cow.fi/") | ||
await dappPage | ||
.locator("#swap-button") | ||
.getByRole("button", { name: "Connect Wallet" }) | ||
.click() | ||
const dappPage = await context.newPage() | ||
await dappPage.goto("https://swap.cow.fi/") | ||
await dappPage | ||
.locator("#swap-button") | ||
.getByRole("button", { name: "Connect Wallet" }) | ||
.click() | ||
|
||
// Get page after a specific action (e.g. clicking a link) | ||
const [popupPage] = await Promise.all([ | ||
context.waitForEvent("page"), | ||
await dappPage.locator("text=Injected").click(), // Opens a new tab | ||
]) | ||
await popupPage.waitForLoadState() | ||
// Get page after a specific action (e.g. clicking a link) | ||
const [popupPage] = await Promise.all([ | ||
context.waitForEvent("page"), | ||
await dappPage.locator("text=Injected").click(), // Opens a new tab | ||
]) | ||
await popupPage.waitForLoadState() | ||
|
||
await popupPage.locator("button", { hasText: "Connect" }).click() | ||
// Clear the one-time informational popup, if present. | ||
const connectingPopupTitle = popupPage.locator("h3", { | ||
hasText: "Connecting with Taho", | ||
}) | ||
|
||
await walletPageHelper.goToStartPage() | ||
expect(await connectingPopupTitle.count()).toBe(1) | ||
await expect(connectingPopupTitle).toBeVisible() | ||
|
||
await page.locator('text="Settings"').click() | ||
await page.locator("text=Connected websites").click() | ||
// Clear the popover. | ||
const bgLocator = popupPage.locator(".bg") | ||
|
||
await page.locator('xpath=//li[contains(., "CoW Swap")]//button').click() | ||
await bgLocator.click() | ||
await bgLocator.waitFor({ state: "detached", timeout: 1000 }) | ||
|
||
await popupPage.locator("button", { hasText: "Reject" }).click() | ||
|
||
await dappPage.close() | ||
|
||
const dappPage2 = await context.newPage() | ||
await dappPage2.goto("https://swap.cow.fi/") | ||
await dappPage2 | ||
.locator("#swap-button") | ||
.getByRole("button", { name: "Connect Wallet" }) | ||
.click() | ||
|
||
// Get page after a specific action (e.g. clicking a link) | ||
const [popupPage2] = await Promise.all([ | ||
context.waitForEvent("page"), | ||
await dappPage2.locator("text=Injected").click(), // Opens a new tab | ||
]) | ||
await popupPage2.waitForLoadState() | ||
|
||
// Check that the popup is no longer displayed. | ||
const connectingPopupTitle2 = popupPage2.locator("h3", { | ||
hasText: "Connecting with Taho", | ||
}) | ||
expect(await connectingPopupTitle2.count()).toBe(0) | ||
}) | ||
|
||
test("should work and add an entry to the connected websites list", async ({ | ||
page, | ||
context, | ||
walletPageHelper, | ||
}) => { | ||
await walletPageHelper.onboarding.addReadOnlyAccount("testertesting.eth") | ||
await walletPageHelper.hideDappConnectPopup() | ||
|
||
const dappPage = await context.newPage() | ||
await dappPage.goto("https://swap.cow.fi/") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably worth running one small dApp along hardhat for some standard tests of this kind There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would really love to avoid more stuff we have to maintain tbh, but agree this is a pretty kludgey way to do it. |
||
await dappPage | ||
.locator("#swap-button") | ||
.getByRole("button", { name: "Connect Wallet" }) | ||
.click() | ||
|
||
// Get page after a specific action (e.g. clicking a link) | ||
const [popupPage] = await Promise.all([ | ||
context.waitForEvent("page"), | ||
await dappPage.locator("text=Injected").click(), // Opens a new tab | ||
]) | ||
await popupPage.waitForLoadState() | ||
|
||
await popupPage.locator("button", { hasText: "Connect" }).click() | ||
|
||
await walletPageHelper.goToStartPage() | ||
|
||
await page.locator('text="Settings"').click() | ||
await page.locator("text=Connected websites").click() | ||
|
||
await page.locator('xpath=//li[contains(., "CoW Swap")]//button').click() | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,7 @@ html, | |
body, | ||
#tally-root { | ||
height: 100%; | ||
width: 100%; | ||
} | ||
|
||
body.popup { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we target the "void space" button instead? Something like this should work:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that was my original approach and then I ran into issues that I thought were related but ultimately weren't, and then never changed it back. I'll poke at it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
220a0b8