feat(HEL-566): 去掉主站行情管理入口并修好模型列表收起
主站行情管理并入数据中枢
- 数据中枢数据源配置页新增「主站行情任务」卡:交易时段后台刷新开关、
手动后台刷新、历史区间回补(任务提交 + 轮询主站 job 记录亮灯),
数据与调度仍归主站,控制台只经桥接代操作
- 新增桥接端点 /api/hub-admin/market/{refresh,backfill};回补改为
market.backfill 后台任务(jobs.config.json 注册,锁独立,超时 30 分钟),
桥接调用秒回,不再阻塞
- 主站桌面端删除顶栏「行情管理」按钮与整个行情管理对话框,清理随之
失效的 CSS;移动端删除 system/admin 页与入口,管理员专区只留数据中枢
- Tushare Token / iFinD 凭证编辑沿用数据源页既有凭证区,无功能缺失
模型池收起修复
- 拉出模型清单后按钮切换为「收起列表」,收起只留一行摘要;再次点击
重新拉取并展开;勾选添加完成后清单自动收起(原逻辑保留)
- 交互全部沿用 HEL-558 已确认样式的既有按钮与提示组件,未新增视觉
自测
- verify_baseline 通过;pytest 492 项通过;数据中枢 240 项通过
- verify_datahub_console 新增 [11b] 行情任务桥接端到端段;UI 自测新增
行情任务卡开关往返、模型清单展开/收起/再展开/添加自动收起,日夜主题
与 1030 窄屏复验通过
- Playwright e2e 102/103:唯一失败项在基线提交上同样失败(本机字体度量
导致的头部溢出,与本卡无关)
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -264,6 +264,40 @@ def main() -> int:
|
||||
row = next((u for u in body.get("users") or [] if u["id"] == member_id), {})
|
||||
check("开通 3 个月会员生效", status == 200 and row.get("membership_status") == "active" and row.get("membership_expires_at"), f"{status} {row.get('membership_status')} {row.get('membership_expires_at')}")
|
||||
|
||||
print("\n[11b] 主站行情任务(后台刷新开关 / 手动刷新 / 历史回补)经桥接可用")
|
||||
status, body, _ = request(f"{hub}/admin/api/market/status", cookie=admin_cookie)
|
||||
check("读取主站行情状态", status == 200 and body.get("background_refresh_enabled") is True, f"{status} {body.get('error', '')}")
|
||||
status, body, _ = request(
|
||||
f"{hub}/admin/api/market/settings", {"background_refresh_enabled": False}, "POST", write_headers, admin_cookie
|
||||
)
|
||||
check("暂停后台刷新生效", status == 200 and body.get("background_refresh_enabled") is False, f"{status} {body.get('background_refresh_enabled')}")
|
||||
status, mainsite_setting, _ = request(f"{review}/api/admin/settings", cookie=admin_cookie)
|
||||
check("主站侧确认开关已落库", (mainsite_setting.get("data") or {}).get("background_refresh_enabled") is False, str((mainsite_setting.get("data") or {}).get("background_refresh_enabled")))
|
||||
status, body, _ = request(
|
||||
f"{hub}/admin/api/market/settings", {"background_refresh_enabled": True}, "POST", write_headers, admin_cookie
|
||||
)
|
||||
check("重新启用后台刷新", status == 200 and body.get("background_refresh_enabled") is True, f"{status}")
|
||||
|
||||
status, body, _ = request(f"{hub}/admin/api/market/refresh", {}, "POST", write_headers, admin_cookie)
|
||||
refresh_key = str(body.get("job_key") or "")
|
||||
check("提交手动后台刷新任务", status == 200 and body.get("started") and refresh_key.startswith("manual:"), f"{status} {body}")
|
||||
status, body, _ = request(f"{hub}/admin/api/market/backfill", {"start_date": "", "end_date": ""}, "POST", write_headers, admin_cookie)
|
||||
check("回补缺日期被拒绝", status == 400, f"{status} {body.get('error', '')}")
|
||||
status, body, _ = request(
|
||||
f"{hub}/admin/api/market/backfill", {"start_date": "2026-09-01", "end_date": "2026-09-08"}, "POST", write_headers, admin_cookie
|
||||
)
|
||||
backfill_key = str(body.get("job_key") or "")
|
||||
check("提交历史回补任务", status == 200 and body.get("started") and backfill_key.startswith("backfill:"), f"{status} {body}")
|
||||
terminal = []
|
||||
for _ in range(60):
|
||||
status, body, _ = request(f"{hub}/admin/api/market/status", cookie=admin_cookie)
|
||||
jobs = {str(item.get("idempotency_key")): str(item.get("status")) for item in body.get("jobs") or []}
|
||||
if jobs.get(refresh_key) in {"success", "failed"} and jobs.get(backfill_key) in {"success", "failed"}:
|
||||
terminal = [jobs[refresh_key], jobs[backfill_key]]
|
||||
break
|
||||
time.sleep(0.5)
|
||||
check("两个任务都进入终态(沙箱无行情源,失败也是正确终态)", len(terminal) == 2 and all(t in {"success", "failed"} for t in terminal), str(terminal))
|
||||
|
||||
print("\n[12] 桥接令牌是唯一信任边界")
|
||||
status, body, _ = request(f"{review}/api/hub-admin/status", {}, "POST", {"X-Hub-Admin-Token": "wrong-token"})
|
||||
check("桥接端点拒绝错误令牌", status == 401, f"{status} {body}")
|
||||
|
||||
@@ -7,8 +7,11 @@
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import threading
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
from pathlib import Path
|
||||
|
||||
import verify_datahub_console as backend
|
||||
@@ -61,6 +64,8 @@ def main() -> int:
|
||||
f"{review}/api/auth/register", {"username": "boss", "password": backend.PASSWORD}, "POST"
|
||||
)
|
||||
admin_cookie = backend.session_cookie(cookie_header).split("=", 1)[1]
|
||||
vendor_port = start_fake_vendor()
|
||||
vendor_url = f"http://127.0.0.1:{vendor_port}/v1"
|
||||
|
||||
with sync_playwright() as play:
|
||||
browser = play.chromium.launch(executable_path=chrome_path())
|
||||
@@ -110,7 +115,28 @@ def main() -> int:
|
||||
check("凭证输入是密码框(不回显明文)",
|
||||
page.get_attribute('[data-cred-input="tushare_token"]', "type") == "password")
|
||||
check("原有接口清单没被删掉", page.locator("table.dtable").count() >= 1)
|
||||
|
||||
print("\n[UI-3b] 主站行情任务卡(HEL-566 自主站行情管理迁入)")
|
||||
page.wait_for_selector('[data-market-toggle]', timeout=10000)
|
||||
check("行情任务卡渲染出开关按钮", page.is_visible('[data-market-toggle]'))
|
||||
check("默认显示后台刷新已启用", "已启用" in page.inner_text("#marketCard"), page.inner_text("#marketCard")[:60])
|
||||
check("手动刷新与回补控件齐全",
|
||||
page.locator("[data-market-refresh]").count() == 1
|
||||
and page.locator("[data-market-backfill]").count() == 1
|
||||
and page.locator("[data-market-refresh-date]").count() == 1
|
||||
and page.locator("[data-market-backfill-start]").count() == 1
|
||||
and page.locator("[data-market-backfill-end]").count() == 1)
|
||||
with page.expect_response(lambda res: "/admin/api/market/settings" in res.url, timeout=15000):
|
||||
page.click("[data-market-toggle]")
|
||||
page.wait_for_function("() => document.querySelector('#marketCard') && document.querySelector('#marketCard').innerText.includes('已暂停')", timeout=15000)
|
||||
check("点击后后台刷新变为已暂停", "已暂停" in page.inner_text("#marketCard"))
|
||||
check("按钮文案切换为启用", "启用后台刷新" in page.inner_text("[data-market-toggle]"))
|
||||
with page.expect_response(lambda res: "/admin/api/market/settings" in res.url, timeout=15000):
|
||||
page.click("[data-market-toggle]")
|
||||
page.wait_for_function("() => document.querySelector('#marketCard') && document.querySelector('#marketCard').innerText.includes('已启用')", timeout=15000)
|
||||
check("再次点击恢复已启用", "已启用" in page.inner_text("#marketCard"))
|
||||
if shots:
|
||||
page.screenshot(path=str(shots / "ui-market-card.png"), full_page=True)
|
||||
page.screenshot(path=str(shots / "ui-sources-night.png"), full_page=True)
|
||||
|
||||
print("\n[UI-4] 模型池按供应商组织,可拉取/手填")
|
||||
@@ -149,6 +175,44 @@ def main() -> int:
|
||||
if shots:
|
||||
page.screenshot(path=str(shots / "ui-models-night.png"), full_page=True)
|
||||
|
||||
print("\n[UI-4c] 模型清单可收起、可再次展开(HEL-566)")
|
||||
page.fill("#newVendorUrl", vendor_url)
|
||||
page.click("#addVendor")
|
||||
page.wait_for_selector(f'[data-vend-fetch="{vendor_url}"]', timeout=10000)
|
||||
page.fill(f'[data-vend-key="{vendor_url}"]', "sk-local-smoke")
|
||||
with page.expect_response(lambda res: "/models/fetch" in res.url, timeout=20000):
|
||||
page.click(f'[data-vend-fetch="{vendor_url}"]')
|
||||
page.wait_for_selector(".vend-fetch-list", timeout=15000)
|
||||
check("拉取成功展开模型清单", page.locator(".vend-fetch-list .vend-pick").count() == 2,
|
||||
str(page.locator(".vend-fetch-list .vend-pick").count()))
|
||||
check("清单展开时按钮变为收起列表", "收起列表" in page.inner_text(f'[data-vend-fetch="{vendor_url}"]'))
|
||||
if shots:
|
||||
page.screenshot(path=str(shots / "ui-models-list-open.png"), full_page=True)
|
||||
page.click(f'[data-vend-fetch="{vendor_url}"]')
|
||||
page.wait_for_function(
|
||||
"() => document.querySelector('.vend-fetch-list') === null && [...document.querySelectorAll('.vend-note')].some((n) => n.innerText.includes('清单已收起'))",
|
||||
timeout=10000,
|
||||
)
|
||||
check("点击收起后清单隐藏", page.locator(".vend-fetch-list").count() == 0)
|
||||
check("收起后按钮回到拉取文案", "获取模型列表" in page.inner_text(f'[data-vend-fetch="{vendor_url}"]'))
|
||||
if shots:
|
||||
page.screenshot(path=str(shots / "ui-models-list-collapsed.png"), full_page=True)
|
||||
with page.expect_response(lambda res: "/models/fetch" in res.url, timeout=20000):
|
||||
page.click(f'[data-vend-fetch="{vendor_url}"]')
|
||||
page.wait_for_selector(".vend-fetch-list", timeout=15000)
|
||||
check("重新拉取后清单再次展开", page.locator(".vend-fetch-list .vend-pick").count() == 2)
|
||||
rows_before = page.locator(".model-row").count()
|
||||
page.locator(".vend-fetch-list .vend-pick input").first.check()
|
||||
with page.expect_response(lambda res: "/models/save" in res.url, timeout=20000):
|
||||
page.click(f'[data-vend-add="{vendor_url}"]')
|
||||
page.wait_for_function(
|
||||
"() => document.querySelector('.vend-fetch-list') === null",
|
||||
timeout=15000,
|
||||
)
|
||||
check("勾选添加完成后清单自动收起", page.locator(".vend-fetch-list").count() == 0)
|
||||
check("模型已入池", page.locator(".model-row").count() == rows_before + 1,
|
||||
f"{page.locator('.model-row').count()}")
|
||||
|
||||
print("\n[UI-5] 会员管理 + 邀请码:生成、复制、作废")
|
||||
page.click('[data-nav="members"]')
|
||||
page.wait_for_selector("#createInvites", timeout=10000)
|
||||
@@ -295,5 +359,30 @@ def _is_light(colour: str) -> bool:
|
||||
return sum(numbers) / 3 > 160
|
||||
|
||||
|
||||
class FakeVendorHandler(BaseHTTPRequestHandler):
|
||||
"""本地假供应商:提供 OpenAI 兼容的 GET /v1/models,供拉取清单的真链路自测。"""
|
||||
|
||||
def do_GET(self) -> None: # noqa: N802
|
||||
if self.path.rstrip("/").endswith("/models"):
|
||||
body = json.dumps({"data": [{"id": "smoke-model-a"}, {"id": "smoke-model-b"}]}).encode("utf-8")
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
return
|
||||
self.send_error(404)
|
||||
|
||||
def log_message(self, *_args: object) -> None:
|
||||
pass
|
||||
|
||||
|
||||
def start_fake_vendor() -> int:
|
||||
port = backend.free_port()
|
||||
server = ThreadingHTTPServer(("127.0.0.1", port), FakeVendorHandler)
|
||||
threading.Thread(target=server.serve_forever, daemon=True).start()
|
||||
return port
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
|
||||
Reference in New Issue
Block a user