diff --git a/app/modules/performance/CLAUDE.md b/app/modules/performance/CLAUDE.md index 65b31fc..175cbef 100644 --- a/app/modules/performance/CLAUDE.md +++ b/app/modules/performance/CLAUDE.md @@ -74,6 +74,10 @@ - KPI 는 **수수료 차감 매출 하나만** 화면 왼쪽 한 줄(`.perf-kpi-line` — 금액 + 비교 기간 대비 %, 모든 기간 공통). 총매출·수수료·월/연 누적 카드는 뺐다. - 일자별 표 기본 보기 = **수수료 차감 매출**(라우터 기본 `metric=net`, 예전에 고른 보기 localStorage 는 안 씀). - 마지막 업데이트 옆 **다음 업데이트까지 남은 시간** 초 단위 실시간(`router._auto_sync_ctx(store, kind)` — 매출 탭 = 매출 일정, 광고비 탭 = 광고비 일정 → `performance.js initNextUpdate`·`nextScheduleSlot`, `auto_sync.next_slot` 과 같은 규칙으로 화면이 다음 회차 계산, 서버 시각으로 PC 시계 보정, 자동 업데이트(env·그 종류 일정) 꺼지면 숨김). +- **화면 자동 새로 고침**(2026-10-26) — 자동 업데이트(다른 사람이 누른 업데이트 포함)가 끝나면 매출 실적·광고비 화면이 20초 안에 reload. + 화면 데이터 `update_watch`(`router._update_watch` = 그린 때 마지막으로 끝난 작업 id, 보는 사람 것 제외) ↔ `GET /api/update-status?kind=sales|ads` + (`jobs.last_finished` — 메모리 작업만, DB 안 읽음). 도는 중이면 끝날 때까지, 칸 입력·창(`.perf-modal`)·메뉴·확인 창이 열려 있으면 닫힐 때까지 기다림 + (마지막 업데이트 옆 안내), 탭이 안 보이면 안 묻고 다시 보이면 바로. 보는 사람이 직접 누른 업데이트는 진행 창이 새로 그린다. `performance.js initUpdateWatch`. - 일자별 표 매출 칸 아래 **광고비(ROAS%)** 주황 줄(`--perf-ad`, `dashboard._ad_lines`) — 광고비 탭과 같은 값(`ad_spend.channel_roas`). 쇼핑몰 → 광고 채널은 `dashboard.sales_ad_channels`: 카페24 = 구글·메타 두 줄(이름 붙임), 네이버 = 네이버, 나머지는 `ROAS_SALES_CODE`(쿠팡 ← 쿠팡(윙)). 일 합계 = 보이는 쇼핑몰 광고비 합, ROAS = **일 합계 금액 ÷ 일 합계 광고비**(2026-10-19 — 예전엔 광고비 있는 쇼핑몰 매출만 더했다; `roas` 총매출·`roas_net` 수수료 차감 매출 기준, 보기 기준에 따라 하나만). 광고비 표 없으면 줄 없음. - **매출 단위** 원·천원·백만원 — 설정 "보기 설정"(누구나, 이 브라우저 쿠키 `perf_unit`), 서버가 `amount_text`(천원 정수·백만원 소수 한 자리)로 그림(`router._unit_ctx` → 템플릿 `amt`). 광고비 탭은 원 그대로. diff --git a/app/modules/performance/jobs.py b/app/modules/performance/jobs.py index 780e9d2..c677cf3 100644 --- a/app/modules/performance/jobs.py +++ b/app/modules/performance/jobs.py @@ -238,6 +238,14 @@ def get_job(job_id: str) -> SyncJob | None: return _JOBS.get(job_id) +def last_finished(kind: str = "sales", *, exclude_user: str = "") -> SyncJob | None: + """가장 최근에 끝난 그 종류의 작업(exclude_user 가 시작한 것은 뺌). 화면이 자동 업데이트(다른 사람 업데이트 포함)가 끝난 것을 + 알아채 새로 그리려고(2026-10-26) — 보는 사람이 직접 누른 업데이트는 진행 창이 알아서 새로 그린다.""" + with _LOCK: + done = [j for j in _JOBS.values() if j.finished and j.kind == kind and not (exclude_user and j.user == exclude_user)] + return max(done, key=lambda j: j.finished_at) if done else None + + def running_job(kind: str = "sales") -> SyncJob | None: """지금 돌고 있는 그 종류의 작업(가장 최근). 없으면 None — 다른 사람이 누른 업데이트도 같이 보여 주려고.""" with _LOCK: diff --git a/app/modules/performance/router.py b/app/modules/performance/router.py index 8663edb..bc3f74a 100644 --- a/app/modules/performance/router.py +++ b/app/modules/performance/router.py @@ -146,6 +146,7 @@ def dashboard_page( ) ctx["metric"] = metric if metric in ("gross", "commission", "net") else "net" ctx["auto_sync"] = _auto_sync_ctx(store, "sales") + ctx["update_watch"] = _update_watch("sales", user) _unit_ctx(request, ctx) return render_template(request, "performance/index.html", {**common.base_ctx(user, active_tab="dashboard"), **ctx}) @@ -173,6 +174,29 @@ def _auto_sync_ctx(store: Any, kind: str) -> dict[str, Any] | None: "label": auto_sync.describe(sched)} +def _update_watch(kind: str, user: dict[str, Any]) -> dict[str, str]: + """화면 자동 새로 그리기(2026-10-26) — 그린 시점에 마지막으로 끝난 업데이트(보는 사람 것 제외). 화면이 + GET /api/update-status 로 이 값이 바뀌면(자동 업데이트 등이 끝나면) 새로 고친다.""" + from . import jobs # noqa: WPS433 + + job = jobs.last_finished(kind, exclude_user=user.get("email", "")) + return {"kind": kind, "seen": job.id if job else ""} + + +@router.get("/api/update-status") +def api_update_status(request: Request, kind: str = "sales") -> JSONResponse: + """지금 그 종류 업데이트가 도는지 · 마지막으로 끝난 업데이트(보는 사람이 시작한 것 제외) — 화면이 20초마다 본다. + 메모리의 진행 작업만 보고 DB 는 안 읽는다.""" + from . import jobs # noqa: WPS433 + + _, user = common.require_store(request) + if kind not in jobs.KINDS: + raise HTTPException(status_code=404, detail="알 수 없는 업데이트 종류입니다.") + job = jobs.last_finished(kind, exclude_user=user.get("email", "")) + return JSONResponse({"kind": kind, "running": jobs.running_job(kind) is not None, "done": job.id if job else "", + "user": job.user if job else ""}) + + def _unit_ctx(request: Request, ctx: dict[str, Any]) -> None: """매출 단위(원·천원·백만원) — 실적 설정 "보기 설정"이 이 브라우저 쿠키(perf_unit)에 둔다. 템플릿은 amt(v) 로 그린다.""" from .dashboard import UNIT_COOKIE, UNITS, amount_text, normalize_unit # noqa: WPS433 @@ -221,6 +245,7 @@ def ads_page( ctx["ad_last_update_at"] = last_ad_update_at(store) ctx["ad_running"] = jobs.running_job("ads") is not None ctx["auto_sync"] = _auto_sync_ctx(store, "ads") + ctx["update_watch"] = _update_watch("ads", user) return render_template(request, "performance/ads.html", {**common.base_ctx(user, active_tab="ads", page_title="광고비"), **ctx}) diff --git a/app/modules/performance/templates/performance/ads.html b/app/modules/performance/templates/performance/ads.html index 89115e4..0c0b434 100644 --- a/app/modules/performance/templates/performance/ads.html +++ b/app/modules/performance/templates/performance/ads.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {#- ROAS 덧붙임 — "광고비(ROAS%)". 광고비가 없으면 아무것도 안 붙는다. -#} {%- macro roas(p) -%}{%- if p is not none -%}({{ "{:,}".format(p) }}%){%- endif -%}{%- endmacro -%} @@ -237,8 +237,9 @@ "period_label": period.label, "empty_text": "기간 내 광고비가 없습니다.", "upload_channels": upload_channels, - "auto_sync": auto_sync + "auto_sync": auto_sync, + "update_watch": update_watch } | tojson }} {% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/performance/templates/performance/index.html b/app/modules/performance/templates/performance/index.html index 2fd2578..aed74e5 100644 --- a/app/modules/performance/templates/performance/index.html +++ b/app/modules/performance/templates/performance/index.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {%- macro won(v) -%} {%- if v is none -%} @@ -288,8 +288,9 @@ "today": today, "unit": unit, "manual_upload_names": manual_upload_names, - "auto_sync": auto_sync + "auto_sync": auto_sync, + "update_watch": update_watch } | tojson }} {% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/performance/templates/performance/settings.html b/app/modules/performance/templates/performance/settings.html index c2167d6..ae681ec 100644 --- a/app/modules/performance/templates/performance/settings.html +++ b/app/modules/performance/templates/performance/settings.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {%- macro when(v) -%}{{ (v or '')[:16] | replace('T', ' ') or '—' }}{%- endmacro -%} @@ -316,4 +316,4 @@ {% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/performance/tests/test_update_watch.py b/app/modules/performance/tests/test_update_watch.py new file mode 100644 index 0000000..c1232bc --- /dev/null +++ b/app/modules/performance/tests/test_update_watch.py @@ -0,0 +1,60 @@ +"""화면 자동 새로 고침(2026-10-26) — 자동 업데이트가 끝나면 매출 실적·광고비 화면이 알아채도록: +jobs.last_finished(종류별·보는 사람 것 제외) · GET /api/update-status · 화면 데이터 update_watch.""" + +from __future__ import annotations + +import importlib +import time + +import pytest +from fastapi import FastAPI +from fastapi.testclient import TestClient + +from app.modules.performance import auto_sync, common, jobs + +perf_router = importlib.import_module("app.modules.performance.router") + + +@pytest.fixture(autouse=True) +def clean_jobs(monkeypatch): + monkeypatch.setattr(jobs, "_JOBS", {}) + + +def _job(kind="sales", user=auto_sync.AUTO_USER, finished=True, at=None): + j = jobs.create_job(user=user, start=None, end=None, kind=kind) + if finished: + j.finish() + if at is not None: + j.finished_at = at + return j + + +def test_last_finished_by_kind_and_excludes_viewer(): + assert jobs.last_finished("sales") is None + a = _job(at=time.time() - 100) + b = _job(user="me@x", at=time.time() - 10) # 보는 사람이 누른 것 — 진행 창이 알아서 새로 그림 + ad = _job(kind="ads", at=time.time()) + _job(finished=False) # 도는 중인 작업은 아님 + assert jobs.last_finished("sales") is b + assert jobs.last_finished("sales", exclude_user="me@x") is a + assert jobs.last_finished("ads", exclude_user="me@x") is ad + assert perf_router._update_watch("sales", {"email": "me@x"}) == {"kind": "sales", "seen": a.id} + assert perf_router._update_watch("ads", {"email": "other@x"}) == {"kind": "ads", "seen": ad.id} + + +def test_update_status_api(monkeypatch): + monkeypatch.setattr(common, "require_store", lambda request, admin=False: (object(), {"email": "me@x"})) + app = FastAPI() + app.include_router(perf_router.router) + c = TestClient(app) + assert c.get("/performance/api/update-status?kind=sales").json() == {"kind": "sales", "running": False, "done": "", "user": ""} + run = _job(finished=False) + r = c.get("/performance/api/update-status?kind=sales").json() + assert r["running"] and r["done"] == "" + run.finish() + r = c.get("/performance/api/update-status?kind=sales").json() + assert r == {"kind": "sales", "running": False, "done": run.id, "user": auto_sync.AUTO_USER} + _job(user="me@x") # 내 업데이트는 done 을 바꾸지 않는다 + assert c.get("/performance/api/update-status?kind=sales").json()["done"] == run.id + assert c.get("/performance/api/update-status?kind=ads").json()["done"] == "" # 광고비는 따로 + assert c.get("/performance/api/update-status?kind=nope").status_code == 404 diff --git a/app/static/performance.css b/app/static/performance.css index 9d48473..c58f44e 100644 --- a/app/static/performance.css +++ b/app/static/performance.css @@ -146,6 +146,7 @@ a.perf-seg.is-active, a.perf-seg.is-active:link, a.perf-seg.is-active:visited { .perf-kpi-line-value { font-size: 22px; font-weight: 700; letter-spacing: -.5px; color: var(--color-rich-black); white-space: nowrap; } /* 다음 자동 업데이트까지 남은 시간(초 단위) — 숫자 폭이 바뀌어도 흔들리지 않게 */ .perf-next-update b { font-variant-numeric: tabular-nums; } +.perf-refresh-note { color: var(--perf-up); font-weight: 600; } /* 자동 업데이트 끝 → 새로 고침 안내 */ .perf-delta { font-weight: 600; } .perf-delta.is-up { color: var(--perf-good); } /* is-up = 좋음(수수료는 줄어야 좋음, invert) */ .perf-delta.is-down { color: var(--perf-down); } diff --git a/app/static/performance.js b/app/static/performance.js index 1ce548a..34bfb1c 100644 --- a/app/static/performance.js +++ b/app/static/performance.js @@ -993,6 +993,49 @@ // 매출 실적 화면은 늘 수수료 차감 매출로 연다(2026-10-19) — 서버 기본 data-metric="net", 예전에 고른 보기(localStorage)는 쓰지 않음 setMetric(root.dataset.metric || "net"); initNextUpdate(data.auto_sync); + initUpdateWatch(data.update_watch); + } + + // 자동 업데이트(다른 사람이 누른 업데이트 포함)가 끝나면 화면 새로 고침(2026-10-26) — 20초마다 GET /api/update-status 로 + // 마지막으로 끝난 업데이트를 보고, 화면을 그린 때(update_watch.seen)와 다르고 지금 도는 업데이트가 없으면 reload. + // 칸 입력 중·창(메모·진행 창 등)·확인 창·메뉴가 열려 있으면 닫힐 때까지 기다린다. 탭이 안 보이면 묻지 않고, 다시 보이면 바로 본다. + // 보는 사람이 직접 누른 업데이트는 서버가 빼고 준다(진행 창이 알아서 새로 그림). + const WATCH_MS = 20000; + function initUpdateWatch(w) { + if (!w || !w.kind) return; + const seen = w.seen || ""; + let pending = false, asking = false; + function busyUi() { + const a = document.activeElement; + if (a && a !== document.body && (/^(INPUT|TEXTAREA|SELECT)$/.test(a.tagName) || a.isContentEditable)) return true; + return !!document.querySelector(".perf-modal, .perf-ctx, .erp-dialog-backdrop"); + } + function note(text) { + const lu = document.getElementById("perf-last-update"); + if (!lu) return; + let n = lu.querySelector(".perf-refresh-note"); + if (!n) { n = el("span", { class: "perf-refresh-note" }); lu.appendChild(n); } + n.textContent = text; + } + function reloadWhenFree() { + if (busyUi()) { + note(" · 새 데이터 있음 — 입력·창을 닫으면 새로 고칩니다"); + setTimeout(reloadWhenFree, 1500); + return; + } + note(" · 새 데이터로 고치는 중…"); + location.reload(); + } + async function check() { + if (pending || asking || document.hidden) return; + asking = true; + try { + const st = await api("GET", "/performance/api/update-status?kind=" + encodeURIComponent(w.kind)); + if (st.done && st.done !== seen && !st.running) { pending = true; reloadWhenFree(); } + } catch (_) { /* 잠깐 끊김·로그아웃 — 다음 차례에 */ } finally { asking = false; } + } + setInterval(check, WATCH_MS); + document.addEventListener("visibilitychange", function () { if (!document.hidden) check(); }); } // 다음 자동 업데이트까지 남은 시간 — 초 단위 실시간(2026-10-19). 서버가 준 다음 회차·지금 시각(PC 시계 차이 보정)으로 세고, diff --git a/docs/PERFORMANCE_MODULE.md b/docs/PERFORMANCE_MODULE.md index 4a5ecfb..e737bb6 100644 --- a/docs/PERFORMANCE_MODULE.md +++ b/docs/PERFORMANCE_MODULE.md @@ -361,6 +361,11 @@ 스레드(`auto_sync.Scheduler`)는 1분마다 일정을 다시 읽어 바뀐 종류만 지금부터 다음 회차를 다시 계산(저장 직후 회차는 안 돌림), 회차가 되면 그 종류만 따로 스레드로 (`run_once(kinds=(kind,))`). 저장 값이 없거나 011 미적용·값이 깨졌으면 그 종류는 기본 일정. 화면 카운트다운은 매출 탭 = 매출 일정, 광고비 탭 = 광고비 일정 (`router._auto_sync_ctx(store, kind)` → `performance.js nextScheduleSlot`, 같은 규칙). env `PERFORMANCE_AUTO_SYNC=false` 면 일정과 상관없이 안 돈다(카드에 안내). +- **화면 자동 새로 고침**(2026-10-26): 자동 업데이트가 끝나도 열어 둔 화면 숫자가 그대로이던 문제 — 매출 실적·광고비 화면이 20초마다 + `GET /api/update-status?kind=sales|ads` → `{running, done(마지막으로 끝난 작업 id, 보는 사람이 시작한 것 제외), user}`(`jobs.last_finished`, + 메모리의 진행 작업만 — DB 안 읽음)를 보고, 화면을 그린 때 값(`update_watch.seen`, `router._update_watch`)과 다르고 도는 중이 아니면 `location.reload()`. + 칸 입력 중(포커스)·창·메뉴·확인 창이 열려 있으면 닫힐 때까지 1.5초마다 다시 보고 마지막 업데이트 옆에 "새 데이터 있음" 안내. 탭이 안 보이면 + 묻지 않고 다시 보이면 바로 묻는다. 서버를 다시 켜면 작업 목록이 비어 그 전 업데이트로는 새로 고치지 않는다(다음 업데이트부터). - **대시보드 [매출 업데이트]** = 지금 보고 있는 기간(오늘까지)을 `POST /api/sync {from, to}` 로 다시 가져온다 ("이번달"이면 1일~오늘). 모듈 권한자는 92일까지, 더 긴 기간(올해 등, 최대 366일)은 관리자만. - **과거 매출 가져오기**(설정 화면, 관리자): 같은 API 로 임의 기간(최대 366일). 같은 사건은 덮어써서 여러 번 해도 중복 없음. diff --git a/tests/js/perf_auto_refresh.browser.test.js b/tests/js/perf_auto_refresh.browser.test.js new file mode 100644 index 0000000..57c6f07 --- /dev/null +++ b/tests/js/perf_auto_refresh.browser.test.js @@ -0,0 +1,110 @@ +// 실적 화면 자동 새로 고침(2026-10-26) — 실제 브라우저(Chromium). +// python tests/js/render_performance.py +// NODE_PATH= PJ_TEST_BROWSER= node tests/js/perf_auto_refresh.browser.test.js +// 자동 업데이트(다른 사람 업데이트 포함)가 끝나면 매출 실적·광고비 화면이 20초 안에 알아채 새로 고친다(GET /api/update-status). +// 도는 중이면 끝날 때까지 기다림, 칸 입력·창이 열려 있으면 닫힐 때까지 기다림(안내 표시), 매출/광고비 종류 따로. +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(//, function () { return ""; }) + .replace(/"; }); +} + +(async function () { + const browser = await chromium.launch(process.env.PJ_TEST_BROWSER ? { executablePath: process.env.PJ_TEST_BROWSER } : {}); + try { + async function open(file, url) { + const ctx = await browser.newContext({ viewport: { width: 1400, height: 900 } }); + const p = await ctx.newPage(); + const s = { loads: 0, asks: [], status: { running: false, done: "job-old" } }; + await p.clock.install({ time: new Date("2026-10-07T10:17:25+09:00") }); + await p.route("**/*", function (r) { + const u = r.request().url(); + if (u.indexOf("/performance/api/update-status") >= 0) { + s.asks.push(u.split("?")[1]); + return r.fulfill({ status: 200, contentType: "application/json", body: JSON.stringify(Object.assign({ kind: "sales", user: "자동 업데이트" }, s.status)) }); + } + if (u.indexOf("/static/") >= 0) return r.fulfill({ status: 200, body: "" }); + if (r.request().resourceType() === "document") s.loads++; + r.fulfill({ status: 200, contentType: "text/html; charset=utf-8", body: page(file) }); + }); + await p.goto(url); + return { ctx: ctx, p: p, s: s }; + } + const tick = async function (o, ms) { await o.p.clock.runFor(ms); await o.p.waitForTimeout(150); }; + + // ── 매출 실적 ── + let o = await open("perf_dash.html", "http://perf.test/performance/"); + await tick(o, 21000); + check("20초마다 묻는다(매출)", o.s.asks.length === 1 && o.s.asks[0] === "kind=sales", o.s.asks); + check("그린 때와 같으면 그대로", o.s.loads === 1, o.s.loads); + o.s.status = { running: true, done: "job-new" }; + await tick(o, 20000); + check("업데이트가 도는 중이면 기다림", o.s.loads === 1, o.s.loads); + o.s.status = { running: false, done: "job-new" }; + await tick(o, 20000); + await o.p.waitForLoadState(); + check("자동 업데이트 끝 → 새로 고침", o.s.loads === 2, o.s.loads); + + // 새로 그린 화면(이 테스트는 같은 HTML — seen=job-old) — 창이 열려 있으면 닫을 때까지 기다림 + o.s.status = { running: false, done: "job-old" }; + await tick(o, 21000); + check("새로 고친 뒤 같은 값이면 그대로", o.s.loads === 2, o.s.loads); + await o.p.evaluate(function () { + const m = document.createElement("div"); m.className = "perf-modal"; m.id = "fake-modal"; document.body.appendChild(m); + }); + o.s.status = { running: false, done: "job-2" }; + await tick(o, 21000); + check("창이 열려 있으면 새로 고치지 않음", o.s.loads === 2, o.s.loads); + const note = await o.p.textContent("#perf-last-update"); + check("안내: 창을 닫으면 새로 고침", /새 데이터 있음/.test(note), note); + await tick(o, 5000); + check("창이 열린 동안은 계속 기다림", o.s.loads === 2, o.s.loads); + await o.p.evaluate(function () { document.getElementById("fake-modal").remove(); }); + await tick(o, 2000); + await o.p.waitForLoadState(); + check("창을 닫으면 새로 고침", o.s.loads === 3, o.s.loads); + + // 칸 입력 중(포커스)이면 기다림 + o.s.status = { running: false, done: "job-3" }; + await o.p.evaluate(function () { + const i = document.createElement("input"); i.id = "fake-input"; document.querySelector("#perf-dash").appendChild(i); i.focus(); + }); + await tick(o, 21000); + check("입력 중이면 새로 고치지 않음", o.s.loads === 3, o.s.loads); + await o.p.evaluate(function () { document.getElementById("fake-input").blur(); }); + await tick(o, 2000); + await o.p.waitForLoadState(); + check("입력을 마치면 새로 고침", o.s.loads === 4, o.s.loads); + await o.ctx.close(); + + // ── 광고비 — 광고비 업데이트를 따로 본다 ── + o = await open("perf_ads.html", "http://perf.test/performance/ads"); + await tick(o, 21000); + check("광고비 화면은 kind=ads", o.s.asks[0] === "kind=ads", o.s.asks); + o.s.status = { running: false, done: "job-ads" }; + await tick(o, 20000); + await o.p.waitForLoadState(); + check("광고비 자동 업데이트 끝 → 새로 고침", o.s.loads === 2, o.s.loads); + await o.ctx.close(); + + // ── 자동 새로 고침 정보가 없는 화면(예전 서버 등) — 묻지 않음 ── + o = await open("perf_dash_groups.html", "http://perf.test/performance/"); + await tick(o, 45000); + check("update_watch 없으면 묻지 않음", o.s.asks.length === 0, o.s.asks); + await o.ctx.close(); + } finally { + await browser.close(); + } + console.log(fails.length ? "\n" + fails.length + " FAILED" : "\nALL PASS"); + process.exit(fails.length ? 1 : 0); +})(); diff --git a/tests/js/render_performance.py b/tests/js/render_performance.py index 09771c6..04b7180 100644 --- a/tests/js/render_performance.py +++ b/tests/js/render_performance.py @@ -95,6 +95,8 @@ def main() -> None: ctx["auto_sync"] = {"next_at": "2026-10-07T10:30:00+09:00", "now": "2026-10-07T10:17:25.000+09:00", "schedule": {"enabled": True, "interval": 30, "days": [0, 1, 2, 3, 4, 5, 6], "start": "09:00", "end": "19:00"}, "label": "매일 09:00~19:00 · 30분마다"} + # 화면 자동 새로 고침(2026-10-26, router._update_watch) — 그린 때 마지막으로 끝난 업데이트 + ctx["update_watch"] = {"kind": "sales", "seen": "job-old"} html = e.get_template("performance/index.html").render(**base, active_tab="dashboard", metric="net", **ctx) with open(os.path.join(OUT_DIR, "perf_dash.html"), "w", encoding="utf-8") as f: f.write(html) @@ -104,12 +106,14 @@ def main() -> None: sbase = {**base, "user": {"email": "me@test.local", "name": "Me", "picture": ""}} mctx = build_dashboard(FakeStore(), kind="month", anchor=date(2026, 10, 7), today=date(2026, 10, 7)) mctx["auto_sync"] = ctx["auto_sync"] + mctx["update_watch"] = {"kind": "sales", "seen": "job-old"} html = shell.get_template("performance/index.html").render(**sbase, active_tab="dashboard", metric="net", **mctx) with open(os.path.join(OUT_DIR, "perf_dash_shell.html"), "w", encoding="utf-8") as f: f.write(html) sactx = build_ad_dashboard(FakeStore(), kind="month", anchor=date(2026, 10, 7), today=date(2026, 10, 7), sales_codes=["cafe24", "coupang"]) sactx["auto_sync"] = ctx["auto_sync"] + sactx["update_watch"] = {"kind": "ads", "seen": "job-old"} html = shell.get_template("performance/ads.html").render(**sbase, active_tab="ads", **sactx) with open(os.path.join(OUT_DIR, "perf_ads_shell.html"), "w", encoding="utf-8") as f: f.write(html) @@ -117,6 +121,7 @@ def main() -> None: sales_codes=["cafe24", "coupang"]) actx["ad_sync_sources"] = [{"code": "google", "name": "구글 광고"}] # [구글 광고 불러오기] actx["auto_sync"] = ctx["auto_sync"] # 광고비 탭도 다음 업데이트 카운트다운(router._auto_sync_ctx) + actx["update_watch"] = {"kind": "ads", "seen": "job-old"} html = e.get_template("performance/ads.html").render(**base, active_tab="ads", **actx) with open(os.path.join(OUT_DIR, "perf_ads.html"), "w", encoding="utf-8") as f: f.write(html) @@ -136,6 +141,7 @@ def main() -> None: # 직접 추가 쇼핑몰·그룹(2026-10-22) — perf_dash_groups.html · perf_settings_groups.html (perf_groups.browser.test.js) gctx = build_dashboard(GroupStore(), kind="week", anchor=date(2026, 10, 7), today=date(2026, 10, 7)) gctx["auto_sync"] = None + gctx["update_watch"] = None html = e.get_template("performance/index.html").render(**base, active_tab="dashboard", metric="gross", **gctx) with open(os.path.join(OUT_DIR, "perf_dash_groups.html"), "w", encoding="utf-8") as f: f.write(html)