fix(presentation): show a support reference on failure screens (08-07)
Route render, unrecovered chunk and query failure screens now show the id a user quotes to support, and the render diagnostic records the same id as correlation_id. The route failure page also offers a reload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f17572a4be
commit
b7fc7e53ce
@@ -138,6 +138,17 @@ describe("async UI state matrix", () => {
|
||||
expect(resolveConflict).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
// 08-07. The id a user quotes when asking for help is the one the request
|
||||
// diagnostics carry as `correlation_id`.
|
||||
it("shows the failure's request id as its support reference", () => {
|
||||
const failure = {
|
||||
...createFailure("SERVER_FAILURE", "LIST", 1),
|
||||
requestId: "req-7f3a",
|
||||
};
|
||||
render(<AsyncSurface state={deriveAsyncState({ failure })} />);
|
||||
expect(screen.getByRole("alert")).toHaveTextContent("지원 참조: req-7f3a");
|
||||
});
|
||||
|
||||
it("renders only safe error vocabulary", () => {
|
||||
const failure = createFailure("SERVER_FAILURE", "LIST", 0, {
|
||||
code: "SERVER_FAILURE",
|
||||
|
||||
@@ -141,6 +141,34 @@ describe("chunk recovery boundary classification", () => {
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
// 08-07. An unrecovered chunk failure shows a reference the render
|
||||
// diagnostic also records.
|
||||
it("shows an unrecovered chunk failure's support reference and records it", async () => {
|
||||
const record = vi.fn();
|
||||
window.history.pushState({}, "", "/examples/states");
|
||||
render(
|
||||
<ApplicationProvider
|
||||
application={createTestApplication({ diagnostics: { record } })}
|
||||
>
|
||||
<PreferenceProviders>
|
||||
<AppRouter buildId="build-a" />
|
||||
</PreferenceProviders>
|
||||
</ApplicationProvider>,
|
||||
);
|
||||
|
||||
const reference = await screen.findByText(/^지원 참조: build-a:[0-9a-f]{8}$/);
|
||||
const incidentId = reference.textContent?.split(":").at(-1);
|
||||
expect(record).toHaveBeenCalledWith({
|
||||
level: "error",
|
||||
eventId: "ui.render.failed",
|
||||
context: expect.objectContaining({
|
||||
route_id: "EXAMPLES_STATES",
|
||||
build_id: "build-a",
|
||||
correlation_id: incidentId,
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
it("clears a failed route chunk when the user moves to a sibling route", async () => {
|
||||
// React Router reuses the rendered-route instance between sibling routes,
|
||||
// so a failure latched in one route's boundary would otherwise follow the
|
||||
|
||||
@@ -11,6 +11,17 @@ import { AsyncSurface } from "../../src/presentation/components/async-surface.ts
|
||||
import { BootErrorShell } from "../../src/presentation/boundaries/boot-error-shell.tsx";
|
||||
import { FeatureBoundary } from "../../src/presentation/boundaries/render-error-boundary.tsx";
|
||||
import { LocaleProvider } from "../../src/presentation/i18n/index.ts";
|
||||
import { ApplicationProvider } from "../../src/presentation/providers/application-provider.tsx";
|
||||
import { PreferenceProviders } from "../../src/presentation/providers/preference-providers.tsx";
|
||||
import { AppRouter } from "../../src/presentation/routes/app-router.tsx";
|
||||
import { createTestApplication } from "../helpers/create-test-application.ts";
|
||||
|
||||
// The states page stands in for any route page with a programmer defect.
|
||||
vi.mock("../../src/presentation/examples/state-gallery-page.tsx", () => ({
|
||||
default: function BrokenPage(): never {
|
||||
throw new Error("ordinary render defect");
|
||||
},
|
||||
}));
|
||||
|
||||
function Defect(): ReactNode {
|
||||
throw new Error("raw render stack");
|
||||
@@ -36,9 +47,39 @@ describe("render recovery boundaries", () => {
|
||||
routeId: "APP_HOME",
|
||||
buildId: "build-a",
|
||||
boundaryName: "feature",
|
||||
incidentId: expect.stringMatching(/^[0-9a-f]{8}$/),
|
||||
});
|
||||
});
|
||||
|
||||
// 08-07. The route failure page shows the reference the user quotes, the
|
||||
// same id the render diagnostic records, and a way out besides the URL.
|
||||
it("shows a route render failure's support reference and records it", async () => {
|
||||
const record = vi.fn();
|
||||
window.history.pushState({}, "", "/examples/states");
|
||||
render(
|
||||
<ApplicationProvider
|
||||
application={createTestApplication({ diagnostics: { record } })}
|
||||
>
|
||||
<PreferenceProviders>
|
||||
<AppRouter buildId="build-a" />
|
||||
</PreferenceProviders>
|
||||
</ApplicationProvider>,
|
||||
);
|
||||
|
||||
const reference = await screen.findByText(/^지원 참조: build-a:[0-9a-f]{8}$/);
|
||||
const incidentId = reference.textContent?.split(":").at(-1);
|
||||
expect(record).toHaveBeenCalledWith({
|
||||
level: "error",
|
||||
eventId: "ui.render.failed",
|
||||
context: expect.objectContaining({
|
||||
route_id: "EXAMPLES_STATES",
|
||||
build_id: "build-a",
|
||||
correlation_id: incidentId,
|
||||
}),
|
||||
});
|
||||
expect(screen.getByRole("button", { name: "한 번 새로고침" })).toBeVisible();
|
||||
});
|
||||
|
||||
it("keeps normalized operational failures in normal async state", () => {
|
||||
const state = deriveAsyncState({
|
||||
failure: createFailure("SERVER_FAILURE", "LIST", 0),
|
||||
|
||||
Reference in New Issue
Block a user