e2e: integration harness (69/69 green) + fix /agent/ws missing bearer auth (BUG-1)
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
// scenarios/web-dist.mjs — the daemon serves the REAL built web UI from
|
||||
// --webdist: index, hashed assets, manifest, SPA fallback.
|
||||
|
||||
import * as fs from "node:fs";
|
||||
import * as path from "node:path";
|
||||
import { WEB_DIST } from "../lib.mjs";
|
||||
|
||||
export async function run(ctx) {
|
||||
const { r, base } = ctx;
|
||||
|
||||
const index = await fetch(`${base}/`);
|
||||
const indexText = await index.text();
|
||||
r.check("GET / → 200 index.html", index.status === 200 && indexText.includes("<!doctype html>"), `got ${index.status}`);
|
||||
r.check(
|
||||
"index references built assets",
|
||||
/src="\/assets\/[^"]+\.js"/.test(indexText) && indexText.includes('id="root"'),
|
||||
indexText.slice(0, 120),
|
||||
);
|
||||
|
||||
const asset = fs.readdirSync(path.join(WEB_DIST, "assets")).find((f) => f.endsWith(".js"));
|
||||
r.check("dist contains a hashed JS asset", Boolean(asset));
|
||||
const assetRes = await fetch(`${base}/assets/${asset}`);
|
||||
const assetText = await assetRes.text();
|
||||
r.check(
|
||||
"GET /assets/<bundle>.js → 200 javascript",
|
||||
assetRes.status === 200 && (assetRes.headers.get("content-type") ?? "").includes("javascript") && assetText.length > 1000,
|
||||
`got ${assetRes.status} ${(assetRes.headers.get("content-type") ?? "")}`,
|
||||
);
|
||||
|
||||
const manifest = await fetch(`${base}/manifest.webmanifest`);
|
||||
const manifestJson = await manifest.json().catch(() => null);
|
||||
r.check(
|
||||
"GET /manifest.webmanifest → 200 with name field",
|
||||
manifest.status === 200 && manifestJson?.name === "lvmh",
|
||||
`got ${manifest.status}`,
|
||||
);
|
||||
|
||||
const spa = await fetch(`${base}/sessions/anything/deep`);
|
||||
const spaText = await spa.text();
|
||||
r.check(
|
||||
"SPA fallback serves index.html for unknown routes",
|
||||
spa.status === 200 && spaText.includes("<!doctype html>"),
|
||||
`got ${spa.status}`,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user