V10.524 補 PChome 過期價格刷新入口
Some checks failed
CD Pipeline / deploy (push) Failing after 1m28s

This commit is contained in:
OoO
2026-06-01 00:29:20 +08:00
parent 915b8d061d
commit 87d47f171c
11 changed files with 259 additions and 46 deletions

View File

@@ -516,11 +516,14 @@ def test_ai_product_pick_agent_uses_real_competitor_data_and_dashboard_action():
assert "@ai_bp.route('/api/ai/product-picks/generate', methods=['POST'])" in route_source
assert "generate_product_pick_list(engine" in route_source
assert "@ai_bp.route('/api/ai/pchome-match/backfill', methods=['POST'])" in route_source
assert "@ai_bp.route('/api/ai/pchome-match/refresh-stale', methods=['POST'])" in route_source
assert "@ai_bp.route('/api/ai/pchome-match/backfill/status', methods=['GET'])" in route_source
assert "_build_pchome_backfill_coverage_payload" in route_source
assert "fetch_competitor_coverage" in route_source
assert "status['coverage'] = _build_pchome_backfill_coverage_payload()" in route_source
assert "run_unmatched_priority(limit=unmatched_limit)" in route_source
assert "run_expired_identity_refresh(limit=limit)" in route_source
assert "stage='refreshing_stale'" in route_source
assert "run_retryable_candidate_revalidation" in route_source
assert "generate_product_pick_list(engine, limit=50)" in route_source
assert "start_pchome_backfill_run" in route_source
@@ -556,12 +559,16 @@ def test_ai_product_pick_agent_uses_real_competitor_data_and_dashboard_action():
assert "backfillPchomeMatches" in template
assert "/api/ai/product-picks/generate" in template
assert "/api/ai/pchome-match/backfill" in template
assert "/api/ai/pchome-match/refresh-stale" in dashboard_template
assert "/api/ai/pchome-match/backfill/status" in dashboard_template
assert "PCHOME MATCH BACKFILL" in dashboard_template
assert "data-pchome-backfill-trigger" in dashboard_template
assert "data-pchome-refresh-stale-trigger" in dashboard_template
assert "刷新過期 120 筆" in dashboard_template
dashboard_js = (ROOT / "web/static/js/page-dashboard-v2.js").read_text(encoding="utf-8")
assert "loadPchomeBackfillStatus" in dashboard_js
assert "window.backfillPchomeMatches" in dashboard_js
assert "window.refreshStalePchomeMatches" in dashboard_js
assert "formatBackfillCoverageSummary" in dashboard_js
assert "status.coverage" in dashboard_js
assert "待刷新 ${formatBackfillCount(coverage.stale_matches)}" in dashboard_js

View File

@@ -55,3 +55,18 @@ def test_pchome_backfill_status_records_failure(tmp_path, monkeypatch):
assert failed["status"] == "failed"
assert failed["last_error"] == "crawler timeout"
assert failed["recent_runs"][0]["last_error"] == "crawler timeout"
def test_pchome_backfill_status_supports_stale_refresh_stage(tmp_path, monkeypatch):
monkeypatch.setenv("PCHOME_BACKFILL_STATUS_PATH", str(tmp_path / "status.json"))
run = start_pchome_backfill_run(limit=120, operator="tester")
refreshing = update_pchome_backfill_run(
run["run_id"],
stage="refreshing_stale",
message="正在刷新過期價格",
)
assert refreshing["stage"] == "refreshing_stale"
assert refreshing["stage_label"] == "刷新過期 PChome 價格"
assert refreshing["progress_pct"] > run["progress_pct"]