feat(vacation): 달력 공휴일 이름 · 잔여 연차를 옵션으로(참여자 표) · 연차 차감·12/31 소멸
- 쉬는 날 = 국경일·대체공휴일(project KR_HOLIDAYS, 2026~2030) + 휴가 설정 공휴일(덮어쓰기, 빨강 해제 = 근무일) — db.holiday_map 한 곳 (달력·날짜 팝업·일수 계산), 메인 달력은 날짜 아래 이름 + 그 주 막대 내림 - 잔여 연차 등록을 설정 → 옵션(관리자): 참여자 전원 아이콘·이름 미리 보여 주는 표, 사용·잔여·작년 참고, 한꺼번에 저장(save_balances) - 사용 연차 = 승인된 연차·오전반차·오후반차만(병가·경조·대체휴무·기타 제외), 해를 넘는 신청은 해마다 나눔, 연도별 12/31 소멸 안내 - 옵션 화면 카드가 화면 높이에 눌려 잘리던 것·입력 칸 최소 너비 수정 - 테스트: 실제 PG(holiday_map·used_days·save_balances), 실제 앱(옵션 표·저장 권한·설정 없음·달력 이름) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -197,9 +197,12 @@ class Store:
|
||||
self.req.update(status="반려", reject_reason=reason); return dict(self.req)
|
||||
def list_mail_log(self, request_id):
|
||||
return []
|
||||
def list_holidays(self, year=None):
|
||||
return [{"holiday_date": f"{year}-10-09", "name": "한글날", "is_red": True},
|
||||
{"holiday_date": f"{year}-05-01", "name": "근로자의날(회사)", "is_red": False}]
|
||||
def list_balances(self, year):
|
||||
return []
|
||||
def used_days(self, user_email, year):
|
||||
return 0.0
|
||||
def holiday_map(self, date_from, date_to): # 국경일 + 설정 공휴일(db.holiday_map) — 해마다 한글날만
|
||||
return {f"{y}-10-09": "한글날" for y in range(int(date_from[:4]), int(date_to[:4]) + 1)}
|
||||
|
||||
st = Store()
|
||||
|
||||
@@ -330,5 +333,77 @@ run(body)
|
||||
self.assertIn("OK", res.stdout)
|
||||
|
||||
|
||||
def test_balances_in_options_settings_and_calendar_holidays(self):
|
||||
"""2026-10-27 — 잔여 연차는 옵션(관리자, 참여자 전원 아이콘·이름 미리), 설정엔 없음, 달력 공휴일 이름."""
|
||||
res = _run('''
|
||||
lee["picture"] = "https://img.test/lee.png"
|
||||
saved = {}
|
||||
class Store2(Store):
|
||||
def list_balances(self, year):
|
||||
return [{"user_email": "lee@test.local", "year": year, "total_days": 15, "memo": "입사 2020"},
|
||||
{"user_email": "gone@test.local", "year": year, "total_days": 10, "memo": ""}] if year == 2026 else \
|
||||
[{"user_email": "kim@test.local", "year": year, "total_days": 12, "memo": ""}]
|
||||
def used_days(self, user_email, year):
|
||||
return {"lee@test.local": 4.5}.get(user_email, 0.0)
|
||||
def save_balances(self, year, rows):
|
||||
saved.update(year=year, rows=rows); return len(rows)
|
||||
def list_holidays(self, year=None):
|
||||
return []
|
||||
def holiday_map(self, date_from, date_to):
|
||||
return {d: n for d, n in {"2026-10-03": "개천절", "2026-10-05": "개천절 대체", "2026-10-09": "한글날"}.items()
|
||||
if date_from <= d <= date_to}
|
||||
def list_overlapping(self, date_from, date_to):
|
||||
return []
|
||||
def balance_summary(self, user_email, year):
|
||||
return {"year": year, "total_days": 15.0, "used_days": 4.5, "remaining_days": 10.5, "memo": ""}
|
||||
def list_pending(self):
|
||||
return []
|
||||
st2 = Store2()
|
||||
def body(c):
|
||||
main.app.state.vacation_store = st2
|
||||
who["u"] = admin
|
||||
r = c.get("/vacation/options?year=2026")
|
||||
assert r.status_code == 200, r.status_code
|
||||
t = r.text
|
||||
assert 'id="balances"' in t and "2026년 · 참여자 4명" in t, t[t.find("잔여 연차"):t.find("잔여 연차") + 200]
|
||||
for u in users: # 참여자 전원 미리(이름 + 이메일 + 줄마다 칸)
|
||||
assert f'name="email" value="{u["email"]}"' in t, u["email"]
|
||||
assert 'src="https://img.test/lee.png"' in t # 사진 있으면 사진, 없으면 첫 글자
|
||||
assert '<span class="vac-opt-face is-ini">k</span>' in t
|
||||
assert "gone@test.local · 휴가 권한 없음" in t # 예전에 등록된 사람도 보여 줌
|
||||
i = t.index('name="email" value="lee@test.local"')
|
||||
row = t[i:i + 900]
|
||||
assert 'value="15"' in row and ">4.5<" in row and ">10.5<" in row and 'value="입사 2020"' in row, row
|
||||
j = t.index('name="email" value="kim@test.local"')
|
||||
assert 'placeholder="12"' in t[j:j + 600], t[j:j + 600] # 올해 없음 → 작년 연차를 회색 참고
|
||||
assert "2026.12.31 에 소멸" in t and "승인되면" in t
|
||||
# 저장 — 빈 칸은 건너뜀, 연도·이메일·메모 그대로
|
||||
r = c.post("/vacation/options/balances", data={"year": "2026", "email": ["lee@test.local", "kim@test.local", "chip@test.local"],
|
||||
"total": ["16", "", "15.5"], "memo": ["a", "b", "c"]})
|
||||
assert r.status_code == 303 and "year=2026" in r.headers["location"], r.status_code
|
||||
assert saved == {"year": 2026, "rows": [{"user_email": "lee@test.local", "total_days": 16.0, "memo": "a"},
|
||||
{"user_email": "chip@test.local", "total_days": 15.5, "memo": "c"}]}, saved
|
||||
assert c.post("/vacation/options/balances", data={"year": "2026", "email": ["lee@test.local"], "total": ["x"], "memo": [""]}).status_code == 400
|
||||
# 관리자 아님 — 표 안 보임, 저장 403
|
||||
who["u"] = kim
|
||||
assert 'id="balances"' not in c.get("/vacation/options").text
|
||||
assert c.post("/vacation/options/balances", data={"year": "2026", "email": ["kim@test.local"], "total": ["30"], "memo": [""]}).status_code == 403
|
||||
# 설정 — 잔여 연차 입력 없음(옵션 안내)
|
||||
who["u"] = admin
|
||||
t = c.get("/vacation/settings?year=2026").text
|
||||
assert "/vacation/settings/balances" not in t and "/vacation/options?year=2026#balances" in t
|
||||
assert c.post("/vacation/settings/balances", data={"user_email": "a@test.local", "year": "2026", "total_days": "1"}).status_code in (404, 405)
|
||||
# 달력 — 국경일·대체공휴일 이름이 날짜 아래, 그 주는 has-hol, 잔여 옆 12/31 소멸
|
||||
t = c.get("/vacation/?year=2026&month=10").text
|
||||
assert '<span class="vac-hol-name">개천절</span>' in t and '<span class="vac-hol-name">개천절 대체</span>' in t
|
||||
assert '<span class="vac-hol-name">한글날</span>' in t and t.count("has-hol") == 2, t.count("has-hol")
|
||||
assert "2026.12.31 소멸" in t
|
||||
print("OK")
|
||||
run(body)
|
||||
''')
|
||||
self.assertEqual(res.returncode, 0, res.stdout + res.stderr)
|
||||
self.assertIn("OK", res.stdout)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user