forked from Scaffold-Stark/scaffold-stark-2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
349 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import endpoint from "./configTypes"; | ||
import { test, expect } from "@playwright/test"; | ||
import { navigateAndWait } from "./utils/navigate"; | ||
import { HomePage } from "./pages/HomePage"; | ||
import { DebugPage } from "./pages/DebugPage"; | ||
|
||
test("interact with contract", async ({ page }) => { | ||
await navigateAndWait(page, endpoint.BASE_URL); | ||
const homePage = new HomePage(page); | ||
await homePage.getDebugPageLinkButton().click(); | ||
|
||
await expect(page.getByText("YourContract")).toBeVisible(); | ||
|
||
const debugPage = new DebugPage(page); | ||
await debugPage.connectWallet("0x64b4...5691"); | ||
|
||
const writeTab = await debugPage.getWriteTab(); | ||
await writeTab.click(); | ||
|
||
const withdrawSection = page.locator("div.py-5", { | ||
has: page.locator("p.text-function", { hasText: "withdraw" }), | ||
}); | ||
const sendButton = withdrawSection.locator("button", { hasText: "Send 💸" }); | ||
await sendButton.click(); | ||
|
||
const transactionReceipt = withdrawSection.locator("strong", { | ||
hasText: "Transaction Receipt", | ||
}); | ||
await expect(transactionReceipt).toBeVisible(); | ||
}); |
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,16 @@ | ||
import { Page } from "playwright"; | ||
import { BasePage } from "./BasePage"; | ||
|
||
export class DebugPage extends BasePage { | ||
constructor(page: Page) { | ||
super(page); | ||
} | ||
|
||
getWriteTab() { | ||
return this.page | ||
.locator('div:not([class*="hidden"]) .tabs a.tab', { | ||
hasText: "Write", | ||
}) | ||
.first(); | ||
} | ||
} |
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,15 @@ | ||
import { Page } from "playwright"; | ||
import { BasePage } from "./BasePage"; | ||
|
||
export class HomePage extends BasePage { | ||
constructor(page: Page) { | ||
super(page); | ||
} | ||
|
||
getDebugPageLinkButton() { | ||
return this.page.locator("a", { | ||
hasText: "Debug Contracts", | ||
has: this.page.locator("svg"), | ||
}); | ||
} | ||
} |
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,9 @@ | ||
import { Page } from "@playwright/test"; | ||
|
||
export async function navigateAndWait(page: Page, url: string) { | ||
await page.goto(url); | ||
await Promise.all([ | ||
page.waitForLoadState("domcontentloaded"), | ||
page.waitForLoadState("networkidle"), | ||
]); | ||
} |