fix(project): fit meeting rows and inline badges
This commit is contained in:
@@ -18,6 +18,14 @@ const server = http.createServer(function (req, res) {
|
||||
.replace("</body>", "</div></body>");
|
||||
res.setHeader("Content-Type", "text/html; charset=utf-8"); res.end(html); return;
|
||||
}
|
||||
if (url.pathname === "/project/goals/2026/meetings/9") {
|
||||
const fixture = url.searchParams.has("readonly") ? "meeting_layout_ro.html" : "meeting_layout_admin.html";
|
||||
const html = fs.readFileSync(path.join(__dirname, ".out", fixture), "utf8")
|
||||
.replace('<link rel="stylesheet"', '<link rel="stylesheet" href="/static/erp.css"><link rel="stylesheet" href="/static/erp-shell.css"><link rel="stylesheet"')
|
||||
.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;
|
||||
}
|
||||
if (url.pathname.startsWith("/project/api/")) {
|
||||
res.setHeader("Content-Type", "application/json"); res.end("{}"); return;
|
||||
}
|
||||
@@ -201,6 +209,63 @@ const server = http.createServer(function (req, res) {
|
||||
console.log("PASS content row height, symmetric padding, top alignment" + (readonly ? " (read-only)" : ", shrink and large font"));
|
||||
await heightPage.close();
|
||||
}
|
||||
for (const readonly of [false, true]) {
|
||||
const meetingPage = await browser.newPage({ viewport: { width: 1600, height: 1000 } });
|
||||
await meetingPage.goto("http://127.0.0.1:" + server.address().port + "/project/goals/2026/meetings/9" + (readonly ? "?readonly=1" : ""));
|
||||
await meetingPage.evaluate(() => document.fonts.ready);
|
||||
async function meetingMetrics() {
|
||||
return meetingPage.evaluate(function () {
|
||||
const row = document.querySelector('tr[data-item="2"]');
|
||||
const long = row.querySelector(".pj-meet-c-text:not(.is-prev) > *"), short = row.querySelector(".pj-meet-c-text.is-prev > *");
|
||||
const cell = long.closest("td"), style = getComputedStyle(long), cs = getComputedStyle(cell);
|
||||
const zoom = document.documentElement.classList.contains("pj-ui-scale") ? 0.75 : 1;
|
||||
const labels = Array.from(document.querySelectorAll(".pj-meet-market")).map(function (badge) {
|
||||
const name = badge.previousElementSibling, br = badge.getBoundingClientRect(), nr = name.getBoundingClientRect();
|
||||
return { text: badge.textContent, rightOfName: br.left >= nr.right,
|
||||
sameLine: br.top < nr.bottom && nr.top < br.bottom,
|
||||
fits: br.right <= badge.closest("th").getBoundingClientRect().right };
|
||||
});
|
||||
return { row: row.getBoundingClientRect().height / zoom, long: long.getBoundingClientRect().height / zoom,
|
||||
short: short.getBoundingClientRect().height / zoom, line: parseFloat(style.lineHeight),
|
||||
top: parseFloat(style.paddingTop), bottom: parseFloat(style.paddingBottom),
|
||||
border: parseFloat(cs.borderTopWidth) + parseFloat(cs.borderBottomWidth),
|
||||
topDifference: (short.getBoundingClientRect().top - long.getBoundingClientRect().top) / zoom,
|
||||
oneLine: document.querySelector('tr[data-item="4"]').getBoundingClientRect().height / zoom,
|
||||
emptySlot: document.querySelector('tr[data-item="4"] .pj-meet-week-slot').getBoundingClientRect().height,
|
||||
cellsAtTop: Array.from(row.querySelectorAll("td, th.pj-meet-c-label")).every(c => getComputedStyle(c).verticalAlign === "top"),
|
||||
labels, clipped: long.scrollHeight > long.clientHeight };
|
||||
});
|
||||
}
|
||||
function checkMeeting(m, lines) {
|
||||
assert.equal(m.top, m.bottom, JSON.stringify(m));
|
||||
assert(Math.abs(m.long - (m.line * lines + m.top + m.bottom)) <= 1, JSON.stringify(m));
|
||||
assert(Math.abs(m.row - m.long - m.border) <= 1, JSON.stringify(m));
|
||||
assert(Math.abs(m.topDifference) <= 1 && m.cellsAtTop && !m.clipped, JSON.stringify(m));
|
||||
assert(m.oneLine <= m.line + m.top + m.bottom + m.border + 1 && m.emptySlot === 0, JSON.stringify(m));
|
||||
assert.deepEqual(m.labels.map(b => b.text), ["자동입력", "실적 미사용"]);
|
||||
assert(m.labels.every(b => b.rightOfName && b.sameLine && b.fits), JSON.stringify(m.labels));
|
||||
}
|
||||
const initial = await meetingMetrics();
|
||||
checkMeeting(initial, 3);
|
||||
assert(Math.abs(initial.short - initial.line * 2 - initial.top - initial.bottom) <= 1, JSON.stringify(initial));
|
||||
if (!readonly) {
|
||||
await meetingPage.locator('tr[data-item="2"] textarea').fill("한 줄");
|
||||
await meetingPage.locator('tr[data-item="2"] .is-prev .pj-meet-ro').evaluate(e => { e.textContent = "한 줄"; });
|
||||
const smaller = await meetingMetrics();
|
||||
checkMeeting(smaller, 1);
|
||||
assert(smaller.row < initial.row);
|
||||
await meetingPage.locator('tr[data-item="2"] textarea').fill("첫 번째 줄\n두 번째 줄\n세 번째 줄");
|
||||
}
|
||||
await meetingPage.evaluate(function () {
|
||||
document.documentElement.classList.add("pj-ui-scale");
|
||||
window.dispatchEvent(new Event("resize"));
|
||||
});
|
||||
checkMeeting(await meetingMetrics(), 3);
|
||||
await meetingPage.locator("#pj-meet-table").screenshot({ path: path.join(__dirname, ".out", readonly ? "meeting-layout-ro.png" : "meeting-layout-admin.png") });
|
||||
await meetingPage.close();
|
||||
console.log("PASS meeting row height, equal padding, top alignment, inline automatic/unused labels, shrink and 75% zoom" + (readonly ? " (read-only)" : ""));
|
||||
}
|
||||
|
||||
const interactive = await browser.newPage({ viewport: { width: 1600, height: 1000 } });
|
||||
let releaseMove, startedMove;
|
||||
const moveGate = new Promise(function (resolve) { releaseMove = resolve; });
|
||||
|
||||
Reference in New Issue
Block a user