b2710a0831
- 가져올 때 그날 메타 행 metrics 에 계정별 값(_accounts: 이름·광고비·ROAS·항목, insights account_name)을 함께 저장 — 새 마이그레이션 없음. "_" 키는 일자별 표 열·합계·화면 값에서 제외. - ad_spend.detail_tabs: 합계 탭 + 계정 탭(그 계정이 광고 낸 날만, 광고비 큰 계정부터), 계정별 값 없는 날 수 안내. - 상세보기 창: 탭(주황 강조, 계정 ID 말풍선), 계정 탭은 1원 반올림 차이 안내. 네이버·구글은 그대로 표 하나. - 테스트: 계정별 변환·탭 순서/이름/가중 ROAS·옛 자료 안내·API 응답, jsdom 탭 전환. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
296 lines
23 KiB
JavaScript
296 lines
23 KiB
JavaScript
// 실적 — 수동 입력(static/performance.js) · 열 순서 · 설정 토글 — jsdom.
|
|
// python tests/js/render_performance.py && NODE_PATH=<jsdom 경로> node tests/js/perf_manual.test.js
|
|
const fs = require("fs"), path = require("path");
|
|
const { JSDOM } = require("jsdom");
|
|
const OUT = path.join(__dirname, ".out");
|
|
const JS = fs.readFileSync(path.join(__dirname, "..", "..", "app", "static", "performance.js"), "utf8");
|
|
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); }
|
|
}
|
|
const settle = function () { return new Promise(function (r) { let i = 0; (function s() { if (i++ > 40) return r(); setImmediate(s); })(); }); };
|
|
const wait = function (ms) { return new Promise(function (r) { setTimeout(r, ms); }); };
|
|
|
|
async function env(file) {
|
|
const html = fs.readFileSync(path.join(OUT, file), "utf8").replace(/<script src="\/static\/performance\.js[^"]*" defer><\/script>/, "");
|
|
const dom = new JSDOM(html, { runScripts: "dangerously", pretendToBeVisual: true, url: "http://localhost/performance/" });
|
|
const w = dom.window;
|
|
const e = { w: w, d: w.document, calls: [], status: 200, alerts: [] };
|
|
w.erpAlert = function (m) { e.alerts.push(m); return Promise.resolve(); };
|
|
w.fetch = async function (url, o) {
|
|
const method = (o && o.method) || "GET";
|
|
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\/naver\/details/.test(url)) {
|
|
return { ok: true, status: 200, json: async function () {
|
|
return { columns: ["총비용", "노출수", "클릭률(%)", "구매완료 광고수익률(%)"], total: { "총비용": 300000, "노출수": 30043, "클릭률(%)": 1.53, "구매완료 광고수익률(%)": 250.5 },
|
|
rows: [{ date: "2026-10-03", amount: 300000, roas: 250.5, values: { "총비용": 300000, "노출수": 30043, "클릭률(%)": 1.53, "구매완료 광고수익률(%)": 250.5 } }] }; } };
|
|
}
|
|
if (/^\/performance\/api\/ad-spend\/meta\/details/.test(url)) { // 메타 — [합계 | 계정…] 탭(2026-10-16)
|
|
const tbl = function (amount, roas) {
|
|
return { columns: ["광고비(부가세 포함)", "ROAS(%)"], total: { "광고비(부가세 포함)": amount, "ROAS(%)": roas },
|
|
rows: [{ date: "2026-10-03", amount: amount, roas: roas, values: { "광고비(부가세 포함)": amount, "ROAS(%)": roas } }] };
|
|
};
|
|
return { ok: true, status: 200, json: async function () {
|
|
return Object.assign(tbl(165001, 400), { accounts_missing: e.metaMissing || 0, tabs: [
|
|
Object.assign({ key: "total", label: "합계" }, tbl(165001, 400)),
|
|
Object.assign({ key: "111", label: "본계정", account_id: "111" }, tbl(110000, 450)),
|
|
Object.assign({ key: "222", label: "서브<계정>", account_id: "222" }, tbl(55001, 300))] }); } };
|
|
}
|
|
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", empty_days: e.uploadEmpty || [] }; } };
|
|
}
|
|
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) {
|
|
const api = m[1] === "coupang" && m[2] === "2026-10-05" ? 50000 : m[1] === "coupang" && m[2] === "2026-10-06" ? 7000 : 0;
|
|
const manual = body.amount == null ? null : body.amount;
|
|
return { ok: true, status: 200, json: async function () { return { ok: true, manual: manual, amount: manual == null ? api : manual, api_amount: api }; } };
|
|
}
|
|
return { ok: true, status: 200, json: async function () { return {}; } };
|
|
};
|
|
w.eval(JS);
|
|
// jsdom 이 문서를 다 읽은 뒤 DOMContentLoaded 를 스스로 보낸다(직접 보내면 초기화가 두 번 됨)
|
|
if (w.document.readyState !== "loading") w.document.dispatchEvent(new w.Event("DOMContentLoaded"));
|
|
await settle();
|
|
return e;
|
|
}
|
|
function key(e, el, k, extra) { el.dispatchEvent(new e.w.KeyboardEvent("keydown", Object.assign({ key: k, bubbles: true, cancelable: true }, extra || {}))); }
|
|
function cell(e, code, day) { return e.d.querySelector('td.is-manual-cell[data-manual-code="' + code + '"][data-date="' + day + '"]'); }
|
|
function gross(td) { return td.querySelector(".v-gross").textContent.trim(); }
|
|
|
|
(async function () {
|
|
// ── 열 순서·제목 ──
|
|
{
|
|
const e = await env("perf_dash.html");
|
|
const heads = Array.from(e.d.querySelectorAll(".perf-main thead th")).map(function (th) { return th.textContent.replace("✎", "").trim(); });
|
|
check("[순서] 카페24·네이버·쿠팡·토스·GS샵·11번가 다음 나머지", heads.join(",") ===
|
|
"날짜,카페24,네이버,쿠팡,토스,GS샵,11번가,오늘의집,G마켓,카카오,롯데ON,일 합계", heads);
|
|
check("[수동] 수동 입력 쇼핑몰 제목에 ✎ 표시", /✎/.test(e.d.querySelectorAll(".perf-main thead th")[3].textContent) &&
|
|
!/✎/.test(e.d.querySelectorAll(".perf-main thead th")[1].textContent));
|
|
check("[수동] 오늘까지 날짜 칸만 입력 칸(앞으로의 날·주간합계 아님), 수동 값 칸은 파란 표시",
|
|
!!cell(e, "coupang", "2026-10-07") && !cell(e, "coupang", "2026-10-08") && cell(e, "coupang", "2026-10-05").classList.contains("is-manual") &&
|
|
!cell(e, "coupang", "2026-10-06").classList.contains("is-manual") && !e.d.querySelector(".perf-row-week td.is-manual-cell"));
|
|
check("[수동] 입력 칸은 주문 상세 링크가 아님", !cell(e, "coupang", "2026-10-06").classList.contains("is-link") &&
|
|
e.d.querySelector('td.is-link[data-code="cafe24"]') !== null);
|
|
check("[수동] 표 아래 사용법 안내", /직접 입력/.test((e.d.querySelector(".perf-manual-help") || {}).textContent || ""));
|
|
}
|
|
// ── 입력 → Enter 저장 후 아래 칸 → Esc 끝 ──
|
|
{
|
|
const e = await env("perf_dash.html");
|
|
let reloaded = 0;
|
|
const td5 = cell(e, "coupang", "2026-10-05");
|
|
td5.click();
|
|
const in5 = td5.querySelector(".perf-manual-input");
|
|
check("[입력] 칸을 누르면 입력칸(수동 값이 들어 있음)", !!in5 && in5.value === "87000" && e.d.activeElement === in5);
|
|
in5.value = "90,000원";
|
|
key(e, in5, "Enter");
|
|
await settle();
|
|
const put = e.calls.find(function (c) { return c.method === "PUT"; });
|
|
check("[입력] Enter → 그 칸 저장(쉼표·원 빼고 숫자)", put && put.url === "/performance/api/manual-sales/coupang/2026-10-05" && put.body.amount === 90000, e.calls);
|
|
check("[입력] 저장한 값 표시 + 아래 칸(10/6)으로 입력칸 이동", gross(td5) === "90,000" && !td5.querySelector(".perf-manual-input") &&
|
|
!!cell(e, "coupang", "2026-10-06").querySelector(".perf-manual-input"));
|
|
const in6 = cell(e, "coupang", "2026-10-06").querySelector(".perf-manual-input");
|
|
check("[입력] 수동 값 없는 칸은 비어 있고 API 값이 흐리게(placeholder)", in6.value === "" && in6.placeholder === "7,000", in6.placeholder);
|
|
key(e, in6, "Enter"); // 아무것도 안 넣고 Enter — 저장 안 함
|
|
await settle();
|
|
check("[입력] 빈 칸 그대로 Enter → 저장 요청 없음", e.calls.filter(function (c) { return c.method === "PUT"; }).length === 1);
|
|
const in7 = cell(e, "coupang", "2026-10-07").querySelector(".perf-manual-input");
|
|
check("[입력] 마지막 입력 칸(오늘)까지 이동", !!in7);
|
|
in7.value = "abc";
|
|
key(e, in7, "Enter");
|
|
await settle(); await wait(200); await settle();
|
|
check("[입력] 숫자가 아니면 저장 안 하고 안내", e.alerts.some(function (m) { return /숫자/.test(m); }) &&
|
|
e.calls.filter(function (c) { return c.method === "PUT"; }).length === 1, e.alerts);
|
|
}
|
|
// ── 수동 값 지우기(비우고 저장) → API 값, 실패 시 안내 ──
|
|
{
|
|
const e = await env("perf_dash.html");
|
|
const td5 = cell(e, "coupang", "2026-10-05");
|
|
td5.click();
|
|
const inp = td5.querySelector(".perf-manual-input");
|
|
inp.value = "";
|
|
key(e, inp, "Escape");
|
|
check("[지우기] Esc → 저장 없이 닫힘", !td5.querySelector(".perf-manual-input") && !e.calls.some(function (c) { return c.method === "PUT"; }));
|
|
td5.click();
|
|
const inp2 = td5.querySelector(".perf-manual-input");
|
|
inp2.value = "";
|
|
inp2.dispatchEvent(new e.w.FocusEvent("blur"));
|
|
await settle();
|
|
const put = e.calls.find(function (c) { return c.method === "PUT"; });
|
|
check("[지우기] 비우고 칸을 떠나면 amount=null(그날 API 값)", put && put.body.amount === null);
|
|
check("[지우기] API 값(50,000) 표시·파란 표시 해제", gross(td5) === "50,000" && !td5.classList.contains("is-manual"));
|
|
e.status = 503;
|
|
const td6 = cell(e, "coupang", "2026-10-06");
|
|
td6.click();
|
|
const i6 = td6.querySelector(".perf-manual-input");
|
|
i6.value = "100";
|
|
i6.dispatchEvent(new e.w.FocusEvent("blur"));
|
|
await settle();
|
|
check("[실패] 저장 실패 → 안내(마이그레이션), 값은 그대로", e.alerts.some(function (m) { return /마이그레이션 002/.test(m); }) && gross(td6) === "7,000", e.alerts);
|
|
}
|
|
// ── 키보드: 칸에서 Enter 로 입력 시작 ──
|
|
{
|
|
const e = await env("perf_dash.html");
|
|
const td = cell(e, "kakao", "2026-10-06");
|
|
td.focus();
|
|
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("✎", "").replace("table_view", "").trim(); });
|
|
check("[광고비] 열 = 구글·메타·네이버·쿠팡(윙)·쿠팡(로켓)·오늘의집·G마켓·카카오·GS샵·11번가·롯데ON·토스·애터미아자몰",
|
|
heads.join(",") === "날짜,구글,메타,네이버,쿠팡(윙),쿠팡(로켓),오늘의집,G마켓,카카오,GS샵,11번가,롯데ON,토스,애터미아자몰,일 합계", heads);
|
|
const wing = cell(e, "coupang_wing", "2026-10-05");
|
|
check("[광고비] 칸 = 광고비(ROAS%) — 쿠팡(윙) 29,000 · 쿠팡 매출 87,000 → 300%",
|
|
wing.textContent.trim() === "29,000(300%)" && !cell(e, "naver", "2026-10-05").querySelector(".perf-roas"), wing.textContent);
|
|
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(); });
|
|
// 렌더 데이터(render_performance.py)에 구글 광고 API 값 10/04 123,457 이 더해졌다(2026-10-15 구글 광고 API 연동)
|
|
check("[광고비] KPI — 이번달 광고비 722,457(네이버 300,000·구글 API 123,457 포함) · 매출 대비 비율", kpi[0] === "₩722,457" && /%$/.test(kpi[1]), kpi);
|
|
const api = cell(e, "google", "2026-10-04");
|
|
check("[광고비] 광고 API 값 = 초록(is-api) — 직접 입력·업로드 표시와 구분, 구글 ROAS(500%)", api.classList.contains("is-api") &&
|
|
!api.classList.contains("is-manual") && !api.classList.contains("is-upload") && api.textContent.trim() === "123,457(500%)", api.className + " " + api.textContent);
|
|
wing.click();
|
|
const wi = wing.querySelector(".perf-manual-input");
|
|
wi.value = "30000";
|
|
wi.dispatchEvent(new e.w.FocusEvent("blur"));
|
|
await settle();
|
|
check("[광고비] 광고비를 고치면 옛 ROAS 는 지움(새로고침 때 다시 계산)", gross(wing) === "30,000" && !wing.querySelector(".perf-roas"));
|
|
e.calls.length = 0;
|
|
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(",") === "naver,coupang_wing,coupang_rocket", opts);
|
|
check("[업로드] 네이버 안내 = 3열 기간·4열 총비용·12열 ROAS", /3열 기간.*4열 총비용.*12열/.test(modal.querySelector(".perf-ad-help").textContent));
|
|
modal.querySelector(".perf-ad-channel").value = "coupang_rocket";
|
|
modal.querySelector(".perf-ad-channel").dispatchEvent(new e.w.Event("change"));
|
|
check("[업로드] 양식 안내(19열 청구금액)", /19열/.test(modal.querySelector(".perf-ad-help").textContent));
|
|
const fileInput = modal.querySelector(".perf-upload-file");
|
|
check("[업로드] 파일 여러 개 고르기", fileInput.multiple === true);
|
|
const f = new e.w.File(["날짜"], "rocket.csv", { type: "text/csv", lastModified: 1700000000000 });
|
|
const f2 = new e.w.File(["날짜"], "rocket2.csv", { type: "text/csv", lastModified: 1800000000000 });
|
|
Object.defineProperty(fileInput, "files", { value: [f, f2] });
|
|
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("[업로드] 파일마다 files + 파일 날짜(modified)", post && post.form.getAll("files").length === 2 &&
|
|
JSON.stringify(post.form.getAll("modified")) === JSON.stringify(["1700000000000", "1800000000000"]), post && post.form.getAll("modified"));
|
|
check("[업로드] 끝나면 창이 닫힘", !e.d.body.contains(modal) && !e.d.querySelector(".perf-modal"));
|
|
// 금액이 없던 날짜가 있으면 창을 두고 알려 준다
|
|
e.uploadEmpty = ["2026-03-02"];
|
|
e.d.getElementById("perf-ad-upload").click();
|
|
const modal2 = e.d.querySelector(".perf-modal");
|
|
Object.defineProperty(modal2.querySelector(".perf-upload-file"), "files", { value: [f] });
|
|
Array.from(modal2.querySelectorAll("button")).filter(function (b) { return b.textContent === "업로드"; })[0].click();
|
|
await settle();
|
|
check("[업로드] 청구금액 없던 날짜가 있어도 넘어가고 창 닫힘", !e.d.body.contains(modal2), modal2.textContent);
|
|
}
|
|
// ── 네이버 — 보고서 ROAS 표시 · 머리글 → 일자별 보고서 항목 ──
|
|
{
|
|
const e = await env("perf_ads.html");
|
|
const nv = cell(e, "naver", "2026-10-03");
|
|
check("[네이버] 칸 = 광고비(보고서 ROAS 반올림)", nv.textContent.trim() === "300,000(251%)", nv.textContent);
|
|
const hb = e.d.querySelector('.perf-main thead [data-detail-channel="naver"]');
|
|
const detailChans = Array.from(e.d.querySelectorAll(".perf-main thead [data-detail-channel]")).map(function (b) { return b.dataset.detailChannel; });
|
|
// 구글도 광고 API 로 가져온 보고서 항목이 있어 상세 보기(2026-10-15) — 그 밖의 채널은 아님
|
|
check("[네이버] 머리글 = 상세 보기 버튼(네이버·구글·메타만)", !!hb && detailChans.sort().join(",") === "google,meta,naver", detailChans);
|
|
hb.click(); await settle();
|
|
const call = e.calls.find(function (c) { return /\/details/.test(c.url); });
|
|
check("[네이버] 지금 기간으로 상세 요청", call && call.url === "/performance/api/ad-spend/naver/details?from=2026-10-01&to=2026-10-31", e.calls);
|
|
const modal = e.d.querySelector(".perf-modal");
|
|
const ths = Array.from(modal.querySelectorAll("thead th")).map(function (t) { return t.textContent; });
|
|
const row = Array.from(modal.querySelectorAll("tbody tr")[0].children).map(function (t) { return t.textContent; });
|
|
check("[네이버] 상세 표 = 날짜 + 보고서 항목(파일 순서), 날짜 mm/dd(요일)", ths.join(",") === "날짜,총비용,노출수,클릭률(%),구매완료 광고수익률(%)" &&
|
|
row.join(",") === "10/03(토),300,000,30,043,1.53,250.50", [ths, row]);
|
|
check("[네이버] 맨 아래 합계 줄", /합계/.test(modal.querySelector("tfoot").textContent) && /30,043/.test(modal.querySelector("tfoot").textContent));
|
|
check("[네이버] 계정 탭 없음(탭 자료 없는 채널)", !modal.querySelector(".perf-detail-tabs"));
|
|
}
|
|
// ── 메타 — 상세보기 [합계 | 계정…] 탭(2026-10-16) ──
|
|
{
|
|
const e = await env("perf_ads.html");
|
|
e.metaMissing = 2;
|
|
e.d.querySelector('.perf-main thead [data-detail-channel="meta"]').click(); await settle();
|
|
const modal = e.d.querySelector(".perf-modal");
|
|
const tabs = Array.from(modal.querySelectorAll(".perf-detail-tabs [data-tab]"));
|
|
const foot = function () { return modal.querySelector(".perf-detail-tab-body tfoot").textContent; };
|
|
check("[메타] 탭 = 합계 + 계정(이름은 글자 그대로, 계정 ID 는 말풍선)", tabs.map(function (b) { return b.textContent; }).join("|") === "합계|본계정|서브<계정>" &&
|
|
tabs[1].getAttribute("title") === "act_111" && !tabs[0].hasAttribute("title"), tabs.map(function (b) { return b.outerHTML; }));
|
|
check("[메타] 처음엔 합계 탭", tabs[0].classList.contains("is-active") && tabs[0].getAttribute("aria-selected") === "true" && /165,001/.test(foot()) &&
|
|
modal.querySelectorAll(".perf-detail-tab-body table").length === 1);
|
|
tabs[2].click();
|
|
check("[메타] 계정 탭 누르면 그 계정 표", tabs[2].classList.contains("is-active") && !tabs[0].classList.contains("is-active") &&
|
|
/55,001/.test(foot()) && /1원 다를 수/.test(modal.textContent));
|
|
check("[메타] 계정별 자료 없는 날 안내", /2일은 계정별 자료가 없어/.test(modal.textContent) && modal.textContent.indexOf("[메타 광고 불러오기]") >= 0);
|
|
}
|
|
// ── 설정: 수동 입력 토글 ──
|
|
{
|
|
const e = await env("perf_settings.html");
|
|
// 쇼핑몰 표만(아래 "광고 API 연동" 표도 같은 표 모양 — 2026-10-15)
|
|
const SHOP = ".perf-card:not(#perf-ad-sources) .perf-set-table";
|
|
const heads = Array.from(e.d.querySelectorAll(SHOP + " thead th")).map(function (th) { return th.textContent.trim(); });
|
|
check("[설정] '수동 입력' 열(매출 집계 다음)", heads.indexOf("수동 입력") === heads.indexOf("매출 집계") + 1, heads);
|
|
const rows = Array.from(e.d.querySelectorAll(SHOP + " tbody tr")).map(function (tr) { return tr.dataset.code; });
|
|
check("[설정] 쇼핑몰 순서 = 어댑터 등록 순서(003 열 순서)", rows.join(",") === "cafe24,naver,coupang,ohouse,gmarket,kakao,gsshop,elevenst,lotteon,toss", rows);
|
|
const adRows = Array.from(e.d.querySelectorAll("#perf-ad-sources tbody tr")).map(function (tr) { return tr.dataset.code + ":" + tr.dataset.api; });
|
|
check("[설정] 광고 API 연동 표는 따로(구글 광고, /api/ad-sources/)", adRows.join(",") === "google:ad-sources", adRows);
|
|
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;
|
|
box.dispatchEvent(new e.w.Event("change", { bubbles: true }));
|
|
await settle();
|
|
const put = e.calls.find(function (c) { return c.method === "PUT"; });
|
|
check("[설정] 토글 → 바로 저장(manual_input)", put && put.url === "/performance/api/marketplaces/coupang" && put.body.manual_input === false, e.calls);
|
|
e.status = 503;
|
|
const box2 = e.d.querySelector('tr[data-code="naver"] input[data-field="manual_input"]');
|
|
box2.checked = true;
|
|
box2.dispatchEvent(new e.w.Event("change", { bubbles: true }));
|
|
await settle();
|
|
check("[설정] 저장 실패(002 미적용) → 되돌리고 안내", !box2.checked && e.alerts.some(function (m) { return /마이그레이션/.test(m); }), e.alerts);
|
|
}
|
|
console.log(fails.length ? "\n" + fails.length + " FAILED" : "\nALL PASS");
|
|
process.exit(fails.length ? 1 : 0);
|
|
})();
|