From 2ed1b03e1e869a67eacba485804ead8e1cc4eddd Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sun, 25 Oct 2026 07:46:28 +0100 Subject: [PATCH] fix(web-app-dashboard): skip the Tab hand-off where the iframe ends on the IdP An anonymous dashboard embeds an oauth2-proxy-gated target as the Keycloak login. The iframe notifier then points ?iframe= at the IdP, whose origin is no a.iframe-link tile, so openIframeInNewTab() refuses it and alerts instead of opening a tab: the spec waited 30s for a popup that never came. The tile href and iframe src are still checked; only the hand-off is skipped for is_proxy_gated targets. Where the embedded page moved to another tile's origin (Synapse to Element), the popup opens on the ?iframe= host, so that host is now the expected one, with the landing domain as fallback. Co-Authored-By: Claude Opus 5.5 --- .../playwright/test-tile-reachability.js | 23 +++++++++++++++++-- .../templates/playwright.env.j2 | 2 +- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/roles/web-app-dashboard/files/playwright/test-tile-reachability.js b/roles/web-app-dashboard/files/playwright/test-tile-reachability.js index ab4a734751..f7cfe77549 100644 --- a/roles/web-app-dashboard/files/playwright/test-tile-reachability.js +++ b/roles/web-app-dashboard/files/playwright/test-tile-reachability.js @@ -60,6 +60,20 @@ function landingDomain(target) { return target.handover_domain || target.canonical_domain; } +/** + * Args: + * dashboardUrl: the dashboard's own URL while a tile is embedded. + * Returns: the host of its `?iframe=` value; empty when the parameter is absent + * or not a URL. + */ +function embeddedHost(dashboardUrl) { + try { + return new URL(new URL(dashboardUrl).searchParams.get("iframe") || "").host; + } catch { + return ""; + } +} + async function findVisibleTile(page, canonicalDomain) { const tile = page.locator(tileSelector(canonicalDomain)).first(); const visible = await tile.isVisible().catch(() => false); @@ -204,6 +218,7 @@ async function assertTabButtonOpensNewTab(page, context, target) { `Expected the dashboard header "Tab" button to be visible for the ${target.id} tile` ).toBeVisible({ timeout: resolveTimeout(30_000) }); + const expectedHost = embeddedHost(page.url()) || landingDomain(target); const [popup] = await Promise.all([ context.waitForEvent("page", { timeout: resolveTimeout(30_000) }), tabButton.click(), @@ -211,8 +226,8 @@ async function assertTabButtonOpensNewTab(page, context, target) { await popup.waitForLoadState("domcontentloaded", { timeout: resolveTimeout(30_000) }).catch(() => {}); expect( - referencesHost(popup.url(), landingDomain(target)), - `Expected popup tab URL to address ${landingDomain(target)}, got ${popup.url()}` + referencesHost(popup.url(), expectedHost), + `Expected popup tab URL to address the embedded ${expectedHost}, got ${popup.url()}` ).toBe(true); await popup.close(); } @@ -228,6 +243,10 @@ exports.register = function (shared) { await gotoOnion(page, "/", { waitUntil: "domcontentloaded" }); await shared.waitForDashboardReady(page); await assertTileLoadsInIframe(page, target); + test.skip( + Boolean(target.is_proxy_gated), + `${target.id} is oauth2-proxy-gated: the anonymous dashboard embeds the IdP login page instead of ${target.id}, so a Tab hand-off from there says nothing about ${target.id}; its tile href and iframe src are checked above` + ); await assertTabButtonOpensNewTab(page, context, target); }); } else { diff --git a/roles/web-app-dashboard/templates/playwright.env.j2 b/roles/web-app-dashboard/templates/playwright.env.j2 index 7c62dfbff5..2e0b159c4a 100644 --- a/roles/web-app-dashboard/templates/playwright.env.j2 +++ b/roles/web-app-dashboard/templates/playwright.env.j2 @@ -24,7 +24,7 @@ DASHBOARD_JS_BASE_URL={{ DASHBOARD_JS_BASE_URL | dotenv_quote }} {% set dashboard_targets = [] %} {% for _t in lookup('roles_with_service', 'dashboard') %} -{% set _ = dashboard_targets.append(_t | combine({'handover_domain': lookup('domain', _t.id) if lookup('network_handover', _t.id, _t.canonical_domain) else ''})) %} +{% set _ = dashboard_targets.append(_t | combine({'handover_domain': lookup('domain', _t.id) if lookup('network_handover', _t.id, _t.canonical_domain) else '', 'is_proxy_gated': lookup('sso', _t.id, 'is_proxy_gated') | bool})) %} {% endfor %} DASHBOARD_TARGET_ROLES_JSON={{ dashboard_targets | to_json | dotenv_quote }}