# backend/tests/test_api_notify.py def test_triage_counts(client): t = client.get("/api/notifications").json() assert len(t["now"]) == 6 assert t["counts"]["later"] == 12 # 6 + later_more(6) assert t["counts"]["held"] == 29 # 6 + held_more(23) assert t["stats"] == {"total": 47, "seen": 6, "filtered": "87%"} def test_now_has_why_chip(client): n1 = next(n for n in client.get("/api/notifications").json()["now"] if n["id"] == "n1") assert n1["why"] == "VIP 발신자" and n1["tone"] == "coral" and n1["act"] == "답장 초안 보기" def test_reclassify_to_later(client): r = client.post("/api/notifications/n1/reclassify", json={"to_bucket": "later"}) assert ( r.json()["bucket"] == "later" and r.json()["why"] == "내가 미룸" and r.json()["tone"] == "muted" ) def test_undo_held_to_now(client): r = client.post("/api/notifications/h2/undo", json={}) assert ( r.json()["bucket"] == "now" and r.json()["why"] == "되돌림" and r.json()["tone"] == "amber" ) def test_guard_toggle(client): assert client.post("/api/notifications/guard", json={"on": False}).json()["on"] is False def test_senders_have_from_alias(client): rows = client.get("/api/notifications/senders").json() assert ( rows[0]["who"] == "수아님" and rows[0]["from"] == "메일 · 메신저" and rows[0]["rule"] == "항상 즉시" ) def test_add_sender(client): r = client.post( "/api/notifications/senders", json={ "who": "뉴스레터 X", "from_label": "메일", "rule": "저녁 다이제스트", "bucket": "later", }, ) assert r.json()["bucket"] == "later" def test_digests(client): rows = client.get("/api/notifications/digests").json() assert len(rows) == 3 assert rows[2]["done"] is False # 저녁 다이제스트 미전달 def test_notification_404(client): assert client.post("/api/notifications/nope/undo", json={}).status_code == 404