chore: remove live url checks from tests
Node.js CI / CI (pull_request) Successful in 27s
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 59s

Too many sites block automated HEAD requests, making the tests
inherently flaky. Keeping structure/type validation only.
This commit is contained in:
2026-04-28 15:33:07 -07:00
parent 719de29d77
commit 4004e4ca9c
+1 -83
View File
@@ -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<void> => {
return new Promise((resolve) => {
setTimeout(resolve, milliseconds);
});
};
const checkUrl = async(url: string, retries = 0): Promise<boolean> => {
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,