diff --git a/e2e-tests/regular/nfts.spec.ts b/e2e-tests/regular/nfts.spec.ts index 9d5ff3572..fbc3ddd37 100644 --- a/e2e-tests/regular/nfts.spec.ts +++ b/e2e-tests/regular/nfts.spec.ts @@ -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) => { @@ -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 }) } }) @@ -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