e3a8649b41
- 마이그레이션 009: perf_marketplaces.is_custom·is_group·parent_code - 설정: [+ 쇼핑몰 추가(수동 입력)]·[+ 그룹 추가], 이름 변경·삭제, 직접 추가 쇼핑몰 그룹 select - custom_ 코드는 registry.get_adapter 가 수동 입력 전용 어댑터(CustomManualAdapter)로 - 매출 실적 표: 그룹 열 = 보이는 하위 쇼핑몰 합계(일 합계엔 안 더함), ▾/▸ 하위 열 접기(localStorage) - 설정 표 ⠿ 드래그 → PUT /api/marketplace-order → sort_order, 화면 순서는 ordered_marketplaces 한 곳 - 테스트: test_custom_groups.py, perf_groups.browser.test.js Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
121 lines
7.5 KiB
JavaScript
121 lines
7.5 KiB
JavaScript
// 실적 쇼핑몰 그룹·드래그 순서(2026-10-22) — 실제 브라우저(Chromium).
|
|
// python tests/js/render_performance.py
|
|
// NODE_PATH=<playwright 경로> PJ_TEST_BROWSER=<Chrome 경로> node tests/js/perf_groups.browser.test.js
|
|
// 매출 실적: 그룹 열 = 하위 합계, ▾ 누르면 하위 열이 숨고(▸) 새로고침해도 기억.
|
|
// 설정: ⠿ 를 끌어 놓으면 화면 순서 그대로 PUT /api/marketplace-order — 그룹은 하위와 함께, 하위는 그룹 안에서만.
|
|
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 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 () {
|
|
const browser = await chromium.launch(process.env.PJ_TEST_BROWSER ? { executablePath: process.env.PJ_TEST_BROWSER } : {});
|
|
try {
|
|
// ── 매출 실적 — 그룹 열 접기/펴기 ──
|
|
const ctx = await browser.newContext({ viewport: { width: 1400, height: 900 } });
|
|
const p = await ctx.newPage();
|
|
await p.route("**/*", function (r) { r.fulfill({ status: 200, contentType: "text/html; charset=utf-8", body: page("perf_dash_groups.html") }); });
|
|
await p.goto("http://perf.test/performance/");
|
|
const heads = function () {
|
|
return p.evaluate(function () {
|
|
return Array.from(document.querySelectorAll(".perf-main thead th")).filter(function (th) { return th.offsetParent !== null; })
|
|
.map(function (th) { return th.textContent.replace(/\s+/g, " ").trim(); });
|
|
});
|
|
};
|
|
const h0 = await heads();
|
|
check("그룹 열이 하위 열 바로 앞", JSON.stringify(h0.slice(1, 7)) === JSON.stringify(["카페24", "네이버", "▾오프라인", "매장A ✎", "매장B ✎", "행사 ✎"]), h0);
|
|
const g5 = await p.evaluate(function () {
|
|
const tr = document.querySelector('td[data-manual-code="custom_a"][data-date="2026-10-05"]').closest("tr");
|
|
return tr.querySelector('[data-group-cell="group_off"] .v-gross').textContent.trim();
|
|
});
|
|
check("그룹 칸 = 하위 합계(30,000 + 12,000)", g5 === "42,000", g5);
|
|
await p.click('[data-group-toggle="group_off"]');
|
|
const h1 = await heads();
|
|
const hiddenTd = await p.evaluate(function () {
|
|
return Array.from(document.querySelectorAll('td[data-group-child="group_off"]')).every(function (td) { return td.offsetParent === null; });
|
|
});
|
|
check("▾ 누르면 하위 열(머리글·칸) 숨김, ▸ 표시", h1.indexOf("매장A ✎") < 0 && h1.indexOf("▸오프라인") >= 0 && hiddenTd && h1.indexOf("행사 ✎") >= 0, h1);
|
|
await p.reload();
|
|
const h2 = await heads();
|
|
check("접은 상태 새로고침 후에도 기억", h2.indexOf("매장A ✎") < 0 && h2.indexOf("▸오프라인") >= 0, h2);
|
|
await p.click('[data-group-toggle="group_off"]');
|
|
check("다시 누르면 펼침", (await heads()).indexOf("매장B ✎") >= 0);
|
|
await ctx.close();
|
|
|
|
// ── 설정 — 드래그 순서 ──
|
|
const sp = await browser.newPage({ viewport: { width: 1500, height: 1000 } });
|
|
const puts = [];
|
|
let reloads = 0; const pages = [];
|
|
await sp.route("**/*", async function (r) {
|
|
const req = r.request(), url = new URL(req.url()).pathname;
|
|
if (url === "/favicon.ico" || url.startsWith("/static/")) { r.fulfill({ status: 404, body: "" }); return; }
|
|
if (!url.startsWith("/performance/api/")) {
|
|
reloads++; pages.push(url);
|
|
r.fulfill({ status: 200, contentType: "text/html; charset=utf-8", body: page("perf_settings_groups.html") });
|
|
return;
|
|
}
|
|
puts.push({ method: req.method(), url: url, body: req.postData() ? JSON.parse(req.postData()) : null });
|
|
r.fulfill({ status: 200, contentType: "application/json", body: "{}" });
|
|
});
|
|
await sp.goto("http://perf.test/performance/settings");
|
|
const order = function () {
|
|
return sp.evaluate(function () {
|
|
return Array.from(document.querySelectorAll(".perf-set-table tbody.perf-sort-block > tr[data-code]")).map(function (tr) { return tr.dataset.code; });
|
|
});
|
|
};
|
|
check("설정 처음 순서(그룹 뒤에 하위)", JSON.stringify(await order()) === JSON.stringify(["cafe24", "naver", "group_off", "custom_a", "custom_b", "custom_c"]), await order());
|
|
async function drag(fromCode, toCode, where) {
|
|
const h = await sp.locator('tr[data-code="' + fromCode + '"] .perf-drag').boundingBox();
|
|
const t = await sp.locator('tr[data-code="' + toCode + '"]').boundingBox();
|
|
await sp.mouse.move(h.x + h.width / 2, h.y + h.height / 2);
|
|
await sp.mouse.down();
|
|
const y = where === "above" ? t.y + 3 : t.y + t.height - 3;
|
|
await sp.mouse.move(h.x + h.width / 2, (h.y + y) / 2, { steps: 4 });
|
|
await sp.mouse.move(h.x + h.width / 2, y, { steps: 6 });
|
|
await sp.mouse.up();
|
|
await sp.waitForTimeout(100);
|
|
}
|
|
// 그룹(하위 포함)을 카페24 위로
|
|
await drag("group_off", "cafe24", "above");
|
|
const o1 = await order();
|
|
check("그룹 블록 통째로 이동", JSON.stringify(o1) === JSON.stringify(["group_off", "custom_a", "custom_b", "cafe24", "naver", "custom_c"]), o1);
|
|
const last = puts[puts.length - 1];
|
|
check("놓으면 화면 순서 그대로 저장", last && last.method === "PUT" && last.url === "/performance/api/marketplace-order" &&
|
|
JSON.stringify(last.body.codes) === JSON.stringify(o1), last);
|
|
// 하위끼리 순서 변경 — 그룹 행 위로는 못 나감
|
|
await drag("custom_b", "custom_a", "above");
|
|
const o2 = await order();
|
|
check("하위 쇼핑몰은 그룹 안에서 순서 변경", JSON.stringify(o2) === JSON.stringify(["group_off", "custom_b", "custom_a", "cafe24", "naver", "custom_c"]), o2);
|
|
const n = puts.length;
|
|
await drag("custom_a", "naver", "below");
|
|
check("하위 쇼핑몰은 그룹 밖으로 안 나감(저장 없음)", JSON.stringify(await order()) === JSON.stringify(o2) && puts.length === n, await order());
|
|
// 그룹 지정 select → PUT parent_code
|
|
check("순서 저장은 새로고침 없음", reloads === 1, pages);
|
|
await sp.selectOption('tr[data-code="custom_c"] select[data-act-group]', "group_off");
|
|
await sp.waitForTimeout(300);
|
|
const g = puts[puts.length - 1];
|
|
check("그룹 지정 → PUT parent_code 후 새로고침", g && g.url === "/performance/api/marketplaces/custom_c" && g.body.parent_code === "group_off" && reloads === 2, { g: g, reloads: reloads });
|
|
const wraps = await sp.evaluate(function () {
|
|
const t = document.querySelector(".perf-set-table");
|
|
return t.scrollWidth <= t.parentElement.clientWidth + 1;
|
|
});
|
|
check("설정 표가 1500px 에서 가로 스크롤 없음", wraps);
|
|
await sp.screenshot({ path: path.join(__dirname, ".out", "perf_settings_groups.png"), fullPage: true });
|
|
} finally {
|
|
await browser.close();
|
|
}
|
|
console.log(fails.length ? "\n" + fails.length + " FAIL" : "\nALL PASS");
|
|
process.exit(fails.length ? 1 : 0);
|
|
})();
|