cd3577b299
- Weeks stay inside the month: week 1 starts on the 1st (through the next Sunday if the 1st is a weekend); a trailing Mon/Tue joins the last week. "Last week" is the previous period. - Prev-week review columns: 전주 업무 | 결과(text, new result_note) | 전주 목표 | 결과(amount). - Header now shows month target, cumulative weekly target, month-to-date sales and gap (amount + %), with decisions/notes beside it; the area stays fixed while scrolling. - Goals board: the monthly sales target is entered per week; the sum becomes the month target. - Migration 020: result_note, goal_week_targets, drop Monday-only check, move absorbed Monday meetings to the new week start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
101 lines
5.5 KiB
JavaScript
101 lines
5.5 KiB
JavaScript
// python tests/js/render_help.py && node tests/js/help_ui.test.js (jsdom 필요)
|
|
const assert = require("node:assert/strict");
|
|
const fs = require("node:fs");
|
|
const path = require("node:path");
|
|
const { JSDOM } = require("jsdom");
|
|
const ROOT = path.resolve(__dirname, "../..");
|
|
const html = fs.readFileSync(path.join(__dirname, ".out/help_render.html"), "utf8");
|
|
const js = fs.readFileSync(path.join(ROOT, "app/static/project-help.js"), "utf8");
|
|
function boot(url) {
|
|
const dom = new JSDOM(html, { url: url || "http://localhost/project/help", runScripts: "outside-only" });
|
|
const w = dom.window;
|
|
w.HTMLElement.prototype.scrollIntoView = function () { w.lastScroll = this.id; };
|
|
w.eval(js);
|
|
return dom;
|
|
}
|
|
const dom = boot(), w = dom.window, d = w.document;
|
|
const input = d.getElementById("pjh-query");
|
|
function search(query) { input.value = query; input.dispatchEvent(new w.Event("input", { bubbles: true })); }
|
|
function links() { return Array.from(d.querySelectorAll("#pjh-results a")); }
|
|
function reset() { d.getElementById("pjh-search-clear").click(); }
|
|
|
|
assert.equal(d.querySelectorAll(".pjh-sec").length, 22);
|
|
assert.equal(d.querySelectorAll(".pjh-toc a").length, 22);
|
|
assert.equal(d.getElementById("pjh-search").hidden, false);
|
|
assert.equal(d.getElementById("pjh-results").hidden, true);
|
|
const ids = Array.from(d.querySelectorAll("[id]")).map(n => n.id);
|
|
assert.equal(new Set(ids).size, ids.length, "앵커 ID는 중복 없음");
|
|
Array.from(d.querySelectorAll('.pjh a[href^="#"]')).forEach(function (link) {
|
|
assert.ok(d.getElementById(link.getAttribute("href").slice(1)), "도움말 내부 링크 유효");
|
|
});
|
|
|
|
search("셀 병합");
|
|
assert.equal(links()[0].hash, "#goals-merge", "소제목 일치를 먼저 표시");
|
|
assert.ok(links()[0].querySelector("mark"));
|
|
assert.ok(d.querySelector("#goals mark"), "본문도 일치어 강조");
|
|
links()[0].click();
|
|
assert.equal(w.location.hash, "#goals-merge");
|
|
assert.equal(d.activeElement.id, "goals-merge", "결과 클릭은 해당 소제목에 포커스");
|
|
assert.equal(w.lastScroll, "goals-merge");
|
|
assert.equal(d.querySelector('.pjh-toc [aria-current="location"]').hash, "#goals");
|
|
assert.equal(new URL(w.location.href).searchParams.get("q"), "셀 병합");
|
|
|
|
search("바로 앞 주차");
|
|
assert.ok(links().some(a => a.hash === "#meetings-review"), "제목에 없는 본문 단어도 검색");
|
|
search("매출 갱신");
|
|
assert.equal(links()[0].hash, "#meetings-markets");
|
|
d.getElementById("pjh-search-form").dispatchEvent(new w.Event("submit", { bubbles: true, cancelable: true }));
|
|
assert.equal(d.activeElement.id, "meetings-markets", "Enter/submit은 첫 결과 이동");
|
|
|
|
const original = d.getElementById("meetings").textContent;
|
|
search("ROAS");
|
|
assert.ok(links().some(a => a.hash === "#goals-metrics"), "영문 대소문자 구분 안 함");
|
|
search("로아스");
|
|
assert.ok(links().length > 0, "한글 검색");
|
|
search("원");
|
|
assert.ok(links().length > 0, "한 글자 검색");
|
|
search(" 매출 갱신 ");
|
|
assert.equal(links()[0].hash, "#meetings-markets", "연속 공백·여러 단어 검색");
|
|
search("zz-no-help-match");
|
|
assert.equal(links().length, 0);
|
|
assert.match(d.getElementById("pjh-search-status").textContent, /결과가 없습니다/);
|
|
search("<img src=x onerror=alert(1)>");
|
|
assert.equal(links().length, 0, "HTML을 검색어 문자열로만 처리");
|
|
assert.equal(d.querySelector('img[src="x"]'), null);
|
|
search("[");
|
|
assert.equal(links().length, 0, "정규식 특수문자에도 예외 없음");
|
|
reset();
|
|
assert.equal(input.value, "");
|
|
assert.equal(d.getElementById("pjh-results").hidden, true);
|
|
assert.equal(d.querySelectorAll("mark.pjh-match").length, 0);
|
|
assert.equal(d.getElementById("meetings").textContent, original, "검색·초기화 뒤 원문 보존");
|
|
assert.equal(new URL(w.location.href).searchParams.has("q"), false);
|
|
assert.equal(d.activeElement, input);
|
|
search("분기");
|
|
input.dispatchEvent(new w.KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true }));
|
|
assert.equal(input.value, "");
|
|
d.body.dispatchEvent(new w.KeyboardEvent("keydown", { key: "/", bubbles: true, cancelable: true }));
|
|
assert.equal(d.activeElement, input, "/ 단축키는 도움말 검색");
|
|
|
|
search("셀 병합");
|
|
input.dispatchEvent(new w.CompositionEvent("compositionstart", { bubbles: true }));
|
|
input.value = "회의록";
|
|
input.dispatchEvent(new w.Event("input", { bubbles: true }));
|
|
const before = w.location.hash;
|
|
d.getElementById("pjh-search-form").dispatchEvent(new w.Event("submit", { cancelable: true }));
|
|
assert.equal(w.location.hash, before, "한글 조합 중 submit은 이동 안 함");
|
|
assert.equal(links()[0].hash, "#goals-merge", "조합 중 검색 안 함");
|
|
input.dispatchEvent(new w.CompositionEvent("compositionend", { bubbles: true }));
|
|
assert.ok(links().some(a => a.hash === "#meetings-intro"), "조합 확정 뒤 검색");
|
|
|
|
const restored = boot("http://localhost/project/help?q=" + encodeURIComponent("매출 갱신") + "#meetings-markets");
|
|
assert.equal(restored.window.document.getElementById("pjh-query").value, "매출 갱신");
|
|
assert.equal(restored.window.document.activeElement.id, "meetings-markets", "공유 링크·새로고침 복원");
|
|
w.history.pushState(null, "", "/project/help?q=" + encodeURIComponent("셀 병합") + "#goals-merge");
|
|
w.dispatchEvent(new w.PopStateEvent("popstate"));
|
|
assert.equal(input.value, "셀 병합");
|
|
assert.equal(d.activeElement.id, "goals-merge", "뒤로 가기 위치·검색 복원");
|
|
restored.window.close();
|
|
dom.window.close();
|
|
console.log("ALL PASS — 도움말 검색·앵커·한글 조합·안전한 문자열·초기화·URL 복원");
|