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 }}