fix(performance): 일자별 표 제목·기간 합계 행 — 페이지 스크롤에 고정(매출·광고비), 스크롤 막대 배경 투명
- 10-26 판은 표 상자 안 세로 스크롤이라 진짜 ERP 셸에서 상자 아래가 화면 밖에 잘리고 휠이 페이지로 안 넘어갔다 - 표 상자 세로 스크롤 없앰 → stickyHead 가 .erp-page 스크롤마다 제목 행·기간 합계 행 칸을 translateY 로 내림(표 끝에서 멈춤), 내려온 동안 제목 칸이 아래 1px 선을 직접 그림(border-collapse 선 틈으로 뒤 줄이 비침 방지) - 스크롤 막대 트랙 투명(scrollbar-color, 표 상자·실적 화면) - perf_sticky.browser.test.js 를 진짜 erp_base.html 셸 렌더(perf_*_shell.html)로 — 휠 스크롤·가로 고정·표 끝 멈춤 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
// 실적 — 기간 빠른 선택(이번달·올해만, 기본 이번달) · 일자별 표 스크롤 고정(2026-10-26) — 실제 브라우저(Chromium).
|
||||
// 실적 — 기간 빠른 선택(이번달·올해만, 기본 이번달) · 일자별 표 제목·기간 합계 행 스크롤 고정(2026-10-26, 10-27 다시) — 실제 브라우저(Chromium).
|
||||
// python tests/js/render_performance.py
|
||||
// NODE_PATH=<playwright 경로> PJ_TEST_BROWSER=<Chrome 경로> node tests/js/perf_sticky.browser.test.js
|
||||
// 매출 실적(이번달)·광고비(이번달): 표 상자 안에서 세로 스크롤하면 제목 행은 상자 맨 위, 기간 합계 행은 제목 행 바로 아래에 붙어 있고
|
||||
// 날짜 칸은 가로 스크롤해도 왼쪽 고정(예전 그대로). 오늘·이번주 버튼은 없다.
|
||||
// 진짜 ERP 셸(erp_base.html — 페이지 스크롤 상자 = .erp-page)로 렌더한 매출 실적·광고비(이번달): 표 위에서 마우스 휠 → 페이지가 스크롤되고
|
||||
// (표 상자는 세로 스크롤 없음 — 예전엔 상자 안에서만 돌아 상자 아래가 화면 밖에 잘렸다) 제목 행은 화면 위, 기간 합계 행은 그 바로 아래,
|
||||
// 표 끝을 넘으면 같이 올라감. 날짜 칸 가로 고정 그대로, 스크롤 막대 배경 투명. 오늘·이번주 버튼 없음.
|
||||
const fs = require("fs"), path = require("path");
|
||||
const { chromium } = require("playwright");
|
||||
const ROOT = path.join(__dirname, "..", "..");
|
||||
@@ -11,64 +12,78 @@ function check(name, cond, extra) {
|
||||
if (cond) console.log("PASS " + name);
|
||||
else { console.log("FAIL " + name + (extra !== undefined ? " → " + JSON.stringify(extra) : "")); fails.push(name); }
|
||||
}
|
||||
function page(file) {
|
||||
const css = fs.readFileSync(path.join(ROOT, "app", "static", "performance.css"), "utf8");
|
||||
const js = fs.readFileSync(path.join(ROOT, "app", "static", "performance.js"), "utf8");
|
||||
return fs.readFileSync(path.join(__dirname, ".out", file), "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>"; });
|
||||
}
|
||||
|
||||
async function stickyFlow(browser, file, label) {
|
||||
const ctx = await browser.newContext({ viewport: { width: 900, height: 600 } });
|
||||
const ctx = await browser.newContext({ viewport: { width: 1300, height: 760 } });
|
||||
const p = await ctx.newPage();
|
||||
await p.route("**/*", function (r) {
|
||||
const url = new URL(r.request().url()).pathname;
|
||||
if (url.startsWith("/performance/api/")) { r.fulfill({ status: 200, contentType: "application/json", body: "{}" }); return; }
|
||||
r.fulfill({ status: 200, contentType: "text/html; charset=utf-8", body: page(file) });
|
||||
if (url.startsWith("/static/")) {
|
||||
const f = path.join(ROOT, "app", url);
|
||||
if (!fs.existsSync(f)) return r.fulfill({ status: 404, body: "" });
|
||||
return r.fulfill({ status: 200, contentType: f.endsWith(".css") ? "text/css" : "application/javascript", body: fs.readFileSync(f) });
|
||||
}
|
||||
if (url.includes("/api/")) return r.fulfill({ status: 200, contentType: "application/json", body: "{}" });
|
||||
r.fulfill({ status: 200, contentType: "text/html; charset=utf-8", body: fs.readFileSync(path.join(__dirname, ".out", file), "utf8") });
|
||||
});
|
||||
await p.goto("http://perf.test/performance/");
|
||||
await p.waitForTimeout(150);
|
||||
const quick = await p.evaluate(function () {
|
||||
return Array.from(document.querySelectorAll(".perf-quick .perf-seg")).map(function (n) { return n.textContent.trim(); });
|
||||
});
|
||||
check(label + " 빠른 선택 = 이번달·올해·직접선택(오늘·이번주 없음)", JSON.stringify(quick) === '["이번달","올해","직접선택"]', quick);
|
||||
const geo = async function () {
|
||||
const geo = function () {
|
||||
return p.evaluate(function () {
|
||||
const wrap = document.querySelector(".perf-main-wrap");
|
||||
const page = document.querySelector(".erp-page"), wrap = document.querySelector(".perf-main-wrap");
|
||||
const head = wrap.querySelector("thead th:nth-child(2)");
|
||||
const total = wrap.querySelector("tbody tr.perf-row-total:first-child");
|
||||
const totalCell = total.querySelector("td");
|
||||
const label = total.querySelector(".perf-td-label");
|
||||
const w = wrap.getBoundingClientRect();
|
||||
return { wrapTop: w.top, wrapLeft: w.left, scrollH: wrap.scrollHeight, clientH: wrap.clientHeight,
|
||||
const cell = total.querySelector("td"), lab = total.querySelector(".perf-td-label");
|
||||
const hit = function (el) {
|
||||
const r = el.getBoundingClientRect();
|
||||
const x = document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2);
|
||||
return !!x && !!x.closest("tr.perf-row-total");
|
||||
};
|
||||
const table = wrap.querySelector("table").getBoundingClientRect();
|
||||
return { pageTop: page.getBoundingClientRect().top, pageScroll: page.scrollTop,
|
||||
wrapScrollH: wrap.scrollHeight, wrapClientH: wrap.clientHeight, wrapLeft: wrap.getBoundingClientRect().left,
|
||||
tableTop: table.top, tableBottom: table.bottom,
|
||||
headTop: head.getBoundingClientRect().top, headBottom: head.getBoundingClientRect().bottom,
|
||||
totalTop: totalCell.getBoundingClientRect().top, labelLeft: label.getBoundingClientRect().left,
|
||||
totalText: label.textContent.trim(),
|
||||
// 기간 합계 행 위에 다른 줄이 겹쳐 보이지 않는가 — 합계 칸 가운데를 찍으면 합계 행 칸이 나와야 한다
|
||||
hit: (function () {
|
||||
const r = totalCell.getBoundingClientRect();
|
||||
const el = document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2);
|
||||
return !!el && !!el.closest("tr.perf-row-total");
|
||||
})(),
|
||||
labelHit: (function () {
|
||||
const r = label.getBoundingClientRect();
|
||||
const el = document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2);
|
||||
return !!el && !!el.closest("tr.perf-row-total");
|
||||
})() };
|
||||
totalTop: cell.getBoundingClientRect().top, totalBottom: cell.getBoundingClientRect().bottom,
|
||||
labelLeft: lab.getBoundingClientRect().left, labelText: lab.textContent.trim(), hitCell: hit(cell), hitLabel: hit(lab),
|
||||
track: getComputedStyle(wrap).scrollbarColor, pageTrack: getComputedStyle(page).scrollbarColor };
|
||||
});
|
||||
};
|
||||
const g0 = await geo();
|
||||
check(label + " 표 상자가 세로로 스크롤된다(화면 높이로 묶음)", g0.scrollH > g0.clientH + 100, g0);
|
||||
check(label + " 맨 위 행 = 기간 합계", g0.totalText === "기간 합계", g0.totalText);
|
||||
await p.evaluate(function () { document.querySelector(".perf-main-wrap").scrollTop = 400; });
|
||||
await p.waitForTimeout(50);
|
||||
check(label + " 맨 위 행 = 기간 합계, 표 상자 세로 스크롤 없음", g0.labelText === "기간 합계" && g0.wrapScrollH <= g0.wrapClientH + 1, g0);
|
||||
check(label + " 처음엔 제자리(옮기지 않음)", Math.abs(g0.totalTop - g0.headBottom) <= 1 && g0.headTop > g0.pageTop + 50, g0);
|
||||
check(label + " 스크롤 막대 배경 투명(표 상자·페이지)", / (transparent|rgba\(0, 0, 0, 0\))$/.test(g0.track) && / (transparent|rgba\(0, 0, 0, 0\))$/.test(g0.pageTrack), [g0.track, g0.pageTrack]);
|
||||
// 표 위에서 휠 → 페이지가 스크롤된다
|
||||
const box = await p.locator(".perf-main-wrap").boundingBox();
|
||||
await p.mouse.move(box.x + 300, box.y + 60);
|
||||
await p.mouse.wheel(0, 500);
|
||||
await p.waitForTimeout(200);
|
||||
const g1 = await geo();
|
||||
check(label + " 세로 스크롤 뒤 제목 행 = 상자 맨 위", Math.abs(g1.headTop - g1.wrapTop) <= 1.5, g1);
|
||||
check(label + " 세로 스크롤 뒤 기간 합계 행 = 제목 행 바로 아래", Math.abs(g1.totalTop - g1.headBottom) <= 1.5 && g1.hit, g1);
|
||||
await p.evaluate(function () { document.querySelector(".perf-main-wrap").scrollLeft = 300; });
|
||||
await p.waitForTimeout(50);
|
||||
check(label + " 표 위 휠 → 페이지 스크롤", g1.pageScroll > 300, g1.pageScroll);
|
||||
check(label + " 스크롤 뒤 제목 행 = 화면(스크롤 상자) 맨 위", g1.tableTop < g1.pageTop && Math.abs(g1.headTop - g1.pageTop) <= 1, g1);
|
||||
check(label + " 스크롤 뒤 기간 합계 행 = 제목 행 바로 아래, 다른 줄에 안 가려짐",
|
||||
Math.abs(g1.totalTop - g1.headBottom) <= 1 && g1.hitCell && g1.hitLabel, g1);
|
||||
// 가로 스크롤 — 날짜 칸은 왼쪽 고정(내려온 합계 행도)
|
||||
await p.evaluate(function () { document.querySelector(".perf-main-wrap").scrollLeft = 400; });
|
||||
await p.waitForTimeout(80);
|
||||
const g2 = await geo();
|
||||
check(label + " 가로 스크롤해도 기간 합계 날짜 칸은 왼쪽 고정", Math.abs(g2.labelLeft - g2.wrapLeft) <= 1.5 && g2.labelHit, g2);
|
||||
check(label + " 가로 스크롤해도 기간 합계 날짜 칸은 왼쪽 고정", Math.abs(g2.labelLeft - g2.wrapLeft) <= 1.5 && g2.hitLabel &&
|
||||
Math.abs(g2.headTop - g2.pageTop) <= 1, g2);
|
||||
// 표 끝을 넘어가면 같이 올라간다(표 밖으로 나가지 않음)
|
||||
await p.evaluate(function () { const pg = document.querySelector(".erp-page"); pg.scrollTop = pg.scrollHeight; });
|
||||
await p.waitForTimeout(120);
|
||||
const g3 = await geo();
|
||||
check(label + " 표 끝을 지나면 제목·합계 행도 표 안(표 끝에서 멈춤)",
|
||||
g3.totalBottom <= g3.tableBottom + 1 && g3.headTop >= g3.tableTop - 1 && g3.headTop < g3.pageTop, g3);
|
||||
// 다시 맨 위 — 제자리
|
||||
await p.evaluate(function () { document.querySelector(".erp-page").scrollTop = 0; });
|
||||
await p.waitForTimeout(120);
|
||||
const g4 = await geo();
|
||||
check(label + " 맨 위로 돌아오면 제자리", Math.abs(g4.headTop - g0.headTop) <= 1 && Math.abs(g4.totalTop - g4.headBottom) <= 1, g4);
|
||||
await ctx.close();
|
||||
}
|
||||
|
||||
@@ -76,8 +91,8 @@ async function stickyFlow(browser, file, label) {
|
||||
const exe = process.env.PJ_TEST_BROWSER;
|
||||
const browser = await chromium.launch(exe ? { executablePath: exe } : {});
|
||||
try {
|
||||
await stickyFlow(browser, "perf_dash_month.html", "[매출 실적]");
|
||||
await stickyFlow(browser, "perf_ads.html", "[광고비]");
|
||||
await stickyFlow(browser, "perf_dash_shell.html", "[매출 실적]");
|
||||
await stickyFlow(browser, "perf_ads_shell.html", "[광고비]");
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
|
||||
@@ -94,11 +94,20 @@ def main() -> None:
|
||||
html = e.get_template("performance/index.html").render(**base, active_tab="dashboard", metric="net", **ctx)
|
||||
with open(os.path.join(OUT_DIR, "perf_dash.html"), "w", encoding="utf-8") as f:
|
||||
f.write(html)
|
||||
# 이번달 보기(기본, 2026-10-26) — 맨 위 기간 합계 행이 있는 표(제목·합계 행 스크롤 고정 확인용)
|
||||
# 이번달 보기(기본) + 진짜 ERP 셸(erp_base.html — .erp-page 가 스크롤 상자) — 제목·기간 합계 행 스크롤 고정 확인용(2026-10-27)
|
||||
shell = jinja2.Environment(loader=jinja2.FileSystemLoader([
|
||||
os.path.join(ROOT, "app", "templates"), os.path.join(ROOT, "app", "modules", "performance", "templates")]), autoescape=True)
|
||||
sbase = {**base, "user": {"email": "me@test.local", "name": "Me", "picture": ""}}
|
||||
mctx = build_dashboard(FakeStore(), kind="month", anchor=date(2026, 10, 7), today=date(2026, 10, 7))
|
||||
mctx["auto_sync"] = ctx["auto_sync"]
|
||||
html = e.get_template("performance/index.html").render(**base, active_tab="dashboard", metric="net", **mctx)
|
||||
with open(os.path.join(OUT_DIR, "perf_dash_month.html"), "w", encoding="utf-8") as f:
|
||||
html = shell.get_template("performance/index.html").render(**sbase, active_tab="dashboard", metric="net", **mctx)
|
||||
with open(os.path.join(OUT_DIR, "perf_dash_shell.html"), "w", encoding="utf-8") as f:
|
||||
f.write(html)
|
||||
sactx = build_ad_dashboard(FakeStore(), kind="month", anchor=date(2026, 10, 7), today=date(2026, 10, 7),
|
||||
sales_codes=["cafe24", "coupang"])
|
||||
sactx["auto_sync"] = ctx["auto_sync"]
|
||||
html = shell.get_template("performance/ads.html").render(**sbase, active_tab="ads", **sactx)
|
||||
with open(os.path.join(OUT_DIR, "perf_ads_shell.html"), "w", encoding="utf-8") as f:
|
||||
f.write(html)
|
||||
actx =build_ad_dashboard(FakeStore(), kind="month", anchor=date(2026, 10, 7), today=date(2026, 10, 7),
|
||||
sales_codes=["cafe24", "coupang"])
|
||||
|
||||
Reference in New Issue
Block a user