From 4004e4ca9cb47496e85f5f79ed71b8d74707a3a8 Mon Sep 17 00:00:00 2001 From: Hikari Date: Tue, 28 Apr 2026 15:33:07 -0700 Subject: [PATCH] chore: remove live url checks from tests Too many sites block automated HEAD requests, making the tests inherently flaky. Keeping structure/type validation only. --- test/yaml.spec.ts | 84 +---------------------------------------------- 1 file changed, 1 insertion(+), 83 deletions(-) diff --git a/test/yaml.spec.ts b/test/yaml.spec.ts index 91441e3..a88eadf 100644 --- a/test/yaml.spec.ts +++ b/test/yaml.spec.ts @@ -14,44 +14,6 @@ import type { Projects } from "../src/interfaces/projects.js"; import type { Resume } from "../src/interfaces/resume.js"; import type { Testimonials } from "../src/interfaces/testimonials.js"; -const maxRetries = 3; -const retryDelayMs = 2000; -const rateLimitDelayMs = 5000; - -const sleep = (milliseconds: number): Promise => { - return new Promise((resolve) => { - setTimeout(resolve, milliseconds); - }); -}; - -const checkUrl = async(url: string, retries = 0): Promise => { - try { - const response = await fetch(url, { - headers: { origin: url }, - method: "HEAD", - }); - if (response.ok) { - return true; - } - if (retries >= maxRetries) { - return false; - } - const delay = response.status === 429 - ? rateLimitDelayMs - : retryDelayMs; - console.log(`URL check failed for ${url} (${String(response.status)}), retrying in ${String(delay)}ms...`); - await sleep(delay); - return checkUrl(url, retries + 1); - } catch (error) { - console.error(`Error checking URL ${url}:`, error); - if (retries < maxRetries) { - await sleep(retryDelayMs); - return checkUrl(url, retries + 1); - } - return false; - } -}; - describe("project data", () => { it("should match the interface", async() => { expect.hasAssertions(); @@ -106,30 +68,15 @@ describe("project data", () => { project.name ?? "unknown" }`, ).toBe("string"); - await expect( - checkUrl(project.avatar), - `Project avatar should be reachable for project: ${ - project.name ?? "unknown" - }`, - ).resolves.toBeTruthy(); } - // We explicitly skip the VSCode and npm urls because they block automated requests. - if (project.url - && !project.url.startsWith("https://marketplace.visualstudio.com") - && !project.url.startsWith("https://www.npmjs.com")) { + if (project.url) { expect( typeof project.url, `Project url should be a string for project: ${ project.name ?? "unknown" }`, ).toBe("string"); - await expect( - checkUrl(project.url), - `Project url should be reachable for project: ${ - project.name ?? "unknown" - }`, - ).resolves.toBeTruthy(); } } }); @@ -460,19 +407,6 @@ describe("donate data", () => { method.name ?? "unknown method" }`, ).toBe("string"); - - // We explicitly skip Ko-Fi, Throne, Twitch, and Patreon because they block all automated requests. - if (!method.url.startsWith("https://ko-fi.com") - && !method.url.startsWith("https://throne.com") - && !method.url.startsWith("https://twitch.tv") - && !method.url.startsWith("https://patreon.com")) { - await expect( - checkUrl(method.url), - `Donation method url should be reachable for ${ - method.name ?? "unknown method" - }`, - ).resolves.toBeTruthy(); - } } }); }); @@ -524,10 +458,6 @@ describe("funding data", () => { typeof parsed.entity.webpageUrl.url, `Funding entity webpageUrl.url should be a string`, ).toBe("string"); - await expect( - checkUrl(parsed.entity.webpageUrl.url), - `Funding entity webpageUrl.url should be reachable`, - ).resolves.toBeTruthy(); if (parsed.entity.webpageUrl.wellKnown) { expect( @@ -574,12 +504,6 @@ describe("funding data", () => { project.name ?? "unknown" }`, ).toBe("string"); - await expect( - checkUrl(project.webpageUrl.url), - `Funding project webpageUrl.url should be reachable for project: ${ - project.name ?? "unknown" - }`, - ).resolves.toBeTruthy(); if (project.webpageUrl.wellKnown) { expect( typeof project.webpageUrl.wellKnown, @@ -600,12 +524,6 @@ describe("funding data", () => { project.name ?? "unknown" }`, ).toBe("string"); - await expect( - checkUrl(project.repositoryUrl.url), - `Funding project repositoryUrl.url should be reachable for project: ${ - project.name ?? "unknown" - }`, - ).resolves.toBeTruthy(); if (project.repositoryUrl.wellKnown) { expect( typeof project.repositoryUrl.wellKnown,