- Introduced a comprehensive Secret Management Guide detailing best practices, secret classification, development setup, production management, rotation procedures, and emergency protocols. - Implemented a client-side performance monitoring script to track various metrics including page load performance, paint metrics, layout shifts, and memory usage. - Enhanced search accessibility with keyboard navigation support for search results, ensuring compliance with WCAG standards and improving user experience.
4.1 KiB
Park Search Tests
Why These Tests Are Disabled
These tests were disabled because they need updating to work with the new ParkLocation model instead of the generic Location model. The model refactoring changed how location data is stored and accessed for parks.
Re-enabling These Tests
To re-enable these tests, follow these steps:
-
Update model imports in
test_filters.pyandtest_models.py:- Replace
from apps.locations.models import Locationwithfrom apps.parks.models import ParkLocation - Update any other location-related imports
- Replace
-
Update test fixtures to use
ParkLocationinstead ofLocation:- Change factory classes to create
ParkLocationinstances - Update fixture data to match the new model structure
- Change factory classes to create
-
Update assertions to match new model structure:
- Adjust field references (e.g.,
park.locationmay now bepark.park_location) - Update any serializer-based assertions
- Adjust field references (e.g.,
-
Move files back to the active test directory:
mv backend/apps/parks/tests_disabled/*.py backend/apps/parks/tests/ -
Run tests to verify they pass:
uv run pytest backend/apps/parks/tests/
Tracking: See TODO(THRILLWIKI-XXX) for tracking issue
Overview
Test suite for the park search functionality including:
- Autocomplete widget integration
- Search form validation
- Filter integration
- HTMX interaction
- View mode persistence
Running Tests
# Run all park tests
uv run pytest parks/tests/
# Run specific search tests
uv run pytest parks/tests/test_search.py
# Run with coverage
uv run pytest --cov=parks parks/tests/
Test Coverage
Search API Tests
test_search_json_format: Validates API response structuretest_empty_search_json: Tests empty search handlingtest_search_format_validation: Verifies all required fields and typestest_suggestion_limit: Confirms 8-item result limit
Search Functionality Tests
test_autocomplete_results: Validates real-time suggestion filteringtest_search_with_filters: Tests filter integration with searchtest_partial_match_search: Verifies partial text matching works
UI Integration Tests
test_view_mode_persistence: Ensures view mode is maintainedtest_empty_search: Tests default state behaviortest_htmx_request_handling: Validates HTMX interactions
Data Format Tests
- Field types validation
- Location formatting
- Status display formatting
- URL generation
- Response structure
Frontend Integration
- HTMX partial updates
- Alpine.js state management
- Loading indicators
- View mode persistence
- Keyboard navigation
Test Commands
# Run all park tests
uv run pytest parks/tests/
# Run search tests specifically
uv run pytest parks/tests/test_search.py
# Run with coverage
uv run pytest --cov=parks parks/tests/
Coverage Areas
-
Search Functionality:
- Suggestion generation
- Result filtering
- Partial matching
- Empty state handling
-
UI Integration:
- HTMX requests
- View mode switching
- Loading states
- Error handling
-
Performance:
- Result limiting
- Debouncing
- Query optimization
-
Accessibility:
- ARIA attributes
- Keyboard controls
- Screen reader support
Configuration
Tests use pytest-django and require:
- PostgreSQL database
- HTMX middleware
- Autocomplete app configuration
Fixtures
The test suite uses standard Django test fixtures. No additional fixtures required.
Common Issues
-
Database Errors
- Ensure PostGIS extensions are installed
- Verify database permissions
-
HTMX Tests
- Use
HTTP_HX_REQUESTheader for HTMX requests - Check response content for HTMX attributes
- Use
Adding New Tests
When adding tests, ensure:
- Database isolation using
@pytest.mark.django_db - Proper test naming following
test_*convention - Clear test descriptions in docstrings
- Coverage for both success and failure cases
- HTMX interaction testing where applicable
Future Improvements
- Add performance benchmarks
- Include accessibility tests
- Add Playwright e2e tests
- Implement geographic search tests