Files
meshcore-hub/tests/test_web/test_home.py
Louis King c8cc049651 feat(web): React SPA shell, markdown migration, vitest coverage, v0.17 docs
- Migrate footer, error page, and announcements to React; slim Jinja2
  shell to SEO/head/config/fonts/theme-init only
- Replace server-side markdown rendering with react-markdown (removes
  Python `markdown` dependency); custom pages + announcements ship
  raw markdown to the client
- Add heading-anchor deep-links with CSS override for inherited colors
- Extract pure helpers from pages (messageHelpers, mapMath, routesHelpers,
  profileHelpers, packetHelpers, packetGroupHelpers) for unit testability
- Add comprehensive vitest suite: 59 test files, 315 tests covering all
  components, pages, and extracted helpers; global i18next mock + matchMedia
  stub + AbortController-aware apiMock in test infrastructure
- Fix SortableTable test DOM nesting (<th> inside proper <table> context)
- Update docs for v0.17.0: upgrading.md release notes, README.md project
  structure + build description, i18n.md path fix
- Delete REACT_MIGRATION.md (migration complete, unreferenced)
- Add announcements dismiss-persistence + custom-page 404 E2E specs
2026-07-22 22:55:20 +01:00

58 lines
2.4 KiB
Python

"""Tests for the home page route (SPA)."""
from fastapi.testclient import TestClient
from tests.test_web.conftest import get_app_config
class TestHomePage:
"""Tests for the home page."""
def test_home_returns_200(self, client: TestClient) -> None:
"""Test that home page returns 200 status code."""
response = client.get("/")
assert response.status_code == 200
def test_home_returns_html(self, client: TestClient) -> None:
"""Test that home page returns HTML content."""
response = client.get("/")
assert "text/html" in response.headers["content-type"]
def test_home_contains_network_name(self, client: TestClient) -> None:
"""Test that home page contains the network name."""
response = client.get("/")
assert "Test Network" in response.text
def test_home_contains_network_city(self, client: TestClient) -> None:
"""Test that home page contains the network city."""
response = client.get("/")
assert "Test City" in response.text
def test_home_contains_network_country(self, client: TestClient) -> None:
"""Test that home page contains the network country."""
response = client.get("/")
assert "Test Country" in response.text
def test_home_contains_app_config(self, client: TestClient) -> None:
"""Test that home page contains the SPA config JSON."""
response = client.get("/")
assert "window.__APP_CONFIG__" in response.text
def test_home_config_contains_network_info(self, client: TestClient) -> None:
"""Test that SPA config contains network information."""
config = get_app_config(client.get("/").text)
assert config["network_name"] == "Test Network"
assert config["network_city"] == "Test City"
assert config["network_country"] == "Test Country"
def test_home_config_contains_contact_info(self, client: TestClient) -> None:
"""Test that SPA config contains contact information for the React footer."""
config = get_app_config(client.get("/").text)
assert config["network_contact_email"] == "test@example.com"
assert config["network_contact_discord"] == "https://discord.gg/test"
def test_home_contains_spa_mount(self, client: TestClient) -> None:
"""Test that home page renders the React SPA mount point."""
response = client.get("/")
assert 'id="app"' in response.text