// frontend/tests/tasks/KanbanCard.test.tsx import { render } from "@testing-library/react"; import { describe, expect, it } from "vitest"; import { KanbanCard } from "@/components/tasks/KanbanCard"; import type { Person, Project, Task } from "@/lib/types"; const people: Record = { jiwoo: { id: "jiwoo", name: "지우", initial: "지", color: "var(--blue)", is_me: true }, }; const projects: Record = { "biz-report": { id: "biz-report", folder_id: "work", parent_id: "biz", name: "분기 리포트", tone: "coral", sort_order: 0, pinned: false, task_count: 0, children: [], }, }; function mk(over: Partial = {}): Task { return { id: "k1", project_id: "biz-report", parent_id: null, title: "분기 리포트 초안 마무리", status: "doing", assignee_id: "jiwoo", due: "2026-06-08", prio: "높음", notes: "", est: "", delegated: false, sort_order: 0, created_at: "", updated_at: "", comments: [], children: [], ...over, }; } describe("KanbanCard", () => { it("제목/프로젝트태그/담당아바타/마감/우선순위 렌더", () => { const { container, getByText } = render( {}} />, ); expect(getByText("분기 리포트 초안 마무리")).toBeInTheDocument(); expect(getByText("분기 리포트")).toBeInTheDocument(); // 프로젝트 태그 expect(getByText("지")).toBeInTheDocument(); // 담당 아바타 expect(getByText("6/8")).toBeInTheDocument(); // 마감 expect(container.querySelector(".prio-높음")).toBeTruthy(); }); it("하위작업 있으면 진행바+N/M", () => { const task = mk({ children: [mk({ id: "a", status: "done" }), mk({ id: "b", status: "todo" })], }); const { container, getByText } = render( {}} />, ); expect(container.querySelector(".bar")).toBeTruthy(); expect(getByText("1/2")).toBeInTheDocument(); }); it("마감 임박(06-08, doing) → .due.soon", () => { const { container } = render( {}} />, ); expect(container.querySelector(".due.soon")).toBeTruthy(); }); it("완료 카드 → .done-card", () => { const { container } = render( {}} />, ); expect(container.querySelector(".kcard.done-card")).toBeTruthy(); }); it("위임 → .deleg-chip", () => { const { getByText } = render( {}} />, ); expect(getByText("위임")).toBeInTheDocument(); }); });