|
|
|
@@ -88,6 +88,7 @@ function makeEnv(html, url, opts) {
|
|
|
|
|
}
|
|
|
|
|
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(JS);
|
|
|
|
|
env.d.dispatchEvent(new env.w.Event("DOMContentLoaded"));
|
|
|
|
|
await settle();
|
|
|
|
@@ -137,16 +138,16 @@ function goalsServer(env, st) {
|
|
|
|
|
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(/(<textarea class="pj-goal-text"[^>]*data-row="(\d+)" data-month="(\d+)"[^>]*>)([\s\S]*?)(<\/textarea>)/g,
|
|
|
|
|
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 ? st.cells[k].replace(/&/g, "&").replace(/</g, "<") : text) + close;
|
|
|
|
|
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"><textarea class="pj-goal-text" rows="1" data-row="30" data-month="0"></textarea></td>' +
|
|
|
|
|
'<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 };
|
|
|
|
@@ -154,6 +155,13 @@ function goalsServer(env, st) {
|
|
|
|
|
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 || {});
|
|
|
|
@@ -368,14 +376,14 @@ function meetServer(env, st) {
|
|
|
|
|
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('textarea.pj-goal-text[data-row="10"][data-month="1"]');
|
|
|
|
|
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('textarea.pj-goal-text[data-row="10"][data-month="1"]').value === "unsaved important plan");
|
|
|
|
|
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 () { // 진행 중 저장 → 그 저장이 끝난 뒤에 영역 추가, 성공하면 표 교체(새 영역 보임, 저장된 글 유지)
|
|
|
|
@@ -383,7 +391,7 @@ function meetServer(env, st) {
|
|
|
|
|
const gate = deferred();
|
|
|
|
|
const st = goalsServer(env, { cellHook: async function () { await gate.promise; } });
|
|
|
|
|
await boot(env);
|
|
|
|
|
const ta = env.d.querySelector('textarea.pj-goal-text[data-row="10"][data-month="1"]');
|
|
|
|
|
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();
|
|
|
|
@@ -394,7 +402,7 @@ function meetServer(env, st) {
|
|
|
|
|
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('textarea.pj-goal-text[data-row="10"][data-month="1"]').value === "plan v2");
|
|
|
|
|
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: "새 영역" });
|
|
|
|
@@ -404,19 +412,19 @@ function meetServer(env, st) {
|
|
|
|
|
await boot(env);
|
|
|
|
|
env.d.getElementById("pj-goal-area-add").click();
|
|
|
|
|
await settle();
|
|
|
|
|
const ta = env.d.querySelector('textarea.pj-goal-text[data-row="11"][data-month="1"]');
|
|
|
|
|
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('textarea.pj-goal-text[data-row="11"][data-month="1"]').value === "typed during refresh");
|
|
|
|
|
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('textarea.pj-goal-text[data-row="10"][data-month="1"]');
|
|
|
|
|
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 }));
|
|
|
|
@@ -656,6 +664,33 @@ function meetServer(env, st) {
|
|
|
|
|
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.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"]');
|
|
|
|
|
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");
|
|
|
|
|
const format = function (name, value, event) { const el = d.querySelector('[data-goal-format="' + name + '"]'); el.value = value; fire(env, el, event || "change"); };
|
|
|
|
|
format("bold", "700"); format("color", "#ff0000", "input"); format("size", "20");
|
|
|
|
|
let runs = w.PJGoalText.readRuns(editor);
|
|
|
|
|
check("[서식] 선택한 두 글자에만 색·굵기·크기", runs.length === 3 && runs[0].text === "앞 " && runs[1].text === "선택" && runs[1].bold === true && runs[1].color === "#ff0000" && runs[1].size === 20 && !runs[2].bold, runs);
|
|
|
|
|
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);
|
|
|
|
|
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"]').value === "400" && d.querySelector('[data-goal-format="size"]').value === "14");
|
|
|
|
|
plainRange.collapse(true); w.getSelection().removeAllRanges(); w.getSelection().addRange(plainRange); fire(env, fresh, "keyup");
|
|
|
|
|
check("[서식] 글자 선택을 해제하면 이전 선택에 적용하지 않음", d.querySelector('[data-goal-format="reset"]').disabled);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
clearTimeout(WATCHDOG);
|
|
|
|
|
const realUnhandled = unhandled.filter(function (m) { return !/Not implemented/.test(m); });
|
|
|
|
|
check("처리 안 된 Promise 거부 없음", realUnhandled.length === 0, realUnhandled);
|
|
|
|
|