diff --git a/main.py b/main.py index f26bea5..30c560b 100644 --- a/main.py +++ b/main.py @@ -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-21b" +APP_VERSION = "2026-11-21c" # Audit: path → action name mapping _AUDIT_MAP = [ diff --git a/static/changelog.json b/static/changelog.json index bc79157..22f48d8 100644 --- a/static/changelog.json +++ b/static/changelog.json @@ -1,4 +1,11 @@ [ + { + "version": "2026-11-21c", + "date": "2026-11-21", + "changes": [ + "Окно пополнения: нажатая сумма теперь видна в поле — раньше поле оставалось пустым, хотя сумма выбиралась" + ] + }, { "version": "2026-11-21b", "date": "2026-11-21", @@ -33,13 +40,5 @@ "Чат: цены из таблицы, поиск расценки по описанию (монтажные сборники), код/регион/квартал из всего диалога; в ответах больше нет внутренних режимов", "Чат: фразы про «выдумывание» убраны из ответов и подсказок" ] - }, - { - "version": "2026-11-18k", - "date": "2026-11-18", - "changes": [ - "Оформление: светлая тема по умолчанию; тёмная — по выбору в переключателе и остаётся после перезагрузки", - "Программа проверки смет на рабочем месте: договор arm-v1 — пропуск устройства, поток проверки, вызов инструментов модели" - ] } ] diff --git a/static/chat.html b/static/chat.html index 07013e4..1bceba9 100644 --- a/static/chat.html +++ b/static/chat.html @@ -2464,7 +2464,9 @@ function openTopupModal() { btn.style.cssText = 'padding:8px;font-size:.88rem;background:transparent;border:1px solid var(--border);border-radius:7px;color:var(--text);cursor:pointer'; btn.onclick = () => { topupAmount = String(p); - document.getElementById('topup-amount').value = ''; + // Сумма обязана появиться в поле: пустое поле после нажатия читается как «не сработало» + // (Хозяин, 21.11.2026). Программная запись input не будит oninput — подсветка цела. + document.getElementById('topup-amount').value = String(p); for (const other of box.children) other.style.borderColor = 'var(--border)'; btn.style.borderColor = 'var(--accent)'; }; diff --git a/tests/test_topup_modal_ui.py b/tests/test_topup_modal_ui.py new file mode 100644 index 0000000..fdf2650 --- /dev/null +++ b/tests/test_topup_modal_ui.py @@ -0,0 +1,62 @@ +"""Окно «Пополнить счёт»: нажатие суммы обязано быть видно и уходить на сервер. + +Живой случай 21.11.2026 (Хозяин): нажал «500 ₽» — поле суммы осталось пустым, будто +ничего не выбрано. Сумма запоминалась в переменной и уходила на сервер, но человек +этого не видел. Здесь проверяется настоящая страница чата в браузере. + +Mutation: убрать заполнение поля — падает первая проверка; не отправлять сумму — +падает вторая. +""" +import functools +import http.server +import json +import socketserver +import sys +import threading +from pathlib import Path + +import pytest + +ROOT = Path(__file__).resolve().parent.parent +sys.path.insert(0, str(ROOT)) +sys.path.insert(0, str(ROOT / "tests")) + +pytest.importorskip("playwright.sync_api", reason="playwright не установлен") + +import ui_smoke_harness # noqa: E402 +from test_password_reset_ui import browser # noqa: E402,F401 + + +@pytest.fixture(scope="module") +def site(tmp_path_factory): + d = tmp_path_factory.mktemp("ui-topup") + ui_smoke_harness.build_stub(d / "index.html", logged_in=True) + handler = functools.partial(http.server.SimpleHTTPRequestHandler, directory=str(d)) + + class Quiet(socketserver.ThreadingTCPServer): + allow_reuse_address = True + daemon_threads = True + + srv = Quiet(("127.0.0.1", 0), handler) + threading.Thread(target=srv.serve_forever, daemon=True).start() + yield f"http://127.0.0.1:{srv.server_address[1]}/index.html" + srv.shutdown() + srv.server_close() + + +def test_preset_shows_amount_and_sends_it(browser, site): + 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_topup','1')") + pg.goto(site + "?topup=1") + pg.wait_for_selector("#topup-modal", state="visible") + pg.get_by_role("button", name="500 ₽").click() + assert pg.input_value("#topup-amount") == "500", ( + "нажатая сумма не видна в поле — человек думает, что выбор не сработал") + pg.get_by_role("button", name="Перейти к оплате").click() + pg.wait_for_function("() => !!window._topupBody") + assert json.loads(pg.evaluate("window._topupBody"))["amount"] == "500" + finally: + ctx.close() diff --git a/tests/ui_smoke_harness.py b/tests/ui_smoke_harness.py index caa8c9a..0ebfe66 100644 --- a/tests/ui_smoke_harness.py +++ b/tests/ui_smoke_harness.py @@ -116,6 +116,18 @@ window.fetch = async (url, opts={}) => { window._recalc = (window._recalc || 0) + 1; return _json({title: 'Смета (пересчёт)', positions, totals: {grand_total: gt}, ok: true, missing: []}); } + // Пополнение — только когда тест попросил (stub_topup=1), иначе прежнее поведение. + if (url.includes('/api/limits')) { + 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({unlimited: true}); + } + if (url.includes('/api/topups')) { + window._topupBody = opts.body || ''; + return _json({topup_id: 1, pay_url: '#', result_token: '1.stub'}); + } if (url.includes('/api/feedback')) { window._fb++; return _json({}); } if (url.includes('/api/history')) return _json([]); // UX-победы 2026-07-21: версия/чейнджлог («что нового») + демо-смета