Adding e2e testing
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import os
|
||||
|
||||
from playwright.sync_api import expect
|
||||
|
||||
|
||||
BASE_URL = os.getenv("E2E_BASE_URL", "http://localhost:8082").rstrip("/")
|
||||
ADMIN_USERNAME = os.getenv("E2E_ADMIN_USERNAME")
|
||||
ADMIN_PASSWORD = os.getenv("E2E_ADMIN_PASSWORD")
|
||||
|
||||
|
||||
def app_url(path):
|
||||
return f"{BASE_URL}/{path.lstrip('/')}"
|
||||
|
||||
|
||||
def login_as_admin(page):
|
||||
if page.locator("#login-username").is_visible():
|
||||
page.locator("#login-username").fill(ADMIN_USERNAME)
|
||||
page.locator("#login-password").fill(ADMIN_PASSWORD)
|
||||
page.locator("#login-btn").click()
|
||||
expect(page.locator("#current-user")).to_have_text(ADMIN_USERNAME)
|
||||
if page.get_by_role("heading", name="Login").count() > 0:
|
||||
expect(page.get_by_role("heading", name="Login")).to_be_hidden()
|
||||
|
||||
|
||||
def skip_without_admin_credentials(pytest):
|
||||
if not ADMIN_USERNAME or not ADMIN_PASSWORD:
|
||||
pytest.skip("Set E2E_ADMIN_USERNAME and E2E_ADMIN_PASSWORD to run authenticated e2e tests")
|
||||
Reference in New Issue
Block a user