Files
clean-architecture-frontend…/tests/integration/http-client.test.ts
T
DongHyeonka 326120867c fix(http): 거절의 적용 여부를 백엔드 기준 표 하나로 V2·V3가 판정한다
문제
계약 문서 6.1절(ed0e4b1, 백엔드 5786126c 코드 기준)은 400·409·422 code마다
쓰기 전 거절인지를 정했다. 쓰기 전이라 적용 안 됨인 것은 400
VALIDATION_FAILED(details 모양과 상관없음), 400 IDEMPOTENCY_KEY_INVALID,
422 IDEMPOTENT_REQUEST_MISMATCH뿐이고, 표에 없는 400·409·422는 쓰기 뒤에도
나올 수 있어 결과 불명이다. 지금 판정은 이 표와 세 곳이 다르다.
- V2: 필드 목록 없는 400 VALIDATION_FAILED({cause}, details 없음,
  {field, code})에 effect가 없다. 결과 불명으로 붙들려 다시 저장할 수 없다.
- V2: 422는 code와 상관없이 적용 안 됨이다. fileserver의 422
  INTEGRITY_MISMATCH·MALWARE_DETECTED는 레코드를 쓴 뒤 던진다.
- V3 Envelope operation(7db32e1): 위 V2 규칙을 같이 쓰고, 표 밖 400·409·422는
  classifyProblem에 맡긴다. 400·422를 모두 적용 안 됨으로 보는 분류기면
  BAD_PARAMETER·도메인 400이 틀린다.

고른 방법
- backend-envelope.ts에 표 REFUSED_BEFORE_WRITE(code → status, 진단
  reason)를 하나 두고 V2 client.ts, V3 실행기가 envelopeFailureEffect로
  같이 읽는다. 표에 있으면 NOT_APPLIED, 그 밖의 400·409·422와 503
  IDEMPOTENCY_UNAVAILABLE은 MAYBE_APPLIED, 나머지 status는 undefined
  (V2는 effect 없음, V3는 classifyProblem)다. 진단 reason도 같은 표에서
  읽는다.
- kind와 validationIssues 판정(isFieldValidationFailure)은 그대로 둔다.
  필드 목록 없는 400 VALIDATION_FAILED는 UNKNOWN_CLIENT_FAILURE, 422는
  VALIDATION_REJECTED다. 적용 여부만 바뀐다.
- V3 Envelope operation에서는 400·409·422를 표가 정하고 classifyProblem이
  바꾸지 못한다.

버린 대안
- V2와 V3에 표를 따로 두기: 7db32e1 전처럼 두 벌이 갈라진다.
- 표 밖 400·409·422를 classifyProblem에 맡기기: 6.1절이 표 밖은
  MAYBE_APPLIED로 정했고, 적용 안 됨을 잘못 내면 다음 저장이 새 키를 써
  같은 작업이 두 번 적용된다. 잘못된 MAYBE_APPLIED는 결과 불명 화면만 남긴다.
- 422 전부를 필드 검증(적용 안 됨)으로 남기기: 짝 백엔드는 필드 검증을
  400으로 보내고, fileserver 422는 쓴 뒤 던진다.
- V3 참조 기능 분류기 고치기: 참조 기능은 Envelope operation이 아니고
  fixture가 problem details라 이 표의 대상이 아니다. 고치지 않았다.

위험·한계
- 필드 검증을 422로 보내는 다른 백엔드를 V2로 쓰는 프로젝트는 422 뒤에
  폼에서 다시 저장할 수 없다(결과 불명). 프론트 계약 문서 4.2절의 "422
  field validation" 행과 어긋난다. 그 문서는 이 커밋에서 고치지 않았다.
- 표는 백엔드 5786126c 기준이다. 백엔드가 쓰기 전 거절 code를 새로 만들면
  6.1절과 이 표를 함께 고쳐야 한다. 두 repo를 비교하는 검사는 없다.
- 6.1절의 남은 위험: 백엔드가 use case 안에서 VALIDATION_FAILED를 내게 되면
  적용 안 됨 판정이 틀린다.

검증
- RED: 바뀐 행 8건 실패. tests/integration/http-client.test.ts 필드 목록
  없는 400 VALIDATION_FAILED 3모양의 effect, http-diagnostics.test.ts의
  "unrelated 422"(effect NOT_APPLIED), http-execution-v3-envelope.test.ts의
  고정 판정 2건(VALIDATION_FAILED 3모양 NOT_APPLIED, BAD_PARAMETER·도메인
  409·fileserver 422 MAYBE_APPLIED), form-foundation.test.tsx 2건({cause}
  실패 뒤 다시 저장, 422 뒤 저장 버튼 꺼짐).
- GREEN: 위 4개 파일 128건 통과. V2와 V3에 같은 응답 11가지를 보내 판정을
  비교하는 행이 모두 같다.
- check:types, lint, check:architecture, check:diagnostics, check:ci,
  check:registries, check:adapter-inventory 통과. test:unit 2,604,
  test:integration 209, test:component 245, tests/features·tests/contract
  124건 통과. check:bundle 203,354 / 204,800 B.

Refs: docs/architecture/backend-api-and-server-state-contract.md 6.1 (ed0e4b1),
docs/reviews/2026-11-01-maturity-review/README.md 14.4, 14.6
2026-11-03 20:26:28 +09:00

702 lines
22 KiB
TypeScript

import { HttpResponse, http } from "msw";
import { setupServer } from "msw/node";
import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest";
import { createHttpClient } from "../../src/adapters/http/client.ts";
import { mappingSuccess } from "../../src/contracts/boundary-mapper.ts";
import {
TEST_HTTP_CONTRACT,
TEST_OPERATIONS,
} from "../helpers/http-contract-fixture.ts";
let attempts = 0;
const server = setupServer(
http.get("https://api.test/api/entities", () => {
attempts += 1;
if (attempts < 3) {
return HttpResponse.json(
{ success: false, error: { code: "TEMPORARY" } },
{ status: 503 },
);
}
return HttpResponse.json({
success: true,
data: [{ id: "resource-1", name: "Example" }],
meta: { requestId: "request-1", traceId: "trace-1" },
});
}),
);
beforeAll(() => server.listen({ onUnhandledRequest: "error" }));
afterEach(() => {
attempts = 0;
server.resetHandlers();
});
afterAll(() => server.close());
const clock = {
now: () => 0,
sleep: async () => {},
};
type HttpDependencies = Parameters<typeof createHttpClient>[0];
function testClient(options: HttpDependencies) {
return createHttpClient({ ...TEST_HTTP_CONTRACT, ...options });
}
describe("shared HTTP client", () => {
it("retries a safe request at most twice and returns validated data", async () => {
const client = testClient({
baseUrl: "https://api.test",
clock,
random: () => 0,
});
await expect(
client.execute("LIST_ENTITIES", { routeId: "TEST_ROUTE" }),
).resolves.toMatchObject({
ok: true,
value: [{ id: "resource-1", displayName: "Example" }],
meta: { requestId: "request-1" },
});
expect(attempts).toBe(3);
});
it.each(["", " ", "bad\u0000key", "x".repeat(513)])(
"rejects invalid keyed command key %j before credentials and fetch",
async (idempotencyKey) => {
let fetched = 0;
let credentialAttempts = 0;
server.use(
http.post("https://api.test/api/entities", () => {
fetched += 1;
return HttpResponse.json({ success: true, data: {} });
}),
);
const client = testClient({
baseUrl: "https://api.test",
clock,
authSession: {
getState: () => "authenticated",
getSubject: () => "user-a",
subscribe: () => () => {},
beginSignIn: async () => {},
signOut: async () => {},
async credentialPatch() {
credentialAttempts += 1;
return { headers: {} };
},
recover: async () => "no-session" as const,
onUnauthenticated: () => {},
},
});
await expect(
client.execute("CREATE_ENTITY", {
body: { name: "n" },
idempotencyKey,
}),
).resolves.toMatchObject({
ok: false,
error: {
kind: "VALIDATION_REJECTED",
code: "IDEMPOTENCY_KEY_INVALID",
// The repository reports attempt counts as 1-based; the invariant
// proved below is that no physical attempt happened at all.
attemptCount: 1,
},
});
expect(fetched).toBe(0);
expect(credentialAttempts).toBe(0);
},
);
it("bounds a non-cooperative legacy credential owner by total deadline", async () => {
let fetched = 0;
let observedSignal: AbortSignal | undefined;
server.use(
http.get("https://api.test/api/entities", () => {
fetched += 1;
return HttpResponse.json({ success: true, data: [] });
}),
);
const client = testClient({
baseUrl: "https://api.test",
timeoutMs: 5,
clock: { now: () => 0, sleep: async () => {} },
authSession: {
getState: () => "authenticated",
getSubject: () => "user-a",
subscribe: () => () => {},
beginSignIn: async () => {},
signOut: async () => {},
credentialPatch: (_binding, context) => {
observedSignal = context?.signal;
// Never settles on its own.
return new Promise<never>(() => {});
},
recover: async () => "no-session" as const,
onUnauthenticated: () => {},
},
});
const result = await client.execute("LIST_ENTITIES");
expect(result).toMatchObject({ ok: false });
expect(fetched).toBe(0);
expect(observedSignal).toBeDefined();
});
it("rejects a non-JSON response without exposing its body", async () => {
server.use(
http.get(
"https://api.test/api/entities",
() => new HttpResponse("<secret>raw body</secret>", { status: 200 }),
),
);
const client = testClient({ baseUrl: "https://api.test", clock });
const result = await client.execute("LIST_ENTITIES");
expect(result).toMatchObject({
ok: false,
error: { kind: "CONTENT_TYPE_MISMATCH" },
});
expect(JSON.stringify(result)).not.toContain("raw body");
});
// Q-6.3-3b. A gateway 5xx/408/425 with an HTML, empty or broken body is a
// server outage, not a contract breach: it keeps its status and the V2
// SERVER_FAILURE retry rule (408/425/502/503/504, R3-1).
it.each([
{ status: 502, contentType: "text/html", body: "<secret>raw body</secret>", fetches: 3 },
{ status: 503, contentType: "application/json", body: "", fetches: 3 },
{ status: 504, contentType: "application/json", body: "{", fetches: 3 },
{ status: 408, contentType: "text/plain", body: "timeout", fetches: 3 },
{ status: 425, contentType: "text/html", body: "<p>too early</p>", fetches: 3 },
])(
"keeps a $status gateway body as a server failure with its status",
async ({ status, contentType, body, fetches }) => {
let fetched = 0;
server.use(
http.get("https://api.test/api/entities", () => {
fetched += 1;
return new HttpResponse(body, {
status,
headers: { "Content-Type": contentType },
});
}),
);
const client = testClient({
baseUrl: "https://api.test",
clock,
random: () => 0,
});
const result = await client.execute("LIST_ENTITIES");
expect(result).toMatchObject({
ok: false,
error: { kind: "SERVER_FAILURE", httpStatus: status },
});
expect(fetched).toBe(fetches);
expect(JSON.stringify(result)).not.toContain("raw body");
},
);
const errorEnvelope = {
success: false,
error: { code: "UPSTREAM_BUSY" },
meta: { requestId: "request-1", traceId: "trace-1" },
};
// A gateway body (not an envelope) or a valid V2 error envelope.
function busyResponse(
status: number,
envelope: boolean,
headers: Record<string, string> = {},
) {
return envelope
? HttpResponse.json(errorEnvelope, { status, headers })
: new HttpResponse("busy", {
status,
headers: { "Content-Type": "text/plain", ...headers },
});
}
const busyCases = [408, 425, 503].flatMap((status) => [
{ status, envelope: false },
{ status, envelope: true },
]);
// R3-1. A 408/425 with a valid error envelope is a server failure in V2 and
// keeps the backend code the envelope carries.
it.each([408, 425, 503])(
"retries a safe request on a %i error envelope and keeps its code",
async (status) => {
let fetched = 0;
server.use(
http.get("https://api.test/api/entities", () => {
fetched += 1;
return busyResponse(status, true);
}),
);
const client = testClient({
baseUrl: "https://api.test",
clock,
random: () => 0,
});
await expect(client.execute("LIST_ENTITIES")).resolves.toMatchObject({
ok: false,
error: {
kind: "SERVER_FAILURE",
code: "UPSTREAM_BUSY",
httpStatus: status,
requestId: "request-1",
},
});
expect(fetched).toBe(3);
},
);
// R3-1. 408/425/503 follow the retry rule of the operation: a keyed command
// may replay, a non-idempotent command is never replayed.
it.each(
busyCases.flatMap((busy) => [
{ ...busy, idempotency: "none" as const, fetches: 1 },
{ ...busy, idempotency: "keyed" as const, fetches: 3 },
]),
)(
"sends a $idempotency command $fetches time(s) on $status (envelope: $envelope)",
async ({ status, envelope, idempotency, fetches }) => {
let fetched = 0;
server.use(
http.post("https://api.test/api/entities", () => {
fetched += 1;
return busyResponse(status, envelope);
}),
);
const client = testClient({
baseUrl: "https://api.test",
clock,
random: () => 0,
getOperation: () => ({ ...TEST_OPERATIONS.CREATE_ENTITY, idempotency }),
});
const result = await client.execute("CREATE_ENTITY", {
body: { name: "n" },
...(idempotency === "keyed" ? { idempotencyKey: "key-1" } : {}),
});
expect(result).toMatchObject({
ok: false,
error: { kind: "SERVER_FAILURE", httpStatus: status },
});
expect(fetched).toBe(fetches);
},
);
function retryAfterClient(delays: number[]) {
return testClient({
baseUrl: "https://api.test",
clock: {
now: () => 0,
sleep: async (ms: number) => {
delays.push(ms);
},
},
random: () => 0.5, // local backoff for the first retry: 125ms
});
}
function listAfter(first: () => Response) {
let fetched = 0;
server.use(
http.get("https://api.test/api/entities", () => {
fetched += 1;
return fetched === 1
? first()
: HttpResponse.json({
success: true,
data: [],
meta: { requestId: "request-1", traceId: "trace-1" },
});
}),
);
}
// R3-1. The retry waits at least the Retry-After of a 408/425/503, under
// the same 30s ceiling as a 429.
it.each(busyCases)(
"waits for the Retry-After of a $status (envelope: $envelope)",
async ({ status, envelope }) => {
listAfter(() => busyResponse(status, envelope, { "Retry-After": "2" }));
const delays: number[] = [];
await expect(
retryAfterClient(delays).execute("LIST_ENTITIES"),
).resolves.toMatchObject({ ok: true });
expect(delays).toEqual([2_000]);
},
);
// R3-1. 502/504 keep the local backoff whatever Retry-After says.
it.each([502, 504])(
"ignores the Retry-After of a %i",
async (status) => {
listAfter(() => busyResponse(status, true, { "Retry-After": "2" }));
const delays: number[] = [];
await expect(
retryAfterClient(delays).execute("LIST_ENTITIES"),
).resolves.toMatchObject({ ok: true });
expect(delays).toEqual([125]);
},
);
it.each(busyCases)(
"does not retry a $status whose Retry-After exceeds 30 seconds (envelope: $envelope)",
async ({ status, envelope }) => {
let fetched = 0;
server.use(
http.get("https://api.test/api/entities", () => {
fetched += 1;
return busyResponse(status, envelope, { "Retry-After": "31" });
}),
);
const delays: number[] = [];
await expect(
retryAfterClient(delays).execute("LIST_ENTITIES"),
).resolves.toMatchObject({
ok: false,
error: { kind: "SERVER_FAILURE", httpStatus: status, retryAfterMs: 31_000 },
});
expect(fetched).toBe(1);
expect(delays).toEqual([]);
},
);
// R3-1. Retry-After goes through the platform kernel parser: delta-seconds
// or an IMF-fixdate only. Anything else falls back to the local backoff.
it.each([
{ value: "2", delay: 2_000 },
{ value: " 2 ", delay: 2_000 },
{ value: "Thu, 01 Jan 1970 00:00:05 GMT", delay: 5_000 },
{ value: "", delay: 125 },
{ value: " ", delay: 125 },
{ value: "1e3", delay: 125 },
{ value: "1.5", delay: 125 },
{ value: "0x10", delay: 125 },
{ value: "-1", delay: 125 },
{ value: "2099-01-01T00:00:00Z", delay: 125 },
{ value: "Thursday, 01-Jan-70 00:00:05 GMT", delay: 125 },
])("parses a 429 Retry-After of $value as $delay ms", async ({ value, delay }) => {
let fetched = 0;
server.use(
http.get("https://api.test/api/entities", () => {
fetched += 1;
return fetched === 1
? HttpResponse.json(
{
success: false,
error: { code: "RATE_LIMITED" },
meta: { requestId: "request-1", traceId: "trace-1" },
},
{ status: 429, headers: { "Retry-After": value } },
)
: HttpResponse.json({
success: true,
data: [],
meta: { requestId: "request-1", traceId: "trace-1" },
});
}),
);
const delays: number[] = [];
await expect(
retryAfterClient(delays).execute("LIST_ENTITIES"),
).resolves.toMatchObject({ ok: true });
expect(delays).toEqual([delay]);
});
it("classifies malformed JSON and invalid payloads at the boundary", async () => {
server.use(
http.get(
"https://api.test/api/entities",
() =>
new HttpResponse("{", {
headers: { "Content-Type": "application/json" },
}),
),
);
const client = testClient({ baseUrl: "https://api.test", clock });
await expect(client.execute("LIST_ENTITIES")).resolves.toMatchObject({
ok: false,
error: { kind: "MALFORMED_JSON" },
});
server.use(
http.get("https://api.test/api/entities", () =>
HttpResponse.json({
success: true,
data: [{ id: "resource-1", name: 42 }],
meta: { requestId: "request-1", traceId: "trace-1" },
}),
),
);
await expect(client.execute("LIST_ENTITIES")).resolves.toMatchObject({
ok: false,
error: { kind: "SCHEMA_MISMATCH" },
});
});
it("projects only approved 422 issue path and code metadata", async () => {
server.use(
http.post("https://api.test/api/entities", () =>
HttpResponse.json(
{
success: false,
error: {
code: "INVALID_INPUT",
message: "raw backend secret",
details: {
issues: [
{ path: "name", code: "REQUIRED", message: "raw field copy" },
{ path: 42, code: "INVALID" },
],
},
},
meta: { requestId: "request-422", traceId: "trace-422" },
},
{ status: 422 },
),
),
);
const client = testClient({ baseUrl: "https://api.test", clock });
const result = await client.execute("CREATE_ENTITY", {
routeId: "TEST_FORM",
body: { name: "Valid" },
});
expect(result).toMatchObject({
ok: false,
error: {
kind: "VALIDATION_REJECTED",
validationIssues: [{ path: "name", code: "REQUIRED" }],
},
});
expect(JSON.stringify(result)).not.toContain("raw backend secret");
expect(JSON.stringify(result)).not.toContain("raw field copy");
});
it("guards mapper exceptions as a mapping contract violation", async () => {
server.use(
http.get("https://api.test/api/entities", () =>
HttpResponse.json({
success: true,
data: [{ id: "resource-1", name: "Example" }],
meta: { requestId: "request-1", traceId: "trace-1" },
}),
),
);
const client = testClient({
baseUrl: "https://api.test",
clock,
mapPayload: () => {
throw new Error("raw mapper detail");
},
});
const result = await client.execute("LIST_ENTITIES");
expect(result).toMatchObject({
ok: false,
error: { kind: "MAPPING_CONTRACT_VIOLATION" },
});
expect(JSON.stringify(result)).not.toContain("raw mapper detail");
});
});
// 백엔드 1101/02-01. The paired backend answers a same-key request while the
// first still runs with 409 IDEMPOTENT_IN_FLIGHT, retryable and Retry-After 2.
// The client does not resend it itself (the result is unknown); it hands the
// Retry-After to whoever resends with the same key.
it("keeps the Retry-After of an in-flight 409 without resending", async () => {
let fetched = 0;
server.use(
http.post("https://api.test/api/entities", () => {
fetched += 1;
return HttpResponse.json(
{
success: false,
error: {
code: "IDEMPOTENT_IN_FLIGHT",
category: "CONFLICT",
message: "같은 요청을 처리하고 있습니다.",
retryable: true,
},
meta: { requestId: "request-1", traceId: "trace-1" },
},
{ status: 409, headers: { "Retry-After": "2" } },
);
}),
);
const client = testClient({ baseUrl: "https://api.test", clock });
await expect(
client.execute("CREATE_ENTITY", {
body: { name: "n" },
idempotencyKey: "key-1",
}),
).resolves.toMatchObject({
ok: false,
error: {
kind: "CONFLICT",
code: "IDEMPOTENT_IN_FLIGHT",
retryAfterMs: 2_000,
},
});
expect(fetched).toBe(1);
});
// 백엔드 1101/02-02. The paired backend drops a null field together with its
// key (its docs/web/http-contract.md §1). A missing key must read as the null
// it stands for.
describe("envelope keys the paired backend omits", () => {
const meta = { requestId: "request-1", traceId: "trace-1" };
it.each([
{ shape: "data: null", body: { success: true, data: null, meta } },
{ shape: "no data key", body: { success: true, meta } },
])("reads a success with $shape as null data", async ({ body }) => {
server.use(
http.get("https://api.test/api/entities", () => HttpResponse.json(body)),
);
const validated: unknown[] = [];
const client = testClient({
baseUrl: "https://api.test",
clock,
validatePayload: (_schemaId, value) => {
validated.push(value);
return { success: true, data: value };
},
mapPayload: (_operationId, value) => mappingSuccess(value),
});
await expect(client.execute("LIST_ENTITIES")).resolves.toMatchObject({
ok: true,
value: null,
});
expect(validated).toEqual([null]);
});
it.each([
{ shape: "with ids and details", meta, details: { reason: "X" } },
{ shape: "without details", meta, details: undefined },
// Answered before the request id filter: the id keys are absent.
{ shape: "without ids", meta: {}, details: undefined },
])("keeps the backend code of a failure $shape", async ({ meta, details }) => {
server.use(
http.get("https://api.test/api/entities", () =>
HttpResponse.json(
{
success: false,
error: {
code: "ACCESS_DENIED",
category: "FORBIDDEN",
message: "권한이 없습니다.",
retryable: false,
...(details === undefined ? {} : { details }),
},
meta,
},
{ status: 403 },
),
),
);
const client = testClient({ baseUrl: "https://api.test", clock });
await expect(client.execute("LIST_ENTITIES")).resolves.toMatchObject({
ok: false,
error: { kind: "FORBIDDEN", code: "ACCESS_DENIED", httpStatus: 403 },
});
});
});
// 백엔드 1101/02-01 후속. The paired backend answers a field validation
// failure with 400 VALIDATION_FAILED, details [{field, code, message}]
// (its docs/web/http-contract.md §4): read as the 422 field validation it is.
// Every other 400 keeps its reading.
describe("paired backend 400 VALIDATION_FAILED", () => {
const meta = { requestId: "request-1", traceId: "trace-1" };
function answer400(code: string, details?: unknown) {
server.use(
http.post("https://api.test/api/entities", () =>
HttpResponse.json(
{
success: false,
error: {
code,
category: "VALIDATION",
message: "요청 값이 올바르지 않습니다.",
retryable: false,
...(details === undefined ? {} : { details }),
},
meta,
},
{ status: 400 },
),
),
);
return testClient({ baseUrl: "https://api.test", clock }).execute(
"CREATE_ENTITY",
{ body: { name: "n" }, idempotencyKey: "key-1" },
);
}
it("reads the field details as validation issues, without backend copy", async () => {
const result = await answer400("VALIDATION_FAILED", [
{ field: "name", code: "NOT_BLANK", message: "raw backend copy" },
{ field: "items.name", code: "SIZE", message: "raw backend copy" },
{ field: "request", code: "INVALID", message: "raw backend copy" },
]);
expect(result).toMatchObject({
ok: false,
error: {
kind: "VALIDATION_REJECTED",
code: "VALIDATION_FAILED",
httpStatus: 400,
retryable: false,
effect: "NOT_APPLIED",
validationIssues: [
{ path: "name", code: "NOT_BLANK" },
{ path: "items.name", code: "SIZE" },
{ path: "request", code: "INVALID" },
],
},
});
expect(JSON.stringify(result)).not.toContain("raw backend copy");
});
// 1101/14.4. The backend raises every VALIDATION_FAILED while it binds the
// request, before it writes (frontend contract 6.1, backend 5786126c), so
// it is not applied whatever its details are. BAD_PARAMETER can come from
// any layer, after a write too.
it.each([
// A body that did not parse: details names the cause, not a field.
{ code: "VALIDATION_FAILED", details: { cause: "JsonParseException" }, effect: "NOT_APPLIED" },
{ code: "VALIDATION_FAILED", details: undefined, effect: "NOT_APPLIED" },
// A page or sort parameter: one {field, code}, not a list.
{ code: "VALIDATION_FAILED", details: { field: "size", code: "MAX" }, effect: "NOT_APPLIED" },
{ code: "BAD_PARAMETER", details: { parameter: "limit" }, effect: undefined },
])(
"reads a 400 $code with details $details as a client failure, effect $effect",
async ({ code, details, effect }) => {
const result = await answer400(code, details);
expect(result).toMatchObject({
ok: false,
error: { kind: "UNKNOWN_CLIENT_FAILURE", code, httpStatus: 400 },
});
expect(result.ok ? null : result.error.validationIssues).toBeUndefined();
expect(result.ok ? null : result.error.effect).toBe(effect);
},
);
});