Spaces:
Running
Running
| """Local E2E of the internal /admin console (dev-token auth).""" | |
| from __future__ import annotations | |
| import pytest | |
| pytestmark = pytest.mark.local | |
| def test_admin_overview_and_invite_card(page, app_url): | |
| page.goto(f"{app_url}/admin?token=admintoken", wait_until="networkidle") | |
| page.wait_for_selector("#tenants tr", timeout=15000) # per-tenant health table | |
| assert page.is_visible("#ioTenant") and page.is_visible("#ioEmail") # invite-a-tenant-owner | |
| def test_admin_provision_a_client(page, app_url): | |
| page.goto(f"{app_url}/admin?token=admintoken", wait_until="networkidle") | |
| page.wait_for_selector("#clients tr", timeout=15000) | |
| page.fill("#ctId", "acme-e2e") | |
| page.fill("#ctCompany", "Acme E2E Lawn") | |
| page.fill("#ctEmail", "owner@acme-e2e.com") | |
| page.fill("#ctOrigin", "https://acme-e2e.com") | |
| page.click("#ctGo") | |
| # Provisioned: the one-time publishable key is shown and the client appears in the list. | |
| page.wait_for_function("document.getElementById('ctMsg').textContent.includes('Provisioned')", timeout=10000) | |
| assert page.locator("#ctMsg code").count() == 1 # the minted key, shown once | |
| page.wait_for_function("document.getElementById('clients').textContent.includes('acme-e2e')", timeout=8000) | |
| def test_admin_gate_without_token(page, app_url): | |
| page.goto(f"{app_url}/admin", wait_until="networkidle") | |
| page.wait_for_selector("#tokenInput", timeout=8000) # no token → sign-in gate | |
| assert page.is_hidden("#tenants") or page.locator("#tenants tr").count() == 0 | |