fix: resolve flaky tests and update project data
Node.js CI / CI (pull_request) Failing after 19s
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 54s

This commit is contained in:
2026-04-28 13:04:11 -07:00
committed by Naomi Carrigan
parent fcf4e09750
commit 5cfd681623
3 changed files with 178 additions and 121 deletions
+34 -16
View File
@@ -14,24 +14,37 @@ 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 checkUrl = async(url: string): Promise<boolean> => {
const MAX_RETRIES = 3;
const RETRY_DELAY_MS = 2000;
const RATE_LIMIT_DELAY_MS = 5000;
const sleep = (milliseconds: number): Promise<void> =>
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.status === 429) {
// Try again after few seconds
console.log(`Rate limited on ${url}, trying again...`);
await new Promise((resolve) => {
// eslint-disable-next-line no-promise-executor-return --- HUH???
return setTimeout(resolve, 5000);
});
return checkUrl(url);
if (response.ok) {
return true;
}
return response.ok;
if (retries >= MAX_RETRIES) {
return false;
}
const delay = response.status === 429 ? RATE_LIMIT_DELAY_MS : RETRY_DELAY_MS;
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 < MAX_RETRIES) {
await sleep(RETRY_DELAY_MS);
return checkUrl(url, retries + 1);
}
return false;
}
};
@@ -444,12 +457,17 @@ describe("donate data", () => {
}`,
).toBe("string");
await expect(
checkUrl(method.url),
`Donation method url should be reachable for ${
method.name ?? "unknown method"
}`,
).resolves.toBeTruthy();
// We explicitly skip Ko-Fi, Throne, and Twitch 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")) {
await expect(
checkUrl(method.url),
`Donation method url should be reachable for ${
method.name ?? "unknown method"
}`,
).resolves.toBeTruthy();
}
}
});
});