96f54db0b1
- 보드 섹션 머리를 왼쪽 프로젝트 목록에 놓으면 확인 창 → 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>
136 lines
8.1 KiB
JavaScript
136 lines
8.1 KiB
JavaScript
// 목표·회의록 칸 하이퍼링크(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); });
|