mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
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 <[email protected]>
This commit is contained in:
1 parent
8257a94925
commit
94c59fe838
2 files changed
+48
-7
No files matched your search
+46
-5
@@ -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) => {
|
||||
|
||||
+2
-2
@@ -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",
|
||||
|
||||
Reference in new issue
Block a user