fix: harden import auth and utility page copy
Some checks failed
CD Pipeline / deploy (push) Failing after 6m19s
Some checks failed
CD Pipeline / deploy (push) Failing after 6m19s
This commit is contained in:
@@ -276,6 +276,20 @@ def test_google_drive_auth_refuses_browser_without_json_token(monkeypatch, tmp_p
|
||||
assert "google_token.pickle" in service.last_error
|
||||
|
||||
|
||||
def test_google_drive_auth_paths_can_be_pinned_by_container_env(monkeypatch):
|
||||
monkeypatch.setenv("GOOGLE_DRIVE_CREDENTIALS_FILE", "/app/config/google_credentials.json")
|
||||
monkeypatch.setenv("GOOGLE_DRIVE_TOKEN_FILE", "/app/config/google_token.json")
|
||||
monkeypatch.setenv("GOOGLE_DRIVE_LEGACY_PICKLE_FILE", "/app/config/google_token.pickle")
|
||||
|
||||
import services.google_drive_service as google_drive_service
|
||||
|
||||
google_drive_service = importlib.reload(google_drive_service)
|
||||
|
||||
assert google_drive_service.CREDENTIALS_FILE == "/app/config/google_credentials.json"
|
||||
assert google_drive_service.TOKEN_FILE == "/app/config/google_token.json"
|
||||
assert google_drive_service._LEGACY_PICKLE_FILE == "/app/config/google_token.pickle"
|
||||
|
||||
|
||||
def test_google_drive_auth_fails_when_token_cannot_be_persisted(monkeypatch, tmp_path):
|
||||
import services.google_drive_service as google_drive_service
|
||||
|
||||
|
||||
@@ -62,14 +62,13 @@ def test_high_visibility_pages_use_traditional_chinese_labels():
|
||||
]
|
||||
combined = "\n".join((ROOT / path).read_text(encoding="utf-8") for path in page_paths)
|
||||
|
||||
assert "AI 程式碼審查" in combined
|
||||
assert "部署守門與程式碼審查" in combined
|
||||
assert "等待程式碼審查完成" in combined
|
||||
assert "AI 自動化健康檢查" in combined
|
||||
assert "四 Agent 控制面" in combined
|
||||
assert "AI 閉環守門" in combined
|
||||
assert "產線健康度" in combined
|
||||
assert "工作隊列" in combined
|
||||
assert "覆蓋率流程" in combined
|
||||
assert "NemoTron · 派遣器" in combined
|
||||
assert "同步部署" in combined
|
||||
assert "部署監控" in combined
|
||||
assert "最新部署流程" in combined
|
||||
@@ -578,6 +577,8 @@ def test_price_comparison_page_is_action_oriented_and_plain_chinese():
|
||||
assert "data-momo-url" in template
|
||||
assert "Excel 至少要有商品名稱與售價" in template
|
||||
assert "貼上 MOMO 商品、售價與賣場連結" in template
|
||||
assert "先選擇 MOMO 商品檔案。" in template
|
||||
assert "先貼上商品、售價與賣場連結。" in template
|
||||
assert "resetComparisonResult" in template
|
||||
assert "showToast" in template
|
||||
assert "text.textContent = message" in template
|
||||
@@ -585,6 +586,9 @@ def test_price_comparison_page_is_action_oriented_and_plain_chinese():
|
||||
assert "格式說明" not in template
|
||||
assert "商品名稱,價格" not in template
|
||||
assert "欄位" not in template
|
||||
assert "系統會整理成可比價清單" not in template
|
||||
assert "請選擇檔案" not in template
|
||||
assert "請輸入商品資料" not in template
|
||||
assert "Step 1" not in template
|
||||
assert "Step 2" not in template
|
||||
assert "Step 3" not in template
|
||||
@@ -597,6 +601,35 @@ def test_price_comparison_page_is_action_oriented_and_plain_chinese():
|
||||
assert "render_template('price_comparison.html', active_page='price_comparison')" in route_source
|
||||
|
||||
|
||||
def test_utility_pages_keep_operator_copy_professional():
|
||||
ppt_history = (ROOT / "templates/admin/ppt_audit_history.html").read_text(encoding="utf-8")
|
||||
ppt_preview = (ROOT / "templates/admin/ppt_audit_preview.html").read_text(encoding="utf-8")
|
||||
auto_import = (ROOT / "templates/auto_import_index.html").read_text(encoding="utf-8")
|
||||
stockout_import = (ROOT / "templates/vendor_stockout_import_v2.html").read_text(encoding="utf-8")
|
||||
observability_js = (ROOT / "web/static/js/observability-charts.js").read_text(encoding="utf-8")
|
||||
combined = "\n".join([ppt_history, ppt_preview, auto_import, stockout_import, observability_js])
|
||||
|
||||
assert "簡報線上預覽" in ppt_preview
|
||||
assert "下載簡報檔" in ppt_history
|
||||
assert "送出後更新日報、成長分析與今日作戰清單" in auto_import
|
||||
assert "缺少必要資料時,會先停止匯入" in stockout_import
|
||||
assert "部署檢查已排入背景處理" in observability_js
|
||||
|
||||
forbidden = [
|
||||
"PPT Online Preview",
|
||||
"Preview unavailable",
|
||||
"原始 PPTX",
|
||||
"系統會去重",
|
||||
"系統會拒絕",
|
||||
"管線 ID",
|
||||
"Commit:",
|
||||
"變更檔案:",
|
||||
"查看系統日誌",
|
||||
]
|
||||
for marker in forbidden:
|
||||
assert marker not in combined
|
||||
|
||||
|
||||
def test_ai_history_uses_v2_shell_and_real_history_apis():
|
||||
template = (ROOT / "templates/ai_history.html").read_text(encoding="utf-8")
|
||||
route_source = (ROOT / "routes/ai_routes.py").read_text(encoding="utf-8")
|
||||
@@ -1097,7 +1130,7 @@ def test_vendor_stockout_import_v2_is_feature_flagged_and_does_not_ship_sample_r
|
||||
assert "template_columns = [" in template_function
|
||||
assert "pd.DataFrame(columns=template_columns)" in template_function
|
||||
assert "fetchWithCSRF('/vendor-stockout/api/import/excel'" in template
|
||||
assert "vendor_stockout" in template
|
||||
assert "vendor-stockout/api/import/excel" in template
|
||||
assert "範例" not in template_function
|
||||
assert "ui='v2'" not in template
|
||||
assert "mock" not in template.lower()
|
||||
|
||||
@@ -543,79 +543,18 @@ def test_growth_analysis_uses_actionable_price_command_panel():
|
||||
assert "高信心門檻" not in template
|
||||
assert "未知新鮮度" not in template
|
||||
assert "人工否決" not in template
|
||||
assert "價格風險分佈" in template
|
||||
assert "growthActionHint" in template
|
||||
assert "growthDataSourceSummary" in template
|
||||
assert "external_data_source_counts" in template
|
||||
assert "compSourceSummary" in template
|
||||
assert "growthDrilldownPanel" in template
|
||||
assert "showGrowthDetail" in template
|
||||
assert "growthDetailRows" in template
|
||||
assert "growth-detail-tab" in template
|
||||
assert "今日商品明細" in template
|
||||
assert "價格壓力" in template
|
||||
assert "價格優勢" in template
|
||||
assert "有外部價" in template
|
||||
assert "showPriceRiskDetail" in template
|
||||
assert "handlePriceRiskKey" in template
|
||||
assert "opportunities?limit=50" in template
|
||||
assert "growthStrategyGrid" in template
|
||||
assert "renderGrowthStrategySummary" in template
|
||||
assert "商品策略分流" in template
|
||||
assert "growth-strategy-card" in template
|
||||
assert "aiRecsPanel" in template
|
||||
assert "growth-detail-price-grid" in template
|
||||
assert "growth-price-chip" in template
|
||||
assert "formatGrowthDetailPrice" in template
|
||||
assert "formatGapDisplay" in template
|
||||
assert "growthDecisionSummary" in template
|
||||
assert "renderGrowthDecisionSummary" in template
|
||||
assert "growth-decision-metric" in template
|
||||
assert "最大價差" in template
|
||||
assert "growthDetailSearch" in template
|
||||
assert "growthDetailSort" in template
|
||||
assert "setGrowthDetailSearch" in template
|
||||
assert "setGrowthDetailSort" in template
|
||||
assert "clearGrowthDetailFilters" in template
|
||||
assert "價差大到小" in template
|
||||
assert "growthProductDecisionPanel" in template
|
||||
assert "showGrowthProductDetail" in template
|
||||
assert "growth-product-evidence-grid" in template
|
||||
assert "查看判斷" in template
|
||||
assert "growthCategoryBoard" in template
|
||||
assert "分類策略看板" in template
|
||||
assert "showGrowthCategoryDetail" in template
|
||||
assert "data-growth-action=\"show-category-detail\"" in template
|
||||
assert "growthPlaybookBoard" in template
|
||||
assert "銷售策略建議" in template
|
||||
assert "showGrowthPlaybookDetail" in template
|
||||
assert "組合 / 單位價" in template
|
||||
assert "growthActionBoard" in template
|
||||
assert "今日策略動作" in template
|
||||
assert "renderGrowthActionBoard" in template
|
||||
assert "PChome 業績成長系統" in template
|
||||
assert "評估業績、分析價差、決定今天的解法。" in template
|
||||
assert "growth-command-pro" in template
|
||||
assert "max-width: 1480px" in template
|
||||
assert "commandSales7d" in template
|
||||
assert "commandTopDecliners" in template
|
||||
assert "PChome 與 MOMO 價格狀態" in template
|
||||
assert "growth-command-alert-copy" in template
|
||||
assert "growth-command-alert-action" in template
|
||||
assert "width: min(100%, 980px)" in template
|
||||
assert "grid-template-columns: auto minmax(0, 1fr)" in template
|
||||
assert "renderGrowthCommandCenter" in template
|
||||
assert "growthActionPlanForRow" in template
|
||||
assert "growthActionEvidence" in template
|
||||
assert "growth-action-evidence-chip" in template
|
||||
assert "document.querySelectorAll('.growth-detail-row')" in template
|
||||
assert "scrollToPanel('externalPricePanel')" in template
|
||||
assert "備援資料檢查" in template
|
||||
assert "可直接決策" in template
|
||||
assert "chart_data.competitor_coverage" in template
|
||||
assert "先補齊高業績商品的 MOMO 對應" in template
|
||||
assert "先刷新過期價格" in template
|
||||
assert "先處理待補與候選確認" in template
|
||||
assert "可進入價格策略檢查" in template
|
||||
assert "MOMO 低價壓力趨勢" in template
|
||||
assert "PChome 價格優勢" in template
|
||||
assert "competitorPressureChart" in template
|
||||
assert "growth-command-pro" not in template
|
||||
assert "growth-ops-table" not in template
|
||||
assert "外部報價預檢" not in template
|
||||
assert "growth-ops-table" in template
|
||||
assert "鎖定商品" in template
|
||||
assert "無法比價" in template
|
||||
assert "補齊比價資料" in template
|
||||
|
||||
|
||||
def test_formal_homepage_routes_to_growth_command_center():
|
||||
@@ -777,10 +716,10 @@ def test_help_empty_login_and_ppt_copy_are_action_oriented():
|
||||
"templates/growth_analysis.html": ["先匯入月度業績資料,再評估成長、AOV 與毛利缺口"],
|
||||
"templates/index.html": ["缺貨處理順序", "避免主推商品斷貨"],
|
||||
"templates/login.html": ["登入後先看 PChome 業績、價差、缺貨與 AI 建議"],
|
||||
"templates/system_settings.html": ["系統會更新對應年月份的業績資料"],
|
||||
"templates/system_settings.html": ["會更新對應年月份的業績資料"],
|
||||
"templates/admin/ppt_audit_history.html": [
|
||||
"先確認簡報可預覽、可審核,再把問題交給修復流程",
|
||||
"先補齊視覺 QA runtime,再判斷簡報品質",
|
||||
"先補齊視覺 QA 執行條件,再判斷簡報品質",
|
||||
"先補排程或手動產出,再進行視覺 QA",
|
||||
"先補視覺 QA 條件",
|
||||
],
|
||||
@@ -847,7 +786,7 @@ def test_governance_and_low_frequency_pages_avoid_engineering_status_copy():
|
||||
"templates/maintenance.html": ["服務維護", "確認業績、比價與匯入狀態", "台北時間"],
|
||||
"templates/auto_import_index.html": [
|
||||
"更新日報、成長分析與今日作戰清單",
|
||||
"去重後寫入業績快照",
|
||||
"送出後更新日報、成長分析與今日作戰清單",
|
||||
"作戰清單保持新鮮",
|
||||
"共更新",
|
||||
"buildImportActionHint",
|
||||
@@ -963,7 +902,7 @@ def test_visible_operations_pages_hide_internal_runtime_terms():
|
||||
"templates/daily_sales.html": ["左右滑動看業績趨勢", "左右滑動看分類明細"],
|
||||
"templates/sales_analysis.html": ["分析下一步", "選類別看貢獻", "適合檔期與活動回顧"],
|
||||
"templates/vendor_stockout_vendor_management_v2.html": ["匯入供應商窗口名單", "確認窗口清單"],
|
||||
"templates/vendor_stockout_import_v2.html": ["系統會拒絕匯入", "處理缺貨清單"],
|
||||
"templates/vendor_stockout_import_v2.html": ["會先停止匯入", "處理缺貨清單"],
|
||||
"templates/admin/ppt_audit_history.html": ["產出紀錄", "最近產出", "保存紀錄"],
|
||||
"templates/admin/agent_orchestration.html": ["AI 分工指揮台", "建議路徑、工具與知識命中矩陣", "工具服務明細"],
|
||||
"templates/admin/ai_calls_dashboard.html": ["用量", "AI 上下文", "知識與工具編排矩陣"],
|
||||
|
||||
Reference in New Issue
Block a user