Strengthen match live admin static QA

This commit is contained in:
hajimi
2026-06-21 13:21:55 +08:00
parent 173871cf6a
commit 4ab24a9ae8
+59 -2
View File
@@ -13,23 +13,80 @@ def assert_contains(path: Path, needle: str) -> None:
def main() -> None: def main() -> None:
match_api = MATCH_API.read_text(encoding="utf-8")
match_live_table = MATCH_LIVE_TABLE.read_text(encoding="utf-8")
assert_contains(MATCH_INDEX, 'type="expand"') assert_contains(MATCH_INDEX, 'type="expand"')
assert_contains(MATCH_INDEX, "MatchLiveTable") assert_contains(MATCH_INDEX, "MatchLiveTable")
for needle in ( for needle in (
"matchLiveLists", "matchLiveLists",
"matchLiveDetail",
"matchLiveAdd", "matchLiveAdd",
"matchLiveEdit", "matchLiveEdit",
"matchLiveDelete", "matchLiveDelete",
): ):
assert_contains(MATCH_API, needle) assert needle in match_api, f"{MATCH_API} missing: {needle}"
for needle in ( for needle in (
"play_url_m3u8", "play_url_m3u8",
"fetch_status", "fetch_status",
"source_url", "source_url",
): ):
assert_contains(MATCH_LIVE_TABLE, needle) assert needle in match_live_table, f"{MATCH_LIVE_TABLE} missing: {needle}"
readonly_fields = (
'play_url_m3u8" readonly',
'play_url_hd_m3u8" readonly',
'play_url_flv" readonly',
'play_url_hd_flv" readonly',
'formatFetchStatus(editData.fetch_status)" readonly',
'editData.last_fetch_at" readonly',
)
for needle in readonly_fields:
assert needle in match_live_table, f"{MATCH_LIVE_TABLE} missing readonly guard: {needle}"
handle_edit_block = match_live_table.split("const handleEdit = async (id: number) => {", 1)[1].split(
"const handleSubmit = async () => {", 1
)[0]
assert "resetEditData()" in handle_edit_block, f"{MATCH_LIVE_TABLE} missing resetEditData usage in handleEdit"
assert "const res = await matchLiveDetail" in handle_edit_block, f"{MATCH_LIVE_TABLE} missing detail request"
assert (
handle_edit_block.index("resetEditData()")
< handle_edit_block.index("const res = await matchLiveDetail")
), "handleEdit must reset editData before matchLiveDetail response is applied"
assert "const params = {" in match_live_table, f"{MATCH_LIVE_TABLE} missing submit payload"
for needle in (
"id: editData.id",
"match_id: props.matchId",
"title: editData.title",
"source_url: editData.source_url",
):
assert needle in match_live_table, f"{MATCH_LIVE_TABLE} missing submit field: {needle}"
forbidden_submit_fields = (
"play_url_m3u8:",
"play_url_hd_m3u8:",
"play_url_flv:",
"play_url_hd_flv:",
"fetch_status:",
"last_fetch_at:",
"create_time:",
"update_time:",
)
params_slice = match_live_table.split("const params = {", 1)[1].split("\n }", 1)[0]
for needle in forbidden_submit_fields:
assert needle not in params_slice, f"submit payload must not include readonly field: {needle}"
for needle in (
"status === 0",
"status === 1",
"status === 2",
"status === '0'",
"status === '1'",
"status === '2'",
):
assert needle in match_live_table, f"{MATCH_LIVE_TABLE} missing fetch_status mapping: {needle}"
print("match live admin static checks passed") print("match live admin static checks passed")