Files
dbx-main/tests/js/goals_meeting_ui.test.js
T
king ee09e8bfd1 feat(project): move whole meeting sections up/down from the 구분 column
- 구분 cell: right-click or ⋯ menu → 구역 위로 / 구역 아래로 / 구역 끝에 줄 추가
- POST /api/goals/meeting-items/{id}/move-section swaps the contiguous section block
  with its neighbour under the meeting lock (row order and merges follow; 409 after completion)
- Next meetings inherit the new order; help + docs; tests (DB-less, real PostgreSQL, jsdom)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 13:29:53 +09:00

1126 lines
86 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 연간 목표(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"].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(/(<div class="pj-goal-text"[^>]*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<tbody class="pj-goal-area" data-area-id="3" data-color="" style="--goal-bg: #fff">' +
'<tr data-row-id="30"><th class="pj-goal-c1 pj-goal-area-name" rowspan="1"><span class="pj-goal-area-text">새 영역</span></th>' +
'<th class="pj-goal-c2 pj-goal-row-label"><span class="pj-goal-row-text"></span></th>' +
'<td class="pj-goal-texttd pj-goal-year-col" data-month="0" data-span="1" data-rspan="1"><div class="pj-goal-text" contenteditable="true" data-row="30" data-month="0"></div></td>' +
"</tr></tbody>$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);
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);
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); });
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 === 1, [call, env.navigations]);
const last = blocks[blocks.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);
});
// ════════════════════ [2g] 머리 영역 3칸 — 결정 사항은 ②, 작업 등록 표(③): 칸 → 목록 → [적용] = 그 프로젝트에 작업 ════════════════════
await section(async function () {
const env = makeEnv(PAGE.meeting_admin, MEET_URL);
meetServer(env);
let posted = null;
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 }] } }; });
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 }] } }; });
env.route("POST", /\/project\/api\/projects\/7\/tasks$/, function (u, body) { posted = body; return { status: 201, body: { ok: true, task: { id: 555 } } }; });
await boot(env);
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"));
const tr = d.querySelector("#pj-meet-quick tbody tr");
const title = tr.querySelector("input[data-field=title]");
title.value = "상세페이지 수정"; title.dispatchEvent(new env.w.Event("input", { bubbles: true }));
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] 프로젝트 목록 = 최상위 프로젝트", 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 people = await pickItem("assignee", "Kim");
check("[2g] 담당자 목록 = 그 프로젝트 소유자·멤버", people.indexOf("Owner") >= 0 && people.indexOf("Kim") >= 0, people);
d.querySelector('#pj-meet-quick tbody tr [data-quick="apply"]').click(); await settle(); await wait(5); await settle();
check("[2g] 적용 → 그 프로젝트에 작업 생성", posted && posted.title === "상세페이지 수정" && posted.stage_id === 71 && posted.assignee_email === "kim@test.local", posted);
check("[2g] 등록된 줄은 '등록됨' 링크", /등록됨/.test(d.querySelector("#pj-meet-quick tbody tr").textContent) &&
d.querySelector("#pj-meet-quick tbody tr a").getAttribute("href") === "/project/p/7?task=555");
// 등록된 줄 삭제 → 확인 → 그 프로젝트의 작업도 삭제(DELETE), 줄 사라짐
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 && d.querySelectorAll("#pj-meet-quick tbody tr").length === before - 1 &&
!d.querySelector("#pj-meet-quick tbody tr.is-done"), [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] 적용 전 줄 × → 줄만 지움", d.querySelectorAll("#pj-meet-quick tbody tr").length === n - 1 && env.calls.length === calls);
}, { notifyOnFail: true });
// ════════════════════ [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 } }));
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();
check("[회의록 병합] 저장 성공 뒤 화면을 다시 받음", env.navigations === 1);
});
await section(async function () {
const env = makeEnv(fs.readFileSync(path.join(OUT, "meeting_merged.html"), "utf8"), MEET_URL); meetServer(env); await boot(env);
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();
check("[회의록 병합 해제] 첫 셀 ID로 요청하고 화면 갱신", env.calls.some(c => c.method === "DELETE" && /\/meeting-items\/2\/cell-merge$/.test(c.url)) && env.navigations === 1);
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 === "작은큰");
});
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); });