feat(project): add font options and selected goal text formatting
Restore the board header add button to the task side panel while keeping footer quick entry. Add safe, persisted goal text formatting and self-hosted Project font preferences with shared help updates and regression coverage.
This commit is contained in:
@@ -33,6 +33,9 @@ function makeEnv() {
|
||||
const dom = new JSDOM(html, { runScripts: "dangerously", pretendToBeVisual: true, url: "http://localhost/project/p/1" });
|
||||
const w = dom.window, d = w.document;
|
||||
w.__PJ_TEST__ = true;
|
||||
w.HTMLDialogElement.prototype.showModal = function () { this.open = true; };
|
||||
w.HTMLDialogElement.prototype.close = function () { this.open = false; this.dispatchEvent(new w.Event("close")); };
|
||||
Object.defineProperty(d, "fonts", { configurable: true, value: { load: async function () { return [{}]; } } });
|
||||
w.HTMLCanvasElement.prototype.getContext = function () { return null; };
|
||||
w.URL.createObjectURL = function () { return "blob:x"; };
|
||||
w.URL.revokeObjectURL = function () {};
|
||||
@@ -103,6 +106,7 @@ async function boot(env) {
|
||||
// 문제없음, 기존 코드 그대로). 테스트에서는 버튼 보강을 건너뛰고 원래 입력칸으로 시험한다.
|
||||
env.d.querySelectorAll("select").forEach(function (s) { s.dataset.pjEnhanced = "1"; });
|
||||
env.d.querySelectorAll("input[type=date]").forEach(function (i) { i.dataset.pjDate = "1"; });
|
||||
env.w.eval(fs.readFileSync(path.join(ROOT, "app", "static", "project-options.js"), "utf8"));
|
||||
env.w.eval(JS);
|
||||
env.d.dispatchEvent(new env.w.Event("DOMContentLoaded"));
|
||||
await settle();
|
||||
@@ -421,7 +425,7 @@ function titleVal(d) { return d.getElementById("pj-t-title").value; }
|
||||
|
||||
// 보드 빠른 추가 — 세 필드, 조합 입력·중복 저장·실패 복구·취소.
|
||||
{
|
||||
const env = makeEnv(); baseRoutes(env); await boot(env);
|
||||
const env = makeEnv(); baseRoutes(env); const P = await boot(env);
|
||||
const d = env.d, w = env.w, pending = deferred();
|
||||
const posts = function () { return env.calls.filter(function (c) { return c.method === "POST" && /projects\/1\/tasks$/.test(c.url); }); };
|
||||
env.route("POST", /projects\/1\/tasks$/, function () { return pending.promise; });
|
||||
@@ -450,6 +454,9 @@ function titleVal(d) { return d.getElementById("pj-t-title").value; }
|
||||
d.body.dispatchEvent(new w.Event("pointerdown", { bubbles: true })); await wait(10); await settle();
|
||||
check("[board] 빈 카드 바깥 클릭은 빈 작업 생성 없이 닫기", !d.querySelector(".pj-tasknew") && posts().length === 1);
|
||||
d.querySelector('.pj-col[data-stage-id="11"] .pj-col-add').click(); await wait(10);
|
||||
check("[board] 상단 +는 기존 오른쪽 상세창을 열기", !d.getElementById("pj-modal-task").hidden && !d.querySelector(".pj-tasknew"));
|
||||
await P.attemptClose(); await wait(400);
|
||||
d.querySelector('.pj-col[data-stage-id="11"] .pj-col-addtask').click(); await wait(10);
|
||||
input = d.querySelector(".pj-tasknew-title"); input.value = "실패해도 유지"; input.dispatchEvent(new w.Event("input"));
|
||||
env.route("POST", /projects\/1\/tasks$/, function () { return { status: 500, body: { detail: "잠시 오류" } }; });
|
||||
d.body.dispatchEvent(new w.Event("pointerdown", { bubbles: true })); await wait(10); await settle();
|
||||
@@ -496,6 +503,28 @@ function titleVal(d) { return d.getElementById("pj-t-title").value; }
|
||||
check("[board] 기존 다른 부모 카드 이동 유지", env.calls.some(function (c) { return /tasks\/901\/move-parent$/.test(c.url) && c.body.parent_task_id === 102; }) && rows().join(",") === "902,903");
|
||||
}
|
||||
|
||||
{
|
||||
const env = makeEnv(); baseRoutes(env); await boot(env); const d = env.d, w = env.w;
|
||||
const button = d.getElementById("pj-options-btn"), dialog = d.getElementById("pj-options-dialog"), select = d.getElementById("pj-options-font");
|
||||
button.click();
|
||||
check("[옵션] 도움말 옆 옵션은 기본 폰트로 대화창 열기", dialog.open && select.value === "system" && select.options.length === 5);
|
||||
select.value = "pretendard"; select.dispatchEvent(new w.Event("change")); d.getElementById("pj-options-cancel").click();
|
||||
check("[옵션] 취소는 선택한 폰트를 적용하지 않음", !dialog.open && !w.localStorage.getItem("pj_font"));
|
||||
button.click(); select.value = "nanum-square-neo"; d.getElementById("pj-options-save").click(); await settle();
|
||||
check("[옵션] 저장은 폰트 적용·기억 후 대화창 닫기", !dialog.open && w.localStorage.getItem("pj_font") === "nanum-square-neo" && d.documentElement.dataset.pjFont === "nanum-square-neo");
|
||||
button.click(); check("[옵션] 다시 열면 저장한 선택 유지", select.value === "nanum-square-neo");
|
||||
const loading = deferred(); d.fonts.load = function () { return loading.promise; };
|
||||
select.value = "pretendard"; d.getElementById("pj-options-save").click(); await settle();
|
||||
const cancel = new w.Event("cancel", { cancelable: true }); dialog.dispatchEvent(cancel);
|
||||
check("[옵션] 저장 중 취소·Esc로 지연 적용이 발생하지 않음", d.getElementById("pj-options-cancel").disabled && cancel.defaultPrevented && dialog.open);
|
||||
loading.resolve([{}]); await settle();
|
||||
check("[옵션] 폰트 로딩 후 저장 완료", !dialog.open && w.localStorage.getItem("pj_font") === "pretendard");
|
||||
button.click();
|
||||
d.fonts.load = async function () { throw new Error("font failed"); };
|
||||
select.value = "nanum-square-round"; d.getElementById("pj-options-save").click(); await settle();
|
||||
check("[옵션] 폰트 로딩 실패는 이전 설정 유지·재시도 가능", dialog.open && !d.getElementById("pj-options-error").hidden && !select.disabled && w.localStorage.getItem("pj_font") === "pretendard");
|
||||
}
|
||||
|
||||
clearTimeout(WATCHDOG);
|
||||
console.log(fails.length ? "\nFAILED: " + fails.join(", ") : "\nALL PASS");
|
||||
process.exit(fails.length ? 1 : 0);
|
||||
|
||||
Reference in New Issue
Block a user