Merge branch 'fix/perf-manual-cell-width'

This commit is contained in:
2026-10-12 17:31:12 +09:00
4 changed files with 62 additions and 5 deletions
@@ -1,6 +1,6 @@
{% extends "erp_base.html" %}
{% block head_extra %}<link rel="stylesheet" href="/static/performance.css?v=20261012b" />{% endblock %}
{% block head_extra %}<link rel="stylesheet" href="/static/performance.css?v=20261012c" />{% endblock %}
{%- macro won(v) -%}
{%- if v is none -%}<span class="perf-na"></span>
@@ -1,6 +1,6 @@
{% extends "erp_base.html" %}
{% block head_extra %}<link rel="stylesheet" href="/static/performance.css?v=20261012b" />{% endblock %}
{% block head_extra %}<link rel="stylesheet" href="/static/performance.css?v=20261012c" />{% endblock %}
{%- macro when(v) -%}{{ (v or '')[:16] | replace('T', ' ') or '—' }}{%- endmacro -%}
+4 -3
View File
@@ -136,9 +136,10 @@ td.is-link:hover { background: #eef2ff; text-decoration: underline; }
.perf-main td.is-manual-cell:focus { outline: 2px solid #1a56db; outline-offset: -2px; }
.perf-main td.is-manual .v-gross { color: #1a56db; font-weight: 600; }
.perf-main td.is-stale .v-commission, .perf-main td.is-stale .v-net { opacity: .4; }
.perf-main td.is-editing { padding: 2px 4px; }
.perf .perf-main td.is-editing .v { display: none; }
.perf-manual-input { width: 100%; min-width: 90px; box-sizing: border-box; padding: 3px 6px; border: 1px solid #1a56db; border-radius: 4px;
/* 입력칸은 칸 위에 겹쳐 띄운다(표 배치에서 빠짐) — 숫자는 자리만 남기고 숨겨 열 너비가 그대로 */
.perf .perf-main td.is-editing .v { visibility: hidden; }
.perf-manual-input { position: absolute; top: 2px; right: 2px; bottom: 2px; left: 2px; width: auto; min-width: 0; height: auto;
box-sizing: border-box; margin: 0; padding: 0 6px; border: 1px solid #1a56db; border-radius: 4px;
font: inherit; text-align: right; background: #fff; outline: none; }
.perf-manual-help { margin: 8px 2px 0; font-size: 12px; }
.perf[data-metric="gross"] .v-gross,
+56
View File
@@ -0,0 +1,56 @@
// 실적 수동 입력 칸 — 실제 브라우저(Chromium). 칸을 눌러 입력칸이 떠도 열 너비·행 높이가 그대로인지.
// python tests/js/render_performance.py
// NODE_PATH=<playwright 경로> PJ_TEST_BROWSER=<Chrome 경로> node tests/js/perf_manual.browser.test.js
const fs = require("fs"), path = require("path");
const { chromium } = require("playwright");
const ROOT = path.join(__dirname, "..", "..");
const fails = [];
function check(name, cond, extra) {
if (cond) console.log("PASS " + name);
else { console.log("FAIL " + name + (extra !== undefined ? " → " + JSON.stringify(extra) : "")); fails.push(name); }
}
(async function () {
// 바꿔 넣는 글에 $ 가 있어도 그대로 들어가게 함수로 치환
const css = fs.readFileSync(process.env.PERF_CSS || path.join(ROOT, "app", "static", "performance.css"), "utf8");
const js = fs.readFileSync(path.join(ROOT, "app", "static", "performance.js"), "utf8");
const html = fs.readFileSync(path.join(__dirname, ".out", "perf_dash.html"), "utf8")
.replace(/<link rel="stylesheet" href="\/static\/performance\.css[^"]*" \/>/, function () { return "<style>" + css + "</style>"; })
.replace(/<script src="\/static\/performance\.js[^"]*" defer><\/script>/, function () { return "<script>" + js + "</script>"; });
const browser = await chromium.launch(process.env.PJ_TEST_BROWSER ? { executablePath: process.env.PJ_TEST_BROWSER } : {});
try {
for (const width of [1400, 900]) {
const page = await browser.newPage({ viewport: { width: width, height: 900 } });
await page.route("**/performance/api/**", function (r) { r.fulfill({ status: 200, contentType: "application/json", body: "{}" }); });
await page.setContent(html, { waitUntil: "load" });
const measure = function () {
return page.evaluate(function () {
const ths = Array.from(document.querySelectorAll(".perf-main thead th")).map(function (th) { return Math.round(th.getBoundingClientRect().width); });
const row = document.querySelector('td.is-manual-cell[data-manual-code="kakao"][data-date="2026-10-05"]').closest("tr");
return { ths: ths, h: Math.round(row.getBoundingClientRect().height) };
});
};
const before = await measure();
for (const sel of ['td.is-manual-cell[data-manual-code="kakao"][data-date="2026-10-05"]',
'td.is-manual-cell[data-manual-code="coupang"][data-date="2026-10-05"]']) {
await page.click(sel);
const during = await measure();
const inp = await page.evaluate(function (s) {
const td = document.querySelector(s), i = td.querySelector(".perf-manual-input");
if (!i) return null;
const a = td.getBoundingClientRect(), b = i.getBoundingClientRect();
return { inside: b.left >= a.left - 0.5 && b.right <= a.right + 0.5 && b.top >= a.top - 0.5 && b.bottom <= a.bottom + 0.5,
focused: document.activeElement === i, w: Math.round(b.width) };
}, sel);
check("[" + width + "px] " + sel.match(/code="(\w+)"/)[1] + " 칸 입력 — 열 너비 그대로", JSON.stringify(during.ths) === JSON.stringify(before.ths),
{ before: before.ths, during: during.ths });
check("[" + width + "px] " + sel.match(/code="(\w+)"/)[1] + " 칸 입력 — 행 높이 그대로·입력칸이 칸 안·포커스",
during.h === before.h && inp && inp.inside && inp.focused && inp.w > 20, { h: [before.h, during.h], inp: inp });
await page.keyboard.press("Escape");
}
await page.close();
}
} finally { await browser.close(); }
console.log(fails.length ? "\n" + fails.length + " FAILED" : "\nALL PASS");
process.exit(fails.length ? 1 : 0);
})();