Files
clean-architecture-frontend…/tests/features/reference-feature/reference-traffic-policy.test.ts
T

27 lines
1.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { composeContractContributions } from "../../../src/contracts/external-contract-runtime.ts";
import { REFERENCE_FEATURE_TEMPLATE_CONTRIBUTION } from "../../../src/features/reference-feature/contracts/reference-feature-contract-contribution.ts";
describe("reference operation traffic policy", () => {
it("declares explicit bounded traffic on every representative reference operation", () => {
const composed = composeContractContributions([
REFERENCE_FEATURE_TEMPLATE_CONTRIBUTION,
]);
for (const operationId of [
"LIST_REFERENCE_RESOURCES",
"GET_REFERENCE_RESOURCE",
"CREATE_REFERENCE_RESOURCE",
]) {
const traffic = composed.httpByOperationId.get(operationId)?.frontend.traffic;
expect(traffic, operationId).toBeDefined();
expect(Number.isSafeInteger(traffic?.maxPhysicalRequests)).toBe(true);
}
// A KEYED command never retries automatically; its policy says so too.
expect(
composed.httpByOperationId.get("CREATE_REFERENCE_RESOURCE")?.frontend
.traffic,
).toMatchObject({ maxPhysicalRequests: 1, maxRetries: 0 });
});
});