feat(project): 섹션째 다른 프로젝트로 · 회의록 글 칸 하이퍼링크 · 업무 등록 표 하위 업무·줄 클릭 업무 창

- 보드 섹션 머리를 왼쪽 프로젝트 목록에 놓으면 확인 창 → POST /api/stages/{id}/move-project
  (db.move_stage_to_project 한 트랜잭션: 섹션 + 업무 + 세부 업무, 대상 맨 끝, 원·대상 멤버만, 남의 연결은 원 프로젝트에 섹션 없음)
- 목표·회의록 글 칸 서식 도구 🔗 — pj-rich 조각 link(http(s)만, 서버 store.goal_link), 주소 붙여넣기 = 링크, Ctrl+클릭 = 새 탭
- 회의록 업무 등록 표: 등록된 줄 [+] = 바로 아래 세부 업무 초안, 세부 업무 줄은 상위 줄 아래 들여쓰기,
  등록된 줄 어디든 클릭 = 오른쪽 업무 창, ↳ 상위 = 상위 업무 창
- 도움말·CLAUDE.md·PROJECT_MODULE.md 6-26, 정적 파일 버전 20261026a
- 테스트: test_move_stage_to_other_project(실제 PG), 링크 서버 검증, project_ui [섹션 이동], goals_meeting_ui [2g5],
  goal_text_link.browser.test.js

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-26 12:29:14 +09:00
parent 3d14ff4a85
commit 96f54db0b1
24 changed files with 741 additions and 51 deletions
+135
View File
@@ -0,0 +1,135 @@
// 목표·회의록 칸 하이퍼링크(2026-10-26) — 실제 브라우저(Chromium).
// python tests/js/render_goals.py
// NODE_PATH=<playwright 경로> PJ_TEST_BROWSER=<Chrome 경로> node tests/js/goal_text_link.browser.test.js
// 회의록 "주요 업무" 칸과 같은 편집 칸(.pj-goal-text contenteditable + PJGoalText) + 렌더한 회의록 화면의 서식 도구:
// 글자 선택 → 🔗 → 주소 Enter = 링크(값 = pj-rich 조각 link), 주소만 붙여 넣기 = 링크, Ctrl+클릭 = 새 탭, [링크 삭제] = 링크만 뺌,
// http(s) 아닌 주소는 거절.
const fs = require("fs"), path = require("path");
const { chromium } = require("playwright");
const ROOT = path.join(__dirname, "..", "..");
const fails = [];
function check(name, cond, extra) {
if (cond) console.log("PASS " + name);
else { console.log("FAIL " + name + (extra !== undefined ? " → " + JSON.stringify(extra) : "")); fails.push(name); }
}
const css = fs.readFileSync(path.join(ROOT, "app", "static", "project.css"), "utf8");
const js = fs.readFileSync(path.join(ROOT, "app", "static", "project-goal-text.js"), "utf8");
const meeting = fs.readFileSync(path.join(__dirname, ".out", "meeting_admin.html"), "utf8");
const toolbar = (function () {
const i = meeting.indexOf('<div class="pj-goal-format" id="pj-goal-format"');
if (i < 0) throw new Error("회의록 화면에 서식 도구가 없습니다 — render_goals.py 를 먼저");
// 짝 맞는 </div> 까지
let depth = 0, j = i;
const re = /<div\b|<\/div>/g;
re.lastIndex = i;
let m;
while ((m = re.exec(meeting))) {
depth += m[0] === "</div>" ? -1 : 1;
if (!depth) { j = m.index + 6; break; }
}
return meeting.slice(i, j);
})();
const PAGE = "<!doctype html><meta charset=utf-8><style>" + css + "</style><body style='padding:120px 40px'>" +
"<div class='pane'><table class='pj-meet-table'><tbody><tr><td data-meet-item='1'>" +
"<div class='pj-meet-text pj-goal-text' contenteditable='true' style='min-width:300px;min-height:40px;font-size:14px'>네이버 바로가기</div>" +
"</td></tr></tbody></table></div>" + toolbar +
"<script>" + js + "</script><script>const ed=document.querySelector('.pj-goal-text');PJGoalText.attach(ed);" +
"PJGoalText.init(document.querySelector('table'),document.getElementById('pj-goal-format'));</script></body>";
(async function () {
const exe = process.env.PJ_TEST_BROWSER;
const browser = await chromium.launch(exe ? { executablePath: exe } : {});
const ctx = await browser.newContext({ viewport: { width: 1000, height: 600 } });
try {
const p = await ctx.newPage();
await ctx.route("**/*", function (r) {
if (new URL(r.request().url()).host === "goal.test") r.fulfill({ status: 200, contentType: "text/html; charset=utf-8", body: PAGE });
else r.fulfill({ status: 200, contentType: "text/html", body: "<title>opened</title>" });
});
await p.goto("http://goal.test/");
const select = function (from, to) {
return p.evaluate(function (a) {
const ed = document.querySelector(".pj-goal-text"); ed.focus();
const t = ed.firstChild, r = document.createRange();
r.setStart(t, a[0]); r.setEnd(t, a[1]);
const s = getSelection(); s.removeAllRanges(); s.addRange(r);
document.dispatchEvent(new Event("selectionchange"));
}, [from, to]);
};
const value = function () { return p.evaluate(function () { return document.querySelector(".pj-goal-text").value; }); };
await select(0, 3);
await p.waitForTimeout(50);
const btn = p.locator('[data-goal-format="link"]');
check("서식 도구에 🔗 링크 버튼(선택하면 켜짐)", await btn.isVisible() && await btn.isEnabled());
await btn.click();
const inp = p.locator(".pj-goal-link-input");
check("🔗 → 주소 칸이 열리고 포커스", await inp.isVisible() && await p.evaluate(function () {
return document.activeElement === document.querySelector(".pj-goal-link-input");
}));
// http(s) 아닌 주소 거절
await inp.fill("javascript:alert(1)");
await inp.press("Enter");
check("javascript: 주소는 거절(칸 그대로·값 변화 없음)", await inp.isVisible() && (await value()) === "네이버 바로가기", await value());
// 스킴 없는 주소 → https:// 붙여 링크
await inp.fill("naver.com");
await inp.press("Enter");
await p.waitForTimeout(30);
const v1 = await value();
let runs = [];
try { runs = JSON.parse(v1.slice("pj-rich:v1:".length)); } catch (_) {}
check("주소 Enter → 고른 글자만 링크(https:// 붙임), 나머지는 그대로",
v1.startsWith("pj-rich:v1:") && runs.length === 2 && runs[0].text === "네이버" && runs[0].link === "https://naver.com" &&
runs[1].text === " 바로가기" && !runs[1].link, v1);
const a = await p.evaluate(function () {
const el = document.querySelector(".pj-goal-text a.pj-goal-link");
return el && { href: el.getAttribute("href"), target: el.target, rel: el.rel, text: el.textContent, color: getComputedStyle(el).color };
});
check("칸에 파란 밑줄 링크(새 탭·noopener)", !!a && a.href === "https://naver.com" && a.target === "_blank" &&
/noopener/.test(a.rel) && a.text === "네이버" && a.color === "rgb(37, 99, 235)", a);
// 그냥 클릭 = 열리지 않음, Ctrl+클릭 = 새 탭
let opened = 0;
ctx.on("page", function () { opened++; });
await p.click(".pj-goal-text a.pj-goal-link");
await p.waitForTimeout(150);
check("편집 칸 링크 그냥 클릭 = 새 탭 안 열림", opened === 0, opened);
const [np] = await Promise.all([ctx.waitForEvent("page"), p.click(".pj-goal-text a.pj-goal-link", { modifiers: ["Control"] })]);
await np.waitForURL(/naver\.com/, { timeout: 5000 }).catch(function () {});
check("Ctrl+클릭 = 새 탭으로 링크 열기", !!np && /naver\.com/.test(np.url()), np && np.url());
if (np) await np.close();
// 링크 다시 고르면 🔗 눌림·주소 채움 → [링크 삭제]
await p.evaluate(function () {
const ed = document.querySelector(".pj-goal-text"), a = ed.querySelector("a"); ed.focus();
const r = document.createRange(); r.selectNodeContents(a);
const s = getSelection(); s.removeAllRanges(); s.addRange(r);
document.dispatchEvent(new Event("selectionchange"));
});
await p.waitForTimeout(50);
check("링크 글자 선택 → 🔗 눌림 표시", (await btn.getAttribute("aria-pressed")) === "true");
await btn.click();
check("주소 칸에 지금 링크 주소", (await inp.inputValue()) === "https://naver.com", await inp.inputValue());
await p.click('[data-goal-link="remove"]');
await p.waitForTimeout(30);
check("[링크 삭제] → 링크만 빠지고 글자는 그대로", (await value()) === "네이버 바로가기" &&
!(await p.evaluate(function () { return !!document.querySelector(".pj-goal-text a"); })), await value());
// 주소만 붙여 넣으면 링크
await p.evaluate(function () {
const ed = document.querySelector(".pj-goal-text"); ed.focus();
const r = document.createRange(); r.selectNodeContents(ed); r.collapse(false);
const s = getSelection(); s.removeAllRanges(); s.addRange(r);
const dt = new DataTransfer(); dt.setData("text/plain", "https://drive.google.com/x?y=1");
ed.dispatchEvent(new ClipboardEvent("paste", { clipboardData: dt, bubbles: true, cancelable: true }));
});
const v2 = await value();
let r2 = [];
try { r2 = JSON.parse(v2.slice("pj-rich:v1:".length)); } catch (_) {}
check("주소만 붙여 넣기 → 그 주소가 링크", r2.length === 2 && r2[1].text === "https://drive.google.com/x?y=1" &&
r2[1].link === "https://drive.google.com/x?y=1", v2);
// 저장값을 다시 그려도(서버 → 칸) 링크 유지
await p.evaluate(function (v) { const ed = document.querySelector(".pj-goal-text"); ed.value = v; }, v2);
check("값을 다시 넣어도 링크 그대로(value 왕복)", (await value()) === v2);
} finally {
await browser.close();
}
if (fails.length) { console.log("\n" + fails.length + " FAILED"); process.exit(1); }
console.log("\nALL PASS");
})().catch(function (e) { console.error(e); process.exit(1); });
+51
View File
@@ -828,6 +828,57 @@ function meetServer(env, st) {
check("[2g4] Esc → 닫히고 표는 제자리", !d.body.querySelector(".pj-meet-quick-modal") && !!d.querySelector("#pj-meet-quick table.pj-meet-quick-table"));
});
// ════════════════════ [2g5] 하위 업무 등록(등록된 줄 [+]) · 세부 업무 줄은 상위 줄 아래 · 등록된 줄 어디든 = 오른쪽 업무 창(2026-10-26) ════════════════════
await section(async function () {
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
meetServer(env);
// 서버 순서: 상위(등록) · 다른 줄 · 상위의 세부 업무(등록) — 화면은 세부 업무 줄을 상위 줄 바로 아래로
const q = quickServer(env, { rows: [
{ id: 1, title: "상위 업무", project_id: 7, project_name: "브랜드", stage_id: 71, stage_name: "할 일", task_id: 900 },
{ id: 2, title: "다른 줄", project_id: 7, project_name: "브랜드", stage_id: 71, stage_name: "할 일" },
{ id: 3, title: "이미 세부", project_id: 7, project_name: "브랜드", task_id: 901, parent_task_id: 900, parent_task_title: "상위 업무" }] });
await boot(env); await settle(); await wait(5); await settle();
const d = env.d;
const trs = function () { return Array.from(d.querySelectorAll("#pj-meet-quick tbody tr")); };
const titleOf = function (tr) { const i = tr.querySelector('input[data-field="title"]'); return i ? i.value : (tr.querySelector(".pj-meet-quick-open") || {}).textContent || ""; };
check("[2g5] 세부 업무 줄은 상위 업무 줄 바로 아래(들여쓰기 is-sub)",
titleOf(trs()[0]) === "상위 업무" && titleOf(trs()[1]) === "이미 세부" && trs()[1].classList.contains("is-sub") &&
titleOf(trs()[2]) === "다른 줄" && !trs()[0].classList.contains("is-sub"), trs().map(titleOf));
check("[2g5] 등록된 줄에만 [+](하위 업무 추가)", !!trs()[0].querySelector('[data-quick="add-sub"]') &&
!!trs()[1].querySelector('[data-quick="add-sub"]') && !trs()[2].querySelector('[data-quick="add-sub"]'));
// 등록된 줄 — 제목이 아닌 칸(프로젝트 칸)을 눌러도 오른쪽 업무 창
trs()[0].children[2].click(); await settle();
const panel = d.body.querySelector(".pj-meet-task-panel");
check("[2g5] 등록된 줄 프로젝트 칸 클릭 → 그 업무 창", !!panel && panel.classList.contains("is-open") &&
panel.querySelector("iframe").getAttribute("src") === "/project/t/900?embed=1" && trs()[0].classList.contains("is-panel-selected"));
// 세부 업무 줄 클릭 → 그 세부 업무 창(창을 닫지 않고 바꿈)
trs()[1].children[1].dispatchEvent(new env.w.MouseEvent("mousedown", { bubbles: true }));
trs()[1].children[1].click(); await settle(); await wait(5); await settle();
check("[2g5] 세부 업무 줄 클릭 → 세부 업무 창으로 바뀜", panel.classList.contains("is-open") &&
panel.querySelector("iframe").getAttribute("src") === "/project/t/901?embed=1");
// 세부 업무 줄의 '↳ 상위 업무' → 상위 업무 창
trs()[1].querySelector('[data-quick="open-parent"]').click(); await settle(); await wait(5); await settle();
check("[2g5] ↳ 상위 업무 클릭 → 상위 업무 창", panel.querySelector("iframe").getAttribute("src") === "/project/t/900?embed=1");
d.dispatchEvent(new env.w.KeyboardEvent("keydown", { key: "Escape", bubbles: true })); await settle(); await wait(5); await settle();
// [+] → 상위 줄 아래(기존 세부 뒤)에 초안 — 프로젝트·↳ 상위 채움, 서버 요청은 제목을 칠 때
const calls = env.calls.length;
trs()[0].querySelector('[data-quick="add-sub"]').click(); await settle();
const draft = trs()[2];
check("[2g5] [+] → 상위 줄 아래 세부 업무 초안(↳ 상위 업무, 프로젝트 채움, 제목 칸 포커스, 요청 없음)",
draft.classList.contains("is-sub") && /↳ 상위 업무/.test(draft.textContent) && /브랜드/.test(draft.textContent) &&
d.activeElement === draft.querySelector('input[data-field="title"]') && draft.querySelector("input").placeholder === "세부 업무 제목" &&
env.calls.length === calls, [trs().map(titleOf), env.calls.length - calls]);
const inp = draft.querySelector('input[data-field="title"]');
type(env, inp, "새 세부"); inp.blur(); await settle(); await wait(700); await settle();
const made = Object.values(q.rows).find(function (r) { return r.title === "새 세부"; });
check("[2g5] 제목을 치면 서버 줄(parent_task_id = 상위 업무, project_id)", !!made && made.parent_task_id === 900 && made.project_id === 7, made);
const tr = trs().find(function (x) { return titleOf(x) === "새 세부"; });
tr.querySelector('[data-quick="apply"]').click(); await settle(); await wait(5); await settle();
check("[2g5] [적용] → 서버 [적용](상위 업무 밑 세부 업무)", q.applied.length === 1 && q.applied[0].parent_task_id === 900, q.applied);
await env.w.__pjMeetQuick.load(true); await settle();
check("[2g5] 다시 읽어도 세부 업무 줄은 상위 줄 아래", trs().slice(0, 3).map(titleOf).join("|") === "상위 업무|이미 세부|새 세부", trs().map(titleOf));
});
// ════════════════════ [2h] 회의록은 누구나 수정 · [회의 완료](관리자)면 잠금 ════════════════════
await section(async function () {
const env = makeEnv(PAGE.meeting_member, MEET_URL);
+37
View File
@@ -1016,6 +1016,43 @@ function titleVal(d) { return d.getElementById("pj-t-title").value; }
fire(d.querySelector('.pj-side .pj-tree-li[data-id="1"]'), "drop"); await settle();
check("[프로젝트 이동] 같은 프로젝트에 놓으면 창 없음", !d.body.querySelector(".pj-move-modal"));
}
// ── 섹션 머리를 왼쪽 프로젝트로 끌어 섹션째 다른 프로젝트로(2026-10-26) — 확인 창 → stages/{id}/move-project ──
{
const env = makeEnv(); baseRoutes(env);
const moves = [];
env.route("POST", /\/project\/api\/stages\/(\d+)\/move-project$/, function (u, b) {
moves.push({ id: +/stages\/(\d+)\//.exec(u)[1], body: b });
return { body: { stage: { id: +/stages\/(\d+)\//.exec(u)[1], project_id: 2 }, task_count: 1, unseen: [] } };
});
await boot(env); const d = env.d, w = env.w;
const data = {}; const transfer = { types: [], dropEffect: "", effectAllowed: "",
setData: function (k, v) { data[k] = v; this.types.push(k); }, getData: function (k) { return data[k] || ""; } };
function fire(el, kind) {
const e = new w.MouseEvent(kind, { bubbles: true, cancelable: true });
Object.defineProperty(e, "dataTransfer", { value: transfer });
el.dispatchEvent(e); return e;
}
const col = d.querySelector('.pj-col[data-stage-id]');
const head = col.querySelector('.pj-col-head[draggable="true"]');
const sid = col.dataset.stageId, sname = col.querySelector(".pj-col-name").textContent;
fire(head, "dragstart");
check("[섹션 이동] 섹션 머리 드래그에 섹션 종류(섹션 id)", data["application/x-pj-stage"] === sid, data);
const li = d.querySelector('.pj-side .pj-tree-li[data-id="2"]');
const over = fire(li.querySelector(".pj-tree-row") || li, "dragover");
check("[섹션 이동] 왼쪽 프로젝트 줄 위 — 놓기 허용·강조", over.defaultPrevented && !!li.querySelector(".pj-tree-row.is-task-drop"));
fire(li.querySelector(".pj-tree-row") || li, "drop"); await settle(); await settle();
const modal = d.body.querySelector(".pj-move-modal");
check("[섹션 이동] 확인 창(body 에, 섹션 이름 → 대상 프로젝트, 섹션 선택 없음)", !!modal && modal.parentElement === d.body &&
modal.textContent.indexOf("섹션 ‘" + sname + "’") >= 0 && /P2/.test(modal.textContent) && !modal.querySelector(".pj-move-stage"),
modal && modal.textContent);
modal.querySelector("[data-move-ok]").click(); await settle(); await settle();
check("[섹션 이동] [이동] → stages/{id}/move-project(대상 프로젝트) 후 창 닫힘",
moves.length === 1 && String(moves[0].id) === sid && moves[0].body.project_id === 2 && !d.body.querySelector(".pj-move-modal"), moves);
// 같은 프로젝트에 놓으면 창 없음 · 업무 카드 끌기는 예전처럼 업무 이동
fire(head, "dragstart");
fire(d.querySelector('.pj-side .pj-tree-li[data-id="1"]'), "drop"); await settle();
check("[섹션 이동] 같은 프로젝트에 놓으면 창 없음", !d.body.querySelector(".pj-move-modal") && moves.length === 1);
}
// ── 세부 업무를 만들 때 협업자 같이(업무 창 추가 칸·보드 카드 새 줄) · 카드 기존 줄 협업자 · 대시보드 프로젝트별(2026-10-13) ──
{
const env = makeEnv(); baseRoutes(env);
+21
View File
@@ -56,6 +56,27 @@ class GoalRichTextTests(unittest.TestCase):
assert store.goal_text_html('<b>legacy</b>') == '&lt;b&gt;legacy&lt;/b&gt;'
def test_link_runs_are_http_only_and_render_as_safe_anchor(self):
"""하이퍼링크(2026-10-26) — http(s) 주소만 남기고 나머지(javascript:·따옴표 섞인 주소)는 버림, HTML 은 새 탭 a."""
body = rich([{"text": "네이버", "link": "https://naver.com/a?b=1&c=2", "bold": True},
{"text": " 나쁜", "link": "javascript:alert(1)"},
{"text": " 따옴표", "link": 'https://x.test/"onmouseover="alert(1)'},
{"text": " 끝"}])
stored = store.validate_goal_text(body)
runs = store.goal_text_runs(stored)
self.assertEqual(runs[0]["link"], "https://naver.com/a?b=1&c=2")
self.assertTrue(all("link" not in r for r in runs[1:]))
html = store.goal_text_html(stored)
self.assertIn('<a class="pj-goal-link" href="https://naver.com/a?b=1&amp;c=2" target="_blank" rel="noopener noreferrer">'
'<span style="font-weight:700">네이버</span></a>', html)
self.assertNotIn("javascript", html)
self.assertNotIn("onmouseover", html)
self.assertEqual(html.count("<a "), 1)
# 회의록 칸 옮기기 비교도 링크를 서식으로 본다(같은 링크끼리만 합침)
moved = store.validate_meeting_content(rich([{"text": "a", "link": "https://a.test"}, {"text": "b", "link": "https://a.test"},
{"text": "c"}]))
self.assertEqual(store.goal_text_runs(moved), [{"text": "ab", "link": "https://a.test"}, {"text": "c"}])
def test_rich_merge_preserves_styles_and_plain_meeting_plan(self):
value = store.merge_goal_texts(['first', rich([{"text": "second", "bold": True, "size": 18}])])
assert store.goal_text_plain(value) == 'first\nsecond'
+50
View File
@@ -1606,6 +1606,56 @@ def test_move_task_to_other_project():
assert BOB in r2.json()["unseen"] # 담당자가 B 멤버가 아님 — 화면이 안내
def test_move_stage_to_other_project():
"""섹션째 다른 프로젝트로(2026-10-26) — 섹션 + 업무 + 세부 업무(모든 단계), 섹션은 맨 끝, 연결 정리, 권한."""
a = _project("P-smA", ADMIN, (ALICE, BOB))
b = _project("P-smB", ADMIN, (ALICE,))
c = _project("P-smC", ADMIN, (BOB,)) # ALICE 는 멤버 아님
sa = _stage(a["id"], name="옮길 섹션", by=ADMIN)
sa2 = _stage(a["id"], name="남는 섹션", by=ADMIN)
_stage(b["id"], name="B 기존", by=ADMIN)
sb2 = _stage(b["id"], name="B 둘째", by=ADMIN)
t = ST.create_task(project_id=a["id"], title="섹션 업무", stage_id=sa["id"], assignee_email=BOB, created_by=ALICE)
sub = ST.create_task(project_id=a["id"], title="세부", parent_task_id=t["id"], created_by=ALICE)
subsub = ST.create_task(project_id=a["id"], title="세부의 세부", parent_task_id=sub["id"], created_by=ALICE)
stay = ST.create_task(project_id=a["id"], title="남는 업무", stage_id=sa2["id"], created_by=ALICE)
# 대상 프로젝트로 걸린 연결(→ 원 소속이 되니 지움) · C 업무가 이 섹션에 연결(→ A 에 "섹션 없음"으로 남음)
assert req("POST", f"/project/api/tasks/{t['id']}/links", ALICE, json={"project_id": b["id"], "stage_id": sb2["id"]}).status_code == 201
ct = ST.create_task(project_id=c["id"], title="C 업무", created_by=BOB)
assert req("POST", f"/project/api/tasks/{ct['id']}/links", BOB, json={"project_id": a["id"], "stage_id": sa["id"]}).status_code == 201
url = f"/project/api/stages/{sa['id']}/move-project"
# 권한·검증 — 대상 비멤버 403, 원 프로젝트 비멤버 403, 같은 프로젝트 400, 없는 섹션 404
assert req("POST", url, ALICE, json={"project_id": c["id"]}).status_code == 403
assert req("POST", f"/project/api/stages/{sb2['id']}/move-project", BOB, json={"project_id": a["id"]}).status_code == 403
assert req("POST", url, ALICE, json={"project_id": a["id"]}).status_code == 400
assert req("POST", url, ALICE, json={}).status_code == 400
assert req("POST", "/project/api/stages/99999999/move-project", ALICE, json={"project_id": b["id"]}).status_code == 404
assert ST.get_stage(stage_id=sa["id"])["project_id"] == a["id"]
# 이동
r = req("POST", url, ALICE, json={"project_id": b["id"]})
assert r.status_code == 200, r.text
body = r.json()
assert body["stage"]["project_id"] == b["id"] and body["task_count"] == 1
assert body["stage"]["sort_order"] > sb2["sort_order"] # 대상 프로젝트 맨 끝
assert BOB in body["unseen"] # 담당자 BOB 은 B 멤버가 아님
for tid in (t["id"], sub["id"], subsub["id"]):
assert ST.get_task(task_id=tid)["project_id"] == b["id"]
moved = ST.get_task(task_id=t["id"])
assert moved["stage_id"] == sa["id"] and moved["assignee_email"] == BOB # 섹션·담당자 그대로
assert ST.get_task(task_id=stay["id"])["project_id"] == a["id"] # 다른 섹션 업무는 그대로
assert _count("SELECT COUNT(*) AS n FROM task_project_links WHERE task_id=%s AND project_id=%s", t["id"], b["id"]) == 0
assert _count("SELECT COUNT(*) AS n FROM task_project_links WHERE task_id=%s AND project_id=%s AND stage_id IS NULL",
ct["id"], a["id"]) == 1
assert _count("SELECT COUNT(*) AS n FROM project_activity WHERE task_id=%s AND action='project_moved' AND project_id=%s",
t["id"], b["id"]) == 1
assert sa["id"] in [s["id"] for s in ST.list_stages(project_id=b["id"])]
assert sa["id"] not in [s["id"] for s in ST.list_stages(project_id=a["id"])]
# 빈 섹션도 옮겨진다(이력은 프로젝트에만)
empty = _stage(a["id"], name="빈 섹션", by=ADMIN)
r2 = req("POST", f"/project/api/stages/{empty['id']}/move-project", ALICE, json={"project_id": b["id"]})
assert r2.status_code == 200 and r2.json()["task_count"] == 0
if __name__ == "__main__":
if not ENABLED:
print("SKIP: PROJECT_TEST_DB_URL(localhost) not set")