From 6c548e22516c8a1fd88c15f9db285c2e14d443ae Mon Sep 17 00:00:00 2001 From: OoO Date: Tue, 19 May 2026 15:44:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=B4=AF=E7=A9=8D=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E9=A9=97=E8=AD=89=E6=B8=AC=E8=A9=A6=E8=88=87=E6=A8=A1?= =?UTF-8?q?=E7=B5=84=E5=8C=96=E7=9B=A4=E9=BB=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../code_modularization_inventory_20260430.md | 2 +- tests/test_frontend_v2_assets.py | 60 +++++++++++-------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/docs/memory/code_modularization_inventory_20260430.md b/docs/memory/code_modularization_inventory_20260430.md index 4931037..8704468 100644 --- a/docs/memory/code_modularization_inventory_20260430.md +++ b/docs/memory/code_modularization_inventory_20260430.md @@ -43,7 +43,7 @@ | 837 | `services/code_review_pipeline_service.py` | P2 Code review pipeline service | scan orchestration / finding normalization / persistence adapter | | 832 | `routes/export_routes.py` | P2 Export flow | export command/router glue / file path / download orchestration | | 816 | `services/ppt_vision_service.py` | P2 PPT vision QA service | runtime state / queue status / model probe / audit execution 分離 | -| 809 | `services/competitor_price_feeder.py` | P2 competitor price feeder | crawler scheduling / price normalization / cache strategy | +| 904 | `services/competitor_price_feeder.py` | P2 competitor price feeder | crawler scheduling / price normalization / cache strategy | | 805 | `routes/bot_api_routes.py` | P2 Bot API Blueprint | route glue / bot action service | ## 市場情報開發前置禁區 diff --git a/tests/test_frontend_v2_assets.py b/tests/test_frontend_v2_assets.py index 8b26423..f2b98c1 100644 --- a/tests/test_frontend_v2_assets.py +++ b/tests/test_frontend_v2_assets.py @@ -76,30 +76,35 @@ def test_legacy_navbar_uses_warm_token_accent_aliases(): def test_campaign_v2_uses_latest_warm_hero_without_fake_data(): template = (ROOT / "templates/edm_dashboard_v2.html").read_text(encoding="utf-8") + style = (ROOT / "web/static/css/page-edm-v2.css").read_text(encoding="utf-8") + combined = template + "\n" + style - assert "--campaign-accent: var(--momo-warm-caramel)" in template - assert "--campaign-accent: var(--momo-warm-honey)" in template - assert "--campaign-accent: var(--momo-warm-rust)" in template - assert "background: var(--momo-bg-paper)" in template - assert "radial-gradient(circle, rgba(42, 37, 32, 0.12) 1px, transparent 1px)" in template - assert ".campaign-hero::after" in template - assert "font-family: var(--momo-font-display)" in template - assert "linear-gradient(160deg" not in template - assert "#7c3aed" not in template - assert "#0891b2" not in template - assert "mock" not in template.lower() - assert "假商品" not in template + assert "css/page-edm-v2.css" in template + assert "--campaign-accent: var(--momo-warm-caramel)" in style + assert "--campaign-accent: var(--momo-warm-honey)" in style + assert "--campaign-accent: var(--momo-warm-rust)" in style + assert "background: var(--momo-bg-paper)" in style + assert "radial-gradient(circle, rgba(42, 37, 32, 0.12) 1px, transparent 1px)" in style + assert ".campaign-hero::after" in style + assert "font-family: var(--momo-font-display)" in style + assert "linear-gradient(160deg" not in combined + assert "#7c3aed" not in combined + assert "#0891b2" not in combined + assert "mock" not in combined.lower() + assert "假商品" not in combined def test_campaign_v2_product_table_keeps_real_operations_columns(): template = (ROOT / "templates/edm_dashboard_v2.html").read_text(encoding="utf-8") route_source = (ROOT / "routes/edm_routes.py").read_text(encoding="utf-8") + page_js = (ROOT / "web/static/js/page-edm-v2.js").read_text(encoding="utf-8") assert "分類 / 狀態" in template assert "銷售 / 庫存" in template assert "追蹤資訊" in template assert "data-campaign-copy=\"{{ item.i_code }}\"" in template - assert "copyCampaignProductId" in template + assert "js/page-edm-v2.js" in template + assert "copyCampaignProductId" in page_js assert "campaign-change-pct" in template assert "item.total_sold" in template assert "item.days_on_shelf" in template @@ -116,8 +121,8 @@ def test_dashboard_v2_is_production_default_and_uses_real_dashboard_data(): route_source = (ROOT / "routes/dashboard_routes.py").read_text(encoding="utf-8") dashboard = (ROOT / "templates/dashboard_v2.html").read_text(encoding="utf-8") - assert "request.args.get('ui') == 'legacy'" in route_source - assert "template_name = 'dashboard.html' if request.args.get('ui') == 'legacy' else 'dashboard_v2.html'" in route_source + assert "template_name = 'dashboard_v2.html'" in route_source + assert "template_name = 'dashboard.html' if request.args.get('ui') == 'legacy' else 'dashboard_v2.html'" not in route_source assert "get_full_dashboard_data()" in route_source assert "_load_shared_full_dashboard_cache(now)" in route_source assert "_load_stale_full_dashboard_cache(now)" in route_source @@ -272,6 +277,7 @@ def test_monthly_summary_analysis_uses_v2_shell_and_real_monthly_api(): def test_dashboard_v2_restores_real_price_history_chart(): route_source = (ROOT / "routes/api_routes.py").read_text(encoding="utf-8") dashboard = (ROOT / "templates/dashboard_v2.html").read_text(encoding="utf-8") + page_js = (ROOT / "web/static/js/page-dashboard-v2.js").read_text(encoding="utf-8") assert "@api_bp.route('/api/history/')" in route_source assert "PRICE_HISTORY_RANGES" in route_source @@ -281,19 +287,22 @@ def test_dashboard_v2_restores_real_price_history_chart(): assert "'year': {'days': 365" in route_source assert "session.query(PriceRecord)" in route_source assert "PriceRecord.product_id == product.id" in route_source - assert "https://cdn.jsdelivr.net/npm/chart.js" in dashboard + assert "js/page-dashboard-v2.js" in dashboard + assert "https://cdn.jsdelivr.net/npm/chart.js" in page_js assert 'id="historyModal"' in dashboard assert 'id="priceChart"' in dashboard assert "data-product-id=\"{{ product.id }}\"" in dashboard assert "data-history-trigger" in dashboard - assert "onclick=\"event.stopPropagation(); showHistory(this.dataset.productId, this.dataset.productName);\"" in dashboard + assert "document.querySelectorAll('[data-history-trigger]')" in page_js + assert "event.stopPropagation();" in page_js + assert "showHistory(button.dataset.productId, button.dataset.productName);" in page_js assert "data-history-range=\"week\"" in dashboard assert "data-history-range=\"month\"" in dashboard assert "data-history-range=\"quarter\"" in dashboard assert "data-history-range=\"year\"" in dashboard - assert "fetch(`/api/history/${productId}?range=${activeHistoryRange}&format=v2`)" in dashboard - assert "priceChartInstance = new Chart" in dashboard - assert "目前沒有可顯示的歷史價格紀錄" in dashboard + assert "fetch(`/api/history/${productId}?range=${activeHistoryRange}&format=v2`)" in page_js + assert "priceChartInstance = new Chart" in page_js + assert "目前沒有可顯示的歷史價格紀錄" in page_js def test_dashboard_v2_shows_pchome_competitor_pricing_and_links(): @@ -302,6 +311,7 @@ def test_dashboard_v2_shows_pchome_competitor_pricing_and_links(): feeder_source = (ROOT / "services/competitor_price_feeder.py").read_text(encoding="utf-8") scheduler_source = (ROOT / "scheduler.py").read_text(encoding="utf-8") dashboard = (ROOT / "templates/dashboard_v2.html").read_text(encoding="utf-8") + page_js = (ROOT / "web/static/js/page-dashboard-v2.js").read_text(encoding="utf-8") migration = (ROOT / "migrations/022_competitor_price_history.sql").read_text(encoding="utf-8") assert "_load_pchome_competitor_map(" in route_source @@ -326,9 +336,9 @@ def test_dashboard_v2_shows_pchome_competitor_pricing_and_links(): assert "_load_pchome_match_attempt_map" in route_source assert "低信心待審" in route_source assert "規格衝突待審" in route_source - assert "series.pchome" in dashboard - assert "label: 'PChome'" in dashboard - assert "含 PChome 歷史快照" in dashboard + assert "series.pchome" in page_js + assert "label: 'PChome'" in page_js + assert "含 PChome 歷史快照" in page_js assert "competitor_price_history" in migration assert "momo_price" in migration @@ -459,9 +469,9 @@ def test_vendor_stockout_v2_is_production_default_and_uses_real_vendor_data(): service_source = (ROOT / "services/vendor_stockout_query_service.py").read_text(encoding="utf-8") template = (ROOT / "templates/vendor_stockout_index_v2.html").read_text(encoding="utf-8") - assert "request.args.get('ui') == 'legacy'" in route_source - assert not (ROOT / "web/templates/vendor_stockout_index_v2.html").exists() assert "vendor_stockout_index_v2.html" in route_source + assert "request.args.get('ui') == 'legacy'" not in route_source + assert not (ROOT / "web/templates/vendor_stockout_index_v2.html").exists() assert "get_vendor_dashboard_stats(vendor_db)" in route_source assert "def get_vendor_dashboard_stats(vendor_db)" in service_source assert "session.query(VendorStockout).count()" in service_source