feat(performance): 날짜 칸 메모·광고비 표 열 너비 자동/날짜 열 고정·기타광고비 열
- 매출 실적·광고비 금액 입력 칸 우클릭 → 메모 삽입·수정·삭제(창), 메모 있는 칸 빨간 삼각형·마우스 올리면 메모 상자
(마이그레이션 010 perf_cell_memos, PUT /api/cell-memos/{kind}/{code}/{date})
- 광고비 표도 열 너비 = 내용 길이, 날짜 열 가로 스크롤 고정(perf-autofit)
- 기타광고비 열(etc, 애터미아자몰 오른쪽) — ROAS 없음
- 테스트: test_cell_memos.py, perf_memo_ads.browser.test.js, 기존 채널 목록 기대값
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -121,7 +121,8 @@ def test_ad_dashboard_month():
|
||||
ctx = ads.build_ad_dashboard(_Store(), kind="month", anchor=date(2026, 10, 7), today=date(2026, 10, 7),
|
||||
sales_codes=["cafe24"])
|
||||
assert ctx["codes"] == ["google", "meta", "naver", "coupang_wing", "coupang_rocket", "ohouse", "gmarket", "kakao",
|
||||
"gsshop", "elevenst", "lotteon", "toss", "atomy"]
|
||||
"gsshop", "elevenst", "lotteon", "toss", "atomy", "etc"] # 기타광고비(2026-10-22) = 애터미아자몰 오른쪽
|
||||
assert ctx["names"]["etc"] == "기타광고비" and ctx["roas_basis"]["etc"] == "" and "etc" not in ads.ROAS_SALES_CODE # 매출 쇼핑몰 없음 = ROAS 없음
|
||||
k = {x["key"]: x for x in ctx["kpis"]}
|
||||
assert k["spend"]["value"] == 270000 and k["ratio"]["pct"] == 10.0 # 270,000 ÷ 2,700,000
|
||||
assert k["ytd"]["value"] == 370000 and k["mtd"]["value"] == 270000
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
"""날짜 칸 메모(2026-10-22, 마이그레이션 010) — API 규칙(종류·코드·길이·지우기·010 미적용 503), 매출·광고비 화면의 메모 표시, 기타광고비 채널."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
from datetime import date
|
||||
|
||||
import pytest
|
||||
from fastapi import FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app.modules.performance import ad_spend, common
|
||||
from app.modules.performance.db import MemoMigrationNeeded
|
||||
|
||||
perf_router = importlib.import_module("app.modules.performance.router")
|
||||
|
||||
|
||||
class Store:
|
||||
def __init__(self, missing=False):
|
||||
self.saved, self.missing = [], missing
|
||||
|
||||
def list_marketplaces(self):
|
||||
return [{"code": "coupang", "name": "쿠팡", "enabled": True, "include_in_sales": True, "manual_input": True}]
|
||||
|
||||
def set_cell_memo(self, kind, code, day, memo, *, user=""):
|
||||
if self.missing:
|
||||
raise MemoMigrationNeeded()
|
||||
self.saved.append((kind, code, day, memo, user))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client_store(monkeypatch):
|
||||
st = Store()
|
||||
monkeypatch.setattr(common, "require_store", lambda request, admin=False: (st, {"email": "me@x"}))
|
||||
app = FastAPI()
|
||||
app.include_router(perf_router.router)
|
||||
return TestClient(app), st
|
||||
|
||||
|
||||
def test_cell_memo_api(client_store):
|
||||
c, st = client_store
|
||||
r = c.put("/performance/api/cell-memos/sales/coupang/2026-10-05", json={"memo": " 행사 매출 포함\r\n2차 정산 예정 "})
|
||||
assert r.status_code == 200 and r.json()["memo"] == "행사 매출 포함\n2차 정산 예정"
|
||||
assert st.saved[-1] == ("sales", "coupang", date(2026, 10, 5), "행사 매출 포함\n2차 정산 예정", "me@x")
|
||||
r = c.put("/performance/api/cell-memos/ad/etc/2026-10-30", json={"memo": "전단지"}) # 기타광고비·앞날도 됨
|
||||
assert r.status_code == 200 and st.saved[-1][:2] == ("ad", "etc")
|
||||
assert c.put("/performance/api/cell-memos/ad/etc/2026-10-30", json={"memo": " "}).status_code == 200
|
||||
assert st.saved[-1][3] is None # 빈 메모 = 지움
|
||||
assert c.put("/performance/api/cell-memos/sales/nope/2026-10-05", json={"memo": "x"}).status_code == 404
|
||||
assert c.put("/performance/api/cell-memos/ad/cafe24/2026-10-05", json={"memo": "x"}).status_code == 404 # 광고 채널 아님
|
||||
assert c.put("/performance/api/cell-memos/other/coupang/2026-10-05", json={"memo": "x"}).status_code == 404
|
||||
assert c.put("/performance/api/cell-memos/sales/coupang/2026-10-05", json={"memo": "가" * 1001}).status_code == 400
|
||||
st.missing = True
|
||||
r = c.put("/performance/api/cell-memos/sales/coupang/2026-10-05", json={"memo": "x"})
|
||||
assert r.status_code == 503 and "010" in r.json()["detail"]
|
||||
|
||||
|
||||
def test_etc_channel_has_no_roas():
|
||||
assert ad_spend.CHANNEL_CODES[-2:] == ("atomy", "etc") and ad_spend.CHANNEL_NAMES["etc"] == "기타광고비"
|
||||
assert ad_spend.channel_roas("etc", lambda m: 1_000_000, 50_000) is None
|
||||
assert ad_spend.roas_basis("etc") == ""
|
||||
from app.modules.performance.dashboard import sales_ad_channels
|
||||
assert not any(ch == "etc" for lines in sales_ad_channels().values() for ch, _ in lines) # 매출 탭 광고비 줄에 안 나옴
|
||||
Reference in New Issue
Block a user