Add Playwright e2e test infrastructure
Set up browser-based end-to-end testing using pytest-playwright: - Add playwright-driver and pytest-playwright to nix flake - Configure PLAYWRIGHT_BROWSERS_PATH for NixOS compatibility - Create ServerHarness to manage live server for tests - Add smoke tests for health endpoint and page loading - Exclude e2e tests from pre-commit hook (require special setup) Run e2e tests with: pytest tests/e2e/ -v -n 0 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
29
tests/e2e/test_smoke.py
Normal file
29
tests/e2e/test_smoke.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# ABOUTME: Basic smoke tests to verify the e2e test setup works.
|
||||
# ABOUTME: Tests server startup, health endpoint, and page loading.
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
from playwright.sync_api import Page, expect
|
||||
|
||||
pytestmark = pytest.mark.e2e
|
||||
|
||||
|
||||
def test_healthz_endpoint(live_server):
|
||||
"""Verify health endpoint returns OK."""
|
||||
response = requests.get(f"{live_server.url}/healthz")
|
||||
assert response.status_code == 200
|
||||
assert response.text == "OK"
|
||||
|
||||
|
||||
def test_home_page_loads(page: Page, live_server):
|
||||
"""Verify the home page loads successfully."""
|
||||
page.goto(live_server.url)
|
||||
# Should see the page body
|
||||
expect(page.locator("body")).to_be_visible()
|
||||
|
||||
|
||||
def test_animals_page_accessible(page: Page, live_server):
|
||||
"""Verify animals list page is accessible."""
|
||||
page.goto(f"{live_server.url}/animals")
|
||||
# Should see some content (exact content depends on seed data)
|
||||
expect(page.locator("body")).to_be_visible()
|
||||
Reference in New Issue
Block a user