diff --git a/static/stats.html b/static/stats.html
index 5b3893f..3861da8 100644
--- a/static/stats.html
+++ b/static/stats.html
@@ -183,7 +183,8 @@ function renderBalance(b) {
b.read_only ? 'Баланс' : (b.trial ? 'Пробный доступ' : 'Остаток на сутки');
if (b.read_only) {
box.append(el('p', 'balance-line', 'Баланс исчерпан: новые вопросы закрыты, диалоги доступны для просмотра. ' +
- 'Чтобы продолжить, напишите на info@infosmeta.ru.'));
+ (b.topup ? 'Чтобы продолжить, нажмите «Пополнить счёт» в блоке «Счёт».'
+ : 'Чтобы продолжить, напишите на info@infosmeta.ru.')));
return;
}
if (b.trial) {
diff --git a/tests/test_topup_pages.py b/tests/test_topup_pages.py
index 9881093..c6b0f5b 100644
--- a/tests/test_topup_pages.py
+++ b/tests/test_topup_pages.py
@@ -76,3 +76,39 @@ def test_pages_have_no_kitchen_words():
text = _read(name).lower()
assert "robokassa" not in text and "комисси" not in text, name
assert not re.search(r"webhook|вебхук", _read("payment_result.html").lower())
+
+
+def _run_stats_balance(limits):
+ """Run the real renderBalance/el from stats.html in node with a minimal DOM stub."""
+ import json
+ import shutil
+ import subprocess
+ import pytest
+ if not shutil.which("node"):
+ pytest.skip("нет node")
+ html = _read("stats.html")
+ def fn(name):
+ body = html[html.index(f"function {name}("):]
+ return body[:body.index("\n}\n") + 3]
+ js = """
+const nodes = {};
+function mk() { return {textContent: '', className: '', children: [],
+ append(...xs) { this.children.push(...xs); }, set hidden(v) {}}; }
+const document = {createElement: () => mk(),
+ getElementById: id => (nodes[id] = nodes[id] || mk())};
+""" + fn("el") + fn("renderBalance") + f"""
+renderBalance({json.dumps(limits)});
+console.log(nodes.balance.children.map(c => c.textContent).join(' '));
+"""
+ out = subprocess.run(["node", "-e", js], capture_output=True, text=True, timeout=20)
+ assert out.returncode == 0, out.stderr
+ return out.stdout
+
+
+def test_stats_exhausted_with_topup_does_not_send_to_mail():
+ """«Баланс исчерпан» на /stats при доступном пополнении зовёт пополнить, а не писать на
+ почту (как в чате); без пополнения — почта. Порча: оставить почту при topup."""
+ with_topup = _run_stats_balance({"read_only": True, "topup": {"enabled": True}})
+ assert "Пополнить" in with_topup and "info@infosmeta.ru" not in with_topup
+ without = _run_stats_balance({"read_only": True})
+ assert "info@infosmeta.ru" in without