feat(project): blinking popup for new mentions and task assignments

Project pages poll GET /api/notifications/alerts every 20s (and when the
tab becomes visible). New unread mention/assigned notifications show in a
large blinking popup at the bottom center until closed; closing in one tab
closes it in the others. A new browser starts from the latest id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-07 17:30:15 +09:00
parent 4bdab1de3d
commit 21fc78adb9
5 changed files with 206 additions and 0 deletions
+26
View File
@@ -727,6 +727,32 @@ function titleVal(d) { return d.getElementById("pj-t-title").value; }
check("[대시보드 담당자별] 항목 → 작업 편집 창(하위 작업은 서버에서 받아)", !env.d.getElementById("pj-modal-task").hidden &&
env.d.getElementById("pj-t-title").value === "하위 2", env.d.getElementById("pj-t-title").value);
}
// ── 나를 태그·작업 배정 알림 팝업 — 본 것 이후 새 알림만, 깜박이는 팝업, 닫기 전까지 유지 ──
{
const env = makeEnv(); baseRoutes(env);
const asked = [];
env.route("GET", /\/project\/api\/notifications\/alerts/, function (u) {
asked.push(u);
const after = /after=(\d+)/.exec(u);
if (!after) return { body: { me: "me@test.local", latest_id: 5, alerts: [] } };
return { body: { me: "me@test.local", latest_id: 5, alerts: [
{ id: 4, type: "assigned", title: "작업 배정: 촬영 준비", body: "P1 · 마감 -", task_id: 101, project_id: 1, actor_email: "bob@test.local" },
{ id: 5, type: "mention", title: "나를 태그함: 작업 A", body: "P1 · 댓글", task_id: 101, project_id: 1, actor_email: "bob@test.local" }] } };
});
env.w.localStorage.setItem("pj_alert_seen:me@test.local", "3");
await boot(env); await settle(); await wait(10); await settle();
const pop = env.d.body.querySelector(".pj-alert-pop");
check("[알림 팝업] 본 것(3) 이후 새 알림 2건을 body 에 팝업", !!pop && pop.querySelectorAll(".pj-alert-item").length === 2 &&
/촬영 준비/.test(pop.textContent) && /나를 태그/.test(pop.textContent) && asked.some(function (u) { return /after=3/.test(u); }), asked);
pop.querySelector("[data-alert-close]").click();
check("[알림 팝업] 닫기 → 사라지고 본 것 = 5", !env.d.body.querySelector(".pj-alert-pop") && env.w.localStorage.getItem("pj_alert_seen:me@test.local") === "5");
}
{
const env = makeEnv(); baseRoutes(env);
env.route("GET", /\/project\/api\/notifications\/alerts/, function () { return { body: { me: "me@test.local", latest_id: 9, alerts: [] } }; });
await boot(env); await settle();
check("[알림 팝업] 처음 쓰는 브라우저 — 옛 알림 안 띄우고 기준점만", !env.d.body.querySelector(".pj-alert-pop") && env.w.localStorage.getItem("pj_alert_seen:me@test.local") === "9");
}
// ── 멤버 배정·제외 — 지금 멤버는 체크된 채로, 체크 = 배정 · 해제 = 제외(확인 뒤) ──
{
const env = makeEnv(adminHtml); baseRoutes(env);
+49
View File
@@ -0,0 +1,49 @@
"""알림 팝업 API — 기준점·태그/배정만·읽지 않은 것·after 이후·오래된 것부터. DB 없이 가짜 저장소로."""
import importlib
import unittest
from unittest.mock import patch
from fastapi import FastAPI
from fastapi.testclient import TestClient
api = importlib.import_module("app.modules.project.router")
ROWS = [ # 최신순(list_notifications 와 같게)
{"id": 9, "type": "completed", "title": "완료", "is_read": False, "task_id": 1, "project_id": 1},
{"id": 8, "type": "mention", "title": "나를 태그함: A", "is_read": False, "task_id": 1, "project_id": 1},
{"id": 7, "type": "assigned", "title": "작업 배정: B", "is_read": True, "task_id": 2, "project_id": 1},
{"id": 6, "type": "assigned", "title": "작업 배정: C", "is_read": False, "task_id": 3, "project_id": 1},
{"id": 2, "type": "assigned", "title": "작업 배정: 옛것", "is_read": False, "task_id": 4, "project_id": 1},
]
class FakeStore:
def list_notifications(self, recipient_email, unread_only=False, limit=100):
rows = [r for r in ROWS if not unread_only or not r["is_read"]]
return rows[:limit]
class AlertsApiTests(unittest.TestCase):
def setUp(self):
app = FastAPI()
app.include_router(api.router)
self.client = TestClient(app)
def get(self, qs=""):
with patch.object(api, "_require_user", return_value={"email": "Me@Test.local"}), \
patch.object(api, "_db_or_503", return_value=FakeStore()), \
patch.object(api, "_visible_notifications", side_effect=lambda st, user, items: items):
return self.client.get("/project/api/notifications/alerts" + qs).json()
def test_without_after_returns_only_baseline(self):
out = self.get()
self.assertEqual((out["me"], out["latest_id"], out["alerts"]), ("me@test.local", 9, []))
def test_after_returns_unread_mentions_and_assignments_oldest_first(self):
out = self.get("?after=5")
self.assertEqual([a["id"] for a in out["alerts"]], [6, 8]) # 완료 알림(9)·읽은 것(7)·옛것(2) 제외
self.assertEqual(out["alerts"][1]["type"], "mention")
if __name__ == "__main__":
unittest.main()