feat(project): 연간 목표 상·하반기 칸·반기 접기·이름 바로 수정·월 칸 병합·로아스 %
- 6월·12월 오른쪽에 상반기·하반기 칸 추가. 매출 목표·실적은 반기 합계, 달성률은 연간과 같은 규칙, 업무 영역 글 칸은 month 13·14 로 저장 - 반기 칸 머리 버튼으로 1~6월 / 7~12월 칸을 접었다 펴기(너비 애니메이션, localStorage pj_goal_fold). 표를 width:1px + table-layout:fixed 로 바꿔 펼칠 때도 애니메이션이 적용되게 함 - 업무 영역·줄 이름을 눌러 그 자리에서 수정(✎ 버튼 제거) - 월 칸 가로 병합(goal_cell_merges, 반기 안에서만): Shift+클릭 선택 후 병합 버튼, 우클릭 메뉴로 좌/우 병합·해제. 병합 시 글은 월 순서대로 첫 칸에 모음 - 로아스 목표·실적 칸 % 표기 - 마이그레이션 014 (goal_cells month CHECK 0~14, goal_cell_merges) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -456,6 +456,75 @@ def test_store_date_range_unit():
|
||||
raise AssertionError(args)
|
||||
|
||||
|
||||
def test_store_goal_merge_unit():
|
||||
from app.modules.project import store
|
||||
assert store.validate_goal_merge(3, 1) == (1, 3)
|
||||
assert store.validate_goal_merge(7, 12) == (7, 12)
|
||||
assert store.validate_goal_month(13, allow_year=True) == 13
|
||||
for args in ((6, 7), (3, 3), (0, 2), (11, 13)):
|
||||
try:
|
||||
store.validate_goal_merge(*args)
|
||||
except ValueError:
|
||||
continue
|
||||
raise AssertionError(args)
|
||||
|
||||
|
||||
# ════════════════════════════════════════════════════════════
|
||||
# 연간 목표 — 상·하반기 글 칸 · 월 칸 병합(마이그레이션 014) · 로아스 % 표기
|
||||
# ════════════════════════════════════════════════════════════
|
||||
def test_goal_halves_and_merges():
|
||||
year = 2060 + int(RUN, 16) % 40
|
||||
ST.delete_goal_year(year=year) if year in ST.list_goal_years() else None
|
||||
assert req("POST", "/project/api/goals/years", ADMIN, json={"year": year}).status_code == 201
|
||||
try:
|
||||
board = ST.get_goal_board(year=year)
|
||||
assert board["halves"] is True, "마이그레이션 014 적용 필요"
|
||||
rid = board["areas"][0]["rows"][0]["id"]
|
||||
cell = lambda m, body, who=ADMIN: req( # noqa: E731
|
||||
"PUT", f"/project/api/goals/rows/{rid}/cells/{m}", who, json={"body": body})
|
||||
# 상·하반기 글 칸(13·14), 범위 밖(15)은 400, 비관리자는 403
|
||||
assert cell(13, "상반기 글").status_code == 200 and cell(14, "하반기 글").status_code == 200
|
||||
assert cell(15, "x").status_code == 400
|
||||
assert cell(13, "y", BOB).status_code == 403
|
||||
for m, body in ((2, "이월"), (3, "삼월"), (5, "오월")):
|
||||
assert cell(m, body).status_code == 200
|
||||
merge = lambda s, e: req( # noqa: E731
|
||||
"POST", f"/project/api/goals/rows/{rid}/merge", ADMIN, json={"start": s, "end": e})
|
||||
# 반기를 넘는 병합·한 칸 병합은 400
|
||||
assert merge(5, 8).status_code == 400 and merge(4, 4).status_code == 400
|
||||
r = merge(2, 3)
|
||||
assert r.status_code == 200 and r.json() == {"ok": True, "start": 2, "span": 2}, r.text
|
||||
cells = ST.get_goal_board(year=year)["areas"][0]["rows"][0]["cells"]
|
||||
assert cells[2] == "이월\n삼월" and 3 not in cells
|
||||
# 병합된 칸의 가운데 월에 늦게 온 저장은 거절(글은 시작 월에만)
|
||||
assert cell(3, "늦은 저장").status_code == 400
|
||||
# 걸친 병합은 흡수: 3~5 → 2~5, 글은 월 순서대로 이어진다
|
||||
r = merge(3, 5)
|
||||
assert r.json() == {"ok": True, "start": 2, "span": 4}, r.text
|
||||
row = ST.get_goal_board(year=year)["areas"][0]["rows"][0]
|
||||
assert row["merges"] == {2: 4} and row["cells"][2] == "이월\n삼월\n오월" and 5 not in row["cells"]
|
||||
assert row["cells"][13] == "상반기 글" and row["cells"][14] == "하반기 글"
|
||||
# 해제 — 글은 시작 월에 남음, 없는 병합 해제는 404
|
||||
assert req("DELETE", f"/project/api/goals/rows/{rid}/merge/2", ADMIN).status_code == 200
|
||||
assert req("DELETE", f"/project/api/goals/rows/{rid}/merge/2", ADMIN).status_code == 404
|
||||
row = ST.get_goal_board(year=year)["areas"][0]["rows"][0]
|
||||
assert row["merges"] == {} and row["cells"][2] == "이월\n삼월\n오월"
|
||||
# 로아스 % 표기(입력에 % 가 있어도 숫자로 저장)
|
||||
r = req("PUT", f"/project/api/goals/{year}/metrics", ADMIN,
|
||||
json={"metric": "roas", "kind": "target", "month": 1, "value": "499%"})
|
||||
assert r.status_code == 200 and r.json()["label"] == "499%" and r.json()["value"] == 499
|
||||
r = req("PUT", f"/project/api/goals/{year}/metrics", ADMIN,
|
||||
json={"metric": "sales", "kind": "target", "month": 1, "value": "1,200"})
|
||||
assert r.json()["label"] == "1,200"
|
||||
# 영역·줄 이름(그 자리 수정이 쓰는 API) — 영역 이름은 빈 값 400, 줄 이름은 빈 값 허용
|
||||
aid = ST.get_goal_board(year=year)["areas"][0]["id"]
|
||||
assert req("PUT", f"/project/api/goals/areas/{aid}", ADMIN, json={"name": ""}).status_code == 400
|
||||
assert req("PUT", f"/project/api/goals/areas/{aid}", ADMIN, json={"name": "상품2"}).status_code == 200
|
||||
assert req("PUT", f"/project/api/goals/rows/{rid}", ADMIN, json={"label": ""}).status_code == 200
|
||||
finally:
|
||||
ST.delete_goal_year(year=year)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if not ENABLED:
|
||||
print("SKIP: PROJECT_TEST_DB_URL(localhost) not set")
|
||||
|
||||
Reference in New Issue
Block a user