test(e2e): add venv + playwright deps and robust Matomo API auth flow

- Add optional dependency group "e2e" with Playwright in pyproject.toml
- Teach Makefile to create/use local .venv, install e2e deps, and fetch Chromium
- Wait for Matomo HTTP response (any status) before running bootstrap
- Switch API calls to /index.php and add HttpClient.get()
- Use UsersManager.getTokenAuth (md5Password) to obtain token_auth for privileged calls
- Make web installer more resilient to HTTPError/500 and locale/button variations
- Update E2E test to pass admin email and call API via /index.php

https://chatgpt.com/share/694a70b0-e520-800f-a3e4-eaf5e96530bd
This commit is contained in:
Kevin Veen-Birkenbach
2025-12-23 11:36:20 +01:00
parent 541eb04351
commit 65e26014e3
14 changed files with 325 additions and 95 deletions

View File

@@ -8,6 +8,7 @@ import urllib.request
MATOMO_URL = os.environ.get("MATOMO_URL", "http://127.0.0.1:8080")
ADMIN_USER = os.environ.get("MATOMO_ADMIN_USER", "administrator")
ADMIN_PASSWORD = os.environ.get("MATOMO_ADMIN_PASSWORD", "AdminSecret123!")
ADMIN_EMAIL = os.environ.get("MATOMO_ADMIN_EMAIL", "administrator@example.org")
class TestMatomoBootstrapE2E(unittest.TestCase):
@@ -22,6 +23,8 @@ class TestMatomoBootstrapE2E(unittest.TestCase):
ADMIN_USER,
"--admin-password",
ADMIN_PASSWORD,
"--admin-email",
ADMIN_EMAIL,
"--token-description",
"e2e-test-token",
]
@@ -34,7 +37,7 @@ class TestMatomoBootstrapE2E(unittest.TestCase):
self.assertRegex(token, r"^[a-f0-9]{32,64}$", f"Expected token_auth, got: {token}")
api_url = (
f"{MATOMO_URL}/api.php"
f"{MATOMO_URL}/index.php"
f"?module=API&method=SitesManager.getSitesWithAtLeastViewAccess"
f"&format=json&token_auth={token}"
)