diff --git a/app/modules/live/templates/live/settings.html b/app/modules/live/templates/live/settings.html
index a1a6a15..0932aa3 100644
--- a/app/modules/live/templates/live/settings.html
+++ b/app/modules/live/templates/live/settings.html
@@ -1,6 +1,6 @@
{% extends "erp_base.html" %}
{#- 라이브 커머스 설정(2026-11-04) — 호스트 정보. 계좌 등 개인정보·지우기는 ERP 관리자만(router.settings), 칩 권한자는 이름·상태만 보임 — `live_host` = 새 등록, `live_host_edit` = 고치기(개인정보는 빈칸으로 열림, 비워 두면 그대로). 추가·고치기는 같은 창(live.js). 문구 = t()(i18n.py). -#}
-{% block head_extra %}{% endblock %}
+{% block head_extra %}{% endblock %}
{% block content %}
diff --git a/app/modules/vacation/templates/vacation/form.html b/app/modules/vacation/templates/vacation/form.html
index 5be5ea9..494c106 100644
--- a/app/modules/vacation/templates/vacation/form.html
+++ b/app/modules/vacation/templates/vacation/form.html
@@ -134,5 +134,5 @@
{% endblock %}
{% block scripts %}
-
+
{% endblock %}
diff --git a/app/modules/vacation/templates/vacation/options.html b/app/modules/vacation/templates/vacation/options.html
index 8a79273..0930b9f 100644
--- a/app/modules/vacation/templates/vacation/options.html
+++ b/app/modules/vacation/templates/vacation/options.html
@@ -149,5 +149,5 @@
{% endblock %}
-{% block scripts %}
+{% block scripts %}
{% endblock %}
diff --git a/app/static/erp-datepop.js b/app/static/erp-datepop.js
index f0804cd..fec7884 100644
--- a/app/static/erp-datepop.js
+++ b/app/static/erp-datepop.js
@@ -63,7 +63,8 @@
const HOLIDAY_SHORT = { "부처님오신날": "석가탄신일", "추석·개천절": "추석" };
// 요일 줄 + 6주 날짜 칸(팝업·붙박이 달력 공용). extra(iso) = 그 칸에 더할 클래스 목록
- function gridHtml(viewY, viewM, holidays, today, extra) {
+ // locale(선택, 라이브 커머스 영문 화면): { weekdays[7], shortName(이름), title(연, 월0), prev, next } — 없으면 한글
+ function gridHtml(viewY, viewM, holidays, today, extra, locale) {
const first = new Date(viewY, viewM, 1);
const gridStart = new Date(viewY, viewM, 1 - first.getDay());
let days = "";
@@ -78,14 +79,14 @@
if (iso === today) cls.push("is-today");
cls.push.apply(cls, extra(iso, d));
if (holName) cls.push("has-hol");
- const holShort = /\s대체$/.test(holName) ? "대체휴일" : (HOLIDAY_SHORT[holName] || holName);
+ const holShort = locale && locale.shortName ? locale.shortName(holName) : /\s대체$/.test(holName) ? "대체휴일" : (HOLIDAY_SHORT[holName] || holName);
days += '";
}
return '' +
- ["일", "월", "화", "수", "목", "금", "토"].map(function (w, i) {
+ ((locale && locale.weekdays) || ["일", "월", "화", "수", "목", "금", "토"]).map(function (w, i) {
return '' + w + "";
}).join("") + days + "
";
}
@@ -355,7 +356,7 @@
// 화면에 붙박이는 기간 달력(2026-11-02, 휴가 신청) — 팝업과 같은 달력 서식(.pj-dp-*).
// 첫 클릭 = 시작일(동그라미), 다음 클릭 = 종료일(둥근 막대), 그다음 클릭 = 새로 시작. 시작일보다 앞을 누르면 그 날이 새 시작일.
- // opts: { start, end, holidays, single() — true 면 클릭마다 하루, onChange(start, end) }. 반환 { set(start, end) }
+ // opts: { start, end, holidays, single() — true 면 클릭마다 하루, onChange(start, end), locale }. 반환 { set(start, end) }
function mountRange(box, opts) {
const holidays = opts.holidays || {};
const today = isoToday();
@@ -373,12 +374,13 @@
return c;
}
function render() {
+ const loc = opts.locale || {};
box.innerHTML =
'' +
- '' +
- '' + viewY + "년 " + (viewM + 1) + "월" +
- '' +
- "
" + gridHtml(viewY, viewM, holidays, today, bandClasses);
+ '' +
+ '' + esc(loc.title ? loc.title(viewY, viewM) : viewY + "년 " + (viewM + 1) + "월") + "" +
+ '' +
+ "" + gridHtml(viewY, viewM, holidays, today, bandClasses, opts.locale);
}
box.addEventListener("click", function (e) {
const nav = e.target.closest(".pj-dp-navbtn");
diff --git a/app/static/live.css b/app/static/live.css
index 57bca78..f338f63 100644
--- a/app/static/live.css
+++ b/app/static/live.css
@@ -46,6 +46,13 @@
.lv-jump-day.is-today { outline: 2px solid #111; outline-offset: -2px; }
.lv-tip { margin: 0; padding: 8px 12px; border: 1px solid var(--color-subtle-ash, #e5e5e5); border-radius: 10px; background: #f6f8fb; font-size: 13px; color: #374151; }
+/* 표 + 오른쪽 달력(공용 erp-datepop 서식) */
+.lv-cal-row { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
+.lv-side-cal { box-sizing: border-box; padding: 12px; border: 1px solid #cfd4dc; border-radius: 10px; background: #fff; font-size: 13px; }
+@media (max-width: 1100px) {
+ .lv-cal-row { grid-template-columns: minmax(0, 1fr); }
+ .lv-side-cal { max-width: 340px; }
+}
.lv-cal-wrap { overflow: auto; max-height: calc(100vh - 150px); border: 1px solid #cfd4dc; border-radius: 10px; background: #fff; }
.lv-cal { border-collapse: separate; border-spacing: 0; min-width: max-content; }
.lv-cal th, .lv-cal td { border-right: 1px solid #e3e6eb; border-bottom: 1px solid #e3e6eb; }
diff --git a/app/static/live.js b/app/static/live.js
index 17ece6d..9fd715b 100644
--- a/app/static/live.js
+++ b/app/static/live.js
@@ -4,6 +4,7 @@
"use strict";
const calWrap = document.getElementById("lv-cal-wrap");
const CAL_POS = "lv_cal_left";
+ const CAL_JUMP = "lv_cal_jump";
function tr(text) { return (window.LV_T && window.LV_T[text]) || text; }
const dialogText = function () { return { okText: tr("확인"), cancelText: tr("취소") }; };
function reload() {
@@ -131,17 +132,54 @@
const time = calWrap.querySelector("thead .lv-cal-time");
if (col && time) calWrap.scrollLeft += col.getBoundingClientRect().left - time.getBoundingClientRect().right;
}
+ // 마지막 날들도 맨 왼쪽까지 오도록 표 끝에 여백(표 상자 너비 − 시간 열 − 날짜 열 하나)
+ function endGap() {
+ const time = calWrap.querySelector("thead .lv-cal-time");
+ const col = calWrap.querySelector("thead th[data-day]");
+ const table = calWrap.querySelector("table");
+ if (time && col && table) table.style.marginRight = Math.max(0, calWrap.clientWidth - time.offsetWidth - col.offsetWidth) + "px";
+ }
+ endGap();
+ window.addEventListener("resize", endGap);
+
+ // ── 오른쪽 달력(공용 erp-datepop, 말레이시아 공휴일): 날짜를 누르면 그 날이 표 맨 왼쪽, 다른 달이면 그 달 화면으로 가서 맨 왼쪽 ──
+ let pending = null;
+ try { pending = sessionStorage.getItem(CAL_JUMP); sessionStorage.removeItem(CAL_JUMP); } catch (_) {}
+ const hasDay = function (iso) { return !!iso && !!calWrap.querySelector('thead th[data-day="' + iso + '"]'); };
+ const todayHead = calWrap.querySelector("thead th[data-today]");
+ const firstHead = calWrap.querySelector("thead th[data-day]");
+ const shownDay = hasDay(pending) ? pending : todayHead ? todayHead.dataset.day : firstHead && firstHead.dataset.day;
+ const sideBox = document.getElementById("lv-side-cal");
+ let sideCal = null;
+ if (sideBox && window.ErpDatePop) {
+ let holidays = {};
+ try { holidays = JSON.parse(document.getElementById("lv-my-holidays").textContent); } catch (_) {}
+ const english = document.querySelector(".lv").lang === "en";
+ sideCal = window.ErpDatePop.mountRange(sideBox, {
+ start: shownDay, end: shownDay, holidays: holidays, single: function () { return true; },
+ locale: english ? {
+ weekdays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], prev: "Previous month", next: "Next month",
+ title: function (y, m) { return new Date(y, m, 1).toLocaleString("en", { month: "long" }) + " " + y; },
+ shortName: function (name) { return / \(Replacement\)$/.test(name) ? "Replacement" : name; },
+ } : undefined,
+ onChange: function (iso) {
+ if (hasDay(iso)) { jumpTo(iso); return; }
+ try { sessionStorage.setItem(CAL_JUMP, iso); } catch (_) {}
+ location.href = "/live/calendar?month=" + iso.slice(0, 7);
+ },
+ });
+ }
document.addEventListener("click", function (e) {
const b = e.target.closest("[data-jump]");
- if (b) jumpTo(b.dataset.jump);
+ if (!b) return;
+ jumpTo(b.dataset.jump);
+ if (sideCal) sideCal.set(b.dataset.jump, b.dataset.jump);
});
let left = null;
try { left = sessionStorage.getItem(CAL_POS); sessionStorage.removeItem(CAL_POS); } catch (_) {}
- if (left !== null) calWrap.scrollLeft = Number(left);
- else {
- const today = calWrap.querySelector("thead th[data-today]");
- if (today) jumpTo(today.dataset.day);
- }
+ if (hasDay(pending)) jumpTo(pending);
+ else if (left !== null) calWrap.scrollLeft = Number(left);
+ else if (todayHead) jumpTo(todayHead.dataset.day);
// ── 달력: 날짜별 광고비 ──
document.addEventListener("click", async function (e) {
diff --git a/tests/js/live_calendar.browser.test.js b/tests/js/live_calendar.browser.test.js
new file mode 100644
index 0000000..c9ec707
--- /dev/null
+++ b/tests/js/live_calendar.browser.test.js
@@ -0,0 +1,82 @@
+// 라이브 커머스 오른쪽 달력(2026-11-05) — 실제 브라우저(Chromium).
+// python tests/js/render_live.py
+// NODE_PATH= PJ_TEST_BROWSER= node tests/js/live_calendar.browser.test.js
+// 표 오른쪽에 달력, 말레이시아 공휴일·대체휴일 빨강·이름·말풍선, 날짜를 누르면 그 날이 표 맨 왼쪽(마지막 날까지), 다른 달은 그 달 화면으로 가서 맨 왼쪽, 영문 화면은 달력도 영어.
+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: 1600, height: 900 } })).newPage();
+ const errors = [];
+ p.on("pageerror", function (e) { errors.push(String(e)); });
+ await p.route("**/*", function (r) {
+ const u = new URL(r.request().url());
+ if (u.pathname.startsWith("/static/")) {
+ const f = path.join(ROOT, "app", u.pathname);
+ 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) });
+ }
+ const page = u.pathname === "/live/calendar" ? (u.searchParams.get("month") === "2026-12" ? "live_cal_dec.html" : "live_cal_ko.html") : u.pathname.slice(1);
+ if (!page.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", page), "utf8") });
+ });
+ // 맨 왼쪽 = 그 날 열의 왼쪽 끝이 고정된 시간 열 바로 옆
+ const gap = function (iso) {
+ return p.evaluate(function (d) {
+ const col = document.querySelector('thead th[data-day="' + d + '"]').getBoundingClientRect();
+ return Math.abs(col.left - document.querySelector("thead .lv-cal-time").getBoundingClientRect().right);
+ }, iso);
+ };
+ const day = function (iso) { return p.locator('#lv-side-cal [data-iso="' + iso + '"]'); };
+
+ await p.goto("http://erp.test/live/calendar?month=2026-11");
+ await p.waitForTimeout(300);
+ const side = await p.locator("#lv-side-cal").boundingBox(), wrap = await p.locator("#lv-cal-wrap").boundingBox();
+ check("달력이 표 오른쪽", side.x >= wrap.x + wrap.width && Math.abs(side.y - wrap.y) < 2, { side: side, wrap: wrap });
+ check("디파발리 = 빨강·이름·말풍선", (await day("2026-11-08").getAttribute("class")).includes("has-hol") && (await day("2026-11-08").getAttribute("title")) === "디파발리");
+ check("대체휴일 표시", (await day("2026-11-09").innerText()).includes("대체휴일") && (await day("2026-11-09").getAttribute("title")) === "디파발리 대체", await day("2026-11-09").innerText());
+ await p.screenshot({ path: path.join(__dirname, ".out", "live_side_cal.png") });
+
+ await day("2026-11-17").click();
+ await p.waitForTimeout(150);
+ check("17일이 맨 왼쪽", (await gap("2026-11-17")) < 2, await gap("2026-11-17"));
+ check("누른 날 선택 표시", (await day("2026-11-17").getAttribute("class")).includes("is-selected"));
+ await day("2026-11-30").click();
+ await p.waitForTimeout(150);
+ check("마지막 날도 맨 왼쪽", (await gap("2026-11-30")) < 2, await gap("2026-11-30"));
+ await p.screenshot({ path: path.join(__dirname, ".out", "live_side_cal_end.png") });
+ await day("2026-11-02").click();
+ await p.waitForTimeout(150);
+ check("앞날로 돌아감", (await gap("2026-11-02")) < 2, await gap("2026-11-02"));
+ await p.locator('.lv-jump-day[data-jump="2026-11-20"]').click();
+ await p.waitForTimeout(150);
+ check("날짜로 이동 줄도 맨 왼쪽·달력 선택 따라감", (await gap("2026-11-20")) < 2 && (await day("2026-11-20").getAttribute("class")).includes("is-selected"));
+
+ await p.locator('#lv-side-cal [data-nav="1"]').click();
+ await Promise.all([p.waitForURL(/month=2026-12/), day("2026-12-10").click()]);
+ await p.waitForTimeout(300);
+ check("다른 달 = 그 달 화면에서 맨 왼쪽", (await gap("2026-12-10")) < 2, await gap("2026-12-10"));
+ check("크리스마스 표시", (await day("2026-12-25").getAttribute("title")) === "크리스마스");
+
+ await p.goto("http://erp.test/live_cal_en.html");
+ await p.waitForTimeout(300);
+ const text = await p.locator("#lv-side-cal").innerText();
+ check("영문 화면 = 달력도 영어", !/[가-힣]/.test(text) && text.includes("November 2026") && text.includes("Sun") && text.includes("Replacement"), text);
+ check("영문 말풍선", (await day("2026-11-09").getAttribute("title")) === "Deepavali (Replacement)");
+ 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");
+})();
diff --git a/tests/js/render_live.py b/tests/js/render_live.py
new file mode 100644
index 0000000..1673686
--- /dev/null
+++ b/tests/js/render_live.py
@@ -0,0 +1,64 @@
+"""라이브 커머스 달력 보기를 진짜 앱 라우터로 렌더 — 오른쪽 달력 브라우저 테스트용(2026-11-05).
+
+ python tests/js/render_live.py # → tests/js/.out/live_cal_ko.html · live_cal_en.html · live_cal_dec.html
+
+DB 없이 가짜 저장소로 11월·12월 화면을 그린다(공휴일 = 실제 표).
+"""
+
+from __future__ import annotations
+
+import os
+import sys
+import tempfile
+from datetime import date, time
+from decimal import Decimal
+from unittest.mock import patch
+
+ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+sys.path.insert(0, ROOT)
+os.chdir(ROOT)
+OUT_DIR = os.path.join(ROOT, "tests", "js", ".out")
+for key in ("ASSET", "CAFE24", "CUPANG", "VACATION", "PROJECT", "DISPATCH", "PERFORMANCE", "MALAYSIA_STOCK", "ITEMCODE", "EXPENSE", "INOUT", "OUTREACH", "LIVE"):
+ os.environ[key + "_DB_URL"] = ""
+os.environ.update(SESSION_SECRET_KEY="local-live-test-only", SESSION_COOKIE_SECURE="false", PERFORMANCE_AUTO_SYNC="false", DATA_DIR=tempfile.mkdtemp())
+
+from fastapi.testclient import TestClient # noqa: E402
+
+import app.main as main # noqa: E402
+
+
+class Fake:
+ def host_choices(self):
+ return [{"id": 1, "display_name": "Nabella", "full_name": "Nazzureen Nabella binti Samad", "is_active": True}]
+
+ def list_broadcasts(self, start, end):
+ if start.month != 11:
+ return []
+ return [{"id": 1, "host_id": 1, "host_name": "Nabella", "tiktok_handle": "MainAccount", "broadcast_date": date(2026, 11, 5), "start_time": time(8),
+ "end_time": time(10), "venue": "", "sales_amount": Decimal("500"), "images": []}]
+
+ def ad_spends(self, start, end):
+ return {}
+
+ def account_choices(self):
+ return ["MainAccount"]
+
+
+def main_() -> None:
+ os.makedirs(OUT_DIR, exist_ok=True)
+ main.app.state.live_store = Fake()
+ user = {"email": "t@test.local", "name": "T", "role": "user", "is_super_admin": False, "modules": {"live": True}}
+ with patch.object(main, "get_current_user_record", side_effect=lambda r: user), patch.object(main, "get_session_user", side_effect=lambda r: user), \
+ patch.object(main.user_store, "get", side_effect=lambda e: user), patch.object(main.user_store, "list_all", side_effect=lambda: [user]):
+ for name, lang, month in (("live_cal_ko.html", "ko", "2026-11"), ("live_cal_en.html", "en", "2026-11"), ("live_cal_dec.html", "ko", "2026-12")):
+ client = TestClient(main.app)
+ client.cookies.set("live_lang", lang)
+ res = client.get("/live/calendar?month=" + month)
+ assert res.status_code == 200, (name, res.status_code)
+ with open(os.path.join(OUT_DIR, name), "w", encoding="utf-8") as f:
+ f.write(res.text)
+ print("ok")
+
+
+if __name__ == "__main__":
+ main_()
diff --git a/tests/test_live.py b/tests/test_live.py
index e5b5173..00ee309 100644
--- a/tests/test_live.py
+++ b/tests/test_live.py
@@ -85,6 +85,21 @@ class StoreTests(unittest.TestCase):
"start_time": time(20, 0), "end_time": time(22, 0), "venue": "", "sales_amount": None, "images": []})
self.assertEqual((view["tiktok_handle"], view["edit"]["tiktok_handle"], view["label"]), ("alt.acc", "alt.acc", "Yaya")) # 카드 머리 = 호스트, 계정은 아래
+ def test_my_holidays(self):
+ from app.modules.live import holidays
+ ko, en = holidays.holiday_names("ko"), holidays.holiday_names("en")
+ self.assertEqual(set(ko), set(en))
+ for day in ko:
+ date.fromisoformat(day)
+ self.assertEqual((ko["2026-11-08"], ko["2026-11-09"]), ("디파발리", "디파발리 대체"))
+ self.assertEqual((en["2026-11-08"], en["2026-11-09"]), ("Deepavali", "Deepavali (Replacement)"))
+ self.assertIn("Federal Territory Day", en["2026-02-01"])
+ self.assertFalse([n for n in en.values() if re.search("[가-힣]", n)])
+ # 대체휴일은 평일에 — 토·일이면 표가 틀린 것
+ for day, name in en.items():
+ if "Replacement" in name:
+ self.assertLess(date.fromisoformat(day).weekday(), 5, day)
+
def test_clean_handle(self):
for raw in ("@siti.live", "siti.live", "https://www.tiktok.com/@siti.live?lang=en", "tiktok.com/@siti.live/video/1"):
self.assertEqual(store.clean_handle(raw), "siti.live", raw)
@@ -356,6 +371,37 @@ def body(c):
assert c.post("/live/settings/hosts", data=form).json()["ok"] and fake.saved[-1][1]["bank_account"] == ""
print("OK")
run(body)
+''')
+ self.assertEqual(res.returncode, 0, res.stdout + res.stderr)
+ self.assertIn("OK", res.stdout)
+
+ def test_calendar_page_side_calendar(self):
+ res = _run('''
+import json, re
+
+class Fake:
+ def host_choices(self):
+ return []
+ def list_broadcasts(self, start, end):
+ return []
+ def ad_spends(self, start, end):
+ return {}
+ def account_choices(self):
+ return []
+main.app.state.live_store = Fake()
+
+def names(page):
+ return json.loads(re.search(r'id="lv-my-holidays">(.*?)', page).group(1))
+
+def body(c):
+ who["u"] = U("s@t.local")
+ page = c.get("/live/calendar?month=2026-11").text
+ assert 'id="lv-side-cal"' in page and "/static/erp-datepop.js" in page
+ assert names(page)["2026-11-09"] == "디파발리 대체"
+ c.cookies.set("live_lang", "en")
+ assert names(c.get("/live/calendar?month=2026-11").text)["2026-11-09"] == "Deepavali (Replacement)"
+ print("OK")
+run(body)
''')
self.assertEqual(res.returncode, 0, res.stdout + res.stderr)
self.assertIn("OK", res.stdout)