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.

78 lines
2.4 KiB
Python

# phase-5 §7.2 — 대시보드 집계 정확성
def test_dashboard_shape(client):
d = client.get("/api/dashboard").json()
for k in (
"user",
"briefing",
"saved_today",
"today_routed",
"schedule",
"task_summary",
"goals",
"approvals_summary",
"inbox_recent",
"badges",
):
assert k in d
def test_user_top_level(client):
d = client.get("/api/dashboard").json()
assert d["user"]["name"] == "지우"
assert d["user"]["initial"] == ""
def test_briefing_seed_values(client):
d = client.get("/api/dashboard").json()
b = d["briefing"]
assert b["today"] == "6월 7일 일요일"
assert b["weather"]["cond"] == "맑음 · 한낮 28°"
assert b["weather"]["icon"] == "sun" # cloudSun → sun
assert d["saved_today"] == "47분"
assert d["today_routed"] == 7
assert "<b>분기 리포트</b>" in b["note"]
def test_schedule_four_items_and_soon(client):
d = client.get("/api/dashboard").json()
sch = d["schedule"]
assert len(sch) == 4
assert sch[0]["time"] == "09:30"
soon = [e for e in sch if e["soon"]]
assert len(soon) == 1 and soon[0]["title"] == "분기 전략 미팅"
def test_approvals_summary_only_high_risk_max3(client):
d = client.get("/api/dashboard").json()
ap = d["approvals_summary"]
assert len(ap) == 3
titles = [a["title"] for a in ap]
assert "현우님께 회신 초안이 준비됐어요" in titles
assert "Netflix 일시정지를 추천해요" in titles
assert all("치과 예약" not in t for t in titles)
def test_inbox_recent_three_with_type_and_proj(client):
d = client.get("/api/dashboard").json()
inb = d["inbox_recent"]
assert len(inb) == 3
assert inb[0]["type"] in ("task", "event", "idea", "")
assert all("proj_label" in x for x in inb)
assert all("tone" in x for x in inb)
def test_goals_three_with_tone_key(client):
d = client.get("/api/dashboard").json()
goals = d["goals"]
assert len(goals) == 3
assert goals[0]["pct"] == 68
assert goals[0]["tone"] == "blue" # var(--blue) 아님
def test_badges_match_counts(client):
d = client.get("/api/dashboard").json()
b = d["badges"]
assert b["appr"] == 4 # high 3 + 심부름 게이트 1(phase-14)
assert b["task"] == d["task_summary"]["open_count"]
assert b["noti"] == 6