Files
computer-playbook/roles/test-e2e-playwright/files/timeouts.js
kevinveenbirkenbachandClaude Opus 5 d7e3aae20d test(e2e): skip OIDC specs when app and issuer live in different realms
BigBlueButton is never served over Tor (WebRTC needs UDP/ICE), but in an
onion deployment its issuer only exists as an onion address. The test
browser reaches clearnet or the onion net, never both, since the private
tor network has no exit — so the login round-trip timed out. A real Tor
Browser handles this fine, which is why the gate belongs in the spec and
not in the role.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-27 23:51:17 +02:00

49 lines
1.4 KiB
JavaScript

/**
* Shared timeout helper for every Playwright spec (staged next to the spec as
* `./timeouts`; persona flows reach it via `../timeouts`). Scales a base
* timeout by the global `TIMEOUT_FACTOR` and, when the target is a `.onion`
* (Tor) service, by an extra multiplier — Tor circuits add per-request latency.
*/
function _canonicalDomain() {
const raw = process.env.CANONICAL_DOMAIN || "";
const unquoted =
raw.length >= 2 && raw.startsWith('"') && raw.endsWith('"') ? raw.slice(1, -1) : raw;
return unquoted.trim();
}
function isOnionTarget() {
return /\.onion$/i.test(_canonicalDomain());
}
function isSplitRealmOidc() {
return !isOnionTarget() && /\.onion(?::\d+)?(?:\/|$)/i.test(process.env.OIDC_ISSUER_URL || "");
}
function timeoutFactor() {
const f = Number(process.env.PLAYWRIGHT_TIMEOUT_FACTOR);
return Number.isFinite(f) && f > 0 ? f : 1;
}
function onionTimeoutMultiplier() {
const m = Number(process.env.PLAYWRIGHT_ONION_TIMEOUT_MULTIPLIER);
return Number.isFinite(m) && m > 0 ? m : 5;
}
/**
* Effective timeout (ms) for the current run: `base * TIMEOUT_FACTOR`, times the
* onion multiplier when the target is a `.onion` service.
*/
function resolveTimeout(baseMs) {
const onionMult = isOnionTarget() ? onionTimeoutMultiplier() : 1;
return Math.round(baseMs * timeoutFactor() * onionMult);
}
module.exports = {
isOnionTarget,
isSplitRealmOidc,
timeoutFactor,
onionTimeoutMultiplier,
resolveTimeout,
};