from fastapi.testclient import TestClient from main import app import pytest def test_activity_view_render(client): """ Test that the activity view page renders the HTML shell correctly and contains the necessary container elements for JS to populate. """ # Requires an activity ID path parameter, but doesn't validate it in the route handler response = client.get("/activity/12345") assert response.status_code == 200 html = response.text # Verify Title/Header placeholders assert 'id="act-name"' in html assert 'id="act-time"' in html # Verify Map Container assert 'id="map"' in html # Verify Chart Container assert 'id="streams-chart"' in html # Verify Stats Grid assert 'class="stats-grid"' in html assert 'id="metric-dist"' in html assert 'id="metric-dur"' in html # Verify Metrics Section assert 'class="metrics-section"' in html assert 'id="m-avg-pwr"' in html def test_segment_view_render(client): """ Test that the segments page renders correctly with the segments table and hidden modals for viewing and comparing segments. """ response = client.get("/segments") assert response.status_code == 200 html = response.text # Verify Page Title assert "Segments" in html # Verify Segments Table assert 'id="segments-table"' in html # Verify Create Modal Trigger assert 'data-bs-target="#createSegmentModal"' in html def test_comparison_modals_render(client): """ Test that the Segment Comparison and Details modals are present in the DOM of the segments page. """ response = client.get("/segments") assert response.status_code == 200 html = response.text # Verify View Modal & Attributes assert 'id="viewSegmentModal"' in html assert 'id="seg-map"' in html assert 'id="elevationChart"' in html assert 'id="leaderboard-table"' in html # Verify Comparison Modal & Attributes assert 'id="compareModal"' in html assert 'Effort Comparison' in html assert 'id="comparison-table"' in html assert 'id="comparisonChart"' in html