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.
77 lines
2.5 KiB
TypeScript
77 lines
2.5 KiB
TypeScript
// frontend/tests/mail/MailRow.test.tsx — AI pill 렌더 규칙
|
|
import { render, screen } from "@testing-library/react";
|
|
import { describe, expect, it } from "vitest";
|
|
import { MailRow } from "@/components/mail/MailRow";
|
|
import type { AiAnalysis, EmailRow } from "@/lib/types";
|
|
|
|
const baseAi: AiAnalysis = {
|
|
summary: "요약",
|
|
priority: "높음",
|
|
category: "검토 요청",
|
|
tasks: [
|
|
{ text: "t1", project: "p", due: "6/13", prio: "높음" },
|
|
{ text: "t2", project: "p", due: "6/12", prio: "보통" },
|
|
],
|
|
events: [{ title: "ev", date: "6/10", day: "오늘", time: "14:00", dur: "60분", place: "" }],
|
|
replies: [{ tone: "수락", preview: "회신 드릴게요", body: "본문" }],
|
|
file: { project: "온보딩 리디자인", reason: "이유" },
|
|
};
|
|
|
|
function row(over: Partial<EmailRow> = {}): EmailRow {
|
|
return {
|
|
id: "m1",
|
|
account: "work",
|
|
from: "hyunwoo",
|
|
to: "나",
|
|
cc: "",
|
|
thread_id: "",
|
|
subject: "온보딩 시안 v3",
|
|
time: "8분 전",
|
|
read: false,
|
|
starred: false,
|
|
has_attach: true,
|
|
labels: ["디자인"],
|
|
preview: "미리보기",
|
|
category: "primary",
|
|
ai: baseAi,
|
|
...over,
|
|
};
|
|
}
|
|
|
|
describe("MailRow", () => {
|
|
it("priority 높음 → 중요 pill", () => {
|
|
render(<MailRow m={row()} on={false} onClick={() => {}} onStar={() => {}} />);
|
|
expect(screen.getByText("중요")).toBeInTheDocument();
|
|
});
|
|
|
|
it("tasks/events/replies pill 카운트", () => {
|
|
render(<MailRow m={row()} on={false} onClick={() => {}} onStar={() => {}} />);
|
|
expect(screen.getByText("할 일 2")).toBeInTheDocument();
|
|
expect(screen.getByText("일정 1")).toBeInTheDocument();
|
|
expect(screen.getByText("답장 추천")).toBeInTheDocument();
|
|
});
|
|
|
|
it("m7 처럼 빈 ai(priority 낮음 · 전부 빈 배열)는 pill 없음", () => {
|
|
const empty: AiAnalysis = {
|
|
summary: "영수증",
|
|
priority: "낮음",
|
|
category: "영수증",
|
|
tasks: [],
|
|
events: [],
|
|
replies: [],
|
|
file: null,
|
|
};
|
|
render(
|
|
<MailRow m={row({ id: "m7", ai: empty })} on={false} onClick={() => {}} onStar={() => {}} />,
|
|
);
|
|
expect(screen.queryByText("중요")).not.toBeInTheDocument();
|
|
expect(screen.queryByText(/할 일/)).not.toBeInTheDocument();
|
|
expect(screen.queryByText("답장 추천")).not.toBeInTheDocument();
|
|
});
|
|
|
|
it("ai 가 null 이면 pill 없음", () => {
|
|
render(<MailRow m={row({ ai: null })} on={false} onClick={() => {}} onStar={() => {}} />);
|
|
expect(screen.queryByText("중요")).not.toBeInTheDocument();
|
|
});
|
|
});
|