feat(ai-character): 커뮤니티 생성 미디어 흐름 개선

This commit is contained in:
Yu Sung
2026-08-05 00:33:49 +09:00
parent 766a06ad0a
commit fb9b550040
22 changed files with 700 additions and 141 deletions

View File

@@ -0,0 +1,37 @@
import { fireEvent, render, screen } from "@testing-library/react";
import { expect, test, vi } from "vitest";
import { CanPriceField } from "@/shared/ui/can-price-field";
test("CanPriceField renders the native numeric CAN price contract", () => {
render(<CanPriceField error={undefined} errorId="price-error" onChange={() => undefined} value="0" />);
const input = screen.getByLabelText("가격");
expect(input).toHaveAttribute("type", "number");
expect(input).toHaveAttribute("inputmode", "numeric");
expect(input).toHaveAttribute("min", "0");
expect(input).toHaveAttribute("step", "1");
expect(input).toHaveAccessibleDescription("단위: 캔");
});
test.each([
"-1",
"1.5",
])("CanPriceField emits the raw input value %s unchanged", (rawValue) => {
const onChange = vi.fn<(value: string) => void>();
render(<CanPriceField error={undefined} errorId="price-error" onChange={onChange} value="0" />);
fireEvent.change(screen.getByLabelText("가격"), { target: { value: rawValue } });
expect(onChange).toHaveBeenCalledWith(rawValue);
});
test("CanPriceField links the visible error and unit description to the invalid input", () => {
render(<CanPriceField error="가격 오류" errorId="price-error" onChange={() => undefined} value="100000" />);
const input = screen.getByLabelText("가격");
expect(input).toHaveAttribute("aria-invalid", "true");
expect(input.getAttribute("aria-describedby")?.split(" ")).toContain("price-error");
expect(input).toHaveAccessibleDescription("단위: 캔 가격 오류");
expect(screen.getByRole("alert")).toHaveAttribute("id", "price-error");
});