문제: 조회 실패는 failure.requestId를 "지원 참조"로 보이는데, 폼의
FormFailureStatus는 넘기지 않았다. 결과 불명 저장은 AsyncSurface의
indicator 분기라 실패 객체가 없고, 폼도 MAYBE_APPLIED 실패를 버렸다.
사용자가 가장 문의하고 싶은 경우에 줄 식별자가 없었다. 샘플의
contact-support 이동은 식별자를 버리고, 상태 페이지는 식별자처럼 보이는
고정 문자열 "REFERENCE-STATUS-DEMO"를 보였다.
고른 방법: 리뷰의 최소 개선 방향(기대 계약 고정)대로 했다.
- FormFailureStatus가 supportReference={failure.requestId}를 넘긴다.
- useAppForm이 MAYBE_APPLIED 실패도 보관하고 supportReference(현재
보이는 상태 실패 또는 결과 불명 저장의 requestId)를 돌려준다. failure는
여전히 상태 결과에만 값이 있어 FormFailureStatus가 결과 불명을 두 번
그리지 않는다.
- AsyncSurface가 supportReference prop을 받아 결과 불명 indicator에서만
보인다. 샘플 폼 페이지가 form.supportReference를 넘긴다.
- 샘플 contact-support 이동은 식별자를 history state로 넘기고(URL에
넣지 않음), 상태 페이지는 받은 문자열만 보이고 없으면 줄을 숨긴다.
공개 API는 추가만 했다(useAppForm 반환 필드, AsyncSurface prop).
버린 대안: 결과 불명 식별자를 mutation 채널(application-query.ts)에
두기 — 재마운트 뒤에도 남지만 925줄 파일의 채널 구조를 바꾸고 08-03
(raw 경로 정리)과 겹친다.
위험·한계: 폼이 재마운트되면 결과 불명 배너는 mutation 채널에서
남지만 식별자는 사라진다(제출 값과 같은 수명). 서버가
x-correlation-id를 노출하지 않으면 식별자가 없다(0929 FOLLOW-UP 03-03).
결과 불명 화면에 줄 하나가 생긴다. 초기 JS는 이번 브랜치 전체 기준
202,520 → 202,631 B(예산 204,800 B).
검증:
- RED: 새 테스트 6건이 수정 전 실패(form-foundation 2, async-surface 1,
reference-page 3. 예: "Unable to find an element with the text: 지원
참조: corr-save-500"). 새 e2e가 이전 빌드에서 실패(getByText('지원 참조:
corr-save-500') not found).
- GREEN: 관련 3파일 70/70, tests/component·features·architecture
59 files 336 tests 통과. e2e reference-save·reference-form·
reference-route chromium·firefox·webkit 42/42. tsc app·test, eslint,
check-i18n, check-design-system 통과.
Refs: docs/reviews/2026-09-29-maturity-review/08-presentation.md 08-04
133 lines
4.4 KiB
TypeScript
133 lines
4.4 KiB
TypeScript
import type { Page, Route } from "@playwright/test";
|
|
import { expect, test } from "../support/browser/strict-browser-test.ts";
|
|
|
|
const CREATE_URL = "http://localhost:8080/api/reference-resources";
|
|
|
|
type CreateCall = Readonly<{ name: unknown; idempotencyKey: string | null }>;
|
|
|
|
async function openForm(page: Page) {
|
|
await page.route(`${CREATE_URL}?*`, (route) => route.fulfill({ json: [] }));
|
|
await page.goto("/examples/reference-resources/new");
|
|
await page.getByRole("button", { name: "로그인 시작" }).click();
|
|
await expect(
|
|
page.getByRole("heading", { name: "Reference resource 만들기" }),
|
|
).toBeVisible();
|
|
}
|
|
|
|
/** Answers each POST with the next responder and records what was sent. */
|
|
async function routeCreate(
|
|
page: Page,
|
|
responders: readonly ((route: Route) => Promise<void>)[],
|
|
): Promise<CreateCall[]> {
|
|
const calls: CreateCall[] = [];
|
|
await page.route(CREATE_URL, async (route) => {
|
|
const request = route.request();
|
|
if (request.method() !== "POST") return route.fallback();
|
|
calls.push({
|
|
name: (request.postDataJSON() as { name?: unknown }).name,
|
|
idempotencyKey: await request.headerValue("idempotency-key"),
|
|
});
|
|
const respond = responders[calls.length - 1];
|
|
if (!respond) throw new Error(`unexpected create call ${calls.length}`);
|
|
await respond(route);
|
|
});
|
|
return calls;
|
|
}
|
|
|
|
const created = (route: Route) =>
|
|
route.fulfill({
|
|
status: 201,
|
|
json: {
|
|
id: "browser-created",
|
|
name: "Saved in the browser",
|
|
createdAt: "2026-07-26T00:00:00.000Z",
|
|
},
|
|
});
|
|
|
|
test("saves a new reference resource through the production command path", async ({
|
|
page,
|
|
}) => {
|
|
await openForm(page);
|
|
const calls = await routeCreate(page, [created]);
|
|
|
|
await page
|
|
.getByRole("textbox", { name: /새 항목 이름/ })
|
|
.fill("Saved in the browser");
|
|
await page.getByRole("button", { name: "저장" }).click();
|
|
|
|
await expect(page.getByRole("status")).toHaveText("저장했습니다.");
|
|
expect(calls).toHaveLength(1);
|
|
expect(calls[0]?.name).toBe("Saved in the browser");
|
|
expect(calls[0]?.idempotencyKey).toBeTruthy();
|
|
});
|
|
|
|
test.describe("after a rate-limited save", () => {
|
|
// Chromium and WebKit log a 4xx fetch response to the console, and the
|
|
// client cancels the 429 body unread, which Chromium reports as aborted.
|
|
test.use({
|
|
allowedBrowserFailure:
|
|
/^console:error:.*status of 429|^requestfailed:POST:\/api\/reference-resources:net::ERR_ABORTED$/u,
|
|
});
|
|
|
|
test("keeps the input and saves on retry", async ({ page }) => {
|
|
await openForm(page);
|
|
const calls = await routeCreate(page, [
|
|
(route) =>
|
|
route.fulfill({
|
|
status: 429,
|
|
headers: { "retry-after": "1" },
|
|
json: { title: "Too many requests" },
|
|
}),
|
|
created,
|
|
]);
|
|
|
|
const name = page.getByRole("textbox", { name: /새 항목 이름/ });
|
|
await name.fill("Saved in the browser");
|
|
await page.getByRole("button", { name: "저장" }).click();
|
|
|
|
await expect(
|
|
page.getByText("요청이 많습니다. 잠시 후 다시 시도해 주세요."),
|
|
).toBeVisible();
|
|
await expect(name).toHaveValue("Saved in the browser");
|
|
await page.getByRole("button", { name: "다시 시도" }).click();
|
|
|
|
await expect(page.getByRole("status")).toHaveText("저장했습니다.");
|
|
expect(calls.map((call) => call.name)).toEqual([
|
|
"Saved in the browser",
|
|
"Saved in the browser",
|
|
]);
|
|
});
|
|
});
|
|
|
|
test.describe("after a save whose result is unknown", () => {
|
|
// The browsers log the 500 response to the console.
|
|
test.use({
|
|
allowedBrowserFailure: /^console:error:.*status of 500/u,
|
|
});
|
|
|
|
// 0929/08-04. The case a user most wants to report shows the id support
|
|
// can find in the server logs.
|
|
test("shows the request id the server echoed", async ({ page }) => {
|
|
await openForm(page);
|
|
await routeCreate(page, [
|
|
(route) =>
|
|
route.fulfill({
|
|
status: 500,
|
|
headers: {
|
|
"x-correlation-id": "corr-save-500",
|
|
"access-control-expose-headers": "x-correlation-id",
|
|
},
|
|
json: { title: "Internal error" },
|
|
}),
|
|
]);
|
|
|
|
await page
|
|
.getByRole("textbox", { name: /새 항목 이름/ })
|
|
.fill("Saved in the browser");
|
|
await page.getByRole("button", { name: "저장" }).click();
|
|
|
|
await expect(page.getByText("변경 결과를 확인할 수 없습니다.")).toBeVisible();
|
|
await expect(page.getByText("지원 참조: corr-save-500")).toBeVisible();
|
|
});
|
|
});
|