Files
clean-architecture-frontend…/tests/component/boot-unexpected-failure.test.tsx
T
DongHyeonkaandClaude Opus 5.5 aca949042f fix(bootstrap): report unclassified boot failures as BOOT_UNEXPECTED_FAILURE (09-04)
Any error the loaders did not classify was shown as BOOT_CONFIG_FAILURE and
dropped. It now shows BOOT_UNEXPECTED_FAILURE with the build id and error class,
logs the original in development, and a schema failure lists the rejected key
names (bounded, never values).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 22:58:29 +09:00

51 lines
2.0 KiB
TypeScript

// @vitest-environment jsdom
import { render, screen, within } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { BootErrorShell } from "../../src/presentation/boundaries/boot-error-shell.tsx";
// 09-04. An assembly defect (here the TypeError a missing feature capability
// used to produce) was shown as BOOT_CONFIG_FAILURE and the error was dropped.
const assemblyDefect = new TypeError(
"Cannot read properties of undefined (reading 'get')",
);
vi.mock("../../src/bootstrap/create-runtime-composition.ts", () => ({
createRuntimeComposition: async () => {
throw assemblyDefect;
},
}));
describe("unexpected boot failure (09-04)", () => {
it("is shown as BOOT_UNEXPECTED_FAILURE and keeps the error in the dev console", async () => {
document.body.innerHTML =
'<div id="root"><div role="status" data-boot-shell="">불러오는 중</div></div>';
const consoleError = vi.spyOn(console, "error").mockImplementation(() => {});
await import("../../src/bootstrap/main.tsx");
const shell = await screen.findByRole("alert", undefined, { timeout: 5_000 });
expect(shell).toHaveTextContent("BOOT_UNEXPECTED_FAILURE");
expect(shell).not.toHaveTextContent("BOOT_CONFIG_FAILURE");
expect(shell).toHaveTextContent("local-build");
expect(shell).toHaveTextContent("TypeError");
expect(shell).not.toHaveTextContent("reading 'get'");
expect(consoleError).toHaveBeenCalledWith(assemblyDefect);
});
it("lists the rejected configuration keys", () => {
const view = render(
<BootErrorShell
kind="BOOT_CONFIG_FAILURE"
code="CONFIG_SCHEMA_INVALID"
buildId="build-a"
invalidKeys={["TELEMETRY_ENABELD"]}
supportReference="build-a:CONFIG_SCHEMA_INVALID"
/>,
);
const shell = within(view.container).getByRole("alert");
expect(within(shell).getByText("잘못된 설정 키")).toBeInTheDocument();
expect(shell).toHaveTextContent("TELEMETRY_ENABELD");
});
});