feat(휴가): 협의자 결재·신청 화면 개편(라디오·붙박이 달력·결재 라인)·내 신청 내역

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-02 15:46:19 +09:00
parent f7a3afcebf
commit 97f4a904cd
22 changed files with 1200 additions and 246 deletions
+111
View File
@@ -88,6 +88,45 @@ class ContentTests(unittest.TestCase):
self.assertIn("제출 — 승인 대기", one["text"])
class ConsultMailTests(unittest.TestCase):
"""협의자(2026-11-02) — 협의자마다 자기 몫만, 결재자·통보자는 전체."""
CONSULTS = [{"email": "park@test.local", "name": "박과장", "message": "박과장 전용 <업무>", "state": "대기"},
{"email": "choi@test.local", "name": "최대리", "message": "최대리 전용 내용", "state": "대기"}]
OWNER = {"email": "kim@test.local", "name": "김철수"}
def test_each_consultant_gets_only_own_message_and_others_get_all(self):
store = FakeStore(["lee@test.local"], ["hr@test.local"])
sent = []
with patch("app.mail.send_email", side_effect=lambda **kw: sent.append(kw) or True), patch("app.mail.mail_enabled", return_value=True):
res = notify.deliver(store, None, event="submitted", req=dict(REQ, status="협의중", consults=self.CONSULTS),
actor=self.OWNER, users=USERS, link="https://erp.test/vacation/r1")
self.assertEqual([m["to"] for m in sent], [["park@test.local"], ["choi@test.local"], ["lee@test.local", "hr@test.local"]])
park, choi, line = sent
self.assertIn("[휴가 협의 요청]", park["subject"])
self.assertIn("박과장 전용 &lt;업무&gt;", park["html"])
self.assertNotIn("최대리", park["html"] + park["body"])
self.assertIn("최대리 전용 내용", choi["body"])
self.assertNotIn("박과장", choi["html"] + choi["body"])
for text in ("박과장", "박과장 전용 <업무>", "최대리", "최대리 전용 내용", "협의 진행 중"):
self.assertIn(text, line["body"])
self.assertIn("협의자가 모두 승인하면", line["html"])
self.assertEqual([log["event"] for log in store.logs], ["consult_request", "consult_request", "submitted"])
self.assertTrue(res["ok"])
self.assertEqual(res["to"], ["lee@test.local", "hr@test.local"])
def test_consulted_goes_to_approver_notifier_owner_and_lists_consults(self):
done = [dict(c, state="승인") for c in self.CONSULTS]
store = FakeStore(["lee@test.local"], ["hr@test.local"])
with patch("app.mail.send_email", return_value=True) as smtp, patch("app.mail.mail_enabled", return_value=True):
notify.deliver(store, None, event="consulted", req=dict(REQ, consults=done), actor={"email": "choi@test.local"},
users=USERS, link="x")
kw = smtp.call_args.kwargs
self.assertEqual(smtp.call_count, 1)
self.assertEqual(kw["to"], ["lee@test.local", "hr@test.local", "kim@test.local"])
self.assertIn("[휴가 협의 완료]", kw["subject"])
self.assertIn("협의자 박과장: 승인", kw["body"])
class DeliverTests(unittest.TestCase):
ACTOR = {"email": "lee@test.local", "name": "이팀장"}
@@ -197,6 +236,14 @@ class Store:
self.req.update(status="반려", reject_reason=reason); return dict(self.req)
def list_mail_log(self, request_id):
return []
def consults_ready(self):
return True
def list_consults(self, request_id):
return []
def consults_for(self, request_ids):
return {}
def my_consults(self, email):
return []
def list_balances(self, year):
return []
def used_days(self, user_email, year):
@@ -360,6 +407,70 @@ run(body)
self.assertIn("OK", res.stdout)
def test_consult_access_and_form(self):
"""협의자(2026-11-02) — 폼 값 저장 규칙, 휴가 권한 없는 협의자도 자기 신청은 보고 처리, 다른 협의자 내용은 안 보임."""
res = _run('''
outsider = U("out@test.local"); outsider["modules"] = {}
other = U("other@test.local"); other["modules"] = {}
users.extend([outsider, other])
CONSULTS = [{"email": "out@test.local", "name": "out", "message": "바깥 사람 전용", "state": "대기", "comment": "", "decided_at": None},
{"email": "lee@test.local", "name": "lee", "message": "이팀장 전용", "state": "대기", "comment": "", "decided_at": None}]
class Store3(Store):
created = None
decided = []
def list_consults(self, request_id):
return [dict(c) for c in CONSULTS]
def get_request(self, request_id):
return dict(self.req)
def create_request(self, owner, owner_name, payload, status, consults=None):
Store3.created = {"status": status, "consults": consults, "owner": owner}
return dict(self.req, id="new1")
def decide_consult(self, request_id, email, approve, reason=""):
Store3.decided.append((email, approve, reason))
return dict(self.req, status="제출"), ("consulted" if approve else "rejected")
def list_overlapping(self, date_from, date_to):
return []
def list_pending(self):
return []
st3 = Store3()
st3.req["status"] = "협의중"
FORM = {"vacation_type": "연차", "start_date": "2026-11-03", "end_date": "2026-11-03", "action": "submit"}
def body(c):
main.app.state.vacation_store = st3
who["u"] = kim
# 신청 화면 — 구성원 전체(휴가 권한 없는 사람 포함, 나 빼고)
t = c.get("/vacation/new").text
assert 'data-email="out@test.local"' in t and 'data-email="lee@test.local"' in t and 'data-email="kim@test.local"' not in t
# 제출 — 협의자도 "협의자 없음"도 없으면 400, 작성중 저장은 통과
assert c.post("/vacation/new", data=FORM).status_code == 400
assert c.post("/vacation/new", data=dict(FORM, action="draft")).status_code == 303 and Store3.created["consults"] == []
assert c.post("/vacation/new", data=dict(FORM, no_consult="1")).status_code == 303 and Store3.created["consults"] == []
# 빈 협의 내용이 있어도 사람과 내용 칸이 어긋나지 않음, 본인은 빠짐
r = c.post("/vacation/new", data=dict(FORM, consult_email=["kim@test.local", "lee@test.local", "out@test.local"], consult_message=["나", "", "부탁드립니다"]))
assert r.status_code == 303, r.text
assert Store3.created["consults"] == [{"email": "lee@test.local", "name": "lee", "message": ""},
{"email": "out@test.local", "name": "out", "message": "부탁드립니다"}], Store3.created
assert c.post("/vacation/new", data=dict(FORM, consult_email=["nobody@test.local"], consult_message=[""])).status_code == 400
# 휴가 권한 없는 협의자 — 메일 링크로 자기 신청을 열어 처리, 자기 내용만
who["u"] = outsider
t = c.get("/vacation/r1").text
assert "바깥 사람 전용" in t and "이팀장 전용" not in t and "협의 승인" in t
assert c.get("/vacation/").status_code == 403
assert c.post("/vacation/r1/consult", data={"decision": "approve"}).status_code == 303
assert Store3.decided[-1] == ("out@test.local", True, "") and sent[-1][0] == "consulted", sent
# 협의자가 아니고 권한도 없으면 못 봄
who["u"] = other
assert c.get("/vacation/r1").status_code == 403
# 신청자·결재자는 전체, 내 신청 내역은 라우팅이 신청 id 보다 먼저
who["u"] = kim
t = c.get("/vacation/r1").text
assert "바깥 사람 전용" in t and "이팀장 전용" in t and "협의 승인" not in t
print("OK")
run(body)
''')
self.assertEqual(res.returncode, 0, res.stdout + res.stderr)
self.assertIn("OK", res.stdout)
def test_balances_in_options_settings_and_calendar_holidays(self):
"""2026-10-27 — 잔여 연차는 옵션(관리자, 참여자 전원 아이콘·이름 미리), 설정엔 없음, 달력 공휴일 이름."""
res = _run('''