refactor(data): establish API contract guardrails
CI / Quality and Bundle Budgets (push) Has been cancelled

This commit is contained in:
2026-07-16 20:09:30 +08:00
parent cc06ed034d
commit 19d36ed5bf
24 changed files with 498 additions and 230 deletions
@@ -0,0 +1,24 @@
import { describe, expect, it } from "vitest";
import apiContract from "../api_contract.json";
import { ApiPath } from "../api_path";
describe("ApiPath contract source", () => {
it("uses the shared contract path for every static operation", () => {
const staticOperations = Object.entries(apiContract).filter(
([operationId]) => operationId !== "privateRoomAlbumUnlock",
);
for (const [operationId, operation] of staticOperations) {
expect(ApiPath[operationId as keyof typeof ApiPath]).toBe(
operation.path,
);
}
});
it("fills and encodes the private album path parameter", () => {
expect(ApiPath.privateRoomAlbumUnlock("album/id 1")).toBe(
"/api/private-room/albums/album%2Fid%201/unlock",
);
});
});