feat(project): 업무 창 작성자 표시·댓글 이미지 붙여넣기

- 업무 창 맨 위 삭제 버튼 오른쪽에 작성자 아이콘 + 이름(yyyy.mm.dd(요일) hh:mm:ss)
- 업무 창 댓글 칸 Ctrl+V 이미지 붙여넣기 — 썸네일 미리보기, 등록 시 /comments/files 한 요청
- 도움말 갱신, 브라우저 테스트 추가

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 14:03:32 +09:00
parent 866dc14f08
commit 981ad386bf
13 changed files with 242 additions and 19 deletions
+108
View File
@@ -0,0 +1,108 @@
// 실제 브라우저 — 업무 창 맨 위 작성자(아이콘 + 이름(yyyy.mm.dd(요일) hh:mm:ss), 삭제 버튼 오른쪽)와
// 댓글 칸 Ctrl+V 이미지 붙여넣기(썸네일 → 등록 = /comments/files 한 요청, 업무를 바꾸면 비움)를 확인한다(2026-10-21).
// python tests/js/render_project.py
// NODE_PATH=<playwright 경로> PJ_TEST_BROWSER=<Chrome 경로> node tests/js/task_creator_paste.browser.test.js
const assert = require("node:assert/strict");
const fs = require("node:fs"), path = require("node:path"), http = require("node:http");
const { chromium } = require("playwright");
const ROOT = path.resolve(__dirname, "../.."), OUT = path.join(__dirname, ".out"), STATIC = path.join(ROOT, "app/static");
const detail = (id) => ({ id, title: "작업 " + id, project_id: 1, stage_id: 11, description: "", priority: "normal",
assignee_email: "", subtasks: [], links: [], followers: [], access: "full", completed_at: null,
created_by: "me@test.local", created_at: "2026-10-21T13:05:09+09:00" });
const posts = [];
const server = http.createServer(async (req, res) => {
const url = new URL(req.url, "http://localhost");
const json = (code, body) => { res.statusCode = code; res.setHeader("Content-Type", "application/json"); res.end(JSON.stringify(body)); };
if (url.pathname === "/project/p/1") { res.setHeader("Content-Type", "text/html; charset=utf-8"); res.end(fs.readFileSync(path.join(OUT, "project_render.html"))); return; }
if (url.pathname.startsWith("/project/api/")) {
const chunks = []; for await (const c of req) chunks.push(c);
const raw = Buffer.concat(chunks);
const task = /^\/project\/api\/tasks\/(\d+)$/.exec(url.pathname);
if (task && req.method === "GET") return json(200, { task: detail(+task[1]) });
if (/\/comments(\/files)?$/.test(url.pathname) && req.method === "POST") {
posts.push({ path: url.pathname, type: req.headers["content-type"] || "", body: raw.toString("utf8") });
return json(201, { comment: { id: 1 }, attachments: [], mention_skipped: [] });
}
if (url.pathname.endsWith("/comments")) return json(200, { comments: [], events: [], features: {} });
if (url.pathname.endsWith("/attachments")) return json(200, { attachments: [] });
if (url.pathname.endsWith("/members")) return json(200, { members: [{ user_email: "me@test.local" }] });
if (url.pathname.endsWith("/live-version")) return json(200, { ts: "v1" });
if (url.pathname.endsWith("/alerts")) return json(200, { me: "me@test.local", latest_id: 0, alerts: [] });
return json(200, {});
}
if (url.pathname.startsWith("/static/")) {
const file = path.join(STATIC, decodeURIComponent(url.pathname.slice("/static/".length)));
if (file.startsWith(STATIC) && fs.existsSync(file)) {
res.setHeader("Content-Type", file.endsWith(".js") ? "text/javascript" : file.endsWith(".css") ? "text/css" : "application/octet-stream");
res.end(fs.readFileSync(file)); return;
}
}
res.statusCode = 404; res.end("");
});
// 붙여넣기 — 이미지만 든 클립보드(캡처 도구)를 흉내 낸다. 반환 = 기본 동작(글자 붙여넣기)을 막았는지.
const pasteImage = (page) => page.evaluate(async () => {
const c = document.createElement("canvas"); c.width = 8; c.height = 8;
c.getContext("2d").fillRect(0, 0, 8, 8);
const blob = await new Promise(r => c.toBlob(r, "image/png"));
const dt = new DataTransfer();
dt.items.add(new File([blob], "image.png", { type: "image/png" }));
const ev = new ClipboardEvent("paste", { clipboardData: dt, bubbles: true, cancelable: true });
document.getElementById("pj-comment-input").dispatchEvent(ev);
return ev.defaultPrevented;
});
(async function () {
await new Promise(r => server.listen(0, "127.0.0.1", r));
const base = "http://127.0.0.1:" + server.address().port;
const browser = await chromium.launch(process.env.PJ_TEST_BROWSER ? { executablePath: process.env.PJ_TEST_BROWSER } : {});
const page = await browser.newPage({ viewport: { width: 1920, height: 1080 } });
const errors = [];
page.on("pageerror", e => errors.push(e.message));
const pass = [];
const ok = (name, cond, extra) => { assert.ok(cond, name + (extra === undefined ? "" : " → " + JSON.stringify(extra))); pass.push(name); console.log("PASS " + name); };
try {
await page.goto(base + "/project/p/1?task=101");
await page.waitForFunction(() => { const m = document.getElementById("pj-modal-task"); return m && !m.hidden && document.getElementById("pj-t-id").value; });
const creator = await page.evaluate(() => {
const b = document.getElementById("pj-task-creator"), del = document.getElementById("pj-delete-task");
const br = b.getBoundingClientRect(), dr = del.getBoundingClientRect();
const text = b.querySelector(".pj-task-creator-name").textContent + b.querySelector(".pj-task-creator-at").textContent;
return { hidden: b.hidden, text: text, icon: !!b.querySelector(".pj-person-ic"),
rightOfDelete: br.left >= dr.right, sameRow: Math.abs((br.top + br.bottom) / 2 - (dr.top + dr.bottom) / 2) < 4 };
});
ok("작성자 = 아이콘 + 이름(yyyy.mm.dd(요일) hh:mm:ss)", !creator.hidden && creator.icon && creator.text === "Me(2026.10.21(수) 13:05:09)", creator);
ok("작성자는 삭제 버튼 오른쪽 같은 줄", creator.rightOfDelete && creator.sameRow, creator);
await page.locator("#pj-modal-task .pj-modal-actions-top").screenshot({ path: path.join(OUT, "task_creator.png") });
ok("이미지 붙여넣기는 기본 붙여넣기를 막고 담는다", await pasteImage(page));
await pasteImage(page);
ok("입력칸 위 썸네일 두 개", await page.evaluate(() => {
const box = document.getElementById("pj-comment-pending");
return !box.hidden && box.querySelectorAll(".pj-comment-pending-img img").length === 2; }));
await page.click("#pj-comment-pending button[data-idx='1']");
ok("× 로 하나 빼기", await page.evaluate(() => document.querySelectorAll("#pj-comment-pending img").length === 1));
await page.click("#pj-comment-send"); // 글 없이 이미지만
await page.waitForFunction(() => document.getElementById("pj-comment-pending").hidden);
const p = posts[posts.length - 1];
ok("등록 = /comments/files 한 요청(파일 1개, '붙여넣은 이미지 1.png')", p && p.path === "/project/api/tasks/101/comments/files" &&
/multipart\/form-data/.test(p.type) && (p.body.match(/name="files"/g) || []).length === 1 &&
p.body.includes("붙여넣은 이미지 1.png"), p && { path: p.path, type: p.type });
await page.fill("#pj-comment-input", "글만");
await page.click("#pj-comment-send");
await page.waitForFunction(() => document.getElementById("pj-comment-input").value === "");
ok("이미지 없으면 예전처럼 JSON 댓글", posts[posts.length - 1].path === "/project/api/tasks/101/comments");
await pasteImage(page);
await page.goto(base + "/project/p/1?task=102");
await page.waitForFunction(() => document.getElementById("pj-t-id").value === "102");
ok("새로 연 업무 창엔 붙여넣은 이미지 없음", await page.evaluate(() => document.getElementById("pj-comment-pending").hidden));
ok("페이지 오류 없음", errors.length === 0, errors);
console.log("\nALL PASS (" + pass.length + ")");
} finally {
await browser.close();
server.close();
}
})().catch(e => { console.error(e); process.exit(1); });