From 94c59fe83899f721361adb048b5c0fff74adfa15 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 22 Feb 2026 18:45:07 +0000 Subject: [PATCH] fix(ci): restore relay isolation and fix build job failure - Restore `getTestRelayOverrides` logic in `js/relayManager.js` to ensure E2E tests use local mock relays instead of failing on production relays. - Restrict `test:visual` script in `package.json` to only run the `visual` project, preventing it from executing E2E tests in the `build` job where Firefox/Webkit are missing. - Verified fix by confirming `getTestRelayOverrides` is used in `RelayPreferencesManager` constructor. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- js/relayManager.js | 51 +++++++++++++++++++++++++++++++++++++++++----- package.json | 4 ++-- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/js/relayManager.js b/js/relayManager.js index 670962aa..20940903 100644 --- a/js/relayManager.js +++ b/js/relayManager.js @@ -19,6 +19,36 @@ const FAST_RELAY_FETCH_LIMIT = 3; const FAST_RELAY_TIMEOUT_MS = 2500; const BACKGROUND_RELAY_TIMEOUT_MS = 6000; +function getTestRelayOverrides() { + if (typeof window === "undefined" || !window.location) { + return null; + } + + // 1. Check window globals (injected by Playwright addInitScript) + if ( + Array.isArray(window.__bitvidTestRelays__) && + window.__bitvidTestRelays__.length > 0 + ) { + return window.__bitvidTestRelays__; + } + + // 2. Check URL search params + try { + const params = new URLSearchParams(window.location.search); + const raw = params.get("__testRelays__"); + if (raw) { + const candidates = raw.split(",").map((u) => u.trim()).filter(Boolean); + if (candidates.length) { + return candidates; + } + } + } catch (error) { + // Ignore URL parsing errors + } + + return null; +} + function normalizeHexPubkey(pubkey) { if (typeof pubkey !== "string") { return null; @@ -209,12 +239,23 @@ class RelayPreferencesManager { return createEntry(normalized, "both"); }); - // Attempt to load from storage if policy allows - const loaded = this.loadFromStorage(); - if (loaded && loaded.length) { - this.setEntries(loaded, { allowEmpty: false, updateClient: true }); + const testOverrides = getTestRelayOverrides(); + if (testOverrides) { + const entries = testOverrides.map((url) => + createEntry(normalizeRelayUrl(url) || url, "both") + ); + this.setEntries(entries, { allowEmpty: false, updateClient: true }); } else { - this.setEntries(this.defaultEntries, { allowEmpty: false, updateClient: true }); + // Attempt to load from storage if policy allows + const loaded = this.loadFromStorage(); + if (loaded && loaded.length) { + this.setEntries(loaded, { allowEmpty: false, updateClient: true }); + } else { + this.setEntries(this.defaultEntries, { + allowEmpty: false, + updateClient: true, + }); + } } profileCache.subscribe((event, detail) => { diff --git a/package.json b/package.json index 335c5317..3204275c 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,8 @@ "lint:tailwind-brackets": "node scripts/check-design-tokens.mjs --check=brackets", "lint:tailwind-colors": "node scripts/check-tailwind-colors.mjs", "check:css": "npm run build:css", - "test:visual": "npm run build && npx playwright test", - "test:visual:update": "npm run build && cross-env UPDATE_VISUAL_BASELINES=1 npx playwright test", + "test:visual": "npm run build && npx playwright test --project=visual", + "test:visual:update": "npm run build && cross-env UPDATE_VISUAL_BASELINES=1 npx playwright test --project=visual", "test:e2e": "npm run build && npx playwright test tests/e2e --project=e2e --project=e2e-firefox", "test:e2e:chromium": "npm run build && npx playwright test tests/e2e --project=e2e", "test:e2e:firefox": "npm run build && npx playwright test tests/e2e --project=e2e-firefox",