-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a utility class for connection popup interactions and a helper function to strictly watch for extension popups.
- Loading branch information
1 parent
2b4c3ce
commit 9405799
Showing
5 changed files
with
104 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { BrowserContext, Page, expect } from "@playwright/test" | ||
|
||
export default class SiteConnectionHelper { | ||
get page() { | ||
if (this.#targetPage === null) { | ||
throw new Error("Connection popup hasn't loaded yet") | ||
} | ||
return this.#targetPage | ||
} | ||
|
||
#targetPage: Page | null = null | ||
|
||
#pagePromise: Promise<Page> | ||
|
||
constructor( | ||
private readonly context: BrowserContext, | ||
extensionId: string, | ||
) { | ||
this.#pagePromise = this.context.waitForEvent("page", (page) => | ||
page.url().includes(extensionId), | ||
) | ||
} | ||
|
||
async ready() { | ||
const popup = await this.#pagePromise | ||
await popup.waitForLoadState() | ||
this.#targetPage = popup | ||
} | ||
|
||
/** | ||
* Hides the dApp Connection "use Taho as default" informational popup so | ||
* tests can proceed assuming dApp connection will be available without | ||
* additional interactions. | ||
*/ | ||
async hideDappConnectPopup(): Promise<void> { | ||
// Clear the one-time informational popup, if present. | ||
const connectingPopupTitle = this.page.locator("h3", { | ||
hasText: "Connecting with Taho", | ||
}) | ||
|
||
expect(await connectingPopupTitle.count()).toBe(1) | ||
|
||
await expect(connectingPopupTitle).toBeVisible() | ||
|
||
// Clear the popover. | ||
const bgLocator = this.page | ||
.locator(".bg") | ||
.getByRole("button", { name: "Close" }) | ||
|
||
await bgLocator.click() | ||
await bgLocator.waitFor({ state: "detached", timeout: 1000 }) | ||
} | ||
|
||
async rejectConnection() { | ||
await this.page.locator("button", { hasText: "Reject" }).click() | ||
} | ||
|
||
async acceptConnection() { | ||
await this.page.getByRole("button", { name: "Connect" }).click() | ||
} | ||
|
||
async closeWindow() { | ||
await this.page.close() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters