fix: professionalize marketplace product ux
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from sqlalchemy import create_engine, text
|
||||
|
||||
|
||||
def test_connector_contract_keeps_shopee_and_coupang_paused_with_manual_csv_path():
|
||||
def test_connector_contract_lists_mainstream_sources_without_auto_alerts():
|
||||
from services.external_market_offer_service import build_connector_contracts
|
||||
|
||||
payload = build_connector_contracts()
|
||||
@@ -12,8 +12,31 @@ def test_connector_contract_keeps_shopee_and_coupang_paused_with_manual_csv_path
|
||||
assert sources["momo_reference"]["status_label"] == "正在使用"
|
||||
assert sources["shopee"]["status_label"] == "先暫停"
|
||||
assert sources["coupang"]["status_label"] == "先暫停"
|
||||
assert {
|
||||
"shopee",
|
||||
"lazada",
|
||||
"amazon",
|
||||
"google_merchant",
|
||||
"tiktok_shop",
|
||||
"line_shopping",
|
||||
"rakuten",
|
||||
"yahoo_shopping",
|
||||
"ruten",
|
||||
"shopify_brand_store",
|
||||
"meta_commerce",
|
||||
"coupang",
|
||||
}.issubset(sources)
|
||||
assert all(
|
||||
sources[code]["status_code"] == "paused"
|
||||
for code in sources
|
||||
if code != "momo_reference"
|
||||
)
|
||||
assert "手動 CSV" in sources["shopee"]["input_methods"]
|
||||
assert "官方 API" in sources["coupang"]["input_methods"]
|
||||
assert "官方報表" in sources["google_merchant"]["input_methods"]
|
||||
assert "商品 Feed" in sources["shopify_brand_store"]["input_methods"]
|
||||
assert sources["tiktok_shop"]["plain_note"].startswith("保留短影音電商")
|
||||
assert sources["ruten"]["display_name"] == "露天"
|
||||
assert "price" in payload["manual_csv"]["required_headers"]
|
||||
|
||||
|
||||
@@ -434,6 +457,11 @@ def test_momo_review_candidate_queue_can_confirm_candidate(monkeypatch):
|
||||
|
||||
stale_marks = []
|
||||
monkeypatch.setattr(service, "mark_pchome_growth_cache_stale", lambda: stale_marks.append(True))
|
||||
monkeypatch.setattr(
|
||||
service,
|
||||
"_fetch_pchome_public_image_map",
|
||||
lambda product_ids: {"PCH-CDP": "https://cs-a.ecimg.tw/items/PCH-CDP/000001.jpg"},
|
||||
)
|
||||
|
||||
engine = create_engine("sqlite:///:memory:")
|
||||
_seed_external_offer_sync_tables(engine)
|
||||
@@ -462,6 +490,8 @@ def test_momo_review_candidate_queue_can_confirm_candidate(monkeypatch):
|
||||
assert candidate["pchome_product_name"] == "cle de peau 光采柔焦蜜粉 24g #1"
|
||||
assert candidate["momo_sku"] == "14917079"
|
||||
assert candidate["plain_status"] == "待確認同款或色號"
|
||||
assert candidate["pchome_image_url"] == "https://cs-a.ecimg.tw/items/PCH-CDP/000001.jpg"
|
||||
assert "momo_image_url" in candidate
|
||||
|
||||
updated = service.update_momo_review_candidate(engine, candidate["id"], "confirm", note="同款 #1")
|
||||
|
||||
@@ -575,7 +605,10 @@ def test_external_source_readiness_uses_legacy_momo_reference_cache():
|
||||
assert sources["momo_reference"]["usable_offer_count"] == 1
|
||||
assert sources["momo_reference"]["plain_state"] == "已接入,可進作戰清單"
|
||||
assert sources["shopee"]["plain_state"] == "先保留接口,不進告警"
|
||||
assert payload["plain_summary"] == "MOMO 先用;蝦皮與酷澎先保留接口,暫不進告警。"
|
||||
assert sources["tiktok_shop"]["plain_state"] == "先保留接口,不進告警"
|
||||
assert sources["line_shopping"]["plain_state"] == "先保留接口,不進告警"
|
||||
assert sources["shopify_brand_store"]["plain_state"] == "先保留接口,不進告警"
|
||||
assert payload["plain_summary"] == "MOMO 先用;其他主流平台已列管,未接合法穩定來源前不進告警。"
|
||||
|
||||
|
||||
def test_external_market_migration_creates_source_and_offer_tables():
|
||||
|
||||
@@ -268,6 +268,7 @@ 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")
|
||||
dashboard_css = (ROOT / "web/static/css/page-dashboard-v2.css").read_text(encoding="utf-8")
|
||||
guard_css = (ROOT / "web/static/css/ewoooc-v3-page-guard.css").read_text(encoding="utf-8")
|
||||
|
||||
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
|
||||
@@ -383,6 +384,17 @@ def test_dashboard_v2_is_production_default_and_uses_real_dashboard_data():
|
||||
assert "AI 挑品清單" in dashboard
|
||||
assert "比價覆核隊列" in dashboard
|
||||
assert "下一步" in dashboard
|
||||
assert "商品ID {{ product.i_code }}" in dashboard
|
||||
assert "開 MOMO 賣場" in dashboard
|
||||
assert "開 PChome 賣場" in dashboard
|
||||
assert "is-ai-picks-wrap" in dashboard
|
||||
assert "dashboard-product-thumb-missing" in dashboard
|
||||
assert "dashboard-product-identity" in dashboard_css
|
||||
assert ".dashboard-table.is-ai-picks td:nth-child(6)" in dashboard_css
|
||||
assert "position: sticky;" in dashboard_css
|
||||
assert "min-width: 230px" in dashboard_css
|
||||
assert ".dashboard-table-wrap.is-ai-picks-wrap" in guard_css
|
||||
assert "min-width: 1660px !important" in guard_css
|
||||
assert "dashboard-ai-summary-grid" in dashboard
|
||||
assert "AI 建議" in dashboard
|
||||
assert "/api/export/excel/ai-picks" in dashboard
|
||||
@@ -1081,6 +1093,7 @@ def test_ai_product_pick_agent_uses_real_competitor_data_and_dashboard_action():
|
||||
|
||||
assert "產生今日清單" in template
|
||||
assert "補齊比價資料" in template
|
||||
assert "ai-intel-legacy-status" in template
|
||||
assert "generatePickList" in template
|
||||
assert "backfillPchomeMatches" in template
|
||||
assert "/api/ai/product-picks/generate" in template
|
||||
|
||||
@@ -218,6 +218,8 @@ def test_momo_review_candidates_return_dual_store_links_and_plain_reasons():
|
||||
row = payload["rows"][0]
|
||||
assert row["pchome_url"] == "https://24h.pchome.com.tw/prod/PCH-REVIEW"
|
||||
assert row["momo_url"] == "https://www.momoshop.com.tw/goods/GoodsDetail.jsp?i_code=MOMO-REVIEW"
|
||||
assert "pchome_image_url" in row
|
||||
assert "momo_image_url" in row
|
||||
assert row["match_reason_labels"]
|
||||
assert all("_" not in label for label in row["match_reason_labels"])
|
||||
assert all("_" not in label for label in row["match_reasons"])
|
||||
@@ -489,6 +491,7 @@ def test_ai_intelligence_template_uses_pchome_growth_name_and_endpoint():
|
||||
assert "/api/ai/pchome-growth/external-offers/csv-dry-run" in template
|
||||
assert "/api/ai/pchome-growth/review-candidates" in template
|
||||
assert "growthSourceReadiness" in template
|
||||
assert "sources.map((source)" in template
|
||||
assert "MOMO 待確認候選" in template
|
||||
assert "確認同款" in template
|
||||
assert "不是同款" in template
|
||||
@@ -502,6 +505,10 @@ def test_ai_intelligence_template_uses_pchome_growth_name_and_endpoint():
|
||||
assert "data-momo-url" in template
|
||||
assert "PChome 賣場" in template
|
||||
assert "MOMO 賣場" in template
|
||||
assert "商品ID ${escapeHtml(row.pchome_product_id" in template
|
||||
assert "商品ID ${escapeHtml(row.momo_sku" in template
|
||||
assert "renderProductThumb" in template
|
||||
assert "待補圖片" in template
|
||||
assert "row.match_reason_labels" in template
|
||||
assert "row.match_reasons" not in template
|
||||
assert "variant_selection_review" not in template
|
||||
@@ -587,11 +594,11 @@ def test_sidebar_uses_growth_command_center_as_primary_entry():
|
||||
assert "{% set _group_monitor = ['ai_intelligence', 'dashboard', 'edm', 'campaigns'] %}" in base
|
||||
assert "momo-growth-rail" in base
|
||||
assert "PChome 業績提升" in base
|
||||
assert "現在:評估缺口" in base
|
||||
assert "現在:分析原因" in base
|
||||
assert "現在:產生建議" in base
|
||||
assert "現在:執行解法" in base
|
||||
assert "現在:守住品質" in base
|
||||
assert "今日重點:優先商品" in base
|
||||
assert "今日重點:價格判斷" in base
|
||||
assert "今日重點:業績建議" in base
|
||||
assert "今日重點:執行清單" in base
|
||||
assert "今日重點:資料品質" in base
|
||||
assert "評估" in base
|
||||
assert "分析" in base
|
||||
assert "建議" in base
|
||||
|
||||
Reference in New Issue
Block a user