# backend/tests/test_api_journey.py # phase-16+: 작업 시드 제거 → 여정 카드가 참조하는 작업(k1/k3)은 테스트가 직접 생성. from tests._factories import make_task def test_journey_shape(client): j = client.get("/api/journey").json() assert [st["id"] for st in j["stages"]] == ["s1", "s2", "s3", "s4"] assert [st["tone"] for st in j["stages"]] == ["blue", "coral", "violet", "ink"] assert j["stages"][0]["time"] == "06:40 – 09:00" assert all(j["cards"][k] for k in ("s1", "s2", "s3", "s4")) def test_journey_links_seed(client): j = client.get("/api/journey").json() assert len(j["links"]) == 8 by = {(link["from_node"], link["to_node"]): link for link in j["links"]} assert ( by[("m-brief", "t-report")]["tone"] == "blue" and by[("m-brief", "t-report")]["dash"] is False ) assert ( by[("t-interview", "k-11")]["tone"] == "green" and by[("t-interview", "k-11")]["dash"] is True ) def test_journey_cards_live_task(client, session): s, _ = session make_task(s, id="k1", title="분기 리포트 초안 마무리", project_id="biz-report", status="doing", assignee_id="jiwoo") make_task(s, id="k3", title="팀 환영 준비", project_id="team", status="done", assignee_id="jiwoo") j = client.get("/api/journey").json() report = next(c for c in j["cards"]["s2"] if c["node"] == "t-report") assert report["title"] == "분기 리포트 초안 마무리" and report["who"] == "jiwoo" welcome = next(c for c in j["cards"]["s2"] if c["node"] == "t-welcome") assert welcome["done"] is True # k3 status=done def test_journey_status_reflects_task_update(client, session): s, _ = session make_task(s, id="k1", title="분기 리포트 초안 마무리", project_id="biz-report", status="doing", assignee_id="jiwoo") client.patch("/api/tasks/k1", json={"status": "done"}) j = client.get("/api/journey").json() report = next(c for c in j["cards"]["s2"] if c["node"] == "t-report") assert report["done"] is True row = next(r for r in j["rows"] if r["node"] == "t-report") assert row["statusKey"] == "done" def test_journey_people(client): j = client.get("/api/journey").json() assert len(j["people"]) == 5 jiwoo = next(p for p in j["people"] if p["id"] == "jiwoo") assert jiwoo["me"] is True and jiwoo["tasks"] == 4 sua = next(p for p in j["people"] if p["id"] == "sua") assert sua["color"] == "oklch(0.66 0.13 200)" and sua["role"] == "리서치" def test_journey_table_subtitle(client): j = client.get("/api/journey").json() assert j["table"]["subtitle"].startswith("5건 · 진행중")