69 lines
2.7 KiB
Python
Executable File
69 lines
2.7 KiB
Python
Executable File
"""
|
|
regression_test.py — JNPF 浏览器回归测试
|
|
用法: python3 /home/ubuntu/ccWorkDir/.claude/skills/jnpf-browser-automation/scripts/regression_test.py
|
|
"""
|
|
import subprocess, json, time
|
|
import urllib.request
|
|
|
|
KNOWN_FORMS = [
|
|
{"id": "836632872700880069", "name": "test1", "url": "model/test1b8f8f"},
|
|
{"id": "836694902208210117", "name": "dacliFix02", "url": "model/dacliFix028825c"},
|
|
{"id": "836729931961476293", "name": "tddHuman628318", "url": "model/tddHuman628318c83ff"},
|
|
{"id": "836665558169560261", "name": "dacliVerify3", "url": "model/dacliVerify3bd870"},
|
|
{"id": "836658473499370693", "name": "e2eTest1", "url": "model/e2eTest132a79"},
|
|
]
|
|
|
|
def test_form_via_api(form_id):
|
|
"""用 API 验证 form 基本信息"""
|
|
with open("/home/ubuntu/ccWorkDir/.dacli-token/token.json") as f:
|
|
tok = json.load(f)["token"]
|
|
req = urllib.request.Request(
|
|
f"http://nginx/api/visualdev/Base/{form_id}",
|
|
headers={"Authorization": tok, "App-Code": "tdd"}
|
|
)
|
|
with urllib.request.urlopen(req, timeout=10) as resp:
|
|
data = json.loads(resp.read())["data"]
|
|
cd = json.loads(data.get("columnData") or "{}")
|
|
return {
|
|
"enCode": data.get("enCode"),
|
|
"state": data.get("state"),
|
|
"webType": data.get("webType"),
|
|
"columnListLen": len(cd.get("columnList", [])),
|
|
"searchListLen": len(cd.get("searchList", [])),
|
|
}
|
|
|
|
print("=" * 60)
|
|
print("JNPF Browser/API Regression Test")
|
|
print("=" * 60)
|
|
|
|
results = []
|
|
for form in KNOWN_FORMS:
|
|
print(f"\n>>> {form['name']} (id={form['id']})")
|
|
try:
|
|
info = test_form_via_api(form["id"])
|
|
passed = info["state"] == 1 and info["columnListLen"] >= 1
|
|
status = "✓ PASS" if passed else "✗ FAIL"
|
|
print(f" {status} state={info['state']} webType={info['webType']} columnList={info['columnListLen']} searchList={info['searchListLen']}")
|
|
results.append({"form": form["name"], **info, "passed": passed})
|
|
except Exception as e:
|
|
print(f" ✗ ERROR: {e}")
|
|
results.append({"form": form["name"], "error": str(e), "passed": False})
|
|
|
|
print("\n" + "=" * 60)
|
|
total = len(results)
|
|
passed = sum(1 for r in results if r.get("passed"))
|
|
print(f"Results: {passed}/{total} passed")
|
|
print("=" * 60)
|
|
print(f"\n详细结果:")
|
|
for r in results:
|
|
if r.get("passed"):
|
|
print(f" ✓ {r['form']}: state={r['state']} columnList={r['columnListLen']}")
|
|
else:
|
|
print(f" ✗ {r['form']}: {r.get('error', 'state=' + str(r.get('state', '?')))}")
|
|
|
|
# 保存结果
|
|
with open("/home/ubuntu/ccWorkDir/docs/tdd/e2e-formDesign-2026-06-16-r3/regression_result.json", "w") as f:
|
|
json.dump({"timestamp": time.time(), "results": results}, f, indent=2, ensure_ascii=False)
|
|
|
|
exit(0 if passed == total else 1)
|