Files
FitTrack2/FitnessSync/backend/tests/integration/test_ui_rendering.py
sstent d1cfd0fd8e feat: implement Fitbit OAuth, Garmin MFA, and optimize segment discovery
- Add Fitbit authentication flow (save credentials, OAuth callback handling)
- Implement Garmin MFA support with successful session/cookie handling
- Optimize segment discovery with new sampling and activity query services
- Refactor database session management in discovery API for better testability
- Enhance activity data parsing for charts and analysis
- Update tests to use testcontainers and proper dependency injection
- Clean up repository by ignoring and removing tracked transient files (.pyc, .db)
2026-01-16 15:35:26 -08:00

75 lines
2.1 KiB
Python

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