feat(project): allow text in meeting target/result cells; fix result note save
- Target and result cells accept text such as "20개". Values that parse
as amounts still go to the integer columns; anything else goes to the
new target_text/result_text columns (migration 021).
- Fix: PUT /api/goals/meeting-items/{id} dropped result_note, so the
last-week result text was never saved.
- Update meeting nav test to the month-bounded week numbering.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -220,7 +220,12 @@ function meetServer(env, st) {
|
||||
const id = Number(u.match(/meeting-items\/(\d+)/)[1]);
|
||||
if (st.itemHook) { const r = await st.itemHook(id, body, call); if (r) return r; }
|
||||
const it = st.items[id] = Object.assign(st.items[id] || { id: id }, {});
|
||||
Object.keys(body).forEach(function (k) { it[k] = /amount$/.test(k) ? amount(body[k]) : body[k]; });
|
||||
// 정량 목표·결과 — 숫자면 원 정수, 아니면(예: 20개) 글 칸(021 target_text·result_text) — 서버와 같게
|
||||
Object.keys(body).forEach(function (k) {
|
||||
if (!/amount$/.test(k)) { it[k] = body[k]; return; }
|
||||
const n = amount(body[k]), tk = k.replace("_amount", "_text");
|
||||
if (n != null && isNaN(n)) { it[k] = null; it[tk] = String(body[k]).trim(); } else { it[k] = n; it[tk] = ""; }
|
||||
});
|
||||
return { body: { ok: true, item: Object.assign({ target_amount: null, result_amount: null }, it) } };
|
||||
});
|
||||
env.route("PUT", /\/project\/api\/goals\/meetings\/2026-09-28$/, async function (u, body, call) {
|
||||
@@ -413,6 +418,15 @@ function meetServer(env, st) {
|
||||
await settle(); await wait(10); await settle();
|
||||
check("[2d] 결과 글 → 지난 주차 줄(902)에 저장", st.items[902] && st.items[902].result_note === "결과 메모", st.items);
|
||||
check("[2d] 페이지 새로고침 없음", env.navigations === 0);
|
||||
// 정량 목표·결과에 글(021) — "20개" 는 글 그대로, 숫자는 쉼표 표기
|
||||
const tin = env.d.querySelector('tr[data-item="2"] input[data-field="target_amount"]');
|
||||
tin.focus(); tin.value = "20개"; tin.blur();
|
||||
await settle(); await wait(10); await settle();
|
||||
check("[2d] 정량 목표 글 저장·표시(20개)", st.items[2].target_text === "20개" && tin.value === "20개", [st.items[2], tin.value]);
|
||||
const rin = env.d.querySelector('tr[data-item="2"] input[data-field="result_amount"]');
|
||||
rin.focus(); rin.value = "1200"; rin.blur();
|
||||
await settle(); await wait(10); await settle();
|
||||
check("[2d] 결과 숫자는 쉼표 표기(1,200)", st.items[902].result_amount === 1200 && rin.value === "1,200", rin.value);
|
||||
check("[2d] 금주 목표 입력칸 없음(위쪽 숫자 4칸)", !env.d.getElementById("pj-meet-target") && env.d.querySelectorAll(".pj-meet-top .pj-meet-kpi").length === 4);
|
||||
});
|
||||
|
||||
|
||||
@@ -208,6 +208,35 @@ class MeetingCellTests(unittest.TestCase):
|
||||
self.assertEqual(client.post("/project/api/goals/meeting-cells/merge", json=dict(item_from=1, item_to=2)).status_code, 503)
|
||||
self.assertEqual(client.post(url, json=self.payload).status_code, 200, "Move/formatting work without 019")
|
||||
|
||||
def test_amount_cells_accept_text_after_021_and_result_note_reaches_store(self):
|
||||
"""정량 목표·결과 — 숫자면 원 정수 칸, 글(예: 20개)이면 글 칸(021). 지난주 결과 글(result_note, 020)은 API 를 거쳐 저장된다."""
|
||||
self.st._column_exists = lambda conn, table, col: col in {"content_row_span", "result_note", "target_text"}
|
||||
for r in self.conn.rows.values():
|
||||
r.update(result_note="", target_text="", result_text="")
|
||||
out = self.st.update_meeting_item(item_id=1, fields={"target_amount": "20개", "result_amount": "120만"})
|
||||
self.assertEqual((out["target_amount"], out["target_text"]), (None, "20개"))
|
||||
self.assertEqual((out["result_amount"], out["result_text"]), (1_200_000, ""))
|
||||
out = self.st.update_meeting_item(item_id=1, fields={"target_amount": "1,000"})
|
||||
self.assertEqual((out["target_amount"], out["target_text"]), (1000, ""), "숫자로 바꾸면 글은 지운다")
|
||||
with self.assertRaises(ValueError):
|
||||
self.st.update_meeting_item(item_id=1, fields={"target_amount": "가" * 101})
|
||||
app = FastAPI()
|
||||
app.include_router(api.router)
|
||||
app.state.project_store = self.st
|
||||
client = TestClient(app)
|
||||
with patch.object(api, "_require_user", return_value=dict(role="admin", email="admin@test.local")):
|
||||
r = client.put("/project/api/goals/meeting-items/2", json={"result_note": "잘함", "result_amount": "3박스"})
|
||||
self.assertEqual(r.status_code, 200, r.text)
|
||||
self.assertEqual(self.conn.rows[2]["result_note"], "잘함")
|
||||
self.assertEqual((self.conn.rows[2]["result_amount"], self.conn.rows[2]["result_text"]), (None, "3박스"))
|
||||
# 021 전 — 글은 예전처럼 숫자 오류(400), 숫자는 그대로 저장
|
||||
for k in ("_meeting_v21_ok", "_meeting_v20_ok"):
|
||||
self.st.__dict__.pop(k, None)
|
||||
self.st._column_exists = lambda conn, table, col: col == "content_row_span"
|
||||
with self.assertRaises(ValueError):
|
||||
self.st.update_meeting_item(item_id=3, fields={"target_amount": "20개"})
|
||||
self.assertEqual(self.st.update_meeting_item(item_id=3, fields={"target_amount": "5"})["target_amount"], 5)
|
||||
|
||||
def test_rendered_meeting_keeps_merge_geometry_and_escapes_rich_text(self):
|
||||
from pathlib import Path
|
||||
from jinja2 import ChoiceLoader, DictLoader, Environment, FileSystemLoader
|
||||
|
||||
@@ -18,7 +18,8 @@ class MeetingNavTests(unittest.TestCase):
|
||||
app.include_router(api.router)
|
||||
self.client = TestClient(app)
|
||||
|
||||
def test_saved_weeks_are_grouped_once_under_monday_month(self):
|
||||
def test_saved_weeks_are_grouped_once_under_their_month(self):
|
||||
# 주차는 그 달 안(2026-10-07 규칙) — 9/28 회의록은 9월 5주차(9/28~9/30), 10월 1주차는 10/1~10/4
|
||||
query = Mock(return_value=["2026-09-28", "2026-10-05", "2026-10-19", "2025-12-29", "2026-09-28"])
|
||||
st = SimpleNamespace(list_goal_years=lambda: [2025, 2026, 2027], meeting_weeks=query)
|
||||
with patch.object(api, "_require_user", return_value={"email": "reader@test"}), \
|
||||
@@ -30,11 +31,11 @@ class MeetingNavTests(unittest.TestCase):
|
||||
self.assertEqual([m["month"] for m in years[0]["months"]], [9, 10])
|
||||
september = years[0]["months"][0]["weeks"]
|
||||
self.assertEqual(len(september), 1)
|
||||
self.assertEqual(september[0]["label"], "4주차 (9/28~10/4)")
|
||||
self.assertEqual(september[0]["label"], "5주차 (9/28~9/30)")
|
||||
self.assertEqual(september[0]["href"], "/project/goals/2026/meetings/9?week=2026-09-28")
|
||||
self.assertEqual([w["label"] for w in years[0]["months"][1]["weeks"]],
|
||||
["1주차 (10/5~10/11)", "3주차 (10/19~10/25)"])
|
||||
self.assertEqual(years[1]["months"][0]["weeks"][0]["label"], "5주차 (12/29~1/4)")
|
||||
["2주차 (10/5~10/11)", "4주차 (10/19~10/25)"])
|
||||
self.assertEqual(years[1]["months"][0]["weeks"][0]["label"], "5주차 (12/29~12/31)")
|
||||
query.assert_called_once_with(start=date(2025, 1, 1), end=date(2027, 12, 31))
|
||||
|
||||
def test_no_meetings_returns_empty_tree(self):
|
||||
|
||||
@@ -760,7 +760,15 @@ def test_goal_meetings():
|
||||
put = lambda iid, body, who=ADMIN: req("PUT", f"/project/api/goals/meeting-items/{iid}", who, json=body) # noqa: E731
|
||||
r = put(coupang["id"], {"content": "추석 타임딜", "target_amount": "1,200만"})
|
||||
assert r.status_code == 200 and r.json()["item"]["target_amount"] == 12_000_000, r.text
|
||||
assert put(coupang["id"], {"target_amount": "abc"}).status_code == 400
|
||||
# 숫자가 아닌 정량 목표 — 021 이면 글 칸(target_text), 전이면 400
|
||||
with ST._pool.connection() as conn: # noqa: SLF001
|
||||
v21 = ST._meeting_v21(conn) # noqa: SLF001
|
||||
r = put(coupang["id"], {"target_amount": "abc"})
|
||||
if v21:
|
||||
assert r.status_code == 200 and r.json()["item"]["target_text"] == "abc" and r.json()["item"]["target_amount"] is None, r.text
|
||||
else:
|
||||
assert r.status_code == 400
|
||||
assert put(coupang["id"], {"target_amount": "1,200만"}).json()["item"]["target_amount"] == 12_000_000
|
||||
assert put(coupang["id"], {"status": "bogus"}).status_code == 400
|
||||
assert put(coupang["id"], {"content": "x"}, BOB).status_code == 403
|
||||
assert req("PUT", f"/project/api/goals/meetings/{w1}", ADMIN,
|
||||
|
||||
Reference in New Issue
Block a user