Хозяин нажал «500 ₽» в окне пополнения 21.11.2026: сумма запоминалась для отправки, но поле оставалось пустым. Теперь нажатие пишет сумму в поле (программная запись не будит oninput, подсветка выбора цела). Проверка — настоящая страница чата в браузере. Co-Authored-By: Claude Code <noreply@anthropic.com>
63 lines
2.6 KiB
Python
63 lines
2.6 KiB
Python
"""Окно «Пополнить счёт»: нажатие суммы обязано быть видно и уходить на сервер.
|
|
|
|
Живой случай 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()
|