Files
dbx-main/tests/js/inout_datepop.browser.test.js
king 74782da88c Revert "style(입출고): 달력과 발주 목록 글자를 다시 90%로"
사용자 요청으로 두 번째 축소를 취소한다. 달력 clamp(270px, 20.7vw, 396px),
발주 목록 글자는 원래의 90%로 되돌린다. 머지 e3b7e55 를 되돌림.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 15:09:20 +09:00

116 lines
8.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 입출고 날짜 칸 = ERP 공용 달력(2026-11-05) — 실제 브라우저(Chromium).
// python tests/js/render_inout.py
// NODE_PATH=<playwright 경로> PJ_TEST_BROWSER=<Chrome 경로> node tests/js/inout_datepop.browser.test.js
// 기본 달력 대신 날짜 버튼, 국경일·대체공휴일 빨강·이름·말풍선(title), 고르면 값 전송, 필수 칸은 지우기 없음, 잠긴 칸은 못 누름.
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: 900 } })).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/inout_form.html");
await p.waitForTimeout(200);
const order = p.locator('input[name="order_date"]'), due = p.locator('input[name="due_date"]');
check("기본 달력 칸은 숨김", !(await order.isVisible()) && !(await due.isVisible()));
const orderBtn = p.locator('input[name="order_date"] + button'), dueBtn = p.locator('input[name="due_date"] + button');
check("발주일 버튼 = yyyy.mm.dd(요일)", (await orderBtn.textContent()).includes("2026.10.05(월)"), await orderBtn.textContent());
await orderBtn.click();
const pop = p.locator(".pj-datepop");
check("달력이 열림", await pop.isVisible());
const hol = pop.locator('[data-iso="2026-10-09"]');
check("한글날 = 빨강 칸·이름·말풍선", (await hol.getAttribute("class")).includes("is-sun") && (await hol.getAttribute("title")) === "한글날" && (await hol.textContent()).includes("한글날"), await hol.getAttribute("title"));
check("필수 칸은 지우기 없음", (await pop.getByText("지우기").count()) === 0);
await p.waitForTimeout(200); // 등장 애니메이션 뒤에 찍는다
await p.screenshot({ path: path.join(__dirname, ".out", "inout_datepop.png") });
await pop.locator('[data-iso="2026-10-08"]').click();
await p.keyboard.press("Escape");
check("고른 날짜가 값으로", (await order.inputValue()) === "2026-10-08", await order.inputValue());
check("버튼 글자도 바뀜", (await orderBtn.textContent()).includes("2026.10.08(목)"));
await dueBtn.click();
check("선택 칸은 지우기 있음", (await pop.getByText("지우기").count()) === 1);
// 대체공휴일 — 2026-03-02 삼일절 대체(달을 넘겨 찾지 않고 표 값으로 확인)
const holidays = await p.evaluate(function () { return JSON.parse(document.getElementById("io-holidays").textContent); });
check("대체공휴일도 표에 있음", holidays["2026-03-02"] === "삼일절 대체", holidays["2026-03-02"]);
await p.keyboard.press("Escape");
await p.goto("http://erp.test/inout_list.html");
await p.waitForTimeout(200);
check("목록 필터 시작일 버튼", (await p.locator('input[name="from"] + button').textContent()).includes("2026.10.01(목)"));
const box = await p.locator('input[name="from"] + button').boundingBox();
const search = await p.locator('input[name="q"]').boundingBox();
check("필터 줄 높이가 맞음", Math.abs((box.y + box.height / 2) - (search.y + search.height / 2)) < 4, { box: box, search: search });
await p.screenshot({ path: path.join(__dirname, ".out", "inout_list.png") });
// 목록 거르기(2026-11-05) — 발주일~찾기 묶음의 오른쪽 끝 = 표 상자 오른쪽 끝(표는 넓으면 상자 안에서 가로 스크롤), 줄이 바뀌어도
const rightEdge = async function () {
const btn = await p.getByRole("button", { name: "찾기" }).boundingBox();
const wrap = await p.locator(".erp-table-wrap").boundingBox();
return Math.abs(btn.x + btn.width - (wrap.x + wrap.width));
};
check("좁은 화면: 찾기가 오른쪽 끝", (await rightEdge()) < 2, await rightEdge());
await p.setViewportSize({ width: 2000, height: 900 });
await p.waitForTimeout(100);
await p.screenshot({ path: path.join(__dirname, ".out", "inout_list_wide.png") });
check("넓은 화면: 찾기가 오른쪽 끝", (await rightEdge()) < 2, await rightEdge());
await p.setViewportSize({ width: 1400, height: 900 });
await p.waitForTimeout(100);
// 목록 머리글(2026-11-05) — 숫자 열까지 가운데, 굵게, 12px × 1.11, 회색 배경
const headStyles = await p.locator(".io-table thead th").evaluateAll(function (els) {
return els.map(function (el) { const c = getComputedStyle(el); return [c.textAlign, c.fontWeight, c.fontSize, c.backgroundColor].join("|"); });
});
check("머리글 모양", headStyles.length > 0 && headStyles.every(function (s) { return /^center\|700\|11\.98\d*px\|rgb\(242, 242, 242\)$/.test(s); }), headStyles);
const sizeOf = function (sel) { return p.locator(sel).first().evaluate(function (el) { return getComputedStyle(el).fontSize; }); };
check("표 글자 90%", (await sizeOf(".io-table tbody td")) === "11.7px" && (await sizeOf(".io-table .erp-row-sub")) === "10.8px" && (await sizeOf(".io-table .io-progress-pct")) === "10.8px" && (await sizeOf(".io-table .io-badge")) === "10.35px");
await p.setViewportSize({ width: 2000, height: 900 });
await p.waitForTimeout(100);
check("달력 최대 396px(440px × 90%)", Math.round((await p.locator(".io-side").boundingBox()).width) === 396, await p.locator(".io-side").boundingBox());
await p.setViewportSize({ width: 1400, height: 900 });
await p.waitForTimeout(100);
// 목록 입고일 열(2026-11-05) — 입고 예정일과 발주 사이, 여러 날은 한 칸에서 줄바꿈, 입고 전 "-"
const heads = await p.locator(".io-table thead th").allInnerTexts();
check("입고일 열 위치", heads.indexOf("입고일") === heads.indexOf("입고 예정일") + 1 && heads.indexOf("발주") === heads.indexOf("입고일") + 1, heads);
const col = heads.indexOf("입고일") + 1;
const cell = function (row) { return p.locator(".io-table tbody tr:nth-child(" + row + ") td:nth-child(" + col + ")"); };
const lines = await cell(1).locator("div").evaluateAll(function (els) {
return els.map(function (el) { return { text: el.textContent, top: el.getBoundingClientRect().top }; });
});
check("여러 날 = 줄바꿈", lines.length === 2 && lines[0].text === "2026.10.21(수)" && lines[1].text === "2026.10.23(금)" && lines[1].top > lines[0].top, lines);
check("하루 입고 = 한 줄", (await cell(2).innerText()).trim() === "2026.10.22(목)");
check("입고 전 = -", (await cell(3).innerText()).trim() === "-");
await p.goto("http://erp.test/inout_locked.html");
await p.waitForTimeout(200);
check("잠긴 입고일은 못 누름", await p.locator('input[name="receipt_date"] + button').isDisabled());
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");
})();