fix(пополнение): на /stats исчерпанный баланс при доступном пополнении не отсылает на почту
Блок «Баланс» говорил «напишите на info@», хотя рядом стояла кнопка пополнения; в чате это уже было исправлено, страница статистики отстала. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+2
-1
@@ -183,7 +183,8 @@ function renderBalance(b) {
|
|||||||
b.read_only ? 'Баланс' : (b.trial ? 'Пробный доступ' : 'Остаток на сутки');
|
b.read_only ? 'Баланс' : (b.trial ? 'Пробный доступ' : 'Остаток на сутки');
|
||||||
if (b.read_only) {
|
if (b.read_only) {
|
||||||
box.append(el('p', 'balance-line', 'Баланс исчерпан: новые вопросы закрыты, диалоги доступны для просмотра. ' +
|
box.append(el('p', 'balance-line', 'Баланс исчерпан: новые вопросы закрыты, диалоги доступны для просмотра. ' +
|
||||||
'Чтобы продолжить, напишите на info@infosmeta.ru.'));
|
(b.topup ? 'Чтобы продолжить, нажмите «Пополнить счёт» в блоке «Счёт».'
|
||||||
|
: 'Чтобы продолжить, напишите на info@infosmeta.ru.')));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (b.trial) {
|
if (b.trial) {
|
||||||
|
|||||||
@@ -76,3 +76,39 @@ def test_pages_have_no_kitchen_words():
|
|||||||
text = _read(name).lower()
|
text = _read(name).lower()
|
||||||
assert "robokassa" not in text and "комисси" not in text, name
|
assert "robokassa" not in text and "комисси" not in text, name
|
||||||
assert not re.search(r"webhook|вебхук", _read("payment_result.html").lower())
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user