# phase-3 §7.2 — 리스크 정확성 (시드 기준)
def test_risk_delay_top1(client):
    # k1(분기 리포트 초안 마무리, due 6/8, doing) → 지연 위험 1건
    r = client.get("/api/risks?area=work").json()
    delay = [x for x in r if x["kind"] == "지연 위험"]
    assert len(delay) == 1
    assert delay[0]["tone"] == "coral" and delay[0]["icon"] == "clock"
    assert delay[0]["task_id"] == "k1"
    assert "6/8" in delay[0]["text"] and "진행 중" in delay[0]["text"]
    assert delay[0]["cta"] == "작업 열기"


def test_risk_dependency(client):
    # 예산 섹션 작성(미완) → 경영진 검토 요청 메일(미완) : violet, cta="후속 작업 보기"
    r = client.get("/api/risks?area=work").json()
    dep = [x for x in r if x["kind"] == "의존성"]
    assert len(dep) == 1 and dep[0]["tone"] == "violet"
    assert "예산 섹션 작성" in dep[0]["text"] and "경영진 검토 요청 메일" in dep[0]["text"]
    assert dep[0]["cta"] == "후속 작업 보기"


def test_risk_overload(client):
    r = client.get("/api/risks?area=work").json()
    over = [x for x in r if x["kind"] == "업무 쏠림"]
    assert len(over) <= 1
    if over:
        assert over[0]["tone"] == "amber" and over[0]["task_id"] is None


def test_risks_max_three(client):
    assert len(client.get("/api/risks?area=work").json()) <= 3


def test_risks_life_scope_ok(client):
    r = client.get("/api/risks?area=life")
    assert r.status_code == 200
