feat(실적): 틱톡 탭 삭제 + [말레이시아 실적] 모듈 추가

- 실적 틱톡 탭·tiktok_ads 광고 API·테스트 삭제, 틱톡 데이터 삭제 SQL(performance_db 012)
- 말레이시아 실적: 실적 라우터·화면을 /malaysia/performance 에 한 번 더 마운트,
  차이는 performance/variant.py(KR·MY) 한 곳 — 저장소·권한키·주소·광고 채널·통화
- 틱톡·쇼피·라자다 그룹(쇼핑몰 + 라이브커머스 하위, 그룹 열 = 합계), 광고비 채널 3개
- 금액 RM 소수 2자리 = 센 정수 저장(입력·엑셀 scale, 화면 num/money, JS money)
- malaysia_performance_db = performance_db 구조 복사 + seed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 16:03:18 +09:00
parent e9f57b6ff6
commit 62cc5e2778
34 changed files with 790 additions and 892 deletions
+79
View File
@@ -0,0 +1,79 @@
// 말레이시아 실적(2026-11-20) — 실제 브라우저. 같은 performance.js 가 data-base(/malaysia/performance)로 저장하고
// 금액을 RM 소수 2자리로 보이는지(저장 단위 = 센).
// python tests/js/render_performance.py
// NODE_PATH=<playwright 경로> PJ_TEST_BROWSER=<Chrome 경로> node tests/js/perf_malaysia.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); }
}
function load(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 () {
const browser = await chromium.launch(process.env.PJ_TEST_BROWSER ? { executablePath: process.env.PJ_TEST_BROWSER } : {});
try {
// 매출 실적 — 틱톡 라이브커머스 10/5 칸(RM 100.05)을 12.34 로
const page = await browser.newPage({ viewport: { width: 1400, height: 900 } });
const calls = [];
await page.route("**/*", function (r) {
if (!/\/api\//.test(r.request().url())) return r.fulfill({ status: 200, contentType: "text/html; charset=utf-8", body: load("perf_my_dash.html") });
calls.push({ url: r.request().url(), body: r.request().postData() });
r.fulfill({ status: 200, contentType: "application/json",
body: JSON.stringify({ ok: true, manual: 1234, amount: 1234, commission: 0, net: 1234, formula: null }) });
});
await page.goto("http://perf.test/malaysia/performance/");
const sel = 'td.is-manual-cell[data-manual-code="custom_tiktok_live"][data-date="2026-10-05"]';
await page.click(sel);
const prefill = await page.$eval(sel + " .perf-manual-input", function (i) { return i.value; });
check("편집창 = RM 값(100.05)", prefill === "100.05", prefill);
await page.keyboard.press("Control+A");
await page.keyboard.type("RM 12.34");
await page.keyboard.press("Escape"); // 저장 뒤 새로고침(합계 다시 계산) 전에 칸 값을 본다 — Enter 는 다음 칸 편집으로 넘어감
await page.click(sel);
await page.keyboard.press("Control+A");
await page.keyboard.type("RM 12.34");
await page.keyboard.press("Enter");
await page.waitForTimeout(300);
const put = calls.find(function (c) { return /manual-sales/.test(c.url); });
check("저장 주소 = /malaysia/performance/api/manual-sales/…", put && /\/malaysia\/performance\/api\/manual-sales\/custom_tiktok_live\/2026-10-05$/.test(put.url), put);
check("보낸 값 = 12.34(RM 글자 지움)", put && JSON.parse(put.body).amount === "12.34", put);
const cell = await page.$eval(sel, function (td) { return { gross: td.querySelector(".v-gross").textContent, v: td.dataset.manualValue }; });
check("저장 뒤 칸 = 12.34, 편집값 12.34", cell.gross === "12.34" && cell.v === "12.34", cell);
const head = await page.$eval("#perf-chart-daily svg", function (s) { return s.querySelector("title").textContent; });
check("그래프 말풍선 = RM", / RM$/.test(head) && /\d\.\d\d RM$/.test(head), head);
await page.close();
// 광고비 — 쇼피 10/5 칸에 계산식
const ap = await browser.newPage({ viewport: { width: 1400, height: 900 } });
const acalls = [];
await ap.route("**/*", function (r) {
if (!/\/api\//.test(r.request().url())) return r.fulfill({ status: 200, contentType: "text/html; charset=utf-8", body: load("perf_my_ads.html") });
acalls.push({ url: r.request().url(), body: r.request().postData() });
r.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify({ ok: true, manual: 300, amount: 300, formula: "1.5*2" }) });
});
await ap.goto("http://perf.test/malaysia/performance/ads");
const heads = await ap.$$eval(".perf-main thead th", function (ths) { return ths.map(function (t) { return t.textContent.trim(); }); });
check("광고비 열 = 틱톡·쇼피·라자다", /틱톡/.test(heads[2]) && /쇼피/.test(heads[3]) && /라자다/.test(heads[4]) && heads.length === 5, heads);
const asel = 'td.is-manual-cell[data-manual-code="shopee"][data-date="2026-10-05"]';
await ap.click(asel);
await ap.keyboard.type("1.5*2");
await ap.keyboard.press("Enter");
await ap.waitForTimeout(300);
const aput = acalls.find(function (c) { return /ad-spend/.test(c.url); });
check("광고비 저장 주소 = /malaysia/performance/api/ad-spend/shopee/…", aput && /\/malaysia\/performance\/api\/ad-spend\/shopee\/2026-10-05$/.test(aput.url), aput);
const av = await ap.$eval(asel + " .v-gross", function (s) { return s.textContent; });
check("광고비 칸 = 3.00", av === "3.00", av);
await ap.close();
} finally { await browser.close(); }
console.log(fails.length ? "\n" + fails.length + " FAILED" : "\nALL PASS");
process.exit(fails.length ? 1 : 0);
})();