fix(пробный доступ): окно зовёт пополнить счёт кнопкой, а не писать на почту; кнопки зелёные

С открытием приёма всем у пробного клиента рядом стоит кнопка «Пополнить счёт», а текст
над ней ещё звал писать на info@infosmeta.ru (Хозяин, 21.11.2026). Теперь при открытом
приёме текст зовёт пополнить счёт; без приёма прежняя почта остаётся. Кнопки пополнения
в чате и на странице статистики перекрашены в зелёный (--money): деньги заметнее
спокойного красного. Проверки — живая страница в браузере и цвет по вычисленному стилю;
мутации возвращают старый текст и красный цвет — обе краснеют.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
anor
2026-11-21 01:27:43 +10:00
co-authored by Claude Code
parent 171d67c59d
commit 22ddb3f167
6 changed files with 48 additions and 14 deletions
+1 -1
View File
@@ -545,7 +545,7 @@ MAX_MESSAGE_LEN = 10_000
# ⚠️ Версия UI — единый источник. БАМПАТЬ ПРИ КАЖДОМ ДЕПЛОЕ (формат: YYYY-MM-DD + буква).
# Фронт берёт её через GET /api/version (chat.html + admin.html, элемент .app-version).
APP_VERSION = "2026-11-21e"
APP_VERSION = "2026-11-21f"
# Audit: path → action name mapping
_AUDIT_MAP = [
+8 -7
View File
@@ -1,4 +1,12 @@
[
{
"version": "2026-11-21f",
"date": "2026-11-21",
"changes": [
"Пробный доступ: окно зовёт пополнить счёт кнопкой, а не писать на почту",
"Кнопки пополнения стали зелёными — заметнее на странице"
]
},
{
"version": "2026-11-21e",
"date": "2026-11-21",
@@ -27,12 +35,5 @@
"changes": [
"Карточка клиента: источник пополнения назван по-русски («онлайн-оплата»), а у владельца вместо непонятного «Счёт не заведён» — «счёт не ведётся»"
]
},
{
"version": "2026-11-21a",
"date": "2026-11-21",
"changes": [
"Страница возврата после оплаты показывает «Зачислено» даже с чужого устройства: теперь она проверяет платёж по подписанной ссылке, а не по входу на сайт"
]
}
]
+11 -3
View File
@@ -28,6 +28,7 @@ try { if (localStorage.getItem('token') && localStorage.getItem('ui_mode') === '
--error-bg: #fff1f2; --error-border: #fecdd3;
--system-bg: #efe9e1; --system-text: #847a6d;
--ok: #1f6f43; --ok-hover: #18603a;
--money: #2d8a56; --money-hover: #247848; /* кнопки пополнения — заметный зелёный */
--shadow-sm: 0 1px 2px rgba(43,41,38,.05);
--shadow-md: 0 6px 24px rgba(43,41,38,.09);
--focus-ring: 0 0 0 3px rgba(192,69,58,.28);
@@ -237,6 +238,9 @@ button { font-family: inherit; }
#date-badge { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#balance-badge.warn-75 { border-color: #f0a500; color: #b47500; }
#balance-badge.warn-90 { border-color: #e03131; color: #c92a2a; }
/* Пополнение — зелёное: деньги и «пополнить» заметнее спокойного красного (Хозяин 21.11.2026). */
#topup-open-btn:hover, #topup-go:hover { background: var(--money-hover); }
#topup-open-btn:disabled, #topup-go:disabled { opacity: .6; cursor: default; background: var(--money); }
.copy-btn { display: block; margin-top: .5rem; margin-left: auto; background: transparent; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: .7rem; padding: .2rem .6rem; color: var(--text-light); width: fit-content; transition: all .15s; }
.copy-btn:hover { background: var(--bg); color: var(--text-muted); border-color: var(--text-light); }
.msg-user .copy-btn { border-color: rgba(255,255,255,.25); color: rgba(255,255,255,.6); }
@@ -464,6 +468,7 @@ html { color-scheme: light; }
--error-bg: #3a1f1d; --error-border: #5e2b27;
--system-bg: #211d17; --system-text: #a89c8a;
--ok: #3fa066; --ok-hover: #4cb074;
--money: #3fa066; --money-hover: #4cb074;
--shadow-sm: 0 1px 2px rgba(0,0,0,.4);
--shadow-md: 0 10px 30px rgba(0,0,0,.55);
--focus-ring: 0 0 0 3px rgba(217,105,92,.42);
@@ -750,7 +755,7 @@ html { color-scheme: light; }
<div id="balance-unknown" style="display:none;font-size:.74rem;color:var(--accent);margin:6px 0;line-height:1.45">Часть ответов ещё не оценена — остаток может уточниться.</div>
<div style="font-size:.74rem;margin:6px 0;line-height:1.45"><a href="/static/pricing.html" target="_blank" rel="noopener" style="color:var(--accent)">Стоимость услуг и как считается цена</a></div>
<div style="display:flex;justify-content:flex-end;gap:8px;flex-wrap:wrap;margin-top:10px">
<button type="button" id="topup-open-btn" onclick="closeBalancePopover(); openTopupModal()" style="display:none;padding:5px 14px;font-size:.8rem;background:var(--accent);color:#fff;border:none;border-radius:7px;cursor:pointer;font-weight:600">Пополнить счёт</button>
<button type="button" id="topup-open-btn" onclick="closeBalancePopover(); openTopupModal()" style="display:none;padding:5px 14px;font-size:.8rem;background:var(--money);color:#fff;border:none;border-radius:7px;cursor:pointer;font-weight:600">Пополнить счёт</button>
<button type="button" onclick="closeBalancePopover()" style="padding:5px 12px;font-size:.8rem;background:transparent;border:1px solid var(--border);border-radius:7px;color:var(--text-muted);cursor:pointer">Закрыть</button>
</div>
</div>
@@ -768,7 +773,7 @@ html { color-scheme: light; }
<div id="topup-error" role="alert" style="display:none;font-size:.78rem;color:var(--accent);margin-top:8px;line-height:1.4"></div>
<div style="display:flex;justify-content:flex-end;gap:8px;flex-wrap:wrap;margin-top:12px">
<button type="button" onclick="closeTopupModal()" style="padding:6px 12px;font-size:.82rem;background:transparent;border:1px solid var(--border);border-radius:7px;color:var(--text-muted);cursor:pointer">Отмена</button>
<button type="button" id="topup-go" onclick="goTopup()" style="padding:6px 14px;font-size:.82rem;background:var(--accent);color:#fff;border:none;border-radius:7px;cursor:pointer;font-weight:600">Перейти к оплате</button>
<button type="button" id="topup-go" onclick="goTopup()" style="padding:6px 14px;font-size:.82rem;background:var(--money);color:#fff;border:none;border-radius:7px;cursor:pointer;font-weight:600">Перейти к оплате</button>
</div>
</div>
</div>
@@ -2402,9 +2407,12 @@ function openBalancePopover() {
document.getElementById('balance-title').textContent =
b.read_only ? 'Баланс' : (b.trial ? 'Пробный доступ' : (b.account ? 'Счёт' : 'Остаток на сутки'));
if (b.trial && !b.read_only) {
// При открытом приёме снимают ограничения пополнением, а не письмом: текст обязан
// совпадать с кнопкой, которая стоит рядом (Хозяин, 21.11.2026).
document.getElementById('balance-window').textContent = 'В пробном доступе один диалог и ' +
b.trial.limit + ' вопросов. Задано: ' + Math.min(b.trial.used, b.trial.limit) + ' из ' +
b.trial.limit + '. Чтобы снять ограничения, напишите на info@infosmeta.ru.';
b.trial.limit + '. Чтобы снять ограничения, ' +
(b.topup ? 'пополните счёт.' : 'напишите на info@infosmeta.ru.');
document.getElementById('balance-price').textContent = '';
document.getElementById('balance-unknown').style.display = 'none';
}
+1 -1
View File
@@ -55,7 +55,7 @@ td.bar-cell { width: 38%; }
.bar { height: 10px; border-radius: 5px; background: var(--bar); min-width: 2px; }
.bar.zero { background: var(--border); }
.bad { color: var(--accent); font-weight: 600; }
.topup-link { display: inline-block; margin: .5rem 0; padding: .45rem .9rem; background: var(--accent, #c4463a); color: #fff; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: .9rem; }
.topup-link { display: inline-block; margin: .5rem 0; padding: .45rem .9rem; background: var(--money, #2d8a56); color: #fff; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: .9rem; }
.deposits { list-style: none; margin-top: .4rem; font-variant-numeric: tabular-nums; }
.deposits li { padding: .2rem 0; border-bottom: 1px solid var(--border-light); font-size: .9rem; }
.state { padding: 1.5rem 0; text-align: center; color: var(--text-muted); }
+22
View File
@@ -44,6 +44,25 @@ def site(tmp_path_factory):
srv.server_close()
def test_trial_tells_to_top_up_not_write_email(browser, site):
"""Пробный доступ при открытом приёме: рядом стоит кнопка «Пополнить счёт» — текст не
должен звать писать на почту (Хозяин, 21.11.2026)."""
ctx = browser.new_context(viewport={"width": 1280, "height": 900})
pg = ctx.new_page()
pg.set_default_timeout(8000)
try:
pg.add_init_script("localStorage.setItem('stub_trial','1')")
pg.goto(site)
pg.wait_for_selector("#chat-screen", state="visible")
pg.click("#balance-badge")
text = pg.locator("#balance-window").inner_text()
assert "пополните счёт" in text, f"текст не зовёт пополнить счёт: {text!r}"
assert "info@infosmeta.ru" not in text, f"устаревшая почта осталась: {text!r}"
assert pg.locator("#topup-open-btn").is_visible(), "нет кнопки пополнения в окне"
finally:
ctx.close()
def test_preset_shows_amount_and_sends_it(browser, site):
ctx = browser.new_context(viewport={"width": 1280, "height": 900})
pg = ctx.new_page()
@@ -52,6 +71,9 @@ def test_preset_shows_amount_and_sends_it(browser, site):
pg.add_init_script("localStorage.setItem('stub_topup','1')")
pg.goto(site + "?topup=1")
pg.wait_for_selector("#topup-modal", state="visible")
цвет = pg.evaluate("getComputedStyle(document.getElementById('topup-go')).backgroundColor")
assert цвет == "rgb(45, 138, 86)", (
f"кнопка оплаты не зелёная, как велел Хозяин: {цвет}")
pg.get_by_role("button", name="500 ₽").click()
assert pg.input_value("#topup-amount") == "500", (
"нажатая сумма не видна в поле — человек думает, что выбор не сработал")
+5 -2
View File
@@ -118,9 +118,12 @@ window.fetch = async (url, opts={}) => {
}
// Пополнение — только когда тест попросил (stub_topup=1), иначе прежнее поведение.
if (url.includes('/api/limits')) {
const topup = {enabled: true, presets: [500, 1000, 3000, 5000], min: 300, max: 20000};
if (localStorage.getItem('stub_trial') === '1') {
return _json({trial: {limit: 5, used: 1, files_at_once: 2}, topup});
}
if (localStorage.getItem('stub_topup') === '1') {
return _json({account: {balance_rub: 0, low: false, exhausted: false},
topup: {enabled: true, presets: [500, 1000, 3000, 5000], min: 300, max: 20000}});
return _json({account: {balance_rub: 0, low: false, exhausted: false}, topup});
}
return _json({unlimited: true});
}