fix(e2e): judge only body-carrying script responses in the ABS SSO spec #132

Merged
dank merged 1 commits from fix/e2e-mime-304 into main 2026-11-03 01:42:28 -08:00
Showing only changes of commit ee9eb353fb - Show all commits
@@ -26,11 +26,11 @@ test("SSO round trip boots the SPA and grants a real Audiobookshelf session", as
}) => { }) => {
test.setTimeout(180_000); test.setTimeout(180_000);
const scripts: { url: string; type: string }[] = []; const scripts: { url: string; type: string; status: number }[] = [];
page.on("response", (res) => { page.on("response", (res) => {
const u = new URL(res.url()); const u = new URL(res.url());
if (u.host === HOST && u.pathname.endsWith(".js")) { if (u.host === HOST && u.pathname.endsWith(".js")) {
scripts.push({ url: u.pathname, type: res.headers()["content-type"] ?? "" }); scripts.push({ url: u.pathname, type: res.headers()["content-type"] ?? "", status: res.status() });
} }
}); });
@@ -59,8 +59,11 @@ test("SSO round trip boots the SPA and grants a real Audiobookshelf session", as
// Defect 1 gate: nothing the app loaded may be HTML dressed as a script. The render proof // Defect 1 gate: nothing the app loaded may be HTML dressed as a script. The render proof
// is the SSO button above — it only exists once the bundle has executed, so no DOM-shape // is the SSO button above — it only exists once the bundle has executed, so no DOM-shape
// guess is needed (the shell's own mount markup says nothing about whether it booted). // guess is needed (the shell's own mount markup says nothing about whether it booted).
expect(scripts.length, "the SPA loaded no JavaScript").toBeGreaterThan(2); // Only responses that carried a body can be judged: the OIDC bounce re-validates the entry
for (const s of scripts) { // script (Cache-Control: max-age=0 + ETag) and a 304 carries no Content-Type by spec.
const bodies = scripts.filter((s) => s.status === 200);
expect(bodies.length, "the SPA loaded no JavaScript").toBeGreaterThan(2);
for (const s of bodies) {
expect(s.type, `${s.url} arrived as ${s.type}`).toContain("javascript"); expect(s.type, `${s.url} arrived as ${s.type}`).toContain("javascript");
} }