feat(입출고): 날짜 칸을 ERP 공용 달력으로

발주 목록 기간, 발주일, 입고 예정일, 입고일을 erp-datepop 으로 교체.
국경일·대체공휴일을 빨강·이름으로 표시하고 마우스를 올리면 이름을 보여 준다.
필수 칸은 지우기를 빼고, 잠긴 입고일은 버튼도 비활성화.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-05 14:11:45 +09:00
parent 01208ea4d4
commit 212a3dd6b0
12 changed files with 168 additions and 16 deletions
+77
View File
@@ -0,0 +1,77 @@
// 입출고 날짜 칸 = 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") });
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");
})();
+45
View File
@@ -0,0 +1,45 @@
"""입출고 날짜 칸 화면을 진짜 ERP 셸(erp_base.html)로 렌더 — 공용 달력 브라우저 테스트용(2026-11-05).
python tests/js/render_inout.py # → tests/js/.out/inout_form.html · inout_list.html · inout_locked.html
DB 없이 날짜 칸에 필요한 값만 넣는다(나머지 값은 비어 있음 — ChainableUndefined). 공휴일 = 실제 표.
"""
from __future__ import annotations
import os
import sys
from datetime import date
import jinja2
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.insert(0, ROOT)
OUT_DIR = os.path.join(ROOT, "tests", "js", ".out")
from app.modules.inout.router import _date_holidays # noqa: E402
def main() -> None:
os.makedirs(OUT_DIR, exist_ok=True)
env = jinja2.Environment(
loader=jinja2.FileSystemLoader([os.path.join(ROOT, "app", "templates"), os.path.join(ROOT, "app", "modules", "inout", "templates")]),
autoescape=True, undefined=jinja2.ChainableUndefined)
base = {"date_holidays": _date_holidays(), "today": date(2026, 10, 5), "user": {"name": "테스트", "email": "t@test.local"}, "nav_items": [], "perms": {"can_order": True, "can_receive": True}}
pages = {
"inout_form.html": ("inout/order_form.html", {"vals": {"order_date": "2026-10-05", "due_date": ""}, "factories": []}),
"inout_list.html": ("inout/index.html", {"filters": {"from": "2026-10-01", "to": "", "status": "open", "q": "", "factory": ""}, "factories": [], "orders": [], "status_filters": {}}),
}
for out, (name, ctx) in pages.items():
with open(os.path.join(OUT_DIR, out), "w", encoding="utf-8") as f:
f.write(env.get_template(name).render(**base, **ctx))
# 입고 칸만 — order_detail.html 은 값이 많아, 전체 입고 완료로 잠긴 입고일 칸(disabled)을 같은 스크립트로 확인
locked = env.from_string('{% extends "erp_base.html" %}{% block head_extra %}<link rel="stylesheet" href="/static/inout.css" />{% endblock %}'
'{% block content %}<section class="io"><input type="date" name="receipt_date" value="2026-10-05" aria-label="입고일" required disabled /></section>{% endblock %}'
'{% block scripts %}{% include "inout/_datepop.html" %}<script src="/static/inout.js" defer></script>{% endblock %}')
with open(os.path.join(OUT_DIR, "inout_locked.html"), "w", encoding="utf-8") as f:
f.write(locked.render(**base))
if __name__ == "__main__":
main()