fix(project): stop quarter reveal numeric drift
This commit is contained in:
@@ -43,6 +43,54 @@ const server = http.createServer(function (req, res) {
|
||||
try {
|
||||
await new Promise(function (resolve) { server.listen(0, "127.0.0.1", resolve); });
|
||||
browser = await chromium.launch({ headless: true, executablePath: process.env.PJ_TEST_BROWSER || undefined });
|
||||
// 접기/펼치기 첫 화면부터 숫자 위치·저장 너비가 안정적이어야 한다(관리자·보기 전용·75% 배율).
|
||||
for (const readonly of [false, true]) {
|
||||
const folding = await browser.newPage({ viewport: { width: 1600, height: 1000 } });
|
||||
await folding.goto("http://127.0.0.1:" + server.address().port + "/project/goals/2026" + (readonly ? "?readonly" : ""));
|
||||
await folding.evaluate(() => localStorage.setItem("pj_goal_col_w", JSON.stringify({ m1: 150, m2: 110, m3: 175 })));
|
||||
await folding.reload();
|
||||
await folding.evaluate(async () => { await document.fonts.ready; });
|
||||
for (const zoom of [1, 0.75]) {
|
||||
const result = await folding.evaluate(async zoom => {
|
||||
document.documentElement.style.zoom = zoom;
|
||||
const table = document.getElementById("pj-goal-table");
|
||||
const q = table.querySelector('thead th[data-col="q1"]');
|
||||
const cells = Array.from(table.querySelectorAll('.pj-goal-kpi .pj-goal-m[data-h="1"]'));
|
||||
function snapshot() {
|
||||
return cells.map(c => {
|
||||
const box = c.getBoundingClientRect();
|
||||
const number = c.querySelector(".pj-goal-num");
|
||||
const range = document.createRange(); range.selectNodeContents(c);
|
||||
const content = number ? number.getBoundingClientRect() : range.getBoundingClientRect();
|
||||
return [box.x, box.width, content.x, content.width];
|
||||
});
|
||||
}
|
||||
const before = snapshot();
|
||||
q.click();
|
||||
const hiddenImmediately = cells.every(c => getComputedStyle(c).display === "none");
|
||||
q.click();
|
||||
const frames = [snapshot()];
|
||||
for (let i = 0; i < 6; i++) {
|
||||
await new Promise(requestAnimationFrame); frames.push(snapshot());
|
||||
}
|
||||
// 기존 애니메이션 종료 시점에도 폭·숫자 위치가 바뀌지 않아야 한다.
|
||||
await new Promise(resolve => setTimeout(resolve, 400)); frames.push(snapshot());
|
||||
q.click(); q.click(); q.click();
|
||||
const rapidHidden = cells.every(c => getComputedStyle(c).display === "none");
|
||||
const savedFold = JSON.parse(localStorage.getItem("pj_goal_fold_q"))[1];
|
||||
q.click();
|
||||
return { before, frames, hiddenImmediately, rapidHidden, savedFold,
|
||||
widths: ["m1", "m2", "m3"].map(key => table.querySelector('thead th[data-col="' + key + '"]').getBoundingClientRect().width / zoom) };
|
||||
}, zoom);
|
||||
assert(result.hiddenImmediately && result.rapidHidden && result.savedFold, JSON.stringify(result));
|
||||
result.frames.forEach(frame => frame.forEach((cell, i) => cell.forEach((value, j) => {
|
||||
assert(Math.abs(value - result.before[i][j]) < 0.1, "quarter numeric position changed during reveal");
|
||||
})));
|
||||
result.widths.forEach((width, i) => assert(Math.abs(width - [150, 110, 175][i]) < 1));
|
||||
}
|
||||
await folding.close();
|
||||
}
|
||||
console.log("PASS instant quarter reveal keeps numeric positions, saved widths and rapid-toggle state at 100%/75%");
|
||||
const page = await browser.newPage({ viewport: { width: 1600, height: 1000 } });
|
||||
const errors = [], writes = [];
|
||||
page.on("pageerror", function (e) { errors.push(e.message); });
|
||||
@@ -173,7 +221,11 @@ const server = http.createServer(function (req, res) {
|
||||
border: parseFloat(cellStyle.borderTopWidth) + parseFloat(cellStyle.borderBottomWidth),
|
||||
topDifference: short.getBoundingClientRect().top - long.getBoundingClientRect().top,
|
||||
lines: new Set(Array.from(range.getClientRects()).filter(function (r) { return r.width > 0; }).map(function (r) { return r.top; })).size,
|
||||
namesAtTop: Array.from(row.querySelectorAll("th")).every(function (th) { return getComputedStyle(th).verticalAlign === "top"; }),
|
||||
namesCentered: Array.from(row.querySelectorAll("th")).every(function (th) {
|
||||
const name = th.querySelector(".pj-goal-area-text, .pj-goal-row-text");
|
||||
const box = th.getBoundingClientRect(), text = name.getBoundingClientRect();
|
||||
return getComputedStyle(th).verticalAlign === "middle" && Math.abs((box.top + box.bottom - text.top - text.bottom) / 2) <= 1;
|
||||
}),
|
||||
oneLineRow: document.querySelector('tr[data-row-id="11"]').getBoundingClientRect().height };
|
||||
});
|
||||
}
|
||||
@@ -182,7 +234,7 @@ const server = http.createServer(function (req, res) {
|
||||
assert.equal(initial.paddingTop, initial.paddingBottom);
|
||||
assert(Math.abs(initial.row - initial.editor - initial.border) <= 1, JSON.stringify(initial));
|
||||
assert(Math.abs(initial.topDifference) <= 1, "짧은 셀도 긴 셀과 같은 위치에서 상단 정렬");
|
||||
assert(initial.namesAtTop, "구역·항목 이름도 상단 정렬");
|
||||
assert(initial.namesCentered, "구역·항목 이름은 병합된 셀도 세로 가운데 정렬");
|
||||
assert(initial.oneLineRow <= 36, "한 줄 셀은 불필요한 빈 줄 없이 내용에 맞는 높이: " + initial.oneLineRow);
|
||||
if (!readonly) {
|
||||
await heightPage.evaluate(function () {
|
||||
|
||||
@@ -604,8 +604,10 @@ function meetServer(env, st) {
|
||||
// 분기 접기는 보기 전용도
|
||||
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("[회귀] 분기 머리 클릭 → 즉시 접힘(보기 전용도)", qth.classList.contains("is-folded") && env.d.querySelector('td.pj-goal-m[data-h="1"]').classList.contains("is-gone"));
|
||||
check("[회귀] 접기 상태 기억", /"1":true/.test(env.w.localStorage.getItem("pj_goal_fold_q") || ""));
|
||||
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-gone"));
|
||||
});
|
||||
await section(async function () { // 회귀 — 열 너비 끌기·고정 열 변수·스크롤 위치 되살리기
|
||||
const env = makeEnv(PAGE.goals_admin, GOALS_URL, { session: { pj_goal_scroll: JSON.stringify(["/project/goals/2026", 120, 45]) } });
|
||||
|
||||
Reference in New Issue
Block a user