// 입출고 날짜 칸 = ERP 공용 달력(2026-11-05) — 실제 브라우저(Chromium). // python tests/js/render_inout.py // NODE_PATH= PJ_TEST_BROWSER= 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") }); 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"); })();