test(frontend): #343 Jest+RTL 인프라 + ARIA Tabs + remotePatterns

테스트 인프라:
- Jest 30 + jest-environment-jsdom + RTL + jest-dom matchers
- next/jest로 SWC/Next.js 자동 통합
- jest.config.ts (setupFilesAfterEnv) + jest.setup.ts
- npm scripts: test, test:watch
- 샘플 테스트 3개, 13/13 통과:
  - i18n/config: isLocale + detectBrowserLocale (5 케이스)
  - Stars 컴포넌트: 별점/aria/clamp/showNumber (5 케이스)
  - admin-utils: getAdminToken + authHeaders (4 케이스)

ARIA Tabs (MyReviewsList):
- role=tablist + tab + aria-selected + aria-controls + tabIndex
- panel에 role=tabpanel + aria-labelledby

next/image:
- next.config.ts remotePatterns: lh3.googleusercontent.com / i.ytimg.com / yt3.ggpht.com
- ReviewSection의 user_avatar_url에 명시적 eslint-disable + 사유

후속(별도): 전체 컴포넌트 테스트 점진 추가, 백엔드 JUnit 인프라, E2E (Playwright), CI 통합

설계서: docs/design/343-frontend-test-infra/README.md

Refs: #343
This commit is contained in:
joungmin
2026-06-15 16:25:55 +09:00
parent 9ba905aad8
commit 730727a7a6
10 changed files with 4493 additions and 34 deletions

View File

@@ -0,0 +1,36 @@
/**
* #343 — Stars 컴포넌트 렌더 테스트.
*/
import { render, screen } from "@testing-library/react";
import Stars from "@/components/Stars";
describe("Stars", () => {
it("renders 5 star slots", () => {
const { container } = render(<Stars rating={3} />);
// 빈 별 5개 (text-gray-300 클래스 갖는 span)
const emptyStars = container.querySelectorAll("span.text-gray-300");
expect(emptyStars.length).toBe(5);
});
it("shows aria-label with rating", () => {
render(<Stars rating={4.5} />);
expect(screen.getByLabelText("4.5점")).toBeInTheDocument();
});
it("clamps rating to 0~5", () => {
render(<Stars rating={-1} />);
expect(screen.getByLabelText("0점")).toBeInTheDocument();
render(<Stars rating={10} />);
expect(screen.getByLabelText("5점")).toBeInTheDocument();
});
it("shows number when showNumber + rating > 0", () => {
const { container } = render(<Stars rating={3.5} showNumber />);
expect(container.textContent).toContain("3.5");
});
it("does not show number when rating is 0 even with showNumber", () => {
const { container } = render(<Stars rating={0} showNumber />);
expect(container.textContent).not.toContain("0");
});
});