Files
thrillwiki_django_no_react/backend/tests/e2e/README.md
pacnpal edcd8f2076 Add secret management guide, client-side performance monitoring, and search accessibility enhancements
- 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.
2025-12-23 16:41:42 -05:00

120 lines
2.8 KiB
Markdown

# ThrillWiki E2E Tests
This directory contains end-to-end tests for ThrillWiki using Playwright and pytest.
## Setup
1. Install dependencies:
```bash
uv pip install -r requirements.txt
```
2. Install Playwright browsers:
```bash
playwright install
```
## Running Tests
### Run all tests:
```bash
pytest tests/e2e/
```
### Run specific test files:
```bash
pytest tests/e2e/test_auth.py
pytest tests/e2e/test_parks.py
pytest tests/e2e/test_rides.py
pytest tests/e2e/test_reviews.py
pytest tests/e2e/test_profiles.py
```
### Run tests by marker:
```bash
pytest -m auth
pytest -m parks
pytest -m rides
pytest -m reviews
pytest -m profiles
```
### Run tests with different browsers:
```bash
pytest --browser chromium
pytest --browser firefox
pytest --browser webkit
```
### Run tests headlessly:
```bash
pytest --headless
```
## Test Structure
- `test_auth.py` - Authentication tests (login, signup, logout)
- `test_parks.py` - Theme park tests (listing, details, reviews, photos)
- `test_rides.py` - Ride tests (listing, details, reviews, photos)
- `test_reviews.py` - Review tests (creation, editing, moderation)
- `test_profiles.py` - User profile tests (settings, preferences)
## Test Data
The tests expect the following test users to exist in the database:
1. Regular User:
- Username: testuser
- Password: testpass123
2. Moderator:
- Username: moderator
- Password: modpass123
You can create these users using Django management commands:
```bash
python manage.py create_test_users
```
## Test Images
Tests that require file uploads use the `test_images` fixture defined in `conftest.py`. This fixture generates temporary JPEG images at runtime, eliminating the need for external fixture files.
Usage in tests:
```python
def test_add_photo(page: Page, test_images):
page.get_by_label("Photo").set_input_files(test_images["test_photo"])
page.get_by_label("Avatar").set_input_files(test_images["test_avatar"])
```
Available keys:
- `test_images["test_photo"]` - Path to a temporary test photo
- `test_images["test_avatar"]` - Path to a temporary test avatar
## Test Environment
Tests expect:
1. Django development server running on http://localhost:8000
2. Database with test data loaded
3. Media handling configured for test uploads
## Debugging
1. Use `--headed` flag to see browser during test execution
2. Use `--slowmo 1000` to slow down test execution
3. Use `--debug` for detailed logging
4. Screenshots are saved in `test-results/` on failure
## Common Issues
1. **Connection Refused**: Ensure Django server is running
2. **Element Not Found**: Check selectors and page load timing
3. **Authentication Errors**: Verify test users exist in database
## Contributing
1. Add new tests in appropriate test files
2. Follow existing test patterns
3. Include comments explaining test scenarios
4. Update README for new test categories
5. Add new fixtures as needed