From 952dc58adea5bc3bbe3845980f3a19a2df462de3 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 30 Jan 2026 02:28:50 +0000 Subject: [PATCH] chore(ai): CI health fixes (flaky tests) - Fix `tests/app-batch-fetch-profiles.test.mjs` by mocking `readRelays` to ensure deterministic query counts. - Set `NODE_ENV=test` in `scripts/run-unit-tests.mjs` to prevent `nostr-tools` bootstrap failures in test environment. - Run `npm ci` and `npm audit fix` to maintain lockfile health. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- scripts/run-unit-tests.mjs | 3 +++ tests/app-batch-fetch-profiles.test.mjs | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/scripts/run-unit-tests.mjs b/scripts/run-unit-tests.mjs index 0a340dd7..6f3caf4c 100755 --- a/scripts/run-unit-tests.mjs +++ b/scripts/run-unit-tests.mjs @@ -4,6 +4,9 @@ import fs from "node:fs"; import { fileURLToPath } from "node:url"; import path from "node:path"; +// Ensure NODE_ENV is set to "test" so that nostrToolsBootstrap.js uses the mock toolkit +process.env.NODE_ENV = "test"; + const rootDir = path.dirname(fileURLToPath(new URL("../package.json", import.meta.url))); const testsDir = path.join(rootDir, "tests"); const testFiles = []; diff --git a/tests/app-batch-fetch-profiles.test.mjs b/tests/app-batch-fetch-profiles.test.mjs index df90a4bc..f682cab3 100644 --- a/tests/app-batch-fetch-profiles.test.mjs +++ b/tests/app-batch-fetch-profiles.test.mjs @@ -52,12 +52,16 @@ test("batchFetchProfiles handles fast and failing relays", async () => { const originalWriteRelays = Array.isArray(nostrClient.writeRelays) ? [...nostrClient.writeRelays] : nostrClient.writeRelays; + const originalReadRelays = Array.isArray(nostrClient.readRelays) + ? [...nostrClient.readRelays] + : nostrClient.readRelays; const originalPool = nostrClient.pool; const poolListCalls = []; nostrClient.relays = [FAST_RELAY, FAIL_RELAY]; nostrClient.writeRelays = [FAST_RELAY, FAIL_RELAY]; + nostrClient.readRelays = [FAST_RELAY, FAIL_RELAY]; nostrClient.pool = { list: (relays, filters) => { poolListCalls.push({ relays, filters }); @@ -93,6 +97,7 @@ test("batchFetchProfiles handles fast and failing relays", async () => { } finally { nostrClient.relays = originalRelays; nostrClient.writeRelays = originalWriteRelays; + nostrClient.readRelays = originalReadRelays; nostrClient.pool = originalPool; }