fix(web-app-keycloak): read the account page body before the console redirects

The CSP spec opens /realms/<realm>/account/, the account console SPA, which
redirects to the login flow from JavaScript. The spec read response.text()
only after the header and meta CSP checks, and once the redirect had
committed Playwright 1.64 no longer holds the body. MediaWiki#0 (swarm) of
main run 37903645290 failed all three attempts at playwright.spec.js:116
with "Response body is not available for a response that was navigated
away from", while the same spec passed locally in under a second.

The body is now read right after the status check, as Playwright's own
message asks. The assertion on the canonical domain is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-10-09 17:46:12 +02:00
1 parent eda3bdbc35
commit d43b86b022
1 file changed
+1 -1
@@ -109,11 +109,11 @@ test("keycloak enforces Content-Security-Policy and exposes canonical domain fro
const response = await gotoOnion(page, `${appBaseUrl}/realms/${realmName}/account/`);
expect(response, "Expected Keycloak account page response").toBeTruthy();
expect(response.status(), "Expected Keycloak account page to respond successfully").toBeLessThan(400);
const documentHtml = await response.text();
const directives = assertCspResponseHeader(response, "keycloak account page");
await assertCspMetaParity(page, directives, "keycloak account page");
const documentHtml = await response.text();
expect(
documentHtml.includes(canonicalDomain) || (await page.content()).includes(canonicalDomain),
`Expected canonical domain "${canonicalDomain}" (from applications lookup) to appear in the Keycloak UI`