Files
fusion/packages/dashboard/src/server-static-assets.test.ts
Fusion b6ec14e8b9 fix(FN-2321): standardize loopback-gated integration test labeling
- Refine the dashboard loopback integration helper with documented helper contracts and centralized skipped-name formatting
- Keep loopback bind detection memoized so all gated integration suites share one environment probe
- Update loopback-gated dashboard suites to use consistent, explicit scope labels in skip output
- Refresh skipped-test inventory docs with the new audit commands and loopback helper usage details
2026-04-23 10:50:44 -07:00

35 lines
1.2 KiB
TypeScript

import express from "express";
import { describe, expect, it } from "vitest";
import { createLoopbackIntegrationTest } from "./__tests__/loopback-integration-test.js";
const staticAssetIntegrationTest = await createLoopbackIntegrationTest("server-static-assets integration");
describe("static asset serving", () => {
staticAssetIntegrationTest("returns 404 for missing asset paths instead of falling back to index.html", async () => {
const app = express();
app.use(express.static("packages/dashboard/dist/client", { index: false }));
app.get(/^(?!\/assets\/).*/, (_req, res) => {
res.sendFile("index.html", { root: "packages/dashboard/dist/client" });
});
const server = await new Promise<import("node:http").Server>((resolve) => {
const s = app.listen(0, "127.0.0.1", () => resolve(s));
});
try {
const address = server.address();
if (!address || typeof address === "string") throw new Error("Failed to get test server port");
const res = await fetch(`http://127.0.0.1:${address.port}/assets/does-not-exist.js`);
expect(res.status).toBe(404);
} finally {
await new Promise<void>((resolve, reject) => {
server.close((err) => (err ? reject(err) : resolve()));
});
}
});
});