Compare commits

...

1 Commits

Author SHA1 Message Date
Pat Sukprasert 8a20050097 test: skip e2e ui url safety configure checks without playwright 2026-06-18 01:26:40 +08:00
+16 -5
View File
@@ -1,12 +1,13 @@
from __future__ import annotations
import socket
from collections.abc import Callable
from dataclasses import dataclass
from typing import Any
from typing import Any, cast
import pytest
from _pytest.config import Config
from tests.e2e_ui.conftest import pytest_configure
from tests.e2e_ui.url_safety import DEV_PORTS, unsafe_ui_base_url_reason
@@ -18,6 +19,13 @@ class _ConfigStub:
return self.options.get(name, default)
def _pytest_configure() -> Callable[[Config], None]:
pytest.importorskip("playwright", exc_type=ImportError)
from tests.e2e_ui.conftest import pytest_configure
return pytest_configure
@pytest.mark.parametrize("port", sorted(DEV_PORTS))
def test_unsafe_ui_base_url_reason_refuses_known_dev_ports(port: int) -> None:
reason = unsafe_ui_base_url_reason(f"http://example.com:{port}")
@@ -63,7 +71,7 @@ def test_pytest_configure_rejects_headed_in_ci(monkeypatch: pytest.MonkeyPatch)
monkeypatch.setenv("CI", "1")
with pytest.raises(pytest.UsageError, match="must run headless in CI"):
pytest_configure(_ConfigStub({"--ui-base-url": None, "--headed": True}))
_pytest_configure()(cast(Config, _ConfigStub({"--ui-base-url": None, "--headed": True})))
def test_pytest_configure_rejects_dev_ui_base_url(
@@ -73,6 +81,9 @@ def test_pytest_configure_rejects_dev_ui_base_url(
monkeypatch.delenv("CI", raising=False)
with pytest.raises(pytest.UsageError, match="Refusing --ui-base-url"):
pytest_configure(
_ConfigStub({"--ui-base-url": "http://127.0.0.1:5173", "--headed": False})
_pytest_configure()(
cast(
Config,
_ConfigStub({"--ui-base-url": "http://127.0.0.1:5173", "--headed": False}),
)
)