feat(админка): счета клиентов и CSV
This commit is contained in:
@@ -38,6 +38,18 @@ 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/accounts":
|
||||
return self._json({"items": [
|
||||
{"email": "anna@x", "balance_rub": 100.0, "deposited_rub": 200.0,
|
||||
"charged_rub": 100.0, "status": "ok"},
|
||||
{"email": "bob@x", "balance_rub": 0.0, "deposited_rub": 100.0,
|
||||
"charged_rub": 100.0, "status": "exhausted"}],
|
||||
"total": 2, "total_kop": 10000, "total_rub": 100.0})
|
||||
if u.path == "/api/admin/v2/accounts.csv":
|
||||
body = "email;balance_rub\nanna@x;100.00\n".encode()
|
||||
self.send_response(200); self.send_header("Content-Type", "text/csv")
|
||||
self.send_header("Content-Length", str(len(body))); self.end_headers()
|
||||
self.wfile.write(body); return
|
||||
if u.path == "/api/admin/v2/payments":
|
||||
q = parse_qs(u.query)
|
||||
items = PAYMENTS
|
||||
@@ -112,10 +124,23 @@ 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.wait_for_selector(".payments table tbody tr")
|
||||
assert page.locator(".payments table tbody tr").count() == 2
|
||||
assert "yk1" in page.locator(".payments table").inner_text()
|
||||
page.fill(".payments input[type=search]", "bob")
|
||||
page.wait_for_function("document.querySelectorAll('.payments table tbody tr').length === 1")
|
||||
assert page.locator(".payments table tbody tr").count() == 1
|
||||
assert "bob@x" in page.locator(".payments table").inner_text()
|
||||
page.close()
|
||||
|
||||
|
||||
def test_accounts_table_and_csv(browser, site):
|
||||
page = browser.new_page()
|
||||
page.add_init_script("localStorage.setItem('token','t')")
|
||||
page.goto(site + "/admin/v2/money")
|
||||
page.wait_for_selector(".accounts table")
|
||||
assert "anna@x" in page.locator(".accounts table").inner_text()
|
||||
with page.expect_download() as dl:
|
||||
page.locator("button", has_text="CSV").click()
|
||||
assert dl.value.suggested_filename == "accounts.csv"
|
||||
page.close()
|
||||
|
||||
Reference in New Issue
Block a user