// 실적 틱톡 탭(2026-11-05) — 실제 브라우저(Chromium). // python tests/js/render_performance.py // NODE_PATH= PJ_TEST_BROWSER= node tests/js/perf_tiktok.browser.test.js // 광고비 오른쪽 탭, ROAS·광고비·매출 열, 매출·광고비 그래프 둘, 합계 줄 스크롤 고정, 칸 입력 없음, 스크립트 오류 없음. 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 exe = process.env.PJ_TEST_BROWSER; const browser = await chromium.launch(exe ? { executablePath: exe } : {}); try { const p = await (await browser.newContext({ viewport: { width: 1400, height: 800 } })).newPage(); const errors = []; p.on("pageerror", function (e) { errors.push(String(e)); }); await p.route("**/*", function (r) { const url = new URL(r.request().url()).pathname; if (url.startsWith("/static/")) { const f = path.join(ROOT, "app", url); if (!fs.existsSync(f)) return r.fulfill({ status: 404, body: "" }); const type = f.endsWith(".css") ? "text/css" : f.endsWith(".js") ? "application/javascript" : "font/woff2"; return r.fulfill({ status: 200, contentType: type, body: fs.readFileSync(f) }); } if (!url.endsWith(".html")) 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", url.slice(1)), "utf8") }); }); await p.goto("http://erp.test/perf_tiktok_shell.html"); await p.waitForTimeout(300); const tabs = await p.locator(".perf-tabs-main .perf-tab").allInnerTexts(); check("탭 순서 = 매출 실적·광고비·틱톡", tabs.map(function (t) { return t.replace(/^[a-z_]+\s*/, "").trim(); }).join() === "매출 실적,광고비,틱톡", tabs); check("틱톡 탭이 켜짐", await p.locator(".perf-tab-tiktok.is-active").count() === 1); const head = await p.locator("table.perf-main thead th").allInnerTexts(); check("열 = 날짜·ROAS·광고비·매출", head.join() === "날짜,ROAS,광고비,매출", head); const total = await p.locator("table.perf-main tbody tr").first().innerText(); check("맨 위 기간 합계", total.includes("합계") && total.includes("210,000") && total.includes("630,000") && total.includes("300%"), total); const day = await p.locator("table.perf-main tbody tr", { hasText: "400%" }).first().innerText(); check("일자 줄 값", day.includes("120,000") && day.includes("480,000"), day); check("매출 그래프", await p.locator("#perf-chart-daily svg rect.bar").count() > 0); check("광고비 그래프", await p.locator("#perf-chart-daily2 svg rect.bar").count() > 0); check("칸 입력 없음", await p.locator("[data-manual-code]").count() === 0); check("업데이트 버튼", (await p.locator("#perf-ad-sync-btn").innerText()).includes("광고비 업데이트")); await p.screenshot({ path: path.join(__dirname, ".out", "perf_tiktok.png") }); await p.locator("table.perf-main").hover(); await p.mouse.wheel(0, 500); await p.waitForTimeout(250); const stuck = await p.evaluate(function () { const first = document.querySelector("table.perf-main tbody tr.perf-row-total:first-child th"); const top = first.getBoundingClientRect().top; return document.querySelector("table.perf-main thead th").getBoundingClientRect().bottom <= top + 2 && top >= 0 && top < 300; }); check("스크롤해도 제목·합계 줄 고정", stuck); check("스크립트 오류 없음", errors.length === 0, errors); } finally { await browser.close(); } if (fails.length) { console.log("\n" + fails.length + " FAILED"); process.exit(1); } console.log("\nALL OK"); })();