Skip to content

Commit

Permalink
Update nfts test to intercept at browser level
Browse files Browse the repository at this point in the history
  • Loading branch information
hyphenized committed Jan 17, 2025
1 parent 4346828 commit 1753252
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions e2e-tests/regular/nfts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import { account1 } from "../utils/onboarding"
test.describe("NFTs", () => {
test("User can view nft collections, poaps and badges", async ({
page,
backgroundPage,
context,
isExtensionRequest,
walletPageHelper,
}) => {
await test.step("Shows loading state", async () => {
let shouldInterceptRequests = true

// Set a delay so we don't miss loading states
await backgroundPage.route(/api\.simplehash\.com/i, async (route) => {
if (!shouldInterceptRequests) {
route.continue()
return
await context.route(/api\.simplehash\.com/i, async (route, request) => {
if (!shouldInterceptRequests || !isExtensionRequest(request)) {
return route.continue()
}

const response = await route.fetch().catch((err) => {
Expand All @@ -32,7 +32,13 @@ test.describe("NFTs", () => {
})

if (response) {
await wait(800)
// Start fulfilling NFT requests once we're in the NFT's page
await page
.getByRole("link", { name: "NFTs" })
.locator(".active")
.waitFor({ state: "visible" })

await wait(5_000)
await route.fulfill({ response })
}
})
Expand All @@ -51,6 +57,7 @@ test.describe("NFTs", () => {
await walletPageHelper.navigateTo("NFTs")

// Wait until load finishes
await expect(page.getByTestId("loading_doggo")).toBeVisible()
await expect(page.getByTestId("loading_doggo")).not.toBeVisible()

shouldInterceptRequests = false
Expand Down

0 comments on commit 1753252

Please sign in to comment.