test(админка): e2e жизненного цикла
This commit is contained in:
@@ -335,8 +335,8 @@
|
||||
## 4.44. P5.1 (частично) — паритет
|
||||
|
||||
- `docs/ADMIN_V2_PARITY.md`: 16 строк старых возможностей → новые, с тестами и известными разрывами.
|
||||
- `tests/test_admin_v2_e2e_api.py`: `/admin` 200, `/admin/v2` 200 + strict CSP, 11 v2 API 200.
|
||||
- Полный e2e/визуал и подпись денег — до P5.2.
|
||||
- `tests/test_admin_v2_e2e_api.py`: `/admin` 200, `/admin/v2` 200 + strict CSP, 11 v2 API 200; жизненный цикл клиента (блок→undo, взнос, delete→restore) и жалобы (new→resolved).
|
||||
- Полный визуальный e2e и подпись денег — до P5.2.
|
||||
|
||||
## 4.45. P5.2-заготовка / P5.3c
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import importlib
|
||||
import os
|
||||
import sys
|
||||
from urllib.parse import quote
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -30,11 +31,11 @@ def env(tmp_path, monkeypatch):
|
||||
client = TestClient(main.app)
|
||||
token = client.post("/api/login", json={"username": "boss@x",
|
||||
"password": "Passw0rd!ok"}).json()["token"]
|
||||
return client, {"Authorization": "Bearer " + token}
|
||||
return client, {"Authorization": "Bearer " + token}, db
|
||||
|
||||
|
||||
def test_legacy_and_v2_sections(env):
|
||||
client, h = env
|
||||
client, h, db = env
|
||||
assert client.get("/admin").status_code == 200
|
||||
r = client.get("/admin/v2", headers=h)
|
||||
assert r.status_code == 200 and "unsafe-inline" not in r.headers.get("content-security-policy", "")
|
||||
@@ -43,3 +44,37 @@ def test_legacy_and_v2_sections(env):
|
||||
"/api/admin/v2/accounts", "/api/admin/v2/feedback", "/api/admin/v2/system",
|
||||
"/api/admin/v2/sessions", "/api/admin/v2/work/dialogs"):
|
||||
assert client.get(path, headers=h).status_code == 200, path
|
||||
|
||||
|
||||
def test_customer_lifecycle(env):
|
||||
client, h, db = env
|
||||
import auth
|
||||
db.create_user("e2e@x", auth.hash_password("Passw0rd!ok"))
|
||||
db.admin_verify_user("e2e@x")
|
||||
r = client.post("/api/admin/v2/customers/e2e@x/action",
|
||||
json={"action": "block", "value": {"blocked": True}}, headers=h)
|
||||
assert r.status_code == 200
|
||||
assert db.get_user_by_email("e2e@x")["blocked"] == 1
|
||||
assert client.post(f"/api/admin/v2/actions/{r.json()['id']}/undo", headers=h).status_code == 200
|
||||
assert db.get_user_by_email("e2e@x")["blocked"] == 0
|
||||
|
||||
t = client.post("/api/admin/v2/customers/e2e@x/topup",
|
||||
json={"amount": "50", "request_id": "e2e-1"}, headers=h)
|
||||
assert t.status_code == 200
|
||||
assert db.account_summary("e2e@x")["deposited_kop"] == 5000
|
||||
|
||||
d = client.post("/api/admin/v2/customers/e2e@x/delete", headers=h)
|
||||
assert d.status_code == 200
|
||||
archived = d.json()["archived_as"]
|
||||
assert client.post("/api/admin/v2/customers/" + quote(archived, safe="") + "/restore", headers=h).status_code == 200
|
||||
|
||||
|
||||
def test_feedback_lifecycle(env):
|
||||
client, h, db = env
|
||||
db.save_feedback("e2e@x", "t1", "не то", "a", category="off_topic", source="chat")
|
||||
items = client.get("/api/admin/v2/feedback?status=new", headers=h).json()["items"]
|
||||
assert items
|
||||
fid = items[0]["id"]
|
||||
assert client.post(f"/api/admin/v2/feedback/{fid}/status",
|
||||
json={"status": "resolved"}, headers=h).status_code == 200
|
||||
assert client.get("/api/admin/v2/feedback?status=new", headers=h).json()["total"] == 0
|
||||
|
||||
Reference in New Issue
Block a user