From 16fa2370d10fe0a18006a9a5fd4678a49719dd99 Mon Sep 17 00:00:00 2001 From: hojooo Date: Wed, 20 May 2026 10:22:07 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20dom?= =?UTF-8?q?=20=EA=B3=84=EC=82=B0=20=EB=B2=94=EC=9C=84=20=EC=B6=95=EC=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/App.test.tsx | 8 ++++---- src/test/setup.ts | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/app/App.test.tsx b/src/app/App.test.tsx index 68ba806..ed99e3d 100644 --- a/src/app/App.test.tsx +++ b/src/app/App.test.tsx @@ -1,4 +1,4 @@ -import { render, screen } from "@testing-library/react"; +import { cleanup, fireEvent, render, screen } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { afterEach, describe, expect, it, vi } from "vitest"; @@ -23,6 +23,7 @@ function renderRoute(path: string) { } afterEach(() => { + cleanup(); clearAdminSession(); window.sessionStorage.clear(); vi.unstubAllGlobals(); @@ -76,16 +77,15 @@ describe("App routes", () => { }); it("약관 관리 화면에 약관 목록을 표시한다", async () => { - const user = userEvent.setup(); mockAdminFetch(); signInTestSession(); renderRoute("/admin/terms"); expect(await screen.findByRole("heading", { name: "약관 관리" })).toBeInTheDocument(); - expect(await screen.findByRole("cell", { name: "서비스 이용약관 v1" })).toBeInTheDocument(); + expect(await screen.findByText("서비스 이용약관 v1")).toBeInTheDocument(); expect(screen.queryByText("서비스 이용약관 본문입니다.")).not.toBeInTheDocument(); - await user.click(screen.getByRole("button", { name: "본문 보기" })); + fireEvent.click(screen.getByRole("button", { name: "본문 보기" })); expect(await screen.findByText("서비스 이용약관 본문입니다.")).toBeInTheDocument(); }); diff --git a/src/test/setup.ts b/src/test/setup.ts index 7efb688..97e47d3 100644 --- a/src/test/setup.ts +++ b/src/test/setup.ts @@ -1,5 +1,12 @@ import "@testing-library/jest-dom/vitest"; +const getComputedStyle = window.getComputedStyle.bind(window); + +Object.defineProperty(window, "getComputedStyle", { + writable: true, + value: (element: Element) => getComputedStyle(element) +}); + Object.defineProperty(window, "matchMedia", { writable: true, value: (query: string) => ({