You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.8 KiB
TypeScript
47 lines
1.8 KiB
TypeScript
// frontend/tests/weekly/WeeklyReview.test.tsx
|
|
import { fireEvent, render, screen } from "@testing-library/react";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import { WeeklyReview } from "@/components/weekly/WeeklyReview";
|
|
import type { WeeklyReview as WeeklyReviewT } from "@/lib/types";
|
|
|
|
const REVIEW: WeeklyReviewT = {
|
|
id: "wr-2026-w24",
|
|
week_label: "6/7~6/13",
|
|
deep_work_h: 8,
|
|
meeting_h: 12,
|
|
done_count: 18,
|
|
auto_count: 12,
|
|
saved_minutes: 196,
|
|
patterns: [
|
|
{
|
|
title: "이번 주 딥워크 8h, 회의 12h",
|
|
suggest: "화요일 오전을 ‘방해 금지’ 딥워크로 보호할까요?",
|
|
action_kind: "automation",
|
|
payload: { name: "화요일 오전 딥워크 보호" },
|
|
},
|
|
],
|
|
note: "이번 주 딥워크 8h, 회의 12h — 화요일 오전을 ‘방해 금지’ 딥워크로 보호할까요?",
|
|
};
|
|
|
|
describe("WeeklyReview", () => {
|
|
it("deep_work_h/meeting_h 스탯 + 패턴 제안 텍스트 렌더", () => {
|
|
const { container } = render(<WeeklyReview review={REVIEW} />);
|
|
const stats = Array.from(container.querySelectorAll(".wr-stat")).map(
|
|
(el) => el.textContent ?? "",
|
|
);
|
|
// 딥워크 8h / 회의 12h 스탯이 라벨과 함께 렌더
|
|
expect(stats.some((t) => t.includes("8") && t.includes("딥워크"))).toBe(true);
|
|
expect(stats.some((t) => t.includes("12") && t.includes("회의"))).toBe(true);
|
|
expect(
|
|
screen.getByText("화요일 오전을 ‘방해 금지’ 딥워크로 보호할까요?"),
|
|
).toBeInTheDocument();
|
|
});
|
|
|
|
it("적용 버튼 → onApply(pattern) 호출", () => {
|
|
const onApply = vi.fn();
|
|
render(<WeeklyReview review={REVIEW} onApply={onApply} />);
|
|
fireEvent.click(screen.getByRole("button", { name: "적용" }));
|
|
expect(onApply).toHaveBeenCalledWith(REVIEW.patterns[0]);
|
|
});
|
|
});
|