feat(performance): 광고비 탭(구글·메타·쿠팡 윙/로켓) + 탭 개편·설정 톱니

- 탭: [매출 실적](검정) · [광고비](주황) 큰 탭 + 맨 오른쪽 설정 톱니(Material Symbols settings)
- /performance/ads: 연·월·일 표(채널 × 날짜)·추이·비중·월/연 누적, 매출 대비 광고비 KPI
- 날짜 칸 직접 입력(PUT /api/ad-spend/{channel}/{day}), 쿠팡(로켓) 광고 보고서 업로드
  (CSV/엑셀, 1열 날짜·19열 청구금액(+부가가치세), 잘못된 줄 있으면 전부 거절)
- performance_db 마이그레이션 005 perf_ad_spend
- 설정 화면 쇼핑몰 순서 jsdom 기대값을 003 열 순서로 갱신(기존 실패)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-13 18:20:44 +09:00
parent 099271fdb2
commit ef38140673
16 changed files with 1026 additions and 26 deletions
+66 -3
View File
@@ -20,8 +20,17 @@ async function env(file) {
w.erpAlert = function (m) { e.alerts.push(m); return Promise.resolve(); };
w.fetch = async function (url, o) {
const method = (o && o.method) || "GET";
const body = o && o.body ? JSON.parse(o.body) : null;
e.calls.push({ method: method, url: url, body: body });
const isForm = o && o.body && typeof o.body !== "string";
const body = o && o.body && !isForm ? JSON.parse(o.body) : null;
e.calls.push({ method: method, url: url, body: body, form: isForm ? o.body : null });
if (/^\/performance\/api\/ad-spend\/upload/.test(url)) {
return { ok: true, status: 200, json: async function () {
return { ok: true, saved: 12, name: "쿠팡(로켓)", total: 2636494, from: "2026-10-01", to: "2026-10-12" }; } };
}
const ad = /^\/performance\/api\/ad-spend\/([^/]+)\/([\d-]+)$/.exec(url);
if (ad) {
return { ok: true, status: 200, json: async function () { return { ok: true, manual: body.amount, amount: body.amount || 0 }; } };
}
if (e.status >= 400) return { ok: false, status: e.status, json: async function () { return { detail: "수동 입력을 쓰려면 마이그레이션 002" }; } };
const m = /^\/performance\/api\/manual-sales\/([^/]+)\/([\d-]+)$/.exec(url);
if (m) {
@@ -119,13 +128,67 @@ function gross(td) { return td.querySelector(".v-gross").textContent.trim(); }
key(e, td, "Enter");
check("[키보드] 칸에 포커스 후 Enter → 입력칸", !!td.querySelector(".perf-manual-input"));
}
// ── 탭: [매출 실적] [광고비] + 맨 오른쪽 설정 톱니 ──
{
const e = await env("perf_dash.html");
const tabs = Array.from(e.d.querySelectorAll(".perf-tabs-main .perf-tab")).map(function (a) { return a.textContent.replace(/monitoring|campaign/, "").trim(); });
check("[탭] 매출 실적 · 광고비", tabs.join(",") === "매출 실적,광고비", tabs);
check("[탭] 매출 실적이 고른 탭", e.d.querySelector(".perf-tab-sales").classList.contains("is-active") &&
!e.d.querySelector(".perf-tab-ads").classList.contains("is-active"));
const gear = e.d.querySelector(".perf-tabs > .perf-tab-gear");
check("[탭] 설정 = 맨 오른쪽 톱니 아이콘(settings)", gear && gear === e.d.querySelector(".perf-tabs").lastElementChild &&
gear.getAttribute("href") === "/performance/settings" && gear.textContent.trim() === "settings" && !!gear.title);
}
// ── 광고비 화면 ──
{
const e = await env("perf_ads.html");
check("[광고비] 광고비 탭이 고른 탭", e.d.querySelector(".perf-tab-ads").classList.contains("is-active"));
const heads = Array.from(e.d.querySelectorAll(".perf-main thead th")).map(function (th) { return th.textContent.replace("✎", "").trim(); });
check("[광고비] 열 = 구글·메타·쿠팡(윙)·쿠팡(로켓)", heads.join(",") === "날짜,구글,메타,쿠팡(윙),쿠팡(로켓),일 합계", heads);
const up = cell(e, "coupang_rocket", "2026-10-01"), man = cell(e, "google", "2026-10-02");
check("[광고비] 업로드 값 = 주황(is-upload), 직접 입력 = 파랑(is-manual)", up.classList.contains("is-upload") &&
!up.classList.contains("is-manual") && man.classList.contains("is-manual") && gross(up) === "220,000");
check("[광고비] 앞으로의 날은 입력 칸 아님", !cell(e, "google", "2026-10-08") && !!cell(e, "google", "2026-10-07"));
const kpi = Array.from(e.d.querySelectorAll(".perf-kpi-value")).map(function (n) { return n.textContent.trim(); });
check("[광고비] KPI — 이번달 광고비 270,000 · 매출 대비 비율", kpi[0] === "₩270,000" && /%$/.test(kpi[1]), kpi);
check("[광고비] 매출 실적의 수수료 전환 없음", !e.d.querySelector(".perf-metric") && e.d.getElementById("perf-dash").dataset.metric === "gross");
const td = cell(e, "meta", "2026-10-03");
td.click();
const inp = td.querySelector(".perf-manual-input");
check("[광고비] 칸을 누르면 입력칸(광고비)", !!inp && /광고비/.test(inp.getAttribute("aria-label")));
inp.value = "33,000";
key(e, inp, "Escape");
td.click();
const inp2 = td.querySelector(".perf-manual-input");
inp2.value = "33,000";
inp2.dispatchEvent(new e.w.FocusEvent("blur"));
await settle();
const put = e.calls.find(function (c) { return c.method === "PUT"; });
check("[광고비] 저장 → /api/ad-spend/meta/2026-10-03 (33000)", put && put.url === "/performance/api/ad-spend/meta/2026-10-03" &&
put.body.amount === 33000, e.calls);
check("[광고비] 저장 후 파란 표시", gross(td) === "33,000" && td.classList.contains("is-manual"));
// 파일 업로드 창
e.d.getElementById("perf-ad-upload").click();
const modal = e.d.querySelector(".perf-modal");
const opts = Array.from(modal.querySelectorAll(".perf-ad-channel option")).map(function (o) { return o.value; });
check("[업로드] 채널 선택 = 양식이 정해진 쿠팡(로켓)", opts.join(",") === "coupang_rocket", opts);
check("[업로드] 양식 안내(19열 청구금액)", /19열/.test(modal.querySelector(".perf-ad-help").textContent));
const fileInput = modal.querySelector(".perf-upload-file");
const f = new e.w.File(["날짜"], "rocket.csv", { type: "text/csv" });
Object.defineProperty(fileInput, "files", { value: [f] });
Array.from(modal.querySelectorAll(".perf-modal-foot button, button")).filter(function (b) { return b.textContent === "업로드"; })[0].click();
await settle();
const post = e.calls.find(function (c) { return c.method === "POST"; });
check("[업로드] POST /api/ad-spend/upload?channel=coupang_rocket (파일)", post && post.url === "/performance/api/ad-spend/upload?channel=coupang_rocket" && !!post.form, e.calls);
check("[업로드] 결과 안내(12일 반영)", /12일 반영/.test(modal.querySelector(".perf-upload-result").textContent));
}
// ── 설정: 수동 입력 토글 ──
{
const e = await env("perf_settings.html");
const heads = Array.from(e.d.querySelectorAll(".perf-set-table thead th")).map(function (th) { return th.textContent.trim(); });
check("[설정] '수동 입력' 열(매출 집계 다음)", heads.indexOf("수동 입력") === heads.indexOf("매출 집계") + 1, heads);
const rows = Array.from(e.d.querySelectorAll(".perf-set-table tbody tr")).map(function (tr) { return tr.dataset.code; });
check("[설정] 쇼핑몰 순서 = 표 순서", rows.join(",") === "cafe24,naver,coupang,toss,gsshop,elevenst,ohouse,gmarket,kakao,lotteon", rows);
check("[설정] 쇼핑몰 순서 = 어댑터 등록 순서(003 열 순서)", rows.join(",") === "cafe24,naver,coupang,ohouse,gmarket,kakao,gsshop,elevenst,lotteon,toss", rows);
const box = e.d.querySelector('tr[data-code="coupang"] input[data-field="manual_input"]');
check("[설정] 켜진 쇼핑몰은 체크", box && box.checked && !e.d.querySelector('tr[data-code="cafe24"] input[data-field="manual_input"]').checked);
box.checked = false;