feat(project): add cell moves and width menus
This commit is contained in:
@@ -499,6 +499,55 @@ def test_store_goal_quarters_unit():
|
||||
# ════════════════════════════════════════════════════════════
|
||||
# 연간 목표 — 상·하반기 글 칸 · 월 칸 병합(마이그레이션 014) · 로아스 % 표기
|
||||
# ════════════════════════════════════════════════════════════
|
||||
def test_goal_cell_content_move():
|
||||
"""실제 PostgreSQL: 서식 포함 이동·동시 이동 충돌·권한·병합 가림·응답 유실 재시도."""
|
||||
from app.modules.project import store
|
||||
year = 2060 + int(RUN, 16) % 40
|
||||
assert req("POST", "/project/api/goals/years", ADMIN, json={"year": year}).status_code == 201
|
||||
try:
|
||||
board = ST.get_goal_board(year=year)
|
||||
rid = board["areas"][0]["rows"][0]["id"]
|
||||
rich = store.validate_goal_text(store.GOAL_RICH_PREFIX + '[{"text":"move","color":"#ff0000","size":24,"bold":true,"italic":true,"underline":true}]')
|
||||
ST.set_goal_cell(row_id=rid, month=1, body=rich)
|
||||
payload = {"source_row": rid, "source_month": 1, "target_row": rid, "target_month": 2,
|
||||
"source_body": rich, "target_body": "", "body": rich}
|
||||
endpoint = "/project/api/goals/cells/move"
|
||||
assert req("POST", endpoint, BOB, json=payload).status_code == 403
|
||||
assert req("POST", endpoint, ADMIN, json=payload | {"target_month": 17}).status_code == 400
|
||||
ST.set_goal_cell(row_id=rid, month=2, body="another edit")
|
||||
assert req("POST", endpoint, ADMIN, json=payload).status_code == 409
|
||||
ST.set_goal_cell(row_id=rid, month=2, body="")
|
||||
assert req("POST", endpoint, ADMIN, json=payload).json() == {"ok": True, "body": rich}
|
||||
assert req("POST", endpoint, ADMIN, json=payload).status_code == 200
|
||||
cells = ST.get_goal_board(year=year)["areas"][0]["rows"][0]["cells"]
|
||||
assert 1 not in cells and cells[2] == rich
|
||||
|
||||
# 같은 원본을 서로 다른 대상으로 동시에 이동하면 한 요청만 성공한다.
|
||||
ST.set_goal_cell(row_id=rid, month=1, body=rich)
|
||||
ST.set_goal_cell(row_id=rid, month=2, body="")
|
||||
barrier = threading.Barrier(2)
|
||||
results = []
|
||||
def move_to(month):
|
||||
barrier.wait()
|
||||
try:
|
||||
ST.move_goal_cell(source_row=rid, source_month=1, target_row=rid, target_month=month,
|
||||
source_body=rich, target_body="", body=rich, updated_by=ADMIN)
|
||||
results.append("ok")
|
||||
except store.GoalCellConflict:
|
||||
results.append("conflict")
|
||||
workers = [threading.Thread(target=move_to, args=(m,)) for m in (2, 3)]
|
||||
for t in workers: t.start()
|
||||
for t in workers: t.join(timeout=10)
|
||||
assert sorted(results) == ["conflict", "ok"], results
|
||||
aid = board["areas"][0]["id"]
|
||||
ST.merge_goal_rect(area_id=aid, row_from=rid, row_to=rid, col_from=4, col_to=5)
|
||||
hidden = payload | {"source_month": 2 if 2 in ST.get_goal_board(year=year)["areas"][0]["rows"][0]["cells"] else 3,
|
||||
"target_month": 5}
|
||||
assert req("POST", endpoint, ADMIN, json=hidden).status_code == 409
|
||||
finally:
|
||||
ST.delete_goal_year(year=year)
|
||||
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user