Files
shaguabijia-app-server/tests/test_h5_hosting.py
T
2026-06-29 13:14:18 +08:00

33 lines
1.2 KiB
Python

"""H5 静态托管冒烟:/h5 同源服务页面 + .html no-cache(热更核心)。"""
from __future__ import annotations
def test_h5_shared_bridge_served(client) -> None:
resp = client.get("/h5/shared/bridge.js")
assert resp.status_code == 200
def test_h5_html_no_cache(client) -> None:
# records 迁入前,先用已在仓库的 mine 页验证 .html 的 no-cache 响应头
resp = client.get("/h5/mine/index.html")
assert resp.status_code == 200
assert resp.headers.get("cache-control") == "no-cache"
def test_h5_html_no_cache_via_dir_url(client) -> None:
# 目录式 URL(WebView 规范入口)经 html=True 回落 index.html,也必须带 no-cache
resp = client.get("/h5/mine/")
assert resp.status_code == 200
assert resp.headers.get("cache-control") == "no-cache"
def test_h5_records_served_and_migrated(client) -> None:
resp = client.get("/h5/records/index.html")
assert resp.status_code == 200
assert resp.headers.get("cache-control") == "no-cache"
body = resp.text
assert "SGBridge" in body # 已切到新桥
assert "NativeBridge" not in body # 旧桥名清零
assert "getApiBase" not in body # 同源:绝对地址拼接已移除
assert "../shared/bridge.js" in body