Files
tech-log-frontend/tests/e2e/tech-log-http-contract.spec.ts
DongHyeonka cfe587c13e test(e2e): HTTP 계약 시험이 경로 패턴으로 서빙하는 지금 서버를 따른다
6784eb1(08-20)부터 운영 서버는 빌드가 본 slug 목록이 아니라 등록된
Public 경로 패턴으로 SPA를 낸다. 빌드 뒤에 게시한 기록도 열려야 하기
때문이다. 그래서 /projects/missing-project는 이제 200으로 SPA를 받고,
화면 안에서 not-found를 보인다. 시험은 아직 그 경로가 edge 404라고
기대해 세 엔진 모두 떨어진다.

모르는 slug는 200 SPA를 기대한다. edge 404 사례는 경로 매개변수가 한
segment만 맞는다는 것을 보이는 /projects/missing-project/unknown-tab으로
바꾼다. 경로가 없는 /definitely-not-a-product-route는 그대로 둔다.

검증: tech-log-http-contract.spec.ts가 세 엔진 모두 통과한다.
2026-11-12 15:03:16 +09:00

85 lines
2.9 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);
});
}
// 6784eb1 (08-20). The server matches each registered Public route as a
// pattern, not the slugs the build saw, so a record published after the build
// is reachable. A slug nobody published is the SPA's in-shell not-found, not an
// edge 404.
test("production HTTP serves the SPA for a slug the build has not seen", async ({
request,
}) => {
const response = await request.get("/projects/missing-project");
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);
});
// A route parameter matches one segment, so a second segment is still an edge
// 404, as is a path no route declares.
for (const path of [
"/projects/missing-project/unknown-tab",
"/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,
);
});
}