fix(project): fit goal rows to text height

This commit is contained in:
2026-10-03 07:59:22 +09:00
parent b32f2ac3a3
commit 2c8542339d
12 changed files with 104 additions and 21 deletions
+1
View File
@@ -28,6 +28,7 @@ node tests/js/goals_meeting_ui.test.js # jsdom 필요(npm install jsdom
목표 열 자동 맞춤은 실제 Chromium에서도 검증한다. 로컬 테스트 HTML·프로젝트 CSS/폰트를 사용하며 운영 서버·DB에 연결하지 않는다.
부분 서식과 셀 여백, 명시적 줄바꿈, 75% 배율, 600px를 넘는 긴 문단, 저장된 너비 복원을 확인한다.
행 높이는 3줄/2줄 셀의 상단 정렬·같은 위아래 여백, 한 줄로 줄였을 때 높이 축소, 큰 글씨, 보기 전용 화면까지 확인한다.
```powershell
python tests/js/render_goals.py
+65 -1
View File
@@ -12,7 +12,8 @@ const STATIC = path.join(ROOT, "app/static");
const server = http.createServer(function (req, res) {
const url = new URL(req.url, "http://localhost");
if (url.pathname === "/project/goals/2026") {
const html = fs.readFileSync(path.join(__dirname, ".out/goals_admin.html"), "utf8")
const fixture = url.searchParams.has("readonly") ? "goals_ro.html" : "goals_admin.html";
const html = fs.readFileSync(path.join(__dirname, ".out", fixture), "utf8")
.replace("<body>", '<body style="font-family:var(--pj-font)"><div class="erp-app">')
.replace("</body>", "</div></body>");
res.setHeader("Content-Type", "text/html; charset=utf-8"); res.end(html); return;
@@ -137,6 +138,69 @@ const server = http.createServer(function (req, res) {
assert(Math.abs(merged.actual - parseFloat(before) - merged.last) < 1, JSON.stringify(merged));
console.log("PASS merged cell mapping, one unwrapped paragraph, other column unchanged");
await mergedPage.close();
for (const readonly of [false, true]) {
const heightPage = await browser.newPage({ viewport: { width: 1600, height: 1000 } });
await heightPage.addInitScript(function () {
document.addEventListener("DOMContentLoaded", function () {
const row = document.querySelector('tr[data-row-id="10"]');
row.querySelector('td[data-month="0"] > div').textContent = "첫 번째 줄\n두 번째 줄\n세 번째 줄";
row.querySelector('td[data-month="1"] > div').textContent = "첫 줄\n둘째 줄";
});
});
await heightPage.goto("http://127.0.0.1:" + server.address().port + "/project/goals/2026" + (readonly ? "?readonly=1" : ""));
await heightPage.evaluate(function () {
// 세 줄은 열 폭에 의해 추가로 접히지 않도록 연간 열만 넓힌다.
const h = document.querySelector('thead .pj-goal-colresize[data-col="y"]');
h.dispatchEvent(new MouseEvent("dblclick", { bubbles: true, cancelable: true }));
});
async function rowMetrics() {
return heightPage.evaluate(function () {
const row = document.querySelector('tr[data-row-id="10"]');
const long = row.querySelector('td[data-month="0"] > div'), short = row.querySelector('td[data-month="1"] > div');
const cell = long.closest("td"), style = getComputedStyle(long), cellStyle = getComputedStyle(cell);
const range = document.createRange(); range.selectNodeContents(long);
return { row: row.getBoundingClientRect().height, editor: long.getBoundingClientRect().height,
paddingTop: parseFloat(style.paddingTop), paddingBottom: parseFloat(style.paddingBottom),
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"; }),
oneLineRow: document.querySelector('tr[data-row-id="11"]').getBoundingClientRect().height };
});
}
const initial = await rowMetrics();
assert.equal(initial.lines, 3, JSON.stringify(initial));
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.oneLineRow <= 36, "한 줄 셀은 불필요한 빈 줄 없이 내용에 맞는 높이: " + initial.oneLineRow);
if (!readonly) {
await heightPage.evaluate(function () {
const row = document.querySelector('tr[data-row-id="10"]');
const long = row.querySelector('td[data-month="0"] > div'), short = row.querySelector('td[data-month="1"] > div');
long.value = "한 줄"; short.value = "한 줄";
long.dispatchEvent(new Event("input", { bubbles: true })); short.dispatchEvent(new Event("input", { bubbles: true }));
});
const smaller = await rowMetrics();
assert(smaller.row < initial.row && smaller.row <= 36, JSON.stringify({ initial, smaller }));
await heightPage.evaluate(function () {
const editor = document.querySelector('tr[data-row-id="10"] td[data-month="1"] > div');
editor.value = "pj-rich:v1:" + JSON.stringify([{ text: "큰 글씨\n두 줄", size: 32, bold: true }]);
editor.dispatchEvent(new Event("input", { bubbles: true }));
});
const largeText = await heightPage.evaluate(function () {
const editor = document.querySelector('tr[data-row-id="10"] td[data-month="1"] > div');
return { row: editor.closest("tr").getBoundingClientRect().height, editor: editor.getBoundingClientRect().height,
clipped: editor.scrollHeight > editor.clientHeight, border: parseFloat(getComputedStyle(editor.closest("td")).borderBottomWidth) };
});
assert(largeText.row > smaller.row && !largeText.clipped);
assert(Math.abs(largeText.row - largeText.editor - largeText.border) <= 1, JSON.stringify(largeText));
}
console.log("PASS content row height, symmetric padding, top alignment" + (readonly ? " (read-only)" : ", shrink and large font"));
await heightPage.close();
}
console.log("ALL PASS");
} finally {
if (browser) await browser.close();