fix: flaky unit test in profile batch fetcher

Updated `tests/app-batch-fetch-profiles.test.mjs` to correctly mock `readRelays` in addition to `relays` and `writeRelays`. `profileMetadataService.js` prioritizes `readRelays`, causing the test to make unexpected network calls when falling back to default values. This fix ensures the test isolation holds and assertions pass consistently.

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-01-30 07:37:47 +00:00
1 parent 7ac4d4eee7
commit 7a3476f926
1 file changed
+5
+5
View File
@@ -49,6 +49,9 @@ test("batchFetchProfiles handles fast and failing relays", async () => {
const originalRelays = Array.isArray(nostrClient.relays)
? [...nostrClient.relays]
: [];
const originalReadRelays = Array.isArray(nostrClient.readRelays)
? [...nostrClient.readRelays]
: nostrClient.readRelays;
const originalWriteRelays = Array.isArray(nostrClient.writeRelays)
? [...nostrClient.writeRelays]
: nostrClient.writeRelays;
@@ -57,6 +60,7 @@ test("batchFetchProfiles handles fast and failing relays", async () => {
const poolListCalls = [];
nostrClient.relays = [FAST_RELAY, FAIL_RELAY];
nostrClient.readRelays = [FAST_RELAY, FAIL_RELAY];
nostrClient.writeRelays = [FAST_RELAY, FAIL_RELAY];
nostrClient.pool = {
list: (relays, filters) => {
@@ -92,6 +96,7 @@ test("batchFetchProfiles handles fast and failing relays", async () => {
});
} finally {
nostrClient.relays = originalRelays;
nostrClient.readRelays = originalReadRelays;
nostrClient.writeRelays = originalWriteRelays;
nostrClient.pool = originalPool;
}