37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
import os
|
|
from dataclasses import dataclass
|
|
from pathlib import Path
|
|
|
|
|
|
def _boolean(name, default):
|
|
value = os.getenv(name)
|
|
return default if value is None else value.strip().lower() not in {"0", "false", "no", "off"}
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class E2ESettings:
|
|
base_url: str | None
|
|
environment: str
|
|
headless: bool
|
|
slow_mo: int
|
|
action_timeout_ms: int
|
|
navigation_timeout_ms: int
|
|
viewport: dict
|
|
artifact_dir: Path
|
|
|
|
@classmethod
|
|
def from_environment(cls):
|
|
return cls(
|
|
base_url=(os.getenv("E2E_BASE_URL") or os.getenv("BASE_URL") or "").rstrip("/") or None,
|
|
environment=os.getenv("E2E_ENVIRONMENT", "local").strip().lower(),
|
|
headless=_boolean("E2E_HEADLESS", True),
|
|
slow_mo=int(os.getenv("E2E_SLOW_MO", "0")),
|
|
action_timeout_ms=int(os.getenv("E2E_ACTION_TIMEOUT_MS", "10000")),
|
|
navigation_timeout_ms=int(os.getenv("E2E_NAVIGATION_TIMEOUT_MS", "45000")),
|
|
viewport={
|
|
"width": int(os.getenv("E2E_VIEWPORT_WIDTH", "1280")),
|
|
"height": int(os.getenv("E2E_VIEWPORT_HEIGHT", "800")),
|
|
},
|
|
artifact_dir=Path(os.getenv("E2E_ARTIFACT_DIR", "test-results/e2e")),
|
|
)
|