69 lines
2.2 KiB
TypeScript
69 lines
2.2 KiB
TypeScript
import { expect, test } from "../support/browser/strict-browser-test.ts";
|
|
|
|
import {
|
|
TECH_LOG_CANONICAL_ROUTES,
|
|
TECH_LOG_PUBLIC_FIXTURE_PATHS,
|
|
} from "../support/browser/tech-log-fixtures.ts";
|
|
|
|
const knownSpaPaths = [
|
|
...new Set([
|
|
...TECH_LOG_CANONICAL_ROUTES
|
|
.filter(({ routeId }) => !["NOT_FOUND", "TECH_LOG_STUDIO_NOT_FOUND"].includes(routeId))
|
|
.map(({ path }) => path),
|
|
...TECH_LOG_PUBLIC_FIXTURE_PATHS,
|
|
]),
|
|
];
|
|
|
|
test("production HTTP preserves the source in-shell Studio 404", async ({
|
|
request,
|
|
}) => {
|
|
const response = await request.get("/studio/unknown-screen");
|
|
|
|
expect(response.status()).toBe(404);
|
|
expect(response.headers()["content-type"]).toBe("text/html;charset=UTF-8");
|
|
expect((await response.text()).startsWith("<!doctype html>")).toBe(true);
|
|
});
|
|
|
|
for (const path of knownSpaPaths) {
|
|
test(`production HTTP serves the SPA for ${path}`, async ({ request }) => {
|
|
const response = await request.get(path);
|
|
|
|
expect(response.status()).toBe(200);
|
|
expect(response.headers()["content-type"]).toBe("text/html;charset=UTF-8");
|
|
expect((await response.text()).startsWith("<!doctype html>")).toBe(true);
|
|
});
|
|
}
|
|
|
|
for (const path of [
|
|
"/projects/missing-project",
|
|
"/definitely-not-a-product-route",
|
|
]) {
|
|
test(`production HTTP returns the source-exact raw 404 for ${path}`, async ({
|
|
request,
|
|
}) => {
|
|
const response = await request.get(path);
|
|
|
|
expect(response.status()).toBe(404);
|
|
expect(response.headers()["content-type"]).toBe(
|
|
"text/plain;charset=UTF-8",
|
|
);
|
|
expect(await response.body()).toEqual(Buffer.from("Not Found", "utf8"));
|
|
});
|
|
}
|
|
|
|
for (const path of ["/config.json", "/release-manifest.json"]) {
|
|
test(`production HTTP frames boot document ${path} like the reviewed preview`, async ({
|
|
request,
|
|
}) => {
|
|
const response = await request.get(path);
|
|
|
|
expect(response.status()).toBe(200);
|
|
expect(response.headers()["content-type"]).toBe("application/json");
|
|
expect(response.headers()["cache-control"]).toBe("no-cache");
|
|
expect(response.headers().vary).toBe("Origin");
|
|
expect(Number(response.headers()["content-length"])).toBe(
|
|
(await response.body()).byteLength,
|
|
);
|
|
});
|
|
}
|