diff --git a/tests/fixtures/login.html b/tests/fixtures/login.html new file mode 100644 index 0000000..fc271be --- /dev/null +++ b/tests/fixtures/login.html @@ -0,0 +1,17 @@ + + +Login + +

Test Login

+
+ + + + +
+ + diff --git a/tests/fixtures/welcome.html b/tests/fixtures/welcome.html new file mode 100644 index 0000000..b68c661 --- /dev/null +++ b/tests/fixtures/welcome.html @@ -0,0 +1,8 @@ + + +Welcome + +

Welcome!

+

You made it.

+ + diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py new file mode 100644 index 0000000..abfa883 --- /dev/null +++ b/tests/integration/conftest.py @@ -0,0 +1,43 @@ +"""Shared fixtures for real-browser integration tests. + +Every test in this directory is marked ``integration`` automatically and +runs with NoPacing (human delays would make the suite glacial). Browsers +run headless against static HTML served from tests/fixtures. +""" + +import functools +import http.server +import threading +from pathlib import Path + +import pytest + +FIXTURES = Path(__file__).parent.parent / "fixtures" +BROWSERS = ["firefox", "chromium"] + + +def pytest_collection_modifyitems(items): + integration_dir = Path(__file__).parent + for item in items: + if integration_dir in item.path.parents: + item.add_marker(pytest.mark.integration) + + +@pytest.fixture(scope="session") +def site_url(): + """Serve tests/fixtures over HTTP on an ephemeral port.""" + handler = functools.partial( + http.server.SimpleHTTPRequestHandler, directory=str(FIXTURES) + ) + server = http.server.ThreadingHTTPServer(("127.0.0.1", 0), handler) + thread = threading.Thread(target=server.serve_forever, daemon=True) + thread.start() + yield f"http://127.0.0.1:{server.server_address[1]}" + server.shutdown() + + +@pytest.fixture +def store(tmp_path): + from wabot.sessions import SessionStore + + return SessionStore(path=tmp_path / "sessions.json")