96 lines
3.3 KiB
Python
96 lines
3.3 KiB
Python
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(r"D:\www\sport-era\admin")
|
|
MATCH_API = ROOT / "src" / "api" / "match.ts"
|
|
MATCH_INDEX = ROOT / "src" / "views" / "match" / "lists" / "index.vue"
|
|
MATCH_LIVE_TABLE = ROOT / "src" / "views" / "match" / "lists" / "components" / "MatchLiveTable.vue"
|
|
|
|
|
|
def assert_contains(path: Path, needle: str) -> None:
|
|
content = path.read_text(encoding="utf-8")
|
|
assert needle in content, f"{path} missing: {needle}"
|
|
|
|
|
|
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 needle in match_api, f"{MATCH_API} missing: {needle}"
|
|
|
|
for needle in (
|
|
"play_url_m3u8",
|
|
"fetch_status",
|
|
"source_url",
|
|
):
|
|
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")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|