feat(админка): мобильный проход
This commit is contained in:
@@ -298,6 +298,12 @@
|
|||||||
- Тесты: `tests/test_customer_export.py` — 2; UI карточки — 9.
|
- Тесты: `tests/test_customer_export.py` — 2; UI карточки — 9.
|
||||||
- P4.7b (удаление/анонимизация) — после P0.4.
|
- P4.7b (удаление/анонимизация) — после P0.4.
|
||||||
|
|
||||||
|
## 4.39. P4.6 — мобильный проход
|
||||||
|
|
||||||
|
- 390: 5 карточек, очередь, карточка/взнос; `document.scrollWidth <= viewport`.
|
||||||
|
- CSS: task/actions в столбик, drawer уже, toolbar без min-width.
|
||||||
|
- Тесты: `tests/test_admin_v2_mobile.py` — 2.
|
||||||
|
|
||||||
## 5. Следующий шаг
|
## 5. Следующий шаг
|
||||||
|
|
||||||
P0.0 design-gate → P0.1 backup/restore → P0.2 (release `feat/topup` отдельно, не в рамках выравнивания).
|
P0.0 design-gate → P0.1 backup/restore → P0.2 (release `feat/topup` отдельно, не в рамках выравнивания).
|
||||||
|
|||||||
@@ -84,3 +84,12 @@ tr.clickable{cursor:pointer} tr.clickable:hover td{background:#f3f6ff}
|
|||||||
.s-deferred,.s-ignored{background:#f2f4f7;color:#667085}
|
.s-deferred,.s-ignored{background:#f2f4f7;color:#667085}
|
||||||
|
|
||||||
.badge.ok,.ok{color:#067647}.bad,.badge.bad{color:#b42318}
|
.badge.ok,.ok{color:#067647}.bad,.badge.bad{color:#b42318}
|
||||||
|
|
||||||
|
@media(max-width:600px){
|
||||||
|
.task{flex-direction:column}
|
||||||
|
.task-actions{width:100%}
|
||||||
|
.task-actions button{flex:1}
|
||||||
|
.actions-bar button{flex:1 1 45%}
|
||||||
|
.drawer{padding:12px}
|
||||||
|
.toolbar input{min-width:0}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
"""P4.6: 390 — «Мой день», карточка клиента, очередь и взнос без разъезда."""
|
||||||
|
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 не установлен")
|
||||||
|
from test_admin_design_ui import browser # noqa: E402,F401
|
||||||
|
|
||||||
|
DASH = {"user": "boss@x", "generated_at": 1794000000, "last_visit": None,
|
||||||
|
"work_24h": {"people": 1, "requests": 5, "failures": 0, "failure_share": 0,
|
||||||
|
"limit_hits": 0, "latency_qa_ms": 1, "latency_qa_p95_ms": 1,
|
||||||
|
"latency_agent_ms": 1, "latency_agent_p95_ms": 1},
|
||||||
|
"money": {"revenue_rub": 0, "flow_rub": 0, "accounts_total_rub": 0,
|
||||||
|
"topups_included": False, "unpriced": 0},
|
||||||
|
"customers": {"total": 1, "active_24h": 1},
|
||||||
|
"attention": {"failures": 0, "limit_hits": 0, "unpriced": 0}}
|
||||||
|
ATT = {"items": [{"key": "unpriced", "severity": "medium", "title": "Без цены",
|
||||||
|
"detail": "1", "action": "/admin/v2/money"}], "count": 1}
|
||||||
|
CARD = {"profile": {"email": "anna@x", "deleted_at": None, "blocked": False,
|
||||||
|
"read_only": False, "trial": False, "agent_access": True,
|
||||||
|
"agent_provider": "claude", "role": "user"},
|
||||||
|
"account": {"balance_rub": 100.0}, "activity": {"last_seen": 1793000000,
|
||||||
|
"messages": 1, "files": 0, "files_capped": False}}
|
||||||
|
|
||||||
|
|
||||||
|
class Handler(http.server.SimpleHTTPRequestHandler):
|
||||||
|
calls = []
|
||||||
|
|
||||||
|
def __init__(self, *a, **kw):
|
||||||
|
super().__init__(*a, directory=str(ROOT), **kw)
|
||||||
|
|
||||||
|
def do_GET(self):
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
u = urlparse(self.path)
|
||||||
|
if u.path == "/api/admin/v2/dashboard":
|
||||||
|
return self._json(DASH)
|
||||||
|
if u.path == "/api/admin/v2/attention":
|
||||||
|
return self._json(ATT)
|
||||||
|
if u.path == "/api/admin/v2/customers":
|
||||||
|
return self._json({"items": [{"email": "anna@x", "raw_email": "anna@x",
|
||||||
|
"role": "user", "status": "active", "last_seen": 1793000000,
|
||||||
|
"spent_rub_24h": 0, "balance_rub": 100,
|
||||||
|
"agent_access": True, "agent_provider": "claude"}],
|
||||||
|
"total": 1, "page": 1, "per_page": 50})
|
||||||
|
if u.path.startswith("/api/admin/v2/customers/"):
|
||||||
|
return self._json(CARD)
|
||||||
|
if self.path == "/admin/v2" or self.path.startswith("/admin/v2/"):
|
||||||
|
data = (ROOT / "static/admin2/index.html").read_bytes()
|
||||||
|
self.send_response(200); self.send_header("Content-Type", "text/html; charset=utf-8")
|
||||||
|
self.send_header("Content-Length", str(len(data))); self.end_headers()
|
||||||
|
self.wfile.write(data); return
|
||||||
|
return super().do_GET()
|
||||||
|
|
||||||
|
def do_POST(self):
|
||||||
|
n = int(self.headers.get('Content-Length') or 0)
|
||||||
|
self.rfile.read(n)
|
||||||
|
Handler.calls.append(self.path)
|
||||||
|
self._json({"ok": True, "id": 1, "previous": None})
|
||||||
|
|
||||||
|
def _json(self, obj):
|
||||||
|
data = json.dumps(obj).encode()
|
||||||
|
self.send_response(200); self.send_header("Content-Type", "application/json")
|
||||||
|
self.send_header("Content-Length", str(len(data))); self.end_headers()
|
||||||
|
self.wfile.write(data)
|
||||||
|
|
||||||
|
def log_message(self, *a):
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="module")
|
||||||
|
def site():
|
||||||
|
Handler.calls = []
|
||||||
|
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]}"
|
||||||
|
srv.shutdown()
|
||||||
|
|
||||||
|
|
||||||
|
def _no_horizontal(page):
|
||||||
|
return page.evaluate("document.documentElement.scrollWidth <= innerWidth")
|
||||||
|
|
||||||
|
|
||||||
|
def test_day_mobile_queue(browser, site):
|
||||||
|
page = browser.new_page(viewport={"width": 390, "height": 844})
|
||||||
|
page.add_init_script("localStorage.setItem('token','t')")
|
||||||
|
page.goto(site + "/admin/v2")
|
||||||
|
page.wait_for_selector(".grid .card")
|
||||||
|
assert page.locator(".grid .card").count() == 5
|
||||||
|
assert _no_horizontal(page)
|
||||||
|
assert page.locator(".task button", has_text="Отменить").count() == 0
|
||||||
|
assert page.locator(".task button", has_text="Готово").is_visible()
|
||||||
|
page.close()
|
||||||
|
|
||||||
|
|
||||||
|
def test_card_mobile_topup_visible(browser, site):
|
||||||
|
page = browser.new_page(viewport={"width": 390, "height": 844})
|
||||||
|
page.add_init_script("localStorage.setItem('token','t')")
|
||||||
|
page.goto(site + "/admin/v2/customers")
|
||||||
|
page.wait_for_selector("tr.clickable")
|
||||||
|
page.locator("tr.clickable").first.click()
|
||||||
|
page.wait_for_selector(".drawer .kv")
|
||||||
|
assert _no_horizontal(page)
|
||||||
|
assert page.locator(".actions-bar button", has_text="Внести").is_visible()
|
||||||
|
page.on("dialog", lambda d: d.accept("100"))
|
||||||
|
page.locator(".actions-bar button", has_text="Внести").click()
|
||||||
|
page.wait_for_selector(".toast")
|
||||||
|
assert page.locator(".toast").inner_text()
|
||||||
|
page.close()
|
||||||
Reference in New Issue
Block a user