diff --git a/agdb_web/e2e/allLinks.spec.ts b/agdb_web/e2e/allLinks.spec.ts index d5351c67..f7b08f35 100644 --- a/agdb_web/e2e/allLinks.spec.ts +++ b/agdb_web/e2e/allLinks.spec.ts @@ -1,6 +1,7 @@ import { test, expect, Page } from "@playwright/test"; const validatedLinks: string[] = []; +const externalLinks: Map, string> = new Map(); const validateLinks = async (page: Page) => { const links = await page @@ -18,26 +19,25 @@ const validateLinks = async (page: Page) => { !href.startsWith("javascript") && !href.startsWith("#") ) { - const error = `${sourcePageTitle} -> ${href}`; - await page.goto(href); - - const pageTitle = await page.title(); - expect(pageTitle.length, error).toBeGreaterThan(0); - expect(pageTitle, error).not.toContain("404"); - validatedLinks.push(href); if (!href.startsWith("http")) { + await page.goto(href); await validateLinks(page); + } else { + externalLinks.set(fetch(href), `${sourcePageTitle} -> ${href}`); } } } + + for (const [f, error] of externalLinks) { + const r = await f; + expect(r.status, error).not.toBe(404); + } }; test("should validate all links", async ({ page }) => { test.setTimeout(300000); - await page.goto("http://localhost:5001/"); - await validateLinks(page); });