diff --git a/qa/frontend/test_match_live_admin_static.py b/qa/frontend/test_match_live_admin_static.py index 10c3d61..3295890 100644 --- a/qa/frontend/test_match_live_admin_static.py +++ b/qa/frontend/test_match_live_admin_static.py @@ -13,23 +13,80 @@ def assert_contains(path: Path, needle: str) -> 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, "MatchLiveTable") for needle in ( "matchLiveLists", + "matchLiveDetail", "matchLiveAdd", "matchLiveEdit", "matchLiveDelete", ): - assert_contains(MATCH_API, needle) + assert needle in match_api, f"{MATCH_API} missing: {needle}" for needle in ( "play_url_m3u8", "fetch_status", "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")