From 9d70f38a34f176034a7e64655897a1ceafeb733e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Jedli=C4=8Dka?= Date: Wed, 6 Dec 2023 18:33:38 +0100 Subject: [PATCH] fix tests --- src/components/SearchInput.tsx | 2 +- src/hooks/usePreloadRuntimeMetadata.ts | 4 ++++ src/screens/home.tsx | 2 +- test/e2e/home.spec.ts | 6 ++++++ test/utils/navigate.ts | 4 ++++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/SearchInput.tsx b/src/components/SearchInput.tsx index fdea5de7..377aa007 100644 --- a/src/components/SearchInput.tsx +++ b/src/components/SearchInput.tsx @@ -205,7 +205,7 @@ function SearchInput(props: SearchInputProps) { }, [persist]); return ( -
+ (localStorage.getItem("runtime-metadata-preloaded") ? 100 : 0); useEffect(() => { + if (localStorage.getItem("skip-runtime-metadata-preload")) { + return; + } + Promise.allSettled(getNetworks().map(async (it) => { try { const specVersion = await getLatestRuntimeSpecVersion(it.name); diff --git a/src/screens/home.tsx b/src/screens/home.tsx index 4f0c34db..79cae749 100644 --- a/src/screens/home.tsx +++ b/src/screens/home.tsx @@ -213,7 +213,7 @@ export const HomePage = () => { persist /> -
+
{networkGroups.map((group) =>
diff --git a/test/e2e/home.spec.ts b/test/e2e/home.spec.ts index 3d6c2e24..5130f5b1 100644 --- a/test/e2e/home.spec.ts +++ b/test/e2e/home.spec.ts @@ -5,6 +5,12 @@ test.describe("home page", () => { test("shows home page", async ({ page, takeScreenshot }) => { await navigate(page, "/", {waitUntil: "load"}); + const $searchInput = page.getByTestId("search-input"); + const $networks = page.getByTestId("networks"); + + await expect($searchInput).toBeVisible(); + await expect($networks).toBeVisible(); + await takeScreenshot("home"); }); }); diff --git a/test/utils/navigate.ts b/test/utils/navigate.ts index f3719cc6..950503c2 100644 --- a/test/utils/navigate.ts +++ b/test/utils/navigate.ts @@ -13,6 +13,10 @@ const customEvents = ["data-loaded", "chart-finished"]; export async function navigate(page: Page, url: string, options: GotoOptions = {}) { let customEvent: string|undefined = undefined; + await page.goto(url, {waitUntil: "commit"}); + await page.evaluate(() => localStorage.setItem("skip-runtime-metadata-preload", "true")); + await page.evaluate(() => localStorage.setItem("runtime-metadata-preloaded", "true")); + if (options.waitUntil && customEvents.includes(options.waitUntil)) { customEvent = options.waitUntil; options.waitUntil = "domcontentloaded";