test: отказ — одна причина без пересказа вопроса, значок «Баланс исчерпан»

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
anor
2026-10-01 00:07:29 +10:00
co-authored by Claude Opus 5.5
parent f0325be486
commit ac885fad1f
3 changed files with 41 additions and 8 deletions
+19
View File
@@ -266,3 +266,22 @@ def test_admin_endpoint_requires_admin(env):
r = client.post("/api/admin/users/read-only", headers=h,
json={"email": "u@x", "read_only": False})
assert r.status_code == 403
def test_limits_report_read_only(env):
# Значок остатка не должен показывать «Осталось: 169 ₽» рядом с отказом «баланс
# исчерпан» (снимок 30.09.2026).
db, auth, main, client = env
h = _hdr(auth, db, "ro@x")
assert client.get("/api/limits", headers=h).json().get("read_only") in (None, False)
db.set_read_only("ro@x", True)
assert client.get("/api/limits", headers=h).json()["read_only"] is True
def test_badge_says_balance_exhausted_in_read_only():
html = open(os.path.join(ROOT, "static", "chat.html"), encoding="utf-8").read()
i = html.index("function renderBalance(b) {")
block = html[i:i + 700]
assert "if (b.read_only) {" in block and "'Баланс исчерпан'" in block
j = html.index("function openBalancePopover() {")
assert "if (b.read_only) {" in html[j:j + 1800]