// 연간 목표(goals.html)·주간 회의록(goal_meeting.html) + static/project.js UI 회귀 테스트 — jsdom.
// 서버는 가짜(fetch 대체)로 두고 지연(deferred)·순서 역전·503·연속 입력을 직접 만든다. 실제 브라우저 레이아웃·입력기·터치 기기는 아니다.
//
// python tests/js/render_goals.py # 템플릿 렌더 → tests/js/.out/goals_*.html · meeting_*.html
// npm install jsdom # (최초 1회, 또는 NODE_PATH 로 jsdom 이 있는 node_modules 지정)
// node tests/js/goals_meeting_ui.test.js
//
// 성공하면 마지막 줄 ALL PASS, 실패하면 항목명과 종료코드 1.
const fs = require("fs");
const path = require("path");
const { JSDOM, VirtualConsole } = require("jsdom");
const WATCHDOG = setTimeout(function () { console.log("TIMEOUT — 어딘가에서 멈춤"); process.exit(2); }, 180000);
const ROOT = path.join(__dirname, "..", "..");
const OUT = path.join(__dirname, ".out");
const JS = fs.readFileSync(path.join(ROOT, "app", "static", "project.js"), "utf8");
const PAGE = {};
["goals_admin", "goals_ro", "goals_weekly_admin", "meeting_admin", "meeting_err", "meeting_ro", "meeting_member",
"meeting_groups", "meeting_groups_added"].forEach(function (n) {
PAGE[n] = fs.readFileSync(path.join(OUT, n + ".html"), "utf8");
});
const GOALS_URL = "http://localhost/project/goals/2026";
const MEET_URL = "http://localhost/project/goals/2026/meetings/9?week=2026-09-28";
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); }
}
function deferred() {
let resolve, reject;
const p = new Promise(function (a, b) { resolve = a; reject = b; });
return { promise: p, resolve: resolve, reject: reject };
}
function settle(n) {
return new Promise(function (r) { let i = 0; (function spin() { if (i++ >= (n || 40)) return r(); setImmediate(spin); })(); });
}
function wait(ms) { return new Promise(function (r) { setTimeout(r, ms); }); }
const unhandled = [];
process.on("unhandledRejection", function (e) { unhandled.push(String(e && e.message || e)); });
// env.route(method, re, fn(url, body, call)) — fn 이 {status, body, text} 또는 "NETWORK" 를 돌려준다(Promise 가능)
function makeEnv(html, url, opts) {
opts = opts || {};
const vc = new VirtualConsole();
const env = { calls: [], routes: [], navigations: 0, toasts: [], prompts: [], inflight: {}, maxInflight: {} };
vc.on("jsdomError", function (e) { if (/navigation/i.test(String(e && e.message))) env.navigations++; });
const dom = new JSDOM(html, { runScripts: "dangerously", pretendToBeVisual: true, url: url, virtualConsole: vc });
const w = dom.window, d = w.document;
env.w = w; env.d = d;
w.__PJ_TEST__ = true;
w.console.error = function () {};
w.scrollTo = function () {};
w.HTMLCanvasElement.prototype.getContext = function () { return null; };
w.erpConfirm = function () { return Promise.resolve(true); };
w.erpPrompt = function (msg, def) { env.prompts.push(msg); return Promise.resolve(opts.promptAnswer != null ? opts.promptAnswer : "새 이름"); };
w.erpAlert = function () {};
if (opts.storage) Object.keys(opts.storage).forEach(function (k) { w.localStorage.setItem(k, opts.storage[k]); });
if (opts.session) Object.keys(opts.session).forEach(function (k) { w.sessionStorage.setItem(k, opts.session[k]); });
env.route = function (method, re, fn) { env.routes.unshift({ method: method, re: re, fn: fn }); };
w.fetch = async function (u, o) {
const method = (o && o.method) || "GET";
let body = o && o.body;
if (typeof body === "string") { try { body = JSON.parse(body); } catch (_) {} }
const call = { method: method, url: String(u), body: body, keepalive: !!(o && o.keepalive), done: false };
env.calls.push(call);
const key = method + " " + String(u).replace(/^https?:\/\/[^/]+/, "");
env.inflight[key] = (env.inflight[key] || 0) + 1;
env.maxInflight[key] = Math.max(env.maxInflight[key] || 0, env.inflight[key]);
try {
for (const r of env.routes) {
if (r.method === method && r.re.test(String(u))) {
const out = await r.fn(String(u), body, call);
if (out === "NETWORK") throw new TypeError("Failed to fetch");
const status = out.status || 200;
return { ok: status < 400, status: status, statusText: "x",
json: async function () { return out.body || {}; }, text: async function () { return out.text || ""; } };
}
}
return { ok: true, status: 200, statusText: "OK", json: async function () { return {}; }, text: async function () { return ""; } };
} finally {
env.inflight[key]--;
call.done = true;
}
};
env.puts = function (re) { return env.calls.filter(function (c) { return c.method === "PUT" && re.test(c.url); }); };
env.toastText = function () { const t = d.querySelector(".erp-toast"); return t ? t.textContent : ""; };
return env;
}
async function boot(env) {
if (env.d.readyState === "loading") await new Promise(function (r) { env.d.addEventListener("DOMContentLoaded", r); });
env.w.eval(fs.readFileSync(path.join(ROOT, "app", "static", "project-goal-text.js"), "utf8"));
env.w.eval(fs.readFileSync(path.join(ROOT, "app", "static", "project-meeting-cells.js"), "utf8"));
env.w.eval(JS);
env.d.dispatchEvent(new env.w.Event("DOMContentLoaded"));
await settle();
return env;
}
function type(env, node, value) {
node.value = value;
node.dispatchEvent(new env.w.Event("input", { bubbles: true }));
}
function fire(env, node, name) { node.dispatchEvent(new env.w.Event(name, { bubbles: name !== "blur" && name !== "focus" })); }
function key(env, node, k, extra) {
const e = new env.w.KeyboardEvent("keydown", Object.assign({ key: k, bubbles: true, cancelable: true }, extra || {}));
node.dispatchEvent(e);
return e;
}
// 블록 하나가 예외로 멈춰도 나머지 블록은 계속(예외는 FAIL 로)
async function section(fn) {
try { await fn(); } catch (e) { check("블록 예외 없음: " + String(e && e.message || e).slice(0, 120), false); }
}
function itemLabel(b) { return (b.querySelector(".pj-ctxmenu-label") || b).textContent.trim(); }
function unload(env) {
const e = new env.w.Event("beforeunload", { cancelable: true });
env.w.dispatchEvent(e);
return e;
}
// jsdom에는 글꼴·레이아웃 엔진이 없다. 숨은 복사본의 실제 DOM/서식을 확인하면서
// 결정적인 글 너비를 제공한다. 실제 CSS·폰트 측정은 별도 브라우저 검증으로 확인한다.
function mockAutoFitLayout(env) {
const realRect = env.w.HTMLElement.prototype.getBoundingClientRect;
const measured = [];
env.w.HTMLElement.prototype.getBoundingClientRect = function () {
if (!this.classList.contains("pj-goal-autofit-measure")) return realRect.call(this);
measured.push(this);
const content = this.querySelector(".pj-goal-text, .pj-goal-text-ro, .pj-goal-num, .pj-goal-area-text, .pj-goal-row-text") || this;
let line = 0, longest = 0;
function walk(node, size, bold) {
if (node.nodeType === 3) {
node.nodeValue.split("\n").forEach(function (text, i) {
if (i) { longest = Math.max(longest, line); line = 0; }
line += text.length * size * (bold ? 1.2 : 1);
});
} else if (node.nodeType === 1) {
if (node.tagName === "BR") { longest = Math.max(longest, line); line = 0; return; }
const nextSize = parseFloat(node.style.fontSize) || size;
const nextBold = node.style.fontWeight ? Number(node.style.fontWeight) >= 600 : bold;
Array.from(node.childNodes).forEach(function (child) { walk(child, nextSize, nextBold); });
}
}
walk(content, 10, false);
const zoom = env.d.documentElement.classList.contains("pj-ui-scale") ? 0.75 : 1;
return { width: (Math.max(longest, line) + 13) * zoom };
};
return measured;
}
function beginGoalMove(env, source, target) {
const td = source.closest("td");
td.dispatchEvent(new env.w.MouseEvent("mousedown", { bubbles: true, button: 0, clientX: 10, clientY: 10 }));
env.d.dispatchEvent(new env.w.MouseEvent("mouseup", { bubbles: true }));
const edge = td.querySelector('.pj-goal-move-edge[data-edge="bottom"]');
edge.dispatchEvent(new env.w.MouseEvent("mousedown", { bubbles: true, button: 0, clientX: 20, clientY: 20 }));
env.d.elementFromPoint = function () { return target; };
env.d.dispatchEvent(new env.w.MouseEvent("mousemove", { bubbles: true, clientX: 300, clientY: 200 }));
return function () { env.d.dispatchEvent(new env.w.MouseEvent("mouseup", { bubbles: true, clientX: 300, clientY: 200 })); };
}
// ── 가짜 서버 — 목표 표(글 칸 상태를 기억해 화면 GET 에 반영) ───────────────
function goalsServer(env, st) {
st = Object.assign({ cells: {}, areaAdded: false, cellHook: null, metricHook: null, getHook: null }, st || {});
env.route("GET", /\/project\/api\//, function () { return { body: {} }; });
env.route("PUT", /\/project\/api\/goals\/rows\/\d+\/cells\/\d+$/, async function (u, body, call) {
const m = u.match(/rows\/(\d+)\/cells\/(\d+)/);
if (st.cellHook) { const r = await st.cellHook(u, body, call); if (r) return r; }
st.cells[m[1] + ":" + m[2]] = body.body;
return { body: { ok: true } };
});
env.route("PUT", /\/project\/api\/goals\/2026\/metrics$/, async function (u, body, call) {
if (st.metricHook) { const r = await st.metricHook(u, body, call); if (r) return r; }
const n = Number(String(body.value).replace(/[,\s]/g, ""));
st.metric = String(body.value);
return { body: { ok: true, label: body.value === "" ? "" : n.toLocaleString("en-US") } };
});
env.route("POST", /\/project\/api\/goals\/2026\/areas$/, function () { st.areaAdded = true; return { body: { ok: true } }; });
env.route("POST", /\/project\/api\/goals\/areas\/\d+\/rows$/, function () { return { status: 201, body: { ok: true } }; });
env.route("POST", /\/project\/api\/goals\/areas\/\d+\/move$/, function () { return { body: { ok: true } }; });
env.route("POST", /\/project\/api\/goals\/areas\/\d+\/merge$/, function () { st.merged = true; return { body: { ok: true, row_id: 10, start: 1 } }; });
env.route("GET", /\/project\/goals\/2026$/, async function () {
if (st.getHook) await st.getHook();
st.gets = (st.gets || 0) + 1;
let html = PAGE.goals_admin.replace(/(
]*data-row="(\d+)" data-month="(\d+)"[^>]*>)([\s\S]*?)(<\/div>)/g,
function (all, open, row, month, text, close) {
const k = row + ":" + month;
return open + (k in st.cells ? renderGoalBody(env, st.cells[k]) : text) + close;
});
if (st.areaAdded) {
html = html.replace(/(<\/tbody>\s*)(<\/table>)/, '$1
' +
'| 새 영역 | ' +
' | ' +
' | ' +
"
|---|
$2");
}
return { text: html };
});
env.route("POST", new RegExp("/project/api/goals/cells/move$"), async function (u, body, call) {
st.moves = (st.moves || 0) + 1;
if (st.moveHook) { const result = await st.moveHook(body, call); if (result) return result; }
st.cells[body.source_row + ":" + body.source_month] = "";
st.cells[body.target_row + ":" + body.target_month] = body.body;
return { body: { ok: true, body: body.body } };
});
return st;
}
function renderGoalBody(env, value) {
const div = env.d.createElement("div");
const runs = value.startsWith("pj-rich:v1:") ? JSON.parse(value.slice(11)) : [{ text: value }];
env.w.PJGoalText.paint(div, runs);
return div.innerHTML;
}
// ── 가짜 서버 — 회의록 ────────────────────────────────────────────────
function meetServer(env, st) {
st = Object.assign({ items: {}, head: {}, itemHook: null, headHook: null, getHook: null, syncHook: null, page: PAGE.meeting_admin }, st || {});
env.route("GET", /\/project\/api\//, function () { return { body: {} }; });
const amount = function (v) { if (v === "" || v == null) return null; return Number(String(v).replace(/[,\s원]/g, "")); };
env.route("PUT", /\/project\/api\/goals\/meeting-items\/\d+$/, async function (u, body, call) {
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 }, {});
// 정량 목표·결과 — 숫자면 원 정수, 아니면(예: 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) {
if (st.headHook) { const r = await st.headHook(body, call); if (r) return r; }
Object.assign(st.head, body);
const out = { ok: true };
if ("week_target" in body) { out.week_target = amount(body.week_target); st.head.week_target = out.week_target; }
return { body: out };
});
env.route("POST", /\/project\/api\/goals\/meetings\/2026-09-28\/items$/, function () { return { status: 201, body: { ok: true, id: 9 } }; });
env.route("POST", /\/project\/api\/goals\/meeting-items\/\d+\/move$/, function () { return { body: { ok: true } }; });
env.route("GET", /\/project\/goals\/2026\/meetings\/9/, async function () {
st.gets = (st.gets || 0) + 1;
const page = st.page;
if (st.getHook) { const r = await st.getHook(); if (r) return r; }
return { text: page };
});
env.route("POST", /\/performance\/api\/sync$/, async function (u, body) {
st.syncCalls = (st.syncCalls || 0) + 1;
if (st.syncHook) return st.syncHook(body);
return { body: { joined: false, job: { id: "j1", finished: true, from: body.from, to: body.to, shops: [{ name: "쿠팡", state: "done", active: true }], overall: {} } } };
});
return st;
}
(async function () {
// ════════════════════ [1] 회의록 글 — A→B 연속 입력과 늦은 A 응답 ════════════════════
await section(async function () {
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
const gate = deferred();
const st = meetServer(env, { itemHook: async function (id, body, call) { if (body.content === "draft A") await gate.promise; } });
await boot(env);
const ta = env.d.querySelector('tr[data-item="1"] .pj-meet-text');
ta.focus(); type(env, ta, "draft A"); ta.blur();
await settle();
ta.focus(); type(env, ta, "draft B");
await settle();
check("[1] A 진행 중엔 같은 칸 두 번째 요청을 보내지 않음(직렬화)", env.puts(/meeting-items\/1$/).length === 1);
gate.resolve();
await wait(900); await settle();
const puts = env.puts(/meeting-items\/1$/).map(function (c) { return c.body.content; });
check("[1] A 응답 뒤 B 가 뒤이어 저장됨(PUT A→B)", JSON.stringify(puts) === JSON.stringify(["draft A", "draft B"]), puts);
check("[1] 최종 서버 값 = B", st.items[1].content === "draft B", st.items[1]);
check("[1] 화면 = B", ta.value === "draft B");
check("[1] 같은 칸 동시 요청 최대 1", env.maxInflight["PUT /project/api/goals/meeting-items/1"] === 1, env.maxInflight);
const e = unload(env);
check("[1] 저장 끝난 뒤 페이지 떠남 = 경고 없음", !e.defaultPrevented);
});
// 지연·중복 blur·빠른 연속 입력 — 응답 순서와 무관하게 최신 값이 남는다
await section(async function () {
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
const gates = [];
const st = meetServer(env, { itemHook: async function () { const g = deferred(); gates.push(g); await g.promise; } });
await boot(env);
const ta = env.d.querySelector('tr[data-item="1"] .pj-meet-text');
ta.focus(); type(env, ta, "x1"); ta.blur(); fire(env, ta, "blur"); fire(env, ta, "blur");
ta.focus(); type(env, ta, "x12"); type(env, ta, "x123"); ta.blur();
await settle();
check("[1b] 중복 blur·연속 입력에도 진행 중 요청 1개", env.puts(/meeting-items\/1$/).length === 1);
gates[0].resolve(); await settle();
check("[1b] 첫 응답 뒤 최신 값으로 한 번 더", env.puts(/meeting-items\/1$/).length === 2 && env.puts(/meeting-items\/1$/)[1].body.content === "x123",
env.puts(/meeting-items\/1$/).map(function (c) { return c.body.content; }));
gates[1].resolve(); await settle();
await wait(50); await settle();
check("[1b] 최종 서버 값 = 마지막 입력", st.items[1].content === "x123" && env.puts(/meeting-items\/1$/).length === 2, st.items[1]);
});
// 저장 실패 → dirty·초안 유지, 페이지 떠남 = keepalive 재전송 + 이탈 경고 + 초안 백업, 다음에 열면 되살림
await section(async function () {
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
let fail = true;
const st = meetServer(env, { itemHook: function () { if (fail) return { status: 503, body: { detail: "temporary" } }; } });
await boot(env);
const ta = env.d.querySelector('tr[data-item="1"] .pj-meet-text');
ta.focus(); type(env, ta, "important"); ta.blur();
await settle();
check("[1c] 실패해도 글 그대로", ta.value === "important");
check("[1c] 실패 표시(빨간 테두리)", ta.closest("td").classList.contains("is-save-failed"));
check("[1c] 실패 안내 토스트", /저장 실패/.test(env.toastText()), env.toastText());
const draft = JSON.parse(env.w.localStorage.getItem("pj_draft:meet:item:1:content") || "null");
check("[1c] 초안 백업(localStorage)", draft && draft.draft === "important" && draft.base === "original", draft);
const before = env.puts(/meeting-items\/1$/).length;
const e = unload(env);
await settle();
const after = env.puts(/meeting-items\/1$/);
check("[1c] 페이지 떠남 — 실패한 칸을 keepalive 로 다시 보냄", after.length === before + 1 && after[after.length - 1].keepalive && after[after.length - 1].body.content === "important",
after.map(function (c) { return [c.body.content, c.keepalive]; }));
check("[1c] 페이지 떠남 — 실패 칸이 있으면 이탈 경고", e.defaultPrevented === true);
// 다음에 열기 — 서버엔 아직 original(keepalive 도 실패) → 초안을 되살려 다시 저장
const env2 = makeEnv(PAGE.meeting_admin, MEET_URL, { storage: { "pj_draft:meet:item:1:content": JSON.stringify(draft) } });
const st2 = meetServer(env2);
await boot(env2);
const ta2 = env2.d.querySelector('tr[data-item="1"] .pj-meet-text');
check("[1c] 다시 열면 초안 되살림", ta2.value === "important");
await wait(900); await settle();
check("[1c] 되살린 초안 자동 저장", st2.items[1] && st2.items[1].content === "important", st2.items[1]);
check("[1c] 저장 뒤 초안 백업 지움", env2.w.localStorage.getItem("pj_draft:meet:item:1:content") === null);
// 다른 곳에서 바뀐 칸(base ≠ 서버 값) — 되살리지 않는다
const stale = JSON.stringify({ base: "someone else", draft: "old draft", at: Date.now() });
const env3 = makeEnv(PAGE.meeting_admin, MEET_URL, { storage: { "pj_draft:meet:item:1:content": stale } });
meetServer(env3);
await boot(env3);
check("[1c] 서버 값이 바뀐 칸은 초안을 덮어쓰지 않음", env3.d.querySelector('tr[data-item="1"] .pj-meet-text').value === "original");
fail = false; void st;
});
// 진행 중 저장이 있으면 줄 작업(위로)은 그 저장이 끝난 뒤에, 저장 실패면 줄 작업을 하지 않는다
await section(async function () {
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
const gate = deferred();
let fail = false;
meetServer(env, { itemHook: async function (id, body) { if ("content" in body) { await gate.promise; if (fail) return { status: 503, body: { detail: "x" } }; } } });
await boot(env);
const ta = env.d.querySelector('tr[data-item="1"] .pj-meet-text');
ta.focus(); type(env, ta, "pending text"); ta.blur();
await settle();
fail = true;
env.d.querySelector('tr[data-item="1"] th.pj-meet-c-label').dispatchEvent(new env.w.MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 5, clientY: 5 }));
const up = Array.from(env.d.querySelectorAll(".pj-ctxmenu-item")).find(function (b) { return itemLabel(b) === "위로"; });
up.click();
await settle();
check("[1d] 저장 진행 중엔 줄 이동 요청을 보내지 않음", !env.calls.some(function (c) { return /\/move$/.test(c.url); }));
gate.resolve();
await settle(); await wait(20); await settle();
check("[1d] 저장 실패 → 줄 이동 취소(글 유지, 새로고침 없음)", !env.calls.some(function (c) { return /\/move$/.test(c.url); }) && ta.value === "pending text" && env.navigations === 0,
{ nav: env.navigations });
});
// 첫 열(구분) — 구역 통째로 위/아래(우클릭·⋯), 맨 위는 "위로" 없음, 구역 첫 줄 id 로 요청
await section(async function () {
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
const st = meetServer(env);
await boot(env);
const blocks = Array.from(env.d.querySelectorAll("tbody.pj-meet-sec"));
blocks[0].querySelector("th.pj-meet-c-sec").dispatchEvent(new env.w.MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 5, clientY: 5 }));
let labels = Array.from(env.d.querySelectorAll(".pj-ctxmenu-item")).map(itemLabel);
check("[1e] 첫 구역 우클릭 — 구역 아래로·구역 끝에 줄 추가(위로 없음)",
labels.indexOf("구역 아래로") >= 0 && labels.indexOf("구역 위로") < 0 && labels.indexOf("구역 끝에 줄 추가") >= 0, labels);
const gets0 = st.gets || 0; // 부팅 때 실적 자동 갱신이 이미 한 번 받는다
Array.from(env.d.querySelectorAll(".pj-ctxmenu-item")).find(function (b) { return itemLabel(b) === "구역 아래로"; }).click();
await settle(); await wait(20); await settle();
const firstId = blocks[0].querySelector("tr[data-item]").dataset.item;
const call = env.calls.find(function (c) { return /\/move-section$/.test(c.url); });
// 2026-10-12 — 새로고침 대신 표만 서버에서 다시 받아 그 자리에서 바꿔 끼운다(연간 목표와 같은 애니메이션)
check("[1e] 구역 아래로 → 그 구역 첫 줄로 move-section(direction 1) 후 표만 다시 받음(새로고침 없음)",
!!call && call.method === "POST" && call.url.indexOf("/meeting-items/" + firstId + "/move-section") >= 0 &&
call.body.direction === 1 && env.navigations === 0 && st.gets === gets0 + 1 &&
!blocks[0].isConnected && env.d.querySelectorAll("tbody.pj-meet-sec").length === blocks.length, [call, env.navigations, st.gets]);
const fresh = Array.from(env.d.querySelectorAll("tbody.pj-meet-sec"));
const last = fresh[fresh.length - 1];
last.querySelector('[data-meet-act="sec-menu"]').click();
labels = Array.from(env.d.querySelectorAll(".pj-ctxmenu-item")).map(itemLabel);
check("[1e] 마지막 구역 ⋯ — 구역 위로(아래로 없음)", labels.indexOf("구역 위로") >= 0 && labels.indexOf("구역 아래로") < 0, labels);
});
// ════════════════════ [2] 숫자 — 늦은 응답이 최신 입력을 덮지 않음 ════════════════════
await section(async function () {
const env = makeEnv(PAGE.goals_admin, GOALS_URL);
const gates = [];
const st = goalsServer(env, { metricHook: async function (u, body) { if (body.value === "200") { const g = deferred(); gates.push(g); await g.promise; } } });
await boot(env);
const inp = env.d.querySelector('input.pj-goal-num[data-metric="sales"][data-kind="target"][data-month="1"]');
inp.focus(); inp.value = "200"; fire(env, inp, "change"); inp.blur();
await settle();
inp.focus(); type(env, inp, "300");
gates[0].resolve();
await settle();
check("[2] 늦은 200 응답 뒤에도 입력 중인 300 유지", inp.value === "300", inp.value);
inp.blur();
await settle(); await wait(10); await settle();
const vals = env.puts(/metrics$/).map(function (c) { return c.body.value; });
check("[2] 300 확정 → 최종 서버 값 300(요청 순서 200→300)", st.metric === "300" && JSON.stringify(vals) === '["200","300"]', vals);
check("[2] 같은 칸 동시 요청 최대 1(순서 역전 불가)", env.maxInflight["PUT /project/api/goals/2026/metrics"] === 1);
check("[2] 확정 뒤 서버 표기", inp.value === "300");
});
await section(async function () { // 실패 응답 — 요청 뒤 새로 입력한 값을 예전 값으로 되돌리지 않는다 / 그대로면 입력 유지 + 실패 표시, Esc = 저장된 값
const env = makeEnv(PAGE.goals_admin, GOALS_URL);
const gate = deferred();
goalsServer(env, { metricHook: async function (u, body) { if (body.value === "200") { await gate.promise; return { status: 503, body: { detail: "down" } }; } } });
await boot(env);
const inp = env.d.querySelector('input.pj-goal-num[data-metric="sales"][data-kind="target"][data-month="1"]');
inp.focus(); inp.value = "200"; inp.blur();
await settle();
inp.focus(); type(env, inp, "300");
gate.resolve(); await settle();
check("[2b] 200 실패 응답이 새 입력 300 을 되돌리지 않음", inp.value === "300", inp.value);
type(env, inp, "200"); inp.blur(); await settle(); await wait(10); await settle();
check("[2b] 실패한 값 그대로면 입력 유지 + 실패 표시", inp.value === "200" && inp.parentElement.classList.contains("is-save-failed"));
const e = unload(env);
check("[2b] 미저장 숫자 칸이 있으면 이탈 경고", e.defaultPrevented === true);
inp.focus(); key(env, inp, "Escape");
check("[2b] Esc = 저장된 값(100)으로", inp.value === "100", inp.value);
});
await section(async function () { // 회의록 정량 목표·지난주 결과 — 늦은 응답이 새 초안을 덮지 않음
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
const gate = deferred();
const st = meetServer(env, { itemHook: async function (id, body) { if (body.target_amount === "200" || body.result_amount === "70") await gate.promise; } });
await boot(env);
const tin = env.d.querySelector('tr[data-item="1"] input[data-field="target_amount"]');
tin.focus(); tin.value = "200"; tin.blur(); await settle();
tin.focus(); type(env, tin, "300");
const rin = env.d.querySelector('tr[data-item="2"] input[data-field="result_amount"]');
rin.focus(); rin.value = "70"; rin.blur(); await settle();
rin.focus(); type(env, rin, "75");
gate.resolve(); await settle();
check("[2c] 정량 목표 늦은 응답이 300 초안 유지", tin.value === "300", tin.value);
check("[2c] 지난주 결과 늦은 응답이 75 초안 유지", rin.value === "75", rin.value);
tin.blur(); rin.blur(); await settle(); await wait(10); await settle();
check("[2c] 최종 서버 정량 목표 300 · 지난주 결과(7일 전 주 줄 902) 75", st.items[1].target_amount === 300 && st.items[902].result_amount === 75, st.items);
check("[2c] 달성률·평가 열 없음(2026-10-06)", !env.d.querySelector("[data-rate], select.pj-meet-eval"));
});
await section(async function () { // 지난주 결과 글(020) — 지난 주차 줄(data-prev)에 저장, 새로고침 없음
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
const st = meetServer(env);
await boot(env);
const note = env.d.querySelector('tr[data-item="2"] .pj-meet-rnote');
check("[2d] 결과 글 칸 = 지난 주차 값", !!note && note.value === "샘플 결과", note && note.value);
note.focus(); type(env, note, "결과 메모"); note.blur();
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-plan-head .pj-meet-kpiline .pj-meet-kpi").length === 4 && !env.d.querySelector(".pj-meet-top"));
});
// ════════════════════ [2e] 주차별 매출 목표(020) — 매출 목표 칸 → 입력 창(body): 월 전체 목표 직접 입력 + 주차별 + 차이 ════════════════════
await section(async function () {
const env = makeEnv(PAGE.goals_weekly_admin, GOALS_URL);
const st = goalsServer(env);
let sent = null;
env.route("PUT", /\/project\/api\/goals\/2026\/week-targets\/1$/, function (u, body) {
sent = body;
const weeks = {};
Object.keys(body.weeks).forEach(function (k) { weeks[k] = body.weeks[k]; });
return { body: { ok: true, value: Number(body.month), label: body.month, week_total: 600, weeks: weeks } };
});
await boot(env);
const inp = env.d.querySelector('input.pj-goal-num[data-metric="sales"][data-kind="target"][data-month="1"]');
check("[2e] 매출 목표 칸은 직접 입력 아님(readonly)", inp.readOnly && inp.dataset.weekly === "1");
const before = inp.value;
inp.click();
const pop = env.d.body.querySelector(".pj-goal-wkpop");
const month = pop && pop.querySelector("input[data-month-total]");
const ins = pop ? Array.from(pop.querySelectorAll("input[data-start]")) : [];
check("[2e] 창은 body 에, 월 전체 목표 칸 + 1월 주차 수만큼 입력칸", !!pop && pop.parentElement === env.d.body && !!month && ins.length === 5, ins.length);
check("[2e] 월 전체 목표 칸 = 지금 월 목표", month && month.value === before, { month: month && month.value, before: before });
check("[2e] 주차 날 수 표시(1월 1주차 1/1~1/4 = 4일)", pop.querySelector(".pj-goal-wkpop-days").textContent === "4일", pop.querySelector(".pj-goal-wkpop-days").textContent);
const sumEl = pop.querySelector('[data-sum="weeks"]'), diffEl = pop.querySelector('[data-sum="diff"]');
check("[2e] 저장된 주차 값·주차 합계", ins[0].value === "100" && ins[1].value === "200" && sumEl.textContent === "300", sumEl.textContent);
type(env, ins[2], "300");
check("[2e] 입력하면 주차 합계 다시 계산", sumEl.textContent === "600", sumEl.textContent);
type(env, month, "700");
check("[2e] 차이 = 월 목표 − 주차 합계(+ 남음)", diffEl.textContent === "+100" && diffEl.classList.contains("is-left"), diffEl.textContent);
type(env, month, "500");
check("[2e] 주차 합계가 넘으면 −", diffEl.textContent === "-100" && diffEl.classList.contains("is-over"), diffEl.textContent);
type(env, month, "700");
pop.querySelector('[data-act="save"]').click();
await settle(); await wait(10); await settle();
check("[2e] 월 목표·주차별 값 전송(주차 시작일 키)", sent && sent.month === "700" && sent.weeks["2026-01-12"] === "300" && Object.keys(sent.weeks).length === 5, sent);
check("[2e] 월 목표 칸 = 입력한 월 목표(주차 합계 아님), 창 닫힘", inp.value === "700" && !env.d.body.querySelector(".pj-goal-wkpop"), inp.value);
check("[2e] 월 목표 직접 저장 요청 없음", !st.metric);
});
// ════════════════════ [2f] 회의록 보드 — 누르는 순간 창을 열고, 서버가 준 Google 슬라이드 주소로 바꾼다 ════════════════════
await section(async function () {
const env = makeEnv(PAGE.meeting_ro, MEET_URL); // 보기만 하는 사람도 연다
meetServer(env);
let posted = null;
env.route("POST", /\/project\/api\/goals\/meetings\/2026-09-28\/board$/, function (u, body) {
posted = u;
return { body: { ok: true, url: "https://docs.google.com/presentation/d/abc/edit", created: true, title: "9월 5주차 (9/28~9/30)" } };
});
await boot(env);
const popup = { closed: false, focused: false, location: { href: "about:blank", replace: function (u) { this.href = u; } },
document: { title: "", body: {} }, focus: function () { this.focused = true; }, close: function () { this.closed = true; } };
let opened = null;
env.w.open = function (url, name, features) { opened = { url: url, name: name, features: features }; return popup; };
const btn = env.d.getElementById("pj-meet-board");
check("[2f] 참석자 옆 회의록 보드 버튼", !!btn && !!btn.closest(".pj-meet-attend"));
btn.click();
check("[2f] 누르는 순간 독립 창(popup)을 연다", opened && opened.name === "pj_meet_board_2026-09-28" && /popup/.test(opened.features), opened);
await settle(); await wait(10); await settle();
check("[2f] 서버에 그 주차 보드 요청", !!posted);
check("[2f] 창을 슬라이드 주소로", popup.location.href === "https://docs.google.com/presentation/d/abc/edit" && popup.focused);
});
// 작업 등록 표 가짜 서버(025) — 주차별 줄, POST·PUT·DELETE·[적용]
function quickServer(env, opts) {
opts = opts || {};
const st = { rows: {}, seq: 100, applied: [], deleted: [] };
(opts.rows || []).forEach(function (r) { st.rows[r.id] = Object.assign({ week: "2026-09-28", task_id: null, visible: true }, r); });
const out = function (r) {
return { id: r.id, title: r.title || "", assignee_email: r.assignee_email || "", project_id: r.project_id || null,
project_name: r.project_name || "", stage_id: r.stage_id || null, stage_name: r.stage_name || "", task_id: r.task_id,
parent_task_id: r.parent_task_id || null, parent_task_title: r.parent_task_id ? (r.parent_task_title || "상세페이지 리뉴얼") : "",
registered: r.task_id != null, visible: r.visible !== false, task_exists: true };
};
env.route("GET", /\/goals\/meetings\/([\d-]+)\/quick-tasks$/, function (u) {
const w = /meetings\/([\d-]+)\//.exec(u)[1];
return { body: { tasks: Object.values(st.rows).filter(function (r) { return r.week === w; }).map(out) } };
});
env.route("POST", /\/goals\/meetings\/([\d-]+)\/quick-tasks$/, function (u, b) {
const r = Object.assign({ id: ++st.seq, week: /meetings\/([\d-]+)\//.exec(u)[1] }, b);
st.rows[r.id] = r;
return { status: 201, body: { task: out(r) } };
});
env.route("PUT", /\/meeting-quick-tasks\/(\d+)$/, function (u, b) {
const r = st.rows[+/(\d+)$/.exec(u)[1]];
Object.assign(r, b);
return { body: { task: out(r) } };
});
env.route("DELETE", /\/meeting-quick-tasks\/(\d+)$/, function (u) {
const id = +/(\d+)$/.exec(u)[1];
st.deleted.push(id); delete st.rows[id];
return { body: { ok: true } };
});
env.route("POST", /\/meeting-quick-tasks\/(\d+)\/apply$/, function (u) {
const r = st.rows[+/(\d+)\/apply$/.exec(u)[1]];
st.applied.push(Object.assign({}, r));
if (r.task_id == null) { r.task_id = 555; return { status: 201, body: { task: out(r), created: true } }; }
return { body: { task: out(r), created: false } };
});
return st;
}
// ════════════════════ [2g] 머리 영역 3칸 — 결정 사항은 ②, 작업 등록 표(③): 칸 → 목록 → [적용] = 서버가 그 프로젝트에 작업 ════════════════════
await section(async function () {
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
meetServer(env);
const q = quickServer(env);
env.route("GET", /\/project\/api\/projects$/, function () { return { body: { projects: [
{ id: 7, name: "브랜드", parent_id: null, owner_email: "owner@test.local" }, { id: 8, name: "하위", parent_id: 7 },
{ id: 9, name: "끝난 프로젝트", parent_id: null, status: "completed" }] } }; });
env.route("GET", /\/project\/api\/projects\/7\/members$/, function () { return { body: { members: [{ user_email: "kim@test.local" }] } }; });
env.route("GET", /\/project\/api\/projects\/7\/stages$/, function () { return { body: { stages: [{ id: 72, name: "진행", sort_order: 2 }, { id: 71, name: "할 일", sort_order: 1 },
{ id: 73, name: "완료", sort_order: 0, is_done_stage: true }] } }; });
await boot(env); await settle(); await wait(5); await settle();
const d = env.d, board = d.querySelector(".pj-meet-board");
check("[2g] 머리 영역: 월 계획 · 결정 사항 · 작업 등록", !!board && board.children.length === 3 &&
!!board.querySelector(".pj-meet-notes #pj-meet-notes") && !!board.querySelector("#pj-meet-quick"));
check("[2g] 서버 표를 읽어 빈 줄 3개", env.calls.some(function (c) { return /\/meetings\/2026-09-28\/quick-tasks$/.test(c.url) && c.method === "GET"; }) &&
d.querySelectorAll("#pj-meet-quick tbody tr").length === 3);
const title = d.querySelector("#pj-meet-quick tbody tr input[data-field=title]");
title.value = "상세페이지 수정"; title.dispatchEvent(new env.w.Event("input", { bubbles: true }));
title.dispatchEvent(new env.w.Event("focusout", { bubbles: true }));
await settle(); await wait(5); await settle();
check("[2g] 제목을 쓰면 서버에 줄이 생김(POST)", Object.values(q.rows).length === 1 && Object.values(q.rows)[0].title === "상세페이지 수정", q.rows);
const pickItem = async function (kind, label) {
d.querySelector('#pj-meet-quick tbody tr [data-pick="' + kind + '"]').click(); await settle(); await wait(5); await settle();
const items = Array.from(d.querySelectorAll(".pj-ctxmenu-item"));
const it = items.find(function (n) { return itemLabel(n) === label; });
if (it) it.click();
await settle(); await wait(5); await settle();
return items.map(itemLabel);
};
const projLabels = await pickItem("project", "브랜드");
check("[2g] 프로젝트 목록 = 맨 위 '새 프로젝트'(Pro user) + 최상위 프로젝트(완료 제외)", JSON.stringify(projLabels) === JSON.stringify(["새 프로젝트", "브랜드"]), projLabels);
const row = d.querySelector("#pj-meet-quick tbody tr");
check("[2g] 프로젝트 고르면 첫 섹션 자동(완료 섹션은 건너뜀)", row.querySelector('[data-pick="stage"]').textContent === "할 일", row.querySelector('[data-pick="stage"]').textContent);
const stageLabels = await pickItem("stage", "할 일");
check("[2g] 섹션 목록에 완료 섹션 없음", stageLabels.indexOf("완료") < 0 && stageLabels.indexOf("할 일") >= 0 && stageLabels.indexOf("진행") >= 0, stageLabels);
const people = await pickItem("assignee", "Kim");
check("[2g] 담당자 목록 = 그 프로젝트 소유자·멤버", people.indexOf("Owner") >= 0 && people.indexOf("Kim") >= 0, people);
const saved = Object.values(q.rows)[0];
check("[2g] 고른 칸은 서버 줄에 저장(PUT)", saved.project_id === 7 && saved.stage_id === 71 && saved.assignee_email === "kim@test.local", saved);
d.querySelector('#pj-meet-quick tbody tr [data-quick="apply"]').click(); await settle(); await wait(5); await settle();
check("[2g] 적용 → 서버 [적용](그 줄로 작업 만들기)", q.applied.length === 1 && q.applied[0].title === "상세페이지 수정" && q.applied[0].stage_id === 71, q.applied);
check("[2g] 등록된 줄은 체크 아이콘만(말풍선 '등록됨') — 새 탭 링크, 휴지통과 같은 줄 상자",
/등록됨/.test(d.querySelector("#pj-meet-quick tbody tr .pj-meet-quick-done").getAttribute("title")) &&
!/등록됨/.test(d.querySelector("#pj-meet-quick tbody tr .pj-meet-quick-acts").textContent) &&
d.querySelector("#pj-meet-quick tbody tr a.pj-meet-quick-done").getAttribute("href") === "/project/t/555" &&
!!d.querySelector('#pj-meet-quick tbody tr .pj-meet-quick-actbox > [data-quick="delete"]'));
check("[2g] 머리의 '제목 → …' 안내 문구 없음", !d.querySelector("#pj-meet-quick h3 small"));
let deleted = null;
env.route("DELETE", /\/project\/api\/tasks\/555$/, function (u) { deleted = u; return { body: { ok: true } }; });
env.w.erpConfirm = function () { return Promise.resolve(true); };
const before = d.querySelectorAll("#pj-meet-quick tbody tr").length;
d.querySelector('#pj-meet-quick tbody tr [data-quick="delete"]').click(); await settle(); await wait(5); await settle();
check("[2g] 등록된 작업 삭제 → 작업 DELETE·서버 줄 삭제·줄 제거", !!deleted && q.deleted.length === 1 && !d.querySelector("#pj-meet-quick tbody tr.is-done"), [deleted, q.deleted, before]);
const calls = env.calls.length, n = d.querySelectorAll("#pj-meet-quick tbody tr").length;
d.querySelector('#pj-meet-quick tbody tr [data-quick="remove"]').click(); await settle();
check("[2g] 아직 저장 안 된 빈 줄 × → 줄만 지움(요청 없음)", env.calls.length === calls && d.querySelectorAll("#pj-meet-quick tbody tr").length >= 3, [env.calls.length - calls, n]);
}, { notifyOnFail: true });
// ════════════════════ [2g2] 작업 등록 — 프로젝트·섹션 목록 맨 위에서 바로 만들기 ════════════════════
await section(async function () {
const env = makeEnv(PAGE.meeting_admin, MEET_URL, { promptAnswer: "신규 브랜드" });
meetServer(env);
const q = quickServer(env);
let madeProject = null, madeStage = null;
env.route("GET", /\/project\/api\/projects$/, function () { return { body: { projects: [{ id: 7, name: "브랜드", parent_id: null }] } }; });
env.route("POST", /\/project\/api\/projects$/, function (u, body) {
madeProject = body;
return { status: 201, body: { project: { id: 9, name: body.name, parent_id: null, owner_email: "me@test.local" } } };
});
env.route("POST", /\/project\/api\/projects\/9\/stages$/, function (u, body) {
madeStage = body;
return { status: 201, body: { stage: { id: 91, project_id: 9, name: body.name, sort_order: 0 } } };
});
await boot(env); await settle(); await wait(5); await settle();
const d = env.d;
const open = async function (kind) {
d.querySelector('#pj-meet-quick tbody tr [data-pick="' + kind + '"]').click(); await settle(); await wait(5); await settle();
return Array.from(d.querySelectorAll(".pj-ctxmenu-item"));
};
const click = async function (items, label) {
items.find(function (n) { return itemLabel(n) === label; }).click(); await settle(); await wait(5); await settle();
};
await click(await open("project"), "새 프로젝트");
const row = function () { return d.querySelector("#pj-meet-quick tbody tr"); };
check("[2g2] 새 프로젝트 → 이름 묻고 만들어 바로 고름(섹션은 비움)",
madeProject && madeProject.name === "신규 브랜드" && row().querySelector('[data-pick="project"]').textContent === "신규 브랜드" &&
row().querySelector('[data-pick="stage"]').classList.contains("is-empty"), [madeProject, row().textContent]);
const stageItems = await open("stage");
check("[2g2] 섹션 목록 맨 위 '새 섹션'", itemLabel(stageItems[0]) === "새 섹션", stageItems.map(itemLabel));
await click(stageItems, "새 섹션");
check("[2g2] 새 섹션 → 그 프로젝트에 만들고 바로 고름(서버 줄에도)", madeStage && madeStage.name === "신규 브랜드" &&
row().querySelector('[data-pick="stage"]').textContent === "신규 브랜드" && Object.values(q.rows)[0].stage_id === 91, [madeStage, q.rows]);
});
await section(async function () {
const env = makeEnv(PAGE.meeting_member, MEET_URL);
meetServer(env);
quickServer(env);
env.route("GET", /\/project\/api\/projects$/, function () { return { body: { projects: [{ id: 7, name: "브랜드", parent_id: null }] } }; });
await boot(env); await settle(); await wait(5); await settle();
const d = env.d;
const box = d.querySelector('#pj-meet-quick tbody tr [data-pick="project"]');
if (!box) { check("[2g2] 직원 화면 작업 등록 표", false); return; }
box.click(); await settle(); await wait(5); await settle();
const labels = Array.from(d.querySelectorAll(".pj-ctxmenu-item")).map(itemLabel);
check("[2g2] 직원(User)에겐 '새 프로젝트' 없음(새 프로젝트는 Pro user 이상)", labels.indexOf("새 프로젝트") < 0 && labels.indexOf("브랜드") >= 0, labels);
});
// ════════════════════ [2g9] 2026-10-15 검토 F03 — 제목 저장이 실패하면 [적용]을 멈춘다(이전 제목으로 업무가 생기지 않게) ════════════════════
await section(async function () {
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
meetServer(env);
const q = quickServer(env, { rows: [{ id: 41, title: "OLD SAVED TITLE", project_id: 7, project_name: "브랜드", stage_id: 71, stage_name: "할 일" }] });
let failPut = true;
env.route("PUT", /\/meeting-quick-tasks\/(\d+)$/, function (u, b) {
if (failPut) return { status: 500, body: { detail: "서버 오류" } };
const r = q.rows[+/(\d+)$/.exec(u)[1]];
Object.assign(r, b);
return { body: { task: { id: r.id, title: r.title, project_id: r.project_id, stage_id: r.stage_id, task_id: null, registered: false } } };
});
await boot(env); await settle(); await wait(5); await settle();
const d = env.d;
const tr = function () { return Array.from(d.querySelectorAll("#pj-meet-quick tbody tr")).find(function (x) {
const i = x.querySelector('input[data-field="title"]'); return i && /TITLE/.test(i.value); }); };
const inp = tr().querySelector('input[data-field="title"]');
inp.value = "NEW UNSAVED TITLE"; inp.dispatchEvent(new env.w.Event("input", { bubbles: true }));
tr().querySelector('[data-quick="apply"]').click(); // 치자마자 [적용] — 제목 저장(PUT)이 500
await settle(); await wait(5); await settle();
check("[2g9] 제목 저장 실패 → [적용] 요청을 보내지 않음(이전 제목으로 업무 안 생김)", q.applied.length === 0, q.applied);
check("[2g9] 실패한 초안은 그대로(입력칸 NEW UNSAVED TITLE) + 저장 실패 표시·다시 저장 버튼",
!!tr() && tr().querySelector('input[data-field="title"]').value === "NEW UNSAVED TITLE" &&
tr().classList.contains("is-unsaved") && !!tr().querySelector('[data-quick="retry"]'), tr() && tr().outerHTML.slice(0, 300));
check("[2g9] 저장 안 된 입력이 있으면 페이지 이탈 경고", (function () {
const ev = new env.w.Event("beforeunload", { cancelable: true });
env.w.dispatchEvent(ev);
return ev.defaultPrevented;
})());
await env.w.__pjMeetQuick.load(true); await settle();
check("[2g9] 새로 읽어도(강제) 초안을 지우지 않음", !!tr() && tr().querySelector('input[data-field="title"]').value === "NEW UNSAVED TITLE");
// 서버가 돌아오면 [다시 저장] → 저장, 그 뒤 [적용]은 새 제목으로
failPut = false;
tr().querySelector('[data-quick="retry"]').click(); await settle(); await wait(5); await settle();
check("[2g9] [다시 저장] → 서버 줄이 새 제목", q.rows[41].title === "NEW UNSAVED TITLE" && !tr().classList.contains("is-unsaved"), q.rows[41]);
check("[2g9] 저장되면 이탈 경고 없음", !env.w.__pjMeetQuick.hasUnsaved());
tr().querySelector('[data-quick="apply"]').click(); await settle(); await wait(5); await settle();
check("[2g9] 저장 뒤 [적용] → 새 제목으로 한 번", q.applied.length === 1 && q.applied[0].title === "NEW UNSAVED TITLE", q.applied);
});
// ════════════════════ [2g3] 작업 등록 = 주차별 서버 표 · 다른 사람 줄도 보임 · 제목 "N주차 작업 등록" · 브라우저 예전 표는 서버로 ════════════════════
await section(async function () {
// 제목 — 입력칸(등록 전) 또는 등록된 줄의 제목 버튼·글자
const titleOf = function (tr) { const i = tr.querySelector('input[data-field="title"]'); return i ? i.value : (tr.querySelector(".pj-meet-quick-open") || {}).textContent || ""; };
const titles = function (d) { return Array.from(d.querySelectorAll("#pj-meet-quick tbody tr")).map(titleOf); };
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
meetServer(env);
quickServer(env, { rows: [
{ id: 1, title: "다른 사람이 적은 줄", created_by: "bob@test.local" },
{ id: 2, title: "다른 사람이 등록한 줄", task_id: 777, project_id: 7, project_name: "브랜드" },
{ id: 3, title: "남의 프로젝트 줄", task_id: 778, project_id: 8, project_name: "(볼 수 없는 프로젝트)", visible: false },
{ id: 4, title: "다른 주차 줄", week: "2026-10-05" }] });
await boot(env); await settle(); await wait(5); await settle();
const d = env.d;
check("[2g3] 제목 = 'N주차 업무 등록'", /^4주차 업무 등록/.test(d.querySelector("#pj-meet-quick h3").textContent.trim()), d.querySelector("#pj-meet-quick h3").textContent);
const ts = titles(d);
check("[2g3] 다른 사람이 적은·등록한 줄도 보임(이 주차만)", ts.indexOf("다른 사람이 적은 줄") >= 0 && ts.indexOf("다른 사람이 등록한 줄") >= 0 &&
ts.indexOf("다른 주차 줄") < 0, ts);
const hidden = Array.from(d.querySelectorAll("#pj-meet-quick tbody tr")).find(function (tr) { return titleOf(tr) === "남의 프로젝트 줄"; });
check("[2g3] 내가 멤버가 아닌 프로젝트 줄 — 이름 가림·작업 링크·삭제 없음", /볼 수 없는 프로젝트/.test(hidden.textContent) && /등록됨/.test(hidden.querySelector(".pj-meet-quick-done").getAttribute("title")) &&
!hidden.querySelector("a") && !hidden.querySelector('[data-quick="delete"]') && !hidden.querySelector('[data-quick="open"]'));
// 이 브라우저에만 있던 예전 표(이 주차 키 · 이번 주면 주차 없는 예전 키) → 서버로 옮기고 지움
for (const isNow of [false, true]) {
const e2 = makeEnv(PAGE.meeting_admin, MEET_URL);
meetServer(e2);
const q2 = quickServer(e2);
const me = e2.d.querySelector(".pj-wrap").dataset.me || "";
const legacy = "pj_meet_quick:" + me, weekKey = legacy + ":2026-09-28";
e2.w.localStorage.setItem(isNow ? legacy : weekKey, JSON.stringify([{ title: "브라우저에만 있던 줄", assignee: "", projectId: null }]));
if (isNow) e2.d.getElementById("pj-meet-quick").dataset.now = "1";
await boot(e2); await settle(); await wait(10); await settle();
check("[2g3] 브라우저 예전 표 → 서버로 옮김·지움(" + (isNow ? "주차 없는 예전 키, 이번 주" : "이 주차 키") + ")",
Object.values(q2.rows).some(function (r) { return r.title === "브라우저에만 있던 줄"; }) &&
e2.w.localStorage.getItem(isNow ? legacy : weekKey) == null && titles(e2.d).indexOf("브라우저에만 있던 줄") >= 0, [q2.rows, titles(e2.d)]);
}
});
// ════════════════════ [2g4] 작업 칸(이미 있는 작업의 세부 작업으로) · 등록된 제목 = 오른쪽 작업 창 · [크게 열기] ════════════════════
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: "할 일" }] });
env.route("GET", /\/project\/api\/projects\/7\/tasks$/, function () { return { body: { tasks: [
{ id: 300, title: "상세페이지 리뉴얼", project_id: 7, stage_id: 71 },
{ id: 301, title: "다른 섹션 작업", project_id: 7, stage_id: 72 },
{ id: 302, title: "끝난 작업", project_id: 7, stage_id: 71, completed_at: "2026-09-01T00:00:00+09:00" },
{ id: 303, title: "이미 세부 작업", project_id: 7, stage_id: null, parent_task_id: 300 }] } }; });
await boot(env); await settle(); await wait(5); await settle();
const d = env.d;
const row = function () { return d.querySelector("#pj-meet-quick tbody tr"); };
check("[2g4] 표 머리에 '업무' 칸, 예전 ↳(줄 세부 작업) 버튼 없음",
Array.from(d.querySelectorAll("#pj-meet-quick thead th")).map(function (t) { return t.textContent; }).indexOf("업무") === 4 &&
!d.querySelector('[data-quick="add-sub"]'));
row().querySelector('[data-pick="task"]').click(); await settle(); await wait(5); await settle();
const labels = Array.from(d.querySelectorAll(".pj-ctxmenu-item")).map(itemLabel);
check("[2g4] 작업 칸 목록 = '새 업무(섹션에)' + 그 섹션의 진행 중 메인 작업만", labels[0] === "새 업무 (‘할 일’ 섹션에)" &&
labels.indexOf("상세페이지 리뉴얼") >= 0 && labels.indexOf("다른 섹션 작업") < 0 && labels.indexOf("끝난 작업") < 0 && labels.indexOf("이미 세부 작업") < 0, labels);
Array.from(d.querySelectorAll(".pj-ctxmenu-item")).find(function (n) { return itemLabel(n) === "상세페이지 리뉴얼"; }).click();
await settle(); await wait(5); await settle();
check("[2g4] 작업을 고르면 ↳ 표시·섹션 '—'·제목 칸 '세부 업무 제목'·서버 줄에 parent_task_id",
/↳ 상세페이지 리뉴얼/.test(row().querySelector('[data-pick="task"]').textContent) && /—/.test(row().children[3].textContent) &&
row().querySelector('input[data-field="title"]').placeholder === "세부 업무 제목" && q.rows[1].parent_task_id === 300, q.rows[1]);
row().querySelector('[data-quick="apply"]').click(); await settle(); await wait(5); await settle();
check("[2g4] 적용 → 서버 [적용](고른 작업 밑 세부 작업)", q.applied.length === 1 && q.applied[0].parent_task_id === 300, q.applied);
// 등록된 줄 — 제목을 누르면 오른쪽 작업 창(iframe, embed). 저장 확인이 '계속 편집'이면 닫히지 않음
const open = row().querySelector('[data-quick="open"]');
check("[2g4] 등록된 줄 제목 = 작업 창 열기 버튼", !!open && open.textContent === "배너 시안");
open.click(); await settle();
const panel = d.body.querySelector(".pj-meet-task-panel");
check("[2g4] 오른쪽 작업 창(body 에) = /project/t/{id}?embed=1", !!panel && panel.classList.contains("is-open") &&
panel.querySelector("iframe").getAttribute("src") === "/project/t/555?embed=1");
let answer = false;
panel.querySelector("iframe").contentWindow.__pjEmbedSettle = function () { return Promise.resolve(answer); };
d.dispatchEvent(new env.w.KeyboardEvent("keydown", { key: "Escape", bubbles: true })); await settle();
check("[2g4] 작업 창 저장 실패에 '계속 편집' → 창 그대로", panel.classList.contains("is-open"));
answer = true;
d.dispatchEvent(new env.w.KeyboardEvent("keydown", { key: "Escape", bubbles: true })); await settle();
check("[2g4] 저장이 끝나면 Esc 로 닫힘", !panel.classList.contains("is-open"));
// 크게 열기 — 같은 표가 넓은 창으로(줄 그대로), Esc 로 제자리
const nRows = d.querySelectorAll("#pj-meet-quick tbody tr").length;
d.querySelector('#pj-meet-quick [data-quick="expand"]').click(); await settle();
const modal = d.body.querySelector(".pj-meet-quick-modal");
check("[2g4] 크게 열기 → 같은 표를 넓은 창으로(제목 'N주차 업무 등록')", !!modal && /4주차 업무 등록/.test(modal.querySelector("h3").textContent) &&
modal.querySelectorAll("tbody tr").length === nRows && nRows > 0);
d.dispatchEvent(new env.w.KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true })); await settle();
check("[2g4] Esc → 닫히고 표는 제자리", !d.body.querySelector(".pj-meet-quick-modal") && !!d.querySelector("#pj-meet-quick table.pj-meet-quick-table"));
});
// ════════════════════ [2h] 회의록은 누구나 수정 · [회의 완료](관리자)면 잠금 ════════════════════
await section(async function () {
const env = makeEnv(PAGE.meeting_member, MEET_URL);
const st = meetServer(env);
await boot(env);
const d = env.d;
check("[2h] 직원도 회의록 입력칸·메모 편집", !!d.querySelector(".pj-meet-text") && !!d.getElementById("pj-meet-notes"));
check("[2h] 직원에겐 삭제·회의 완료 버튼 없음", !d.getElementById("pj-meet-del") && !d.getElementById("pj-meet-complete"));
const ta = d.querySelector('tr[data-item="1"] .pj-meet-text');
ta.focus(); type(env, ta, "직원이 적은 업무"); ta.blur(); await settle(); await wait(10); await settle();
check("[2h] 직원 입력 저장", st.items[1] && st.items[1].content === "직원이 적은 업무", st.items[1]);
});
await section(async function () {
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
meetServer(env);
let posted = null;
env.route("POST", /\/project\/api\/goals\/meetings\/2026-09-28\/complete$/, function (u, body) { posted = body; return { body: { ok: true, completed: true } }; });
env.w.erpConfirm = function () { return Promise.resolve(true); };
await boot(env);
env.d.getElementById("pj-meet-complete").click(); await settle(); await wait(10); await settle();
check("[2h] 관리자 [회의 완료] → 완료 요청·새로고침", posted && posted.done === true && env.navigations === 1, [posted, env.navigations]);
const ro = makeEnv(PAGE.meeting_ro, MEET_URL); meetServer(ro); await boot(ro);
check("[2h] 완료된 회의록 — 입력칸 없음·완료 표시", !ro.d.querySelector(".pj-meet-text, #pj-meet-notes") && /회의 완료/.test(ro.d.querySelector(".pj-meet-done-badge").textContent));
});
// ════════════════════ [3] 목표 표 — 글 저장 실패면 구조 변경·표 교체 중단 ════════════════════
await section(async function () {
const env = makeEnv(PAGE.goals_admin, GOALS_URL, { promptAnswer: "새 영역" });
const st = goalsServer(env, { cellHook: function () { return { status: 503, body: { detail: "temporary save failure" } }; } });
await boot(env);
const ta = env.d.querySelector('.pj-goal-text[data-row="10"][data-month="1"]');
ta.focus(); type(env, ta, "unsaved important plan");
env.d.getElementById("pj-goal-area-add").click();
await settle(); await wait(20); await settle();
check("[3] 글 저장 실패 → 영역 추가 요청 안 보냄", !env.calls.some(function (c) { return c.method === "POST" && /\/areas$/.test(c.url); }),
env.calls.map(function (c) { return c.method + " " + c.url; }));
check("[3] 표를 다시 받지 않음", !st.gets);
check("[3] 미저장 계획 그대로", env.d.querySelector('.pj-goal-text[data-row="10"][data-month="1"]').value === "unsaved important plan");
check("[3] 실패 안내", /저장/.test(env.toastText()), env.toastText());
});
await section(async function () { // 진행 중 저장 → 그 저장이 끝난 뒤에 영역 추가, 성공하면 표 교체(새 영역 보임, 저장된 글 유지)
const env = makeEnv(PAGE.goals_admin, GOALS_URL, { promptAnswer: "새 영역" });
const gate = deferred();
const st = goalsServer(env, { cellHook: async function () { await gate.promise; } });
await boot(env);
const ta = env.d.querySelector('.pj-goal-text[data-row="10"][data-month="1"]');
ta.focus(); type(env, ta, "plan v2"); ta.blur();
await settle();
env.d.getElementById("pj-goal-area-add").click();
await settle();
check("[3b] 진행 중 저장이 끝나기 전엔 영역 추가 안 보냄", !env.calls.some(function (c) { return c.method === "POST"; }));
gate.resolve();
await settle(); await wait(20); await settle();
const order = env.calls.filter(function (c) { return c.method !== "GET" || /goals\/2026$/.test(c.url); }).map(function (c) { return c.method + " " + c.url.replace(/^https?:\/\/[^/]+/, ""); });
check("[3b] 순서: 글 PUT → 영역 POST → 표 GET", order.join(" | ") === "PUT /project/api/goals/rows/10/cells/1 | POST /project/api/goals/2026/areas | GET /project/goals/2026", order);
check("[3b] 새 영역이 그 자리에 보임(새로고침 없음)", !!env.d.querySelector('tbody.pj-goal-area[data-area-id="3"]') && env.navigations === 0);
check("[3b] 저장된 글 유지", env.d.querySelector('.pj-goal-text[data-row="10"][data-month="1"]').value === "plan v2");
});
await section(async function () { // 표를 받는 사이에 새로 입력 → 저장 후 다시 받아 교체(입력 유실 없음)
const env = makeEnv(PAGE.goals_admin, GOALS_URL, { promptAnswer: "새 영역" });
const gate = deferred();
let first = true;
const st = goalsServer(env, { getHook: async function () { if (first) { first = false; await gate.promise; } } });
await boot(env);
env.d.getElementById("pj-goal-area-add").click();
await settle();
const ta = env.d.querySelector('.pj-goal-text[data-row="11"][data-month="1"]');
ta.focus(); type(env, ta, "typed during refresh");
gate.resolve();
await settle(); await wait(30); await settle();
check("[3c] 받는 사이 입력한 글 저장됨", st.cells["11:1"] === "typed during refresh", st.cells);
check("[3c] 교체된 표에도 그 글", env.d.querySelector('.pj-goal-text[data-row="11"][data-month="1"]').value === "typed during refresh");
check("[3c] 표를 다시 받음(2회)", st.gets === 2, st.gets);
});
await section(async function () { // 병합 — 저장 실패면 병합 요청 안 보냄
const env = makeEnv(PAGE.goals_admin, GOALS_URL);
const st = goalsServer(env, { cellHook: function () { return { status: 503, body: { detail: "x" } }; } });
await boot(env);
const ta = env.d.querySelector('.pj-goal-text[data-row="10"][data-month="1"]');
ta.focus(); type(env, ta, "draft before merge");
const a = env.d.querySelector('td.pj-goal-texttd[data-month="1"]'), b = env.d.querySelector('tr[data-row-id="10"] td.pj-goal-texttd[data-month="2"]');
a.dispatchEvent(new env.w.MouseEvent("mousedown", { bubbles: true, button: 0 }));
b.dispatchEvent(new env.w.MouseEvent("mouseover", { bubbles: true }));
env.d.dispatchEvent(new env.w.MouseEvent("mouseup", { bubbles: true }));
b.dispatchEvent(new env.w.MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 5, clientY: 5 }));
const merge = Array.from(env.d.querySelectorAll(".pj-ctxmenu-item")).find(function (x) { return /셀 병합/.test(itemLabel(x)); });
check("[3d] 끌어 고른 뒤 우클릭 → 셀 병합 메뉴(기존 동작)", !!merge);
if (merge) merge.click();
await settle(); await wait(20); await settle();
check("[3d] 저장 실패 → 병합 요청 안 보냄, 글 유지", !st.merged && ta.value === "draft before merge");
});
// ════════════════════ [7] 줄별 이번주 실적 표시 폐지(2026-10-06) — 정량 목표 저장만, 실적 글자 없음 ════════════════════
await section(async function () {
const env = makeEnv(PAGE.meeting_admin, MEET_URL, { session: { "pj_meet_sync:2026-09-28": JSON.stringify({ at: Date.now(), state: "ok" }) } });
meetServer(env);
await boot(env);
const row = env.d.querySelector('tr[data-item="1"]');
check("[7] 이번주 실적 표시 없음", !row.querySelector(".pj-meet-week-slot") && !/이번주 실적/.test(row.textContent), row.textContent);
const tin = row.querySelector('input[data-field="target_amount"]');
tin.focus(); tin.value = "200"; tin.blur(); await settle(); await wait(10); await settle();
check("[7] 목표 200 저장 → 확정값 반영", row.dataset.targetAmount === "200" && tin.value === "200", [row.dataset.targetAmount, tin.value]);
});
await section(async function () { // 실적 조회 실패 화면 — 미확인(0원·0% 아님)
const env = makeEnv(PAGE.meeting_err, MEET_URL, { session: { "pj_meet_sync:2026-09-28": JSON.stringify({ at: Date.now(), state: "ok" }) } });
meetServer(env, { page: PAGE.meeting_err });
await boot(env);
const kpi = Array.from(env.d.querySelectorAll(".pj-meet-kpi")).map(function (k) { return k.textContent.replace(/\s+/g, " ").trim(); });
const mtd = kpi.find(function (t) { return /누적 실적/.test(t); });
check("[6] 월 누적 = 미확인(0원 아님)", /미확인/.test(mtd) && !/0원|0 원/.test(mtd), mtd);
check("[6] 누적 목표 대비 달성 = 미확인(차액·% 계산하지 않음)", /미확인/.test(kpi.find(function (t) { return /목표 대비/.test(t); })));
const row = env.d.querySelector('tr[data-item="1"]');
check("[6] 쇼핑몰 줄도 결과 = 직접 입력 칸(자동 결과 폐지)", !!row.querySelector(".pj-meet-c-result input") && !/미확인/.test(row.querySelector(".pj-meet-c-result").textContent));
check("[6] 줄별 이번주 실적 표시 없음 · 달성률 열 없음", !row.querySelector(".pj-meet-week-slot") && !row.querySelector("[data-rate]"));
check("[6] 회의록 입력은 그대로 가능", !!row.querySelector(".pj-meet-text") && !!env.d.getElementById("pj-meet-notes"));
check("[6] 조회 실패 안내 문구", /미확인/.test(env.d.querySelector(".pj-meet-perf-warn").textContent));
});
await section(async function () { // 지난주 리뷰 머리 = 지난주(9/21~) — 지난주 회의록에 없는 줄 안내
const env = makeEnv(PAGE.meeting_admin, MEET_URL, { session: { "pj_meet_sync:2026-09-28": JSON.stringify({ at: Date.now(), state: "ok" }) } });
meetServer(env);
await boot(env);
check("[5] 지난주 리뷰 머리 = 09/21 ~ 09/27", /09\/21 ~ 09\/27/.test(env.d.querySelector("th.is-prev").textContent));
check("[5] 새 줄 = 지난주 회의록에 없는 줄", /지난주 회의록에 없는 줄/.test(env.d.querySelector('tr[data-item="3"]').textContent));
});
// ════════════════════ [8] 구역·항목 메뉴 — ⋮ 버튼(키보드·터치) + 우클릭 ════════════════════
await section(async function () {
const env = makeEnv(PAGE.goals_admin, GOALS_URL, { promptAnswer: "줄 이름" });
goalsServer(env);
await boot(env);
const btns = env.d.querySelectorAll(".pj-goal-menu-btn");
check("[8] 관리자: 구역 2 + 항목 4 메뉴 버튼", btns.length === 6, btns.length);
const areaBtn = env.d.querySelector('tbody[data-area-id="1"] .pj-goal-menu-btn[data-goal-menu="area"]');
check("[8] 접근성 이름", areaBtn.getAttribute("aria-label") === "상품 구역 메뉴" && areaBtn.getAttribute("aria-haspopup") === "menu");
check("[8] Tab 으로 갈 수 있는 버튼", areaBtn.tagName === "BUTTON" && areaBtn.tabIndex === 0);
areaBtn.focus();
areaBtn.dispatchEvent(new env.w.MouseEvent("click", { bubbles: true, cancelable: true, detail: 0 })); // Enter/Space → click(detail 0)
let menu = env.d.querySelector(".pj-ctxmenu");
check("[8] 키보드로 열기 → role=menu, 첫 항목 포커스", menu && menu.getAttribute("role") === "menu" && env.d.activeElement === menu.querySelector(".pj-ctxmenu-item"));
check("[8] aria-expanded=true", areaBtn.getAttribute("aria-expanded") === "true");
key(env, env.d.activeElement, "ArrowDown");
check("[8] ↓ 로 다음 항목", env.d.activeElement === menu.querySelectorAll(".pj-ctxmenu-item")[1]);
await settle();
key(env, env.d.activeElement, "Escape");
check("[8] Esc 닫기 → 버튼으로 포커스 복귀", !env.d.querySelector(".pj-ctxmenu") && env.d.activeElement === areaBtn && areaBtn.getAttribute("aria-expanded") === "false");
// 키보드로 항목 실행 — "줄 추가(구역 맨 아래)"
areaBtn.dispatchEvent(new env.w.MouseEvent("click", { bubbles: true, cancelable: true, detail: 0 }));
menu = env.d.querySelector(".pj-ctxmenu");
const add = Array.from(menu.querySelectorAll(".pj-ctxmenu-item")).find(function (b) { return /줄 추가/.test(itemLabel(b)); });
add.focus(); add.click();
await settle(); await wait(20); await settle();
check("[8] 메뉴 항목 실행 → 줄 추가 API", env.calls.some(function (c) { return c.method === "POST" && /areas\/1\/rows$/.test(c.url); }));
// 터치(탭) — 포인터 터치 뒤 click(detail 1)
const rowBtn = env.d.querySelector('tr[data-row-id="20"] .pj-goal-menu-btn[data-goal-menu="row"]');
rowBtn.dispatchEvent(new env.w.Event("pointerdown", { bubbles: true }));
rowBtn.dispatchEvent(new env.w.MouseEvent("click", { bubbles: true, cancelable: true, detail: 1 }));
menu = env.d.querySelector(".pj-ctxmenu");
const labels = menu ? Array.from(menu.querySelectorAll(".pj-ctxmenu-item")).map(itemLabel) : [];
check("[8] 탭(click) → 줄 메뉴(우클릭과 같은 항목)", labels.indexOf("위에 줄 추가") >= 0 && labels.indexOf("아래에 줄 추가") >= 0 && labels.indexOf("줄 삭제") >= 0, labels);
check("[8] 터치로 연 메뉴도 ↑↓·Esc 가능(메뉴에 포커스)", env.d.activeElement === menu);
// 다시 누르면 닫힘(토글) — 마우스는 mousedown 이 먼저 닫는다
env.d.dispatchEvent(new env.w.MouseEvent("mousedown", { bubbles: true }));
rowBtn.dispatchEvent(new env.w.MouseEvent("mousedown", { bubbles: true }));
await settle();
rowBtn.dispatchEvent(new env.w.MouseEvent("click", { bubbles: true, cancelable: true, detail: 1 }));
check("[8] 열린 메뉴 버튼 다시 누름 = 닫힘", !env.d.querySelector(".pj-ctxmenu"));
// 우클릭은 그대로
env.d.querySelector('tbody[data-area-id="2"] th.pj-goal-area-name').dispatchEvent(new env.w.MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 3, clientY: 3 }));
const ctx = Array.from(env.d.querySelectorAll(".pj-ctxmenu-item")).map(itemLabel);
check("[8] 우클릭 메뉴 그대로(색·위로·줄 추가·삭제)", ctx.indexOf("색 바꾸기") >= 0 && ctx.indexOf("위로") >= 0 && ctx.indexOf("영역 삭제") >= 0, ctx);
key(env, env.d.body, "Escape");
// 이름 칸 — Tab 으로 와서 Enter = 이름 수정, 한글 조합 중 Enter 는 무시
const name = env.d.querySelector('tr[data-row-id="10"] .pj-goal-row-text');
check("[8] 이름 칸 Tab 접근(tabindex=0)", name.getAttribute("tabindex") === "0");
name.focus();
key(env, name, "Enter", { isComposing: true });
check("[8] 한글 조합 중 Enter 는 편집 시작 안 함", name.isContentEditable !== true && name.contentEditable !== "true");
key(env, name, "Enter");
check("[8] Enter → 이름 수정", name.contentEditable === "true");
key(env, name, "Escape");
});
await section(async function () {
const env = makeEnv(PAGE.goals_ro, GOALS_URL);
goalsServer(env);
await boot(env);
check("[8] 보기 전용: 메뉴 버튼·이름 편집 없음", !env.d.querySelector(".pj-goal-menu-btn") && !env.d.querySelector("[data-goal-edit]"));
const th = env.d.querySelector("th.pj-goal-area-name");
th.dispatchEvent(new env.w.MouseEvent("contextmenu", { bubbles: true, cancelable: true }));
check("[8] 보기 전용: 우클릭은 너비 맞춤만 제공", Array.from(env.d.querySelectorAll(".pj-ctxmenu-item")).map(itemLabel).join("|") === "현재 열 너비 자동 맞춤|전체 열 너비 자동 맞춤");
// 분기 접기는 보기 전용도
const qth = env.d.querySelector('th.pj-goal-fold-th[data-h="1"]');
qth.dispatchEvent(new env.w.MouseEvent("click", { bubbles: true }));
check("[회귀] 분기 머리 클릭 → 접기 애니메이션(보기 전용도)", qth.classList.contains("is-folded") && env.d.querySelector('td.pj-goal-m[data-h="1"]').classList.contains("is-shrunk"));
check("[회귀] 접기 상태 기억", /"1":true/.test(env.w.localStorage.getItem("pj_goal_fold_q") || ""));
qth.dispatchEvent(new env.w.MouseEvent("click", { bubbles: true }));
await wait(380);
check("[회귀] 분기 머리 재클릭 → 펼침 완료·오래된 타이머 취소", !qth.classList.contains("is-folded") && !env.d.querySelector('td.pj-goal-m[data-h="1"]').classList.contains("is-gone") && !env.d.querySelector('td.pj-goal-m[data-h="1"]').classList.contains("is-folding"));
});
await section(async function () { // 회귀 — 열 너비 끌기·고정 열 변수·스크롤 위치 되살리기
const env = makeEnv(PAGE.goals_admin, GOALS_URL, { session: { pj_goal_scroll: JSON.stringify(["/project/goals/2026", 120, 45]) } });
goalsServer(env);
await boot(env);
const pane = env.d.getElementById("pj-goal-pane");
check("[회귀] 스크롤 위치 되살림", pane.scrollLeft === 120 && pane.scrollTop === 45, [pane.scrollLeft, pane.scrollTop]);
const h = env.d.querySelector('.pj-goal-colresize[data-col="c1"]');
h.dispatchEvent(new env.w.MouseEvent("mousedown", { bubbles: true, button: 0, clientX: 100 }));
env.d.dispatchEvent(new env.w.MouseEvent("mousemove", { bubbles: true, clientX: 140 }));
env.d.dispatchEvent(new env.w.MouseEvent("mouseup", { bubbles: true }));
const table = env.d.getElementById("pj-goal-table");
check("[회귀] 1열 너비 끌기 → --goal-c1-w 112px·기억", table.style.getPropertyValue("--goal-c1-w") === "112px" && /"c1":112/.test(env.w.localStorage.getItem("pj_goal_col_w") || ""),
table.style.getPropertyValue("--goal-c1-w"));
check("[너비] 지표·업무 모든 행의 셀 경계에 손잡이", Array.from(table.querySelectorAll("tbody th, tbody td")).every(function (td) { return !!td.querySelector(".pj-goal-colresize"); }));
const lower = env.d.querySelector('tbody.pj-goal-area .pj-goal-colresize[data-col="m1"]');
lower.dispatchEvent(new env.w.MouseEvent("mousedown", { bubbles: true, button: 0, clientX: 100 }));
env.d.dispatchEvent(new env.w.MouseEvent("mousemove", { bubbles: true, clientX: 160 }));
env.d.dispatchEvent(new env.w.MouseEvent("mouseup", { bubbles: true }));
check("[너비] 아래 행에서 월 너비 조절", table.querySelector('thead th[data-col="m1"]').style.getPropertyValue("--cw") === "145px");
env.d.getElementById("pj-goal-area-add").click(); await settle(); await wait(20); await settle();
const fresh = env.d.querySelector('tbody.pj-goal-area .pj-goal-colresize[data-col="m1"]');
check("[너비] 표 새로 그린 뒤에도 손잡이", !!fresh && fresh !== lower);
mockAutoFitLayout(env);
fresh.dispatchEvent(new env.w.MouseEvent("dblclick", { bubbles: true }));
check("[너비] 표를 다시 그린 뒤에도 더블클릭 내용 맞춤", table.querySelector('thead th[data-col="m1"]').style.getPropertyValue("--cw") === "95px");
});
await section(async function () {
const env = makeEnv(PAGE.goals_admin, GOALS_URL);
goalsServer(env); await boot(env);
const table = env.d.getElementById("pj-goal-table"), measured = mockAutoFitLayout(env);
const first = table.querySelector('.pj-goal-text[data-row="10"][data-month="1"]');
const second = table.querySelector('.pj-goal-text[data-row="11"][data-month="1"]');
first.value = "짧은 문단\n다담: 100 백만(김지통)\n주부콩: 20백만(김지통)";
second.value = "pj-rich:v1:" + JSON.stringify([{ text: "가장 긴 문단", size: 32, bold: true }, { text: " 끝" }]);
const draft = second.value, calls = env.calls.length;
function fit(key, body) {
const handle = table.querySelector((body ? "tbody " : "thead ") + '.pj-goal-colresize[data-col="' + key + '"]');
handle.dispatchEvent(new env.w.MouseEvent("dblclick", { bubbles: true, cancelable: true }));
}
function width(key) { return parseFloat(table.querySelector('thead th[data-col="' + key + '"]').style.getPropertyValue("--cw")); }
fit("m1", true);
const wanted = Math.ceil(7 * 32 * 1.2 + 2 * 10 + 13) + 2;
check("[자동 너비] 모든 행 중 가장 긴 문단·큰 글씨·굵기 반영", width("m1") === wanted, [width("m1"), wanted]);
check("[자동 너비] 원본 초안·부분 서식 보존·저장 요청 없음", second.value === draft && env.calls.length === calls);
check("[자동 너비] 복사본만 줄바꿈 해제·메뉴/손잡이 제외·측정 뒤 제거", measured.every(function (cell) {
const editor = cell.querySelector(".pj-goal-text");
return !cell.querySelector(".pj-goal-colresize, .pj-goal-menu-btn") && (!editor || editor.style.whiteSpace === "pre");
}) && !table.querySelector(".pj-goal-autofit-measure"));
second.value = "짧음";
fit("m1");
const paragraphWidth = Math.max.apply(null, first.value.split("\n").map(function (line) { return line.length; })) * 10 + 15;
check("[자동 너비] 명시적 줄바꿈 유지·문단 너비로 축소도 가능", width("m1") === paragraphWidth, [width("m1"), paragraphWidth]);
env.d.documentElement.classList.add("pj-ui-scale"); fit("m1");
check("[자동 너비] 75% 화면 배율에서도 같은 논리 너비", width("m1") === paragraphWidth);
env.d.documentElement.classList.remove("pj-ui-scale");
first.value = "긴".repeat(100); fit("m1");
const saved = env.w.localStorage.getItem("pj_goal_col_w");
check("[자동 너비] 600px를 넘는 문단도 잘리지 않고 기억", width("m1") === 1015 && JSON.parse(saved).m1 === 1015);
const restored = makeEnv(PAGE.goals_ro, GOALS_URL, { storage: { pj_goal_col_w: saved } });
goalsServer(restored); await boot(restored);
check("[자동 너비] 다시 열면 큰 자동 너비도 복원", restored.d.querySelector('thead th[data-col="m1"]').style.getPropertyValue("--cw") === "1015px");
const numeric = table.querySelector('input.pj-goal-num[data-month="2"]');
numeric.value = "12345678901234567890"; fit("m2");
check("[자동 너비] 숫자 입력칸의 현재 초안도 측정", width("m2") === 215);
table.querySelector(".pj-goal-area-text").textContent = "아주 긴 영역 이름"; fit("c1", true);
check("[자동 너비] rowspan 이름 열·메뉴 아이콘 제외", table.style.getPropertyValue("--goal-c1-w") === "115px");
const row = first.closest("tr"), merged = first.closest("td");
merged.colSpan = 2; merged.dataset.goalCols = "m1,m2";
merged.querySelector(".pj-goal-colresize").dataset.col = "m2";
row.querySelector('td[data-month="2"]').remove();
first.value = "병합".repeat(80);
const beforeM1 = width("m1"); fit("m2", true);
check("[자동 너비] 병합 셀은 나머지 열 유지·오른쪽 끝 열만 맞춤", width("m1") === beforeM1 && width("m2") === 1615 - beforeM1, [width("m1"), width("m2")]);
const qth = table.querySelector('thead th[data-col="q1"]'), folded = qth.classList.contains("is-folded");
fit("q1");
check("[자동 너비] 분기 열 더블클릭은 접기 상태를 바꾸지 않음", qth.classList.contains("is-folded") === folded);
mockAutoFitLayout(restored);
restored.d.querySelector('tbody .pj-goal-colresize[data-col="m1"]').dispatchEvent(new restored.w.MouseEvent("dblclick", { bubbles: true }));
check("[자동 너비] 보기 전용도 내용 맞춤 가능·쓰기 요청 없음", restored.d.querySelector('thead th[data-col="m1"]').style.getPropertyValue("--cw") === "95px" && !restored.calls.some(function (c) { return c.method !== "GET"; }));
});
await section(async function () {
const env = makeEnv(PAGE.goals_admin, GOALS_URL); goalsServer(env); await boot(env); mockAutoFitLayout(env);
const table = env.d.getElementById("pj-goal-table"), editor = table.querySelector('.pj-goal-text[data-row="10"][data-month="1"]');
editor.value = "길게".repeat(25);
function menu(cell) { cell.dispatchEvent(new env.w.MouseEvent("contextmenu", { bubbles: true, cancelable: true })); }
function action(label) { return Array.from(env.d.querySelectorAll(".pj-ctxmenu-item")).find(function (b) { return itemLabel(b) === label; }); }
menu(editor);
check("[너비 메뉴] 기존 내용 지우기·현재 열·전체 열 맞춤 함께 표시", !!action("내용 지우기 (Del)") && !!action("현재 열 너비 자동 맞춤") && !!action("전체 열 너비 자동 맞춤"));
action("현재 열 너비 자동 맞춤").click();
check("[너비 메뉴] 현재 열만 맞춤", table.querySelector('thead th[data-col="m1"]').style.getPropertyValue("--cw") === "515px" && table.querySelector('thead th[data-col="m2"]').style.getPropertyValue("--cw") === "85px");
table.querySelector('thead th[data-col="q1"]').click();
menu(table.querySelector('thead th[data-col="y"]')); action("전체 열 너비 자동 맞춤").click();
check("[너비 메뉴] 머리에서도 전체 맞춤·접힌 열 포함·저장", table.querySelector('thead th[data-col="m1"]').style.getPropertyValue("--cw") === "515px" && table.querySelector('thead th[data-col="q1"]').classList.contains("is-folded") && JSON.parse(env.w.localStorage.getItem("pj_goal_col_w")).m1 === 515);
menu(table.querySelector("th.pj-goal-area-name"));
check("[너비 메뉴] 구역 이름 편집 메뉴에도 맞춤 제공", !!action("색 바꾸기") && !!action("현재 열 너비 자동 맞춤"));
});
await section(async function () { // 연간 목표 셀 끌어서 이동 — 2026-10-07 요청으로 없앰(회의록 표 이동은 그대로)
const env = makeEnv(PAGE.goals_admin, GOALS_URL), st = goalsServer(env); await boot(env);
const source = env.d.querySelector('.pj-goal-text[data-row="10"][data-month="1"]');
check("[셀 이동 없음] 연간 목표 글 칸에 이동 테두리 없음", !env.d.querySelector("#pj-goal-table .pj-goal-move-edge"));
source.closest("td").dispatchEvent(new env.w.MouseEvent("mousedown", { bubbles: true, cancelable: true, button: 0 }));
check("[셀 이동 없음] 누르면 칸 표시만", source.closest("td").classList.contains("is-goal-active") && !st.moves);
});
// ════════════════════ [9] 매출 자동 갱신 — 정상 조용히 · 실패/일부 실패 안내 + 재시도 · 권한 없음 ════════════════════
await section(async function () {
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
const st = meetServer(env);
await boot(env);
await wait(20); await settle();
const box = env.d.getElementById("pj-meet-sync");
check("[9] 정상 갱신 → 안내 숨김(조용)", st.syncCalls === 1 && box.hidden === true);
check("[9] 갱신 뒤 숫자 칸 다시 그림(GET)", (st.gets || 0) >= 1);
});
await section(async function () {
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
const st = meetServer(env, { syncHook: function (body) {
return { body: { joined: false, job: { id: "j1", finished: true, from: body.from, to: body.to,
shops: [{ name: "쿠팡", state: "done", active: true }, { name: "네이버", state: "error", label: "인증 오류", active: true }], overall: {} } } };
} });
await boot(env);
const ta = env.d.querySelector('tr[data-item="1"] .pj-meet-text');
ta.focus(); type(env, ta, "editing while sync");
await wait(20); await settle();
const box = env.d.getElementById("pj-meet-sync"), btn = env.d.getElementById("pj-meet-sync-btn");
check("[9] 일부 실패 → 안내 보임 + 실패 쇼핑몰 이름", !box.hidden && box.dataset.state === "partial" && /네이버\(인증 오류\)/.test(box.textContent), box.textContent);
check("[9] 일부 실패를 전체 성공처럼 쓰지 않음 + 서버 기록 시각", !/갱신 성공 10\/01 14:20.*전체/.test(box.textContent) && /마지막 갱신 성공 10\/01 14:20/.test(box.textContent), box.textContent);
check("[9] 재시도 버튼", !btn.hidden);
check("[9] 갱신·다시 그리기 중에도 편집 글 유지", ta.value === "editing while sync");
const rec = JSON.parse(env.w.sessionStorage.getItem("pj_meet_sync:2026-09-28"));
check("[9] 기록 = partial(성공으로 기록하지 않음)", rec.state === "partial");
btn.click(); await wait(20); await settle();
check("[9] 재시도 → 다시 부름", st.syncCalls === 2);
});
await section(async function () {
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
const st = meetServer(env, { syncHook: function () { return { status: 500, body: { detail: "서버 오류" } }; } });
await boot(env);
await wait(20); await settle();
const box = env.d.getElementById("pj-meet-sync");
check("[9] 실패 → 식별 가능한 안내 + 재시도", !box.hidden && box.dataset.state === "error" && /실패/.test(box.textContent) && !env.d.getElementById("pj-meet-sync-btn").hidden, box.textContent);
st.syncHook = null;
env.d.getElementById("pj-meet-sync-btn").click(); await wait(20); await settle();
check("[9] 재시도 성공 → 안내 사라짐", box.hidden === true);
});
await section(async function () {
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
const st = meetServer(env, { syncHook: function () { return { status: 403, body: { detail: "권한 없음" } }; } });
await boot(env);
await wait(20); await settle();
const box = env.d.getElementById("pj-meet-sync");
check("[9] 403 → 권한 없음 설명, 재시도 버튼 없음", box.dataset.state === "noperm" && env.d.getElementById("pj-meet-sync-btn").hidden);
check("[9] 403 기억 → 같은 세션 자동 재호출 안 함", JSON.parse(env.w.sessionStorage.getItem("pj_meet_sync:2026-09-28")).state === "noperm");
void st;
});
await section(async function () { // 권한 없음(서버가 can_sync=0) — API 를 아예 부르지 않는다
const env = makeEnv(PAGE.meeting_ro, MEET_URL);
const st = meetServer(env, { page: PAGE.meeting_ro });
await boot(env);
await wait(20); await settle();
check("[9] 실적 권한 없음 → sync API 호출 0", !st.syncCalls && !env.calls.some(function (c) { return /performance/.test(c.url); }));
check("[9] 권한 없음 설명(저장된 실적·마지막 갱신 시각)", /권한이 없어/.test(env.d.getElementById("pj-meet-sync").textContent) && /10\/01 14:20/.test(env.d.getElementById("pj-meet-sync").textContent));
check("[9] 보기 전용: 입력칸 없음", !env.d.querySelector(".pj-meet-text, .pj-meet-rnote, #pj-meet-notes"));
});
await section(async function () { // 10분 제한 — 최근 기록이 있으면 다시 부르지 않고 그 상태만(일부 실패면 안내 유지)
const env = makeEnv(PAGE.meeting_admin, MEET_URL, { session: { "pj_meet_sync:2026-09-28": JSON.stringify({ at: Date.now(), state: "partial", bad: ["네이버"] }) } });
const st = meetServer(env);
await boot(env);
await wait(20); await settle();
check("[9] 10분 안 = 다시 부르지 않음, 일부 실패 안내 유지", !st.syncCalls && env.d.getElementById("pj-meet-sync").dataset.state === "partial");
});
await section(async function () { // 다른 사람 업데이트에 합류했는데 기간이 이 주를 다 덮지 못하면 한 번 더
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
let n = 0;
const st = meetServer(env, { syncHook: function (body) {
n++;
if (n === 1) return { body: { joined: true, job: { id: "other", finished: true, from: "2026-09-29", to: "2026-10-01", shops: [], overall: {} } } };
return { body: { joined: false, job: { id: "mine", finished: true, from: body.from, to: body.to, shops: [], overall: {} } } };
} });
await boot(env);
await wait(20); await settle();
check("[9] 합류한 작업이 기간을 못 덮으면 이 주 기간으로 한 번 더", st.syncCalls === 2 && env.d.getElementById("pj-meet-sync").hidden);
});
await section(async function () { // 회귀 — 참석자 고르기(칩·저장)
const html = PAGE.meeting_admin.replace("window.PJ_MEET_MEMBERS = []", 'window.PJ_MEET_MEMBERS = [{"email":"a@test.local","name":"에이","avatar":""}]');
const env = makeEnv(html, MEET_URL, { session: { "pj_meet_sync:2026-09-28": JSON.stringify({ at: Date.now(), state: "ok" }) } });
const st = meetServer(env);
await boot(env);
env.d.getElementById("pj-meet-attend-add").click();
const cb = env.d.querySelector('.pj-meet-pick input[type=checkbox][data-email="a@test.local"]');
cb.checked = true; cb.dispatchEvent(new env.w.Event("change", { bubbles: true }));
await settle();
check("[회귀] 참석자 고르기 → 칩 + 저장", !!env.d.querySelector('.pj-meet-chip[data-key="a@test.local"]') && st.head.attendees === "a@test.local", st.head);
});
await section(async function () { // 회의록에서도 같은 글자 서식·저장·초안 형식
const env = makeEnv(PAGE.meeting_admin, MEET_URL), st = meetServer(env); await boot(env);
const d = env.d, w = env.w, editor = d.querySelector('tr[data-item="1"] .pj-meet-text');
type(env, editor, "앞 선택 뒤"); editor.focus();
const range = d.createRange(); range.setStart(editor.firstChild, 2); range.setEnd(editor.firstChild, 4);
w.getSelection().removeAllRanges(); w.getSelection().addRange(range); fire(env, editor, "mouseup");
check("[회의록 서식] 같은 선택 글자 도구 표시", !d.getElementById("pj-goal-format").hidden);
["bold", "italic", "underline", "size-up"].forEach(k => d.querySelector('[data-goal-format="' + k + '"]').click());
d.querySelector('[data-goal-color="#DC2626"]').click();
fire(env, editor, "blur"); await settle();
const runs = JSON.parse(st.items[1].content.slice(11));
check("[회의록 서식] 선택 부분의 색·크기·굵게·기울임·밑줄 저장", runs[1].text === "선택" && runs[1].bold && runs[1].italic && runs[1].underline && runs[1].size === 16 && runs[1].color === "#dc2626" && !runs[0].bold, runs);
d.querySelector('[data-goal-format="reset"]').click(); fire(env, editor, "blur"); await settle();
check("[회의록 서식] 초기화는 내용 보존·평문으로 저장", st.items[1].content === "앞 선택 뒤");
});
await section(async function () { // 회의록 셀 이동 — 지연 응답·저장 순서·후속 blur
const env = makeEnv(PAGE.meeting_admin, MEET_URL), st = meetServer(env); const gate = deferred(); await boot(env);
env.route("POST", /\/meeting-cells\/move$/, async function (u, body) { await gate.promise; return { body: { ok: true, body: body.source_body } }; });
const source = env.d.querySelector('tr[data-item="2"] .pj-meet-text'), target = env.d.querySelector('tr[data-item="3"] .pj-meet-text');
const rich = 'pj-rich:v1:' + JSON.stringify([{ text: "이동", bold: true, italic: true, underline: true, size: 24, color: "#dc2626" }]);
type(env, source, rich); const end = beginGoalMove(env, source, target);
check("[회의록 이동] 대상 미리보기", target.closest("td").classList.contains("is-goal-move-target"));
end(); await settle();
const call = env.calls.find(c => /\/meeting-cells\/move$/.test(c.url));
check("[회의록 이동] 초안 저장 후 이동, 응답 전 원본 유지", st.items[2].content === rich && call && source.value === rich && target.value === "" && source.getAttribute("contenteditable") === "false");
gate.resolve(); await settle();
check("[회의록 이동] 내용과 모든 서식 함께 반영", source.value === "" && target.value === rich && source.getAttribute("contenteditable") === "true");
const before = env.calls.length; fire(env, source, "blur"); fire(env, target, "blur"); await settle();
check("[회의록 이동] 후속 blur 중복 저장 없음", env.calls.length === before);
});
for (const failure of ["network", "conflict", "save"]) await section(async function () {
const env = makeEnv(PAGE.meeting_admin, MEET_URL); meetServer(env, { itemHook: failure === "save" ? () => ({ status: 503 }) : null }); await boot(env);
env.route("POST", /\/meeting-cells\/move$/, () => failure === "network" ? "NETWORK" : { status: 409 });
const source = env.d.querySelector('tr[data-item="1"] .pj-meet-text'), target = env.d.querySelector('tr[data-item="2"] .pj-meet-text');
if (failure === "save") type(env, source, "미저장 글");
const before = source.value; beginGoalMove(env, source, target)(); await settle();
check("[회의록 이동 " + failure + "] 실패 후 원본·대상·편집 가능 상태 유지", source.value === before && target.value === "" && source.getAttribute("contenteditable") === "true");
check("[회의록 이동 " + failure + "] 저장 실패면 이동 요청 없음", failure !== "save" || !env.calls.some(c => /\/meeting-cells\/move$/.test(c.url)));
});
await section(async function () { // 회의록 범위 지우기·Ctrl+Z, 병합 실패시 입력 유지
const env = makeEnv(PAGE.meeting_admin, MEET_URL), st = meetServer(env); await boot(env);
const a = env.d.querySelector('tr[data-item="2"] .pj-meet-text'), b = env.d.querySelector('tr[data-item="3"] .pj-meet-text');
type(env, a, "첫 줄"); type(env, b, "둘째 줄"); fire(env, a, "blur"); fire(env, b, "blur"); await settle();
a.closest("td").dispatchEvent(new env.w.MouseEvent("mousedown", { bubbles: true, cancelable: true, button: 0 }));
env.d.dispatchEvent(new env.w.MouseEvent("mouseup", { bubbles: true }));
b.closest("td").dispatchEvent(new env.w.MouseEvent("mousedown", { bubbles: true, cancelable: true, button: 0, shiftKey: true }));
key(env, env.d.body, "Delete"); await settle();
check("[회의록 범위] 선택한 두 셀만 지우고 저장", a.value === "" && b.value === "" && st.items[2].content === "" && st.items[3].content === "");
key(env, env.d.body, "z", { ctrlKey: true }); await settle();
check("[회의록 범위] Ctrl+Z는 내용과 저장 복원", a.value === "첫 줄" && b.value === "둘째 줄" && st.items[2].content === "첫 줄");
env.route("POST", /\/meeting-cells\/merge$/, () => ({ status: 503 }));
b.dispatchEvent(new env.w.MouseEvent("contextmenu", { bubbles: true, cancelable: true }));
const merge = Array.from(env.d.querySelectorAll(".pj-ctxmenu-item")).find(n => itemLabel(n).startsWith("셀 병합"));
check("[회의록 병합] 같은 구역 범위에 병합 메뉴", !!merge); merge.click(); await settle();
check("[회의록 병합] 실패 후 모든 글·편집 상태 유지", a.value === "첫 줄" && b.value === "둘째 줄" && a.getAttribute("contenteditable") === "true" && !env.navigations);
const request = env.calls.find(c => /\/meeting-cells\/merge$/.test(c.url));
check("[회의록 병합] 선택한 주의 줄 ID로 요청", request.body.item_from === "2" && request.body.item_to === "3");
env.route("POST", /\/meeting-cells\/merge$/, () => ({ body: { ok: true } }));
const gets0 = st.gets || 0;
b.dispatchEvent(new env.w.MouseEvent("contextmenu", { bubbles: true, cancelable: true }));
Array.from(env.d.querySelectorAll(".pj-ctxmenu-item")).find(n => itemLabel(n).startsWith("셀 병합")).click(); await settle();
await wait(20); await settle();
check("[회의록 병합] 저장 성공 뒤 표만 다시 받음(새로고침 없음)", env.navigations === 0 && st.gets === gets0 + 1, [env.navigations, st.gets]);
});
await section(async function () {
const env = makeEnv(fs.readFileSync(path.join(OUT, "meeting_merged.html"), "utf8"), MEET_URL); const st = meetServer(env); await boot(env);
const gets0 = st.gets || 0;
const a = env.d.querySelector('td[data-meet-item="2"]');
check("[회의록 병합 화면] 첫 셀만 표시하고 숫자 칸 유지", a.rowSpan === 2 && !env.d.querySelector('td[data-meet-item="3"]') && env.d.querySelectorAll('.pj-meet-amount[data-field="target_amount"]').length === 3);
a.dispatchEvent(new env.w.MouseEvent("contextmenu", { bubbles: true, cancelable: true }));
Array.from(env.d.querySelectorAll(".pj-ctxmenu-item")).find(n => itemLabel(n) === "병합 해제").click(); await settle();
await wait(20); await settle();
check("[회의록 병합 해제] 첫 셀 ID로 요청하고 표만 다시 받음", env.calls.some(c => c.method === "DELETE" && /\/meeting-items\/2\/cell-merge$/.test(c.url)) &&
env.navigations === 0 && st.gets === gets0 + 1, [env.navigations, st.gets]);
check("[회의록 병합 해제] 요청 중 합쳐진 글 보존", a.textContent.includes("병합한 계획"));
});
await section(async function () {
const env = makeEnv(PAGE.meeting_admin, MEET_URL); meetServer(env); await boot(env);
const field = env.d.querySelector('tr[data-item="2"] .pj-meet-text'), handle = field.closest("td").querySelector(".pj-meet-colresize");
// 열면 늘 전체 열 너비 자동 맞춤으로 시작(2026-10-07) — 저장된 너비가 있어도 맞춘 값
const startW = parseFloat(env.d.querySelector('col[data-meet-col="content"]').style.width);
check("[회의록 너비] 열 때 전체 자동 맞춤 결과를 기억", JSON.parse(env.w.localStorage.getItem("pj_meet_col_w")).content === startW, startW);
handle.dispatchEvent(new env.w.MouseEvent("mousedown", { bubbles: true, cancelable: true, button: 0, clientX: 100 }));
env.d.dispatchEvent(new env.w.MouseEvent("mousemove", { bubbles: true, clientX: 200 }));
env.d.dispatchEvent(new env.w.MouseEvent("mouseup", { bubbles: true }));
check("[회의록 너비] 드래그 너비 저장", JSON.parse(env.w.localStorage.getItem("pj_meet_col_w")).content === startW + 100);
env.d.getElementById("pj-meet-order").click(); await settle();
check("[회의록 너비] 순서 변경 후 논리 열 유지", field.closest("td").dataset.meetCols === "content");
const ro = makeEnv(PAGE.meeting_ro, MEET_URL); meetServer(ro); await boot(ro);
ro.d.querySelector("td.pj-meet-c-text").dispatchEvent(new ro.w.MouseEvent("contextmenu", { bubbles: true, cancelable: true }));
const labels = Array.from(ro.d.querySelectorAll(".pj-ctxmenu-item")).map(itemLabel);
check("[회의록 보기 전용] 너비 맞춤 제공·쓰기 도구 없음", labels.join("|") === "현재 열 너비 자동 맞춤|전체 열 너비 자동 맞춤" && !ro.d.querySelector(".pj-goal-move-edge,[contenteditable='true'],#pj-goal-format"));
});
await section(async function () { // 선택한 글자만 서식·서식 초기화·저장·다시 그리기
const env = makeEnv(PAGE.goals_admin, "http://localhost/project/goals/2026"); const st = goalsServer(env); await boot(env);
const d = env.d, w = env.w, editor = d.querySelector('.pj-goal-text[data-row="10"][data-month="1"]');
const toolbar = d.getElementById("pj-goal-format");
check("[서식] 글자를 선택하기 전 도구 숨김", toolbar.hidden);
const swatches = Array.from(d.querySelectorAll("[data-goal-color]"));
check("[서식] 요청한 12색 견본만 표시", swatches.map(function (b) { return b.dataset.goalColor; }).join(",") === "#000000,#4B5563,#9CA3AF,#DC2626,#EA580C,#CA8A04,#16A34A,#0891B2,#2563EB,#7C3AED,#DB2777,#FFFFFF" && swatches.every(function (b) { return !b.textContent.trim(); }));
type(env, editor, "앞 선택 뒤"); editor.focus();
const range = d.createRange(); range.setStart(editor.firstChild, 2); range.setEnd(editor.firstChild, 4);
w.getSelection().removeAllRanges(); w.getSelection().addRange(range); fire(env, editor, "mouseup");
check("[서식] 글자 선택하면 body 팝업 표시", !toolbar.hidden && toolbar.parentElement === d.body);
const format = function (name) { d.querySelector('[data-goal-format="' + name + '"]').click(); };
format("bold"); format("italic"); format("underline");
d.querySelector('[data-goal-format="color"]').click();
check("[서식] 색상 버튼으로 견본 펼침", !d.getElementById("pj-goal-color-grid").hidden);
d.querySelector('[data-goal-color="#DC2626"]').click(); format("size-up"); format("size-up"); format("size-up");
let runs = w.PJGoalText.readRuns(editor);
check("[서식] 선택한 두 글자에만 색·굵게·기울임·밑줄·크기", runs.length === 3 && runs[0].text === "앞 " && runs[1].text === "선택" && runs[1].bold === true && runs[1].italic === true && runs[1].underline === true && runs[1].color === "#dc2626" && runs[1].size === 20 && !runs[2].bold, runs);
check("[서식] 토글 버튼은 적용 상태 표시", ["bold", "italic", "underline"].every(function (k) { return d.querySelector('[data-goal-format="' + k + '"]').getAttribute("aria-pressed") === "true"; }));
format("size-down");
check("[서식] 크기 줄이기는 2px", w.PJGoalText.readRuns(editor)[1].size === 18 && d.querySelector('[data-goal-format="size"]').textContent === "18px");
format("size-up"); format("italic"); format("underline");
check("[서식] 다시 누르면 기울임·밑줄 해제", w.PJGoalText.readRuns(editor)[1].italic === false && w.PJGoalText.readRuns(editor)[1].underline === false);
format("italic"); format("underline");
fire(env, editor, "blur"); await settle();
check("[서식] 텍스트 조각을 기존 셀 API에 저장", st.cells["10:1"].startsWith("pj-rich:v1:") && JSON.parse(st.cells["10:1"].slice(11))[1].size === 20);
const persisted = st.cells["10:1"];
d.querySelector('[data-goal-format="reset"]').click(); fire(env, editor, "blur"); await settle();
check("[서식] 선택 서식 초기화는 글을 유지하고 평문 저장", editor.textContent === "앞 선택 뒤" && st.cells["10:1"] === "앞 선택 뒤");
editor.value = persisted; fire(env, editor, "input"); fire(env, editor, "blur"); await settle();
d.getElementById("pj-goal-area-add").click(); await settle(); await wait(20); await settle();
const fresh = d.querySelector('.pj-goal-text[data-row="10"][data-month="1"]');
check("[서식] 표 다시 그리기에도 선택 서식 유지", fresh !== editor && w.PJGoalText.readRuns(fresh)[1].size === 20 && w.PJGoalText.readRuns(fresh)[1].italic === true && w.PJGoalText.readRuns(fresh)[1].underline === true);
fresh.focus();
const plainRange = d.createRange(); plainRange.setStart(fresh.firstChild, 0); plainRange.setEnd(fresh.firstChild, 1);
w.getSelection().removeAllRanges(); w.getSelection().addRange(plainRange); fire(env, fresh, "mouseup");
check("[서식] 새 평문 선택은 도구 값을 기본값으로 표시", d.querySelector('[data-goal-format="bold"]').getAttribute("aria-pressed") === "false" && d.querySelector('[data-goal-format="size"]').textContent === "14px");
plainRange.collapse(true); w.getSelection().removeAllRanges(); w.getSelection().addRange(plainRange); fire(env, fresh, "keyup");
check("[서식] 글자 선택을 해제하면 숨김·이전 선택 적용 차단", toolbar.hidden && d.querySelector('[data-goal-format="reset"]').disabled);
});
await section(async function () { // 혼합 서식·각 조각 크기 변경·상한/하한
const env = makeEnv(PAGE.goals_admin, GOALS_URL); goalsServer(env); await boot(env);
const d = env.d, w = env.w, editor = d.querySelector('.pj-goal-text[data-row="10"][data-month="1"]');
editor.value = 'pj-rich:v1:' + JSON.stringify([{text:"작은", size:10, bold:true, italic:true}, {text:"큰", size:30, underline:true}]);
editor.focus(); const r = d.createRange(); r.selectNodeContents(editor);
w.getSelection().removeAllRanges(); w.getSelection().addRange(r); fire(env, editor, "mouseup");
const button = function (key) { return d.querySelector('[data-goal-format="' + key + '"]'); };
check("[서식 혼합] 크기는 혼합·토글은 혼합 상태", button("size").textContent === "혼합" && button("bold").getAttribute("aria-pressed") === "mixed");
button("size-up").click(); let runs = w.PJGoalText.readRuns(editor);
check("[서식 혼합] 선택 조각마다 2px 증가", runs[0].size === 12 && runs[1].size === 32);
button("size-up").click(); runs = w.PJGoalText.readRuns(editor);
check("[서식 혼합] 32px 상한 보존", runs[0].size === 14 && runs[1].size === 32);
button("bold").click(); runs = w.PJGoalText.readRuns(editor);
check("[서식 혼합] 혼합에서 클릭하면 전체 굵게·다른 서식 유지", runs.every(function (run) { return run.bold === true; }) && runs[0].italic && runs[1].underline);
button("bold").click();
check("[서식 혼합] 다시 클릭하면 전체 굵게 해제", w.PJGoalText.readRuns(editor).every(function (run) { return run.bold === false; }));
for (let i = 0; i < 12; i++) button("size-down").click();
check("[서식 혼합] 10px 하한·감소 비활성", w.PJGoalText.readRuns(editor).every(function (run) { return run.size === 10; }) && button("size-down").disabled);
for (let i = 0; i < 12; i++) button("size-up").click();
check("[서식 혼합] 32px 상한·증가 비활성", w.PJGoalText.readRuns(editor).every(function (run) { return run.size === 32; }) && button("size-up").disabled);
button("reset").click();
check("[서식 혼합] 초기화는 모든 서식 제거·내용 보존", editor.value === "작은큰");
});
// ════════════════════ [2h] 항목 칸 묶음(027) — 주요 업무 칸 줄 추가는 같은 항목 칸 안에 · 표만 다시 그리며 애니메이션 ════════════════════
await section(async function () {
const env = makeEnv(PAGE.meeting_groups, MEET_URL);
const st = meetServer(env, { page: PAGE.meeting_groups });
// jsdom 에는 Web Animations 가 없다 — 있는 것처럼(애니메이션 경로·새 줄 강조 확인용)
const animated = [];
env.w.Element.prototype.animate = function (frames) { animated.push([this, frames]); return { finished: Promise.resolve(), cancel: function () {} }; };
const posts = [];
env.route("POST", /\/project\/api\/goals\/meetings\/2026-09-28\/items$/, function (u, body) {
posts.push(body); st.page = PAGE.meeting_groups_added; return { status: 201, body: { ok: true, id: 9 } };
});
await boot(env);
const gets0 = st.gets || 0;
const head = env.d.querySelector('tr[data-item="2"] th.pj-meet-c-label');
check("[2h] 묶음 첫 줄 항목 칸 rowspan=2 · 이어 붙은 줄은 항목 칸 없음",
head && head.rowSpan === 2 && !env.d.querySelector('tr[data-item="3"] th.pj-meet-c-label') &&
env.d.querySelector('tr[data-item="3"]').dataset.labelCont === "1");
const td = env.d.querySelector('td[data-meet-item="2"]');
td.dispatchEvent(new env.w.MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 5, clientY: 5 }));
let labels = Array.from(env.d.querySelectorAll(".pj-ctxmenu-item")).map(itemLabel);
check("[2h] 주요 업무 칸 메뉴 — 위/아래 줄 추가 · 줄 삭제", labels.indexOf("위에 줄 추가") >= 0 && labels.indexOf("아래에 줄 추가") >= 0 &&
labels.indexOf("줄 삭제") >= 0, labels);
const prompts = env.prompts.length;
const oldRow2 = env.d.querySelector('tr[data-item="2"]');
Array.from(env.d.querySelectorAll(".pj-ctxmenu-item")).find(function (b) { return itemLabel(b) === "아래에 줄 추가"; }).click();
await settle(); await wait(20); await settle();
check("[2h] 아래에 줄 추가 → 같은 항목 칸(same_label)·이름 안 물음", posts.length === 1 && posts[0].same_label === true &&
String(posts[0].ref_item_id) === "2" && posts[0].place === "below" && env.prompts.length === prompts, posts);
check("[2h] 새로고침 없이 표만 다시 받아 바꿔 끼움", env.navigations === 0 && st.gets === gets0 + 1 && !oldRow2.isConnected &&
!!env.d.querySelector('tr[data-item="9"]'), [env.navigations, st.gets]);
const head2 = env.d.querySelector('tr[data-item="2"] th.pj-meet-c-label');
check("[2h] 항목 칸은 그대로(rowspan 3) — 새 줄에 항목 칸 없음", head2 && head2.rowSpan === 3 &&
!env.d.querySelector('tr[data-item="9"] th.pj-meet-c-label'));
const row9 = env.d.querySelector('tr[data-item="9"]');
check("[2h] 새 줄 — 내려오며 나타나고 잠깐 강조", row9.classList.contains("is-new-row") &&
animated.some(function (a) { return a[0] === row9 && a[1][0].opacity === 0; }));
// 다시 끼운 칸도 저장이 연결됨(새 줄 주요 업무 입력 → 그 줄로 PUT)
const ta9 = row9.querySelector(".pj-meet-text");
ta9.focus(); type(env, ta9, "새 줄 업무"); ta9.blur();
await settle(); await wait(20); await settle();
check("[2h] 다시 끼운 새 줄도 저장 연결", st.items[9] && st.items[9].content === "새 줄 업무", st.items[9]);
// 항목 칸 메뉴(묶음) — 순서 대신 항목 칸 나누기, 아래 추가는 묶음 맨 아래 줄 기준(항목 칸 밖에 따로)
env.d.querySelector('tr[data-item="2"] th.pj-meet-c-label').dispatchEvent(new env.w.MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 5, clientY: 5 }));
labels = Array.from(env.d.querySelectorAll(".pj-ctxmenu-item")).map(itemLabel);
check("[2h] 묶인 항목 칸 메뉴 — 항목 칸 나누기·첫 줄 삭제(위로·아래로 없음)", labels.indexOf("항목 칸 나누기") >= 0 &&
labels.indexOf("첫 줄 삭제") >= 0 && labels.indexOf("위로") < 0 && labels.indexOf("아래로") < 0, labels);
Array.from(env.d.querySelectorAll(".pj-ctxmenu-item")).find(function (b) { return itemLabel(b) === "아래에 줄 추가"; }).click();
await settle(); await wait(20); await settle();
check("[2h] 항목 칸에서 아래 줄 추가 → 묶음 맨 아래 줄(3) 기준·따로(같은 항목 아님)·이름 물음",
posts.length === 2 && String(posts[1].ref_item_id) === "3" && !posts[1].same_label && env.prompts.length === prompts + 1, posts[1]);
// 이어 붙은 줄의 주요 업무 칸 → 줄 삭제(흐려지며 사라진 뒤 다시 그림)
let deleted = null;
env.route("DELETE", /\/project\/api\/goals\/meeting-items\/\d+$/, function (u) { deleted = u; return { body: { ok: true } }; });
const gets = st.gets;
const row3 = env.d.querySelector('tr[data-item="3"]');
row3.querySelector('td[data-meet-item="3"]').dispatchEvent(new env.w.MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 5, clientY: 5 }));
Array.from(env.d.querySelectorAll(".pj-ctxmenu-item")).find(function (b) { return itemLabel(b) === "줄 삭제"; }).click();
await settle(); await wait(20); await settle();
check("[2h] 주요 업무 칸 줄 삭제 → 그 줄 DELETE · 흐려짐 · 표 다시 받음",
/\/meeting-items\/3$/.test(deleted || "") && animated.some(function (a) { return a[0] === row3 && a[1][1].opacity === 0; }) &&
st.gets === gets + 1 && env.navigations === 0, [deleted, st.gets]);
});
clearTimeout(WATCHDOG);
const realUnhandled = unhandled.filter(function (m) { return !/Not implemented/.test(m); });
check("처리 안 된 Promise 거부 없음", realUnhandled.length === 0, realUnhandled);
console.log(fails.length ? fails.length + " FAIL" : "ALL PASS");
process.exit(fails.length ? 1 : 0);
})().catch(function (e) { console.error(e); process.exit(1); });