Files
2025-09-21 20:19:12 -04:00

116 lines
2.6 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
```
3. Create test fixtures:
```bash
mkdir -p tests/fixtures
```
4. Add test assets:
Place the following files in `tests/fixtures/`:
- `test_photo.jpg` - A sample photo for testing uploads
- `test_avatar.jpg` - A sample avatar image for profile tests
## 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 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. **Upload Failures**: Verify test fixtures exist
4. **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