Integration tests (350 passing): - test_evidence_summary.py: HTML/PDF generation, XSS safety, anchor rendering - test_tor.py: Tor module unit tests (mocked, no Tor needed) - test_c2pa_importer.py: Import result dataclass, trust evaluation, graceful degradation - test_file_attestation.py: All file types (PNG, PDF, CSV, empty, large), determinism - test_paths.py: Registry correctness, env var override, all paths under BASE_DIR - test_killswitch_coverage.py: Tor keys, trusted keys, carrier history destruction Playwright e2e infrastructure: - tests/e2e/ with conftest (live server, auth fixtures), helpers (test file generators) - test_auth.py: Setup flow, login/logout, protected routes - test_attest.py: Image/PDF/CSV attestation, verify, attestation log - test_dropbox.py: Token creation, source upload, branding check - test_keys.py: Identity display, trust store - test_fieldkit.py: Status dashboard, killswitch page - test_navigation.py: All nav links, responsive layout Run: pytest (unit/integration) or pytest -m e2e tests/e2e/ (browser) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
84 lines
3.0 KiB
Python
84 lines
3.0 KiB
Python
"""
|
|
e2e tests for the Fieldkit pages.
|
|
|
|
Safety note: we do NOT actually fire the killswitch in any test — doing so
|
|
would destroy the session-scoped data directory and break all subsequent tests.
|
|
We verify the UI renders correctly and the form fields are present, but we do
|
|
not submit the final "Execute Purge" action.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from playwright.sync_api import Page, expect
|
|
|
|
|
|
@pytest.mark.e2e
|
|
def test_fieldkit_status_page_loads(live_server: str, authenticated_page: Page) -> None:
|
|
"""The /fieldkit/ status dashboard loads and shows expected sections."""
|
|
page = authenticated_page
|
|
page.goto(f"{live_server}/fieldkit/")
|
|
page.wait_for_load_state("networkidle")
|
|
|
|
# Two key sections: dead man's switch and killswitch
|
|
expect(page.locator("body")).to_contain_text("Dead Man")
|
|
expect(page.locator("body")).to_contain_text("Killswitch")
|
|
|
|
|
|
@pytest.mark.e2e
|
|
def test_fieldkit_status_shows_disarmed_deadman(
|
|
live_server: str, authenticated_page: Page
|
|
) -> None:
|
|
"""With deadman disabled in test config, the switch shows 'Disarmed'."""
|
|
page = authenticated_page
|
|
page.goto(f"{live_server}/fieldkit/")
|
|
page.wait_for_load_state("networkidle")
|
|
|
|
# The conftest configures deadman_enabled=False so the badge must be Disarmed
|
|
deadman_section = page.locator("body")
|
|
expect(deadman_section).to_contain_text("Disarmed")
|
|
|
|
|
|
@pytest.mark.e2e
|
|
def test_killswitch_page_loads(live_server: str, authenticated_page: Page) -> None:
|
|
"""The /fieldkit/killswitch page loads and shows the confirmation form."""
|
|
page = authenticated_page
|
|
page.goto(f"{live_server}/fieldkit/killswitch")
|
|
page.wait_for_load_state("networkidle")
|
|
|
|
# Must have the text confirmation input
|
|
expect(page.locator("input[name='confirm']")).to_be_visible()
|
|
|
|
# Must have the password confirmation input
|
|
expect(page.locator("input[name='password']")).to_be_visible()
|
|
|
|
# The destructive submit button must be present but we do NOT click it
|
|
expect(page.locator("button[type='submit']")).to_be_visible()
|
|
|
|
|
|
@pytest.mark.e2e
|
|
def test_killswitch_requires_admin(live_server: str, page: Page) -> None:
|
|
"""The killswitch page requires authentication; unauthenticated access is redirected."""
|
|
page.goto(f"{live_server}/fieldkit/killswitch")
|
|
page.wait_for_load_state("networkidle")
|
|
|
|
assert "/login" in page.url or "/setup" in page.url, (
|
|
f"Expected auth redirect for killswitch, got {page.url}"
|
|
)
|
|
|
|
|
|
@pytest.mark.e2e
|
|
def test_fieldkit_link_from_status(live_server: str, authenticated_page: Page) -> None:
|
|
"""The 'Killswitch Panel' link on the status page navigates correctly."""
|
|
page = authenticated_page
|
|
page.goto(f"{live_server}/fieldkit/")
|
|
page.wait_for_load_state("networkidle")
|
|
|
|
link = page.locator("a[href*='killswitch']")
|
|
expect(link).to_be_visible()
|
|
link.click()
|
|
page.wait_for_load_state("networkidle")
|
|
|
|
assert "killswitch" in page.url, f"Expected killswitch URL, got {page.url}"
|
|
expect(page.locator("input[name='confirm']")).to_be_visible()
|