feat(админка): платежи v2 с фильтрами
This commit is contained in:
@@ -18,6 +18,12 @@ MONEY = {"period_days": 30, "revenue_rub": 1000, "refunded_rub": 0, "cost_rub":
|
||||
"accounts_count": 2, "unpriced": 0}
|
||||
MONTHS = [{"month": "2026-09", "revenue_rub": 500, "cost_rub": 100},
|
||||
{"month": "2026-10", "revenue_rub": 500, "cost_rub": 150}]
|
||||
PAYMENTS = [
|
||||
{"id": 1, "ts": 1793000000, "username": "anna@x", "product": "tariff1",
|
||||
"amount_rub": "100.50", "yk_payment_id": "yk1", "status": "succeeded"},
|
||||
{"id": 2, "ts": 1793000001, "username": "bob@x", "product": "tariff2",
|
||||
"amount_rub": "200.00", "yk_payment_id": "yk2", "status": "pending"},
|
||||
]
|
||||
|
||||
|
||||
class Handler(http.server.SimpleHTTPRequestHandler):
|
||||
@@ -32,6 +38,14 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
||||
if u.path == "/api/admin/v2/money":
|
||||
Handler.calls.append(u.query)
|
||||
return self._json({**MONEY, "period_days": int(parse_qs(u.query).get("days", ["30"])[0])})
|
||||
if u.path == "/api/admin/v2/payments":
|
||||
q = parse_qs(u.query)
|
||||
items = PAYMENTS
|
||||
if q.get("q"):
|
||||
items = [r for r in items if q["q"][0] in r["username"] or q["q"][0] in r["yk_payment_id"]]
|
||||
if q.get("status"):
|
||||
items = [r for r in items if r["status"] == q["status"][0]]
|
||||
return self._json({"items": items, "total": len(items), "page": 1, "per_page": 50})
|
||||
if u.path == "/api/admin/v2/finance":
|
||||
return self._json({"months": MONTHS, "days": int(parse_qs(u.query).get("days", ["30"])[0])})
|
||||
if self.path == "/admin/v2" or self.path.startswith("/admin/v2/"):
|
||||
@@ -92,3 +106,16 @@ def test_money_empty_months(browser, site):
|
||||
page.wait_for_selector(".note")
|
||||
assert page.locator(".chart").count() == 0
|
||||
page.close()
|
||||
|
||||
|
||||
def test_payments_table_and_filter(browser, site):
|
||||
page = browser.new_page()
|
||||
page.add_init_script("localStorage.setItem('token','t')")
|
||||
page.goto(site + "/admin/v2/money")
|
||||
page.wait_for_selector("table tbody tr")
|
||||
assert page.locator("table tbody tr").count() == 2
|
||||
assert "yk1" in page.locator("table").inner_text()
|
||||
page.fill("input[type=search]", "bob")
|
||||
page.wait_for_function("document.querySelectorAll('table tbody tr').length === 1")
|
||||
assert "bob@x" in page.locator("table").inner_text()
|
||||
page.close()
|
||||
|
||||
Reference in New Issue
Block a user