feat: major project restructure - move Django to backend dir and fix critical imports

- Restructure project: moved Django backend to backend/ directory
- Add frontend/ directory for future Next.js application
- Add shared/ directory for common resources
- Fix critical Django import errors:
  - Add missing sys.path modification for apps directory
  - Fix undefined CATEGORY_CHOICES imports in rides module
  - Fix media migration undefined references
  - Remove unused imports and f-strings without placeholders
- Install missing django-environ dependency
- Django server now runs without ModuleNotFoundError
- Update .gitignore and README for new structure
- Add pnpm workspace configuration for monorepo setup
This commit is contained in:
pacnpal
2025-08-23 18:37:55 -04:00
parent 652ea149bd
commit b0e0678590
996 changed files with 370 additions and 192768 deletions

View File

@@ -1,116 +0,0 @@
# 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

View File

@@ -1,25 +0,0 @@
#!/bin/bash
set -e # Exit on error
echo "Cleaning up test data..."
# Run Django cleanup command
uv run manage.py cleanup_test_data
# Clean up test fixtures
echo "Cleaning up test fixtures..."
rm -f tests/fixtures/test_photo.jpg
rm -f tests/fixtures/test_avatar.jpg
# Clean up Playwright artifacts
echo "Cleaning up Playwright artifacts..."
rm -rf test-results/
rm -rf playwright-report/
# Clean up pytest cache
echo "Cleaning up pytest cache..."
rm -rf .pytest_cache/
rm -rf tests/e2e/__pycache__/
find . -type d -name "__pycache__" -exec rm -r {} + 2>/dev/null || true
echo "Cleanup complete!"

View File

@@ -1,101 +0,0 @@
import pytest
from playwright.sync_api import Page
import subprocess
@pytest.fixture(autouse=True)
def setup_test_data():
"""Setup test data before each test session"""
subprocess.run(["uv", "run", "manage.py", "create_test_users"], check=True)
yield
subprocess.run(["uv", "run", "manage.py", "cleanup_test_data"], check=True)
@pytest.fixture(autouse=True)
def setup_page(page: Page):
"""Configure page for tests"""
# Set viewport size
page.set_viewport_size({"width": 1280, "height": 720})
# Set default navigation timeout
page.set_default_timeout(5000)
# Listen for console errors
page.on(
"console",
lambda msg: (
print(f"Browser console {msg.type}: {msg.text}")
if msg.type == "error"
else None
),
)
yield page
@pytest.fixture
def auth_page(page: Page):
"""Fixture for authenticated page"""
# Login
page.goto("http://localhost:8000/accounts/login/")
page.get_by_label("Username").fill("testuser")
page.get_by_label("Password").fill("testpass123")
page.get_by_role("button", name="Sign In").click()
yield page
@pytest.fixture
def mod_page(page: Page):
"""Fixture for moderator page"""
# Login as moderator
page.goto("http://localhost:8000/accounts/login/")
page.get_by_label("Username").fill("moderator")
page.get_by_label("Password").fill("modpass123")
page.get_by_role("button", name="Sign In").click()
yield page
@pytest.fixture
def test_park(auth_page: Page):
"""Fixture for test park"""
# Create test park
auth_page.goto("http://localhost:8000/parks/create/")
auth_page.get_by_label("Name").fill("Test Park")
auth_page.get_by_label("Location").fill("Orlando, FL")
auth_page.get_by_label("Description").fill("A test theme park")
auth_page.get_by_label("Photo").set_input_files("tests/fixtures/test_photo.jpg")
auth_page.get_by_role("button", name="Create Park").click()
yield auth_page
@pytest.fixture
def test_ride(test_park: Page):
"""Fixture for test ride"""
# Create test ride
test_park.goto("http://localhost:8000/rides/create/")
test_park.get_by_label("Name").fill("Test Ride")
test_park.get_by_label("Park").select_option("Test Park")
test_park.get_by_label("Type").select_option("Roller Coaster")
test_park.get_by_label("Description").fill("A test ride")
test_park.get_by_label("Photo").set_input_files("tests/fixtures/test_photo.jpg")
test_park.get_by_role("button", name="Create Ride").click()
yield test_park
@pytest.fixture
def test_review(test_park: Page):
"""Fixture for test review"""
# Create test review
test_park.goto("http://localhost:8000/parks/test-park/")
test_park.get_by_role("tab", name="Reviews").click()
test_park.get_by_role("button", name="Write Review").click()
test_park.get_by_label("Rating").select_option("5")
test_park.get_by_label("Title").fill("Test Review")
test_park.get_by_label("Review").fill("This is a test review")
test_park.get_by_role("button", name="Submit Review").click()
yield test_park

View File

@@ -1,28 +0,0 @@
[pytest]
# Base URL for tests
base_url = http://localhost:8000
# Test file patterns
python_files = test_*.py
python_classes = Test*
python_functions = test_*
# Playwright specific settings
addopts = --headed --browser chromium
# Markers
markers =
auth: authentication related tests
parks: theme park related tests
rides: ride related tests
reviews: review related tests
profiles: user profile related tests
# Test timeout
timeout = 30
# Logging settings
log_cli = true
log_cli_level = INFO
log_cli_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)
log_cli_date_format = %Y-%m-%d %H:%M:%S

View File

@@ -1,55 +0,0 @@
#!/bin/bash
set -e # Exit on error
# Function to check command exists
check_command() {
if ! command -v $1 &> /dev/null; then
echo "Error: $1 is required but not installed."
exit 1
fi
}
# Check required commands
check_command uv
check_command curl
check_command playwright
# Clean up any existing test data
echo "Cleaning up any existing test data..."
uv run manage.py cleanup_test_data || true
# Install Python dependencies
echo "Installing Python dependencies..."
uv pip install -r requirements.txt
# Install Playwright browsers
echo "Installing Playwright browsers..."
playwright install chromium firefox webkit
# Create test fixtures directory
echo "Setting up test fixtures..."
mkdir -p tests/fixtures
# Download test images
echo "Downloading test images..."
curl -L "https://picsum.photos/1920/1080" -o tests/fixtures/test_photo.jpg
curl -L "https://picsum.photos/500/500" -o tests/fixtures/test_avatar.jpg
# Verify images were downloaded
if [ ! -f tests/fixtures/test_photo.jpg ] || [ ! -f tests/fixtures/test_avatar.jpg ]; then
echo "Error: Failed to download test images"
exit 1
fi
# Create test users
echo "Creating test users..."
uv run manage.py create_test_users
# Make cleanup script executable
chmod +x tests/e2e/cleanup.sh
echo "Setup complete! You can now:"
echo "1. Run all tests: pytest tests/e2e/"
echo "2. Run specific tests: pytest tests/e2e/test_auth.py"
echo "3. Run with specific browser: pytest --browser firefox tests/e2e/"
echo "4. Clean up test data: ./tests/e2e/cleanup.sh"

View File

@@ -1,91 +0,0 @@
from playwright.sync_api import expect, Page
def test_login_page(page: Page):
# Navigate to login page
page.goto("http://localhost:8000/accounts/login/")
# Check login form elements
expect(page.get_by_label("Username")).to_be_visible()
expect(page.get_by_label("Password")).to_be_visible()
expect(page.get_by_role("button", name="Sign In")).to_be_visible()
# Check social login buttons
expect(page.get_by_role("link", name="Sign in with Google")).to_be_visible()
expect(page.get_by_role("link", name="Sign in with Discord")).to_be_visible()
def test_successful_login(page: Page):
# Navigate to login page
page.goto("http://localhost:8000/accounts/login/")
# Fill in login form
page.get_by_label("Username").fill("testuser")
page.get_by_label("Password").fill("testpass123")
# Click login button
page.get_by_role("button", name="Sign In").click()
# Verify redirect to home page
expect(page).to_have_url("http://localhost:8000/")
expect(page.get_by_role("link", name="Profile")).to_be_visible()
def test_failed_login(page: Page):
# Navigate to login page
page.goto("http://localhost:8000/accounts/login/")
# Fill in incorrect credentials
page.get_by_label("Username").fill("wronguser")
page.get_by_label("Password").fill("wrongpass")
# Click login button
page.get_by_role("button", name="Sign In").click()
# Verify error message
expect(page.get_by_text("Invalid username or password")).to_be_visible()
def test_signup_page(page: Page):
# Navigate to signup page
page.goto("http://localhost:8000/accounts/signup/")
# Check signup form elements
expect(page.get_by_label("Username")).to_be_visible()
expect(page.get_by_label("Email")).to_be_visible()
expect(page.get_by_label("Password")).to_be_visible()
expect(page.get_by_label("Password (again)")).to_be_visible()
expect(page.get_by_role("button", name="Sign Up")).to_be_visible()
def test_successful_signup(page: Page):
# Navigate to signup page
page.goto("http://localhost:8000/accounts/signup/")
# Fill in signup form
page.get_by_label("Username").fill("newuser")
page.get_by_label("Email").fill("newuser@example.com")
page.get_by_label("Password").fill("newpass123")
page.get_by_label("Password (again)").fill("newpass123")
# Click signup button
page.get_by_role("button", name="Sign Up").click()
# Verify redirect to home page
expect(page).to_have_url("http://localhost:8000/")
expect(page.get_by_role("link", name="Profile")).to_be_visible()
def test_logout(page: Page):
# First login
page.goto("http://localhost:8000/accounts/login/")
page.get_by_label("Username").fill("testuser")
page.get_by_label("Password").fill("testpass123")
page.get_by_role("button", name="Sign In").click()
# Click logout
page.get_by_role("link", name="Logout").click()
# Verify redirect to home page and logged out state
expect(page).to_have_url("http://localhost:8000/")
expect(page.get_by_role("link", name="Login")).to_be_visible()

View File

@@ -1,130 +0,0 @@
from playwright.sync_api import expect, Page
def test_parks_list_page(page: Page):
# Navigate to parks page
page.goto("http://localhost:8000/parks/")
# Check parks list elements
expect(page.get_by_role("heading", name="Theme Parks")).to_be_visible()
expect(page.get_by_role("searchbox", name="Search parks")).to_be_visible()
# Check filter options
expect(page.get_by_role("combobox", name="Country")).to_be_visible()
expect(page.get_by_role("combobox", name="State/Region")).to_be_visible()
def test_park_search(page: Page):
# Navigate to parks page
page.goto("http://localhost:8000/parks/")
# Search for a park
search_box = page.get_by_role("searchbox", name="Search parks")
search_box.fill("Universal")
search_box.press("Enter")
# Verify search results
expect(page.get_by_text("Universal Studios")).to_be_visible()
expect(page.get_by_text("Universal's Islands of Adventure")).to_be_visible()
def test_park_filters(page: Page):
# Navigate to parks page
page.goto("http://localhost:8000/parks/")
# Select country filter
page.get_by_role("combobox", name="Country").select_option("United States")
# Select state filter
page.get_by_role("combobox", name="State/Region").select_option("Florida")
# Verify filtered results
expect(page.get_by_text("Walt Disney World")).to_be_visible()
expect(page.get_by_text("Universal Orlando Resort")).to_be_visible()
def test_park_detail_page(page: Page):
# Navigate to a specific park page
page.goto("http://localhost:8000/parks/walt-disney-world/")
# Check park details
expect(page.get_by_role("heading", name="Walt Disney World")).to_be_visible()
expect(page.get_by_text("Location:")).to_be_visible()
expect(page.get_by_text("Orlando, Florida")).to_be_visible()
# Check park sections
expect(page.get_by_role("tab", name="Overview")).to_be_visible()
expect(page.get_by_role("tab", name="Rides")).to_be_visible()
expect(page.get_by_role("tab", name="Reviews")).to_be_visible()
expect(page.get_by_role("tab", name="Photos")).to_be_visible()
def test_add_park_review(page: Page):
# First login
page.goto("http://localhost:8000/accounts/login/")
page.get_by_label("Username").fill("testuser")
page.get_by_label("Password").fill("testpass123")
page.get_by_role("button", name="Sign In").click()
# Navigate to park page
page.goto("http://localhost:8000/parks/walt-disney-world/")
# Click on Reviews tab
page.get_by_role("tab", name="Reviews").click()
# Click Write Review button
page.get_by_role("button", name="Write Review").click()
# Fill review form
page.get_by_label("Rating").select_option("5")
page.get_by_label("Title").fill("Amazing Experience")
page.get_by_label("Review").fill("Had a fantastic time at the park!")
# Submit review
page.get_by_role("button", name="Submit Review").click()
# Verify review appears
expect(page.get_by_text("Amazing Experience")).to_be_visible()
expect(page.get_by_text("Had a fantastic time at the park!")).to_be_visible()
def test_add_park_photo(page: Page):
# First login
page.goto("http://localhost:8000/accounts/login/")
page.get_by_label("Username").fill("testuser")
page.get_by_label("Password").fill("testpass123")
page.get_by_role("button", name="Sign In").click()
# Navigate to park page
page.goto("http://localhost:8000/parks/walt-disney-world/")
# Click on Photos tab
page.get_by_role("tab", name="Photos").click()
# Click Add Photo button
page.get_by_role("button", name="Add Photo").click()
# Upload photo
page.get_by_label("Photo").set_input_files("tests/fixtures/test_photo.jpg")
page.get_by_label("Caption").fill("Beautiful castle at sunset")
# Submit photo
page.get_by_role("button", name="Upload Photo").click()
# Verify photo appears
expect(page.get_by_text("Beautiful castle at sunset")).to_be_visible()
def test_park_map(page: Page):
# Navigate to park page
page.goto("http://localhost:8000/parks/walt-disney-world/")
# Check map exists
expect(page.locator("#park-map")).to_be_visible()
# Check map controls
expect(page.get_by_role("button", name="Zoom in")).to_be_visible()
expect(page.get_by_role("button", name="Zoom out")).to_be_visible()
# Verify map markers
expect(page.locator(".map-marker")).to_have_count.greater_than(0)

View File

@@ -1,171 +0,0 @@
from playwright.sync_api import expect, Page
def test_profile_page(page: Page):
# First login
page.goto("http://localhost:8000/accounts/login/")
page.get_by_label("Username").fill("testuser")
page.get_by_label("Password").fill("testpass123")
page.get_by_role("button", name="Sign In").click()
# Navigate to profile
page.get_by_role("link", name="Profile").click()
# Check profile sections
expect(page.get_by_role("heading", name="Profile")).to_be_visible()
expect(page.get_by_role("tab", name="Overview")).to_be_visible()
expect(page.get_by_role("tab", name="Reviews")).to_be_visible()
expect(page.get_by_role("tab", name="Photos")).to_be_visible()
expect(page.get_by_role("tab", name="Settings")).to_be_visible()
def test_edit_profile(page: Page):
# First login
page.goto("http://localhost:8000/accounts/login/")
page.get_by_label("Username").fill("testuser")
page.get_by_label("Password").fill("testpass123")
page.get_by_role("button", name="Sign In").click()
# Navigate to profile settings
page.get_by_role("link", name="Profile").click()
page.get_by_role("tab", name="Settings").click()
# Edit profile information
page.get_by_label("Display Name").fill("Test User")
page.get_by_label("Bio").fill("Theme park enthusiast")
page.get_by_label("Location").fill("Orlando, FL")
# Upload avatar
page.get_by_label("Avatar").set_input_files("tests/fixtures/test_avatar.jpg")
# Save changes
page.get_by_role("button", name="Save Changes").click()
# Verify updates
expect(page.get_by_text("Profile updated successfully")).to_be_visible()
expect(page.get_by_text("Test User")).to_be_visible()
expect(page.get_by_text("Theme park enthusiast")).to_be_visible()
expect(page.get_by_text("Orlando, FL")).to_be_visible()
def test_change_password(page: Page):
# First login
page.goto("http://localhost:8000/accounts/login/")
page.get_by_label("Username").fill("testuser")
page.get_by_label("Password").fill("testpass123")
page.get_by_role("button", name="Sign In").click()
# Navigate to profile settings
page.get_by_role("link", name="Profile").click()
page.get_by_role("tab", name="Settings").click()
# Click change password
page.get_by_role("link", name="Change Password").click()
# Fill password form
page.get_by_label("Current Password").fill("testpass123")
page.get_by_label("New Password").fill("newpass123")
page.get_by_label("Confirm New Password").fill("newpass123")
# Submit form
page.get_by_role("button", name="Change Password").click()
# Verify password changed
expect(page.get_by_text("Password changed successfully")).to_be_visible()
def test_email_preferences(page: Page):
# First login
page.goto("http://localhost:8000/accounts/login/")
page.get_by_label("Username").fill("testuser")
page.get_by_label("Password").fill("testpass123")
page.get_by_role("button", name="Sign In").click()
# Navigate to profile settings
page.get_by_role("link", name="Profile").click()
page.get_by_role("tab", name="Settings").click()
# Click email preferences
page.get_by_role("link", name="Email Preferences").click()
# Update preferences
page.get_by_label("Newsletter").check()
page.get_by_label("Review Notifications").check()
page.get_by_label("Photo Comments").uncheck()
# Save changes
page.get_by_role("button", name="Save Preferences").click()
# Verify updates
expect(page.get_by_text("Email preferences updated")).to_be_visible()
def test_privacy_settings(page: Page):
# First login
page.goto("http://localhost:8000/accounts/login/")
page.get_by_label("Username").fill("testuser")
page.get_by_label("Password").fill("testpass123")
page.get_by_role("button", name="Sign In").click()
# Navigate to profile settings
page.get_by_role("link", name="Profile").click()
page.get_by_role("tab", name="Settings").click()
# Click privacy settings
page.get_by_role("link", name="Privacy Settings").click()
# Update settings
page.get_by_label("Show Email").uncheck()
page.get_by_label("Show Location").check()
page.get_by_label("Public Profile").check()
# Save changes
page.get_by_role("button", name="Save Privacy Settings").click()
# Verify updates
expect(page.get_by_text("Privacy settings updated")).to_be_visible()
def test_connected_accounts(page: Page):
# First login
page.goto("http://localhost:8000/accounts/login/")
page.get_by_label("Username").fill("testuser")
page.get_by_label("Password").fill("testpass123")
page.get_by_role("button", name="Sign In").click()
# Navigate to profile settings
page.get_by_role("link", name="Profile").click()
page.get_by_role("tab", name="Settings").click()
# Click connected accounts
page.get_by_role("link", name="Connected Accounts").click()
# Check available connections
expect(page.get_by_role("link", name="Connect Google")).to_be_visible()
expect(page.get_by_role("link", name="Connect Discord")).to_be_visible()
def test_delete_account(page: Page):
# First login
page.goto("http://localhost:8000/accounts/login/")
page.get_by_label("Username").fill("testuser")
page.get_by_label("Password").fill("testpass123")
page.get_by_role("button", name="Sign In").click()
# Navigate to profile settings
page.get_by_role("link", name="Profile").click()
page.get_by_role("tab", name="Settings").click()
# Click delete account
page.get_by_role("link", name="Delete Account").click()
# Confirm deletion
page.get_by_label("Password").fill("testpass123")
page.get_by_label("Confirm").check()
# Click delete button
page.get_by_role("button", name="Delete Account").click()
# Verify redirect to home and logged out
expect(page).to_have_url("http://localhost:8000/")
expect(page.get_by_role("link", name="Login")).to_be_visible()

View File

@@ -1,160 +0,0 @@
from playwright.sync_api import expect, Page
def test_reviews_list_page(page: Page):
# Navigate to reviews page
page.goto("http://localhost:8000/reviews/")
# Check reviews list elements
expect(page.get_by_role("heading", name="Latest Reviews")).to_be_visible()
expect(page.get_by_role("searchbox", name="Search reviews")).to_be_visible()
# Check filter options
expect(page.get_by_role("combobox", name="Type")).to_be_visible()
expect(page.get_by_role("combobox", name="Rating")).to_be_visible()
expect(page.get_by_role("combobox", name="Sort By")).to_be_visible()
def test_review_search(page: Page):
# Navigate to reviews page
page.goto("http://localhost:8000/reviews/")
# Search for reviews
search_box = page.get_by_role("searchbox", name="Search reviews")
search_box.fill("great experience")
search_box.press("Enter")
# Verify search results
expect(page.get_by_text("great experience", exact=False)).to_be_visible()
def test_review_filters(page: Page):
# Navigate to reviews page
page.goto("http://localhost:8000/reviews/")
# Select type filter
page.get_by_role("combobox", name="Type").select_option("Parks")
# Select rating filter
page.get_by_role("combobox", name="Rating").select_option("5 Stars")
# Select sort order
page.get_by_role("combobox", name="Sort By").select_option("Most Recent")
# Verify filtered results
expect(page.get_by_text("Park Review")).to_be_visible()
expect(page.locator(".five-star-rating")).to_be_visible()
def test_review_detail_page(page: Page):
# Navigate to a specific review
page.goto("http://localhost:8000/reviews/1/")
# Check review details
expect(page.get_by_role("heading", name="Review")).to_be_visible()
expect(page.locator(".review-rating")).to_be_visible()
expect(page.locator(".review-date")).to_be_visible()
expect(page.locator(".review-author")).to_be_visible()
expect(page.locator(".review-content")).to_be_visible()
def test_review_voting(page: Page):
# First login
page.goto("http://localhost:8000/accounts/login/")
page.get_by_label("Username").fill("testuser")
page.get_by_label("Password").fill("testpass123")
page.get_by_role("button", name="Sign In").click()
# Navigate to review
page.goto("http://localhost:8000/reviews/1/")
# Click helpful button
page.get_by_role("button", name="Helpful").click()
# Verify vote registered
expect(page.get_by_text("You found this review helpful")).to_be_visible()
expect(page.locator(".helpful-count")).to_contain_text("1")
def test_review_comments(page: Page):
# First login
page.goto("http://localhost:8000/accounts/login/")
page.get_by_label("Username").fill("testuser")
page.get_by_label("Password").fill("testpass123")
page.get_by_role("button", name="Sign In").click()
# Navigate to review
page.goto("http://localhost:8000/reviews/1/")
# Add comment
page.get_by_label("Comment").fill("Great review! Very helpful.")
page.get_by_role("button", name="Post Comment").click()
# Verify comment appears
expect(page.get_by_text("Great review! Very helpful.")).to_be_visible()
def test_review_moderation(page: Page):
# First login as moderator
page.goto("http://localhost:8000/accounts/login/")
page.get_by_label("Username").fill("moderator")
page.get_by_label("Password").fill("modpass123")
page.get_by_role("button", name="Sign In").click()
# Navigate to review
page.goto("http://localhost:8000/reviews/1/")
# Check moderation options
expect(page.get_by_role("button", name="Edit Review")).to_be_visible()
expect(page.get_by_role("button", name="Delete Review")).to_be_visible()
expect(page.get_by_role("button", name="Flag Review")).to_be_visible()
def test_review_reporting(page: Page):
# First login
page.goto("http://localhost:8000/accounts/login/")
page.get_by_label("Username").fill("testuser")
page.get_by_label("Password").fill("testpass123")
page.get_by_role("button", name="Sign In").click()
# Navigate to review
page.goto("http://localhost:8000/reviews/1/")
# Click report button
page.get_by_role("button", name="Report Review").click()
# Fill report form
page.get_by_label("Reason").select_option("inappropriate")
page.get_by_label("Details").fill("This review contains inappropriate content")
# Submit report
page.get_by_role("button", name="Submit Report").click()
# Verify report confirmation
expect(page.get_by_text("Review reported successfully")).to_be_visible()
def test_review_editing(page: Page):
# First login as review author
page.goto("http://localhost:8000/accounts/login/")
page.get_by_label("Username").fill("testuser")
page.get_by_label("Password").fill("testpass123")
page.get_by_role("button", name="Sign In").click()
# Navigate to own review
page.goto("http://localhost:8000/reviews/1/")
# Click edit button
page.get_by_role("button", name="Edit Review").click()
# Modify review
page.get_by_label("Title").fill("Updated Review Title")
page.get_by_label("Review").fill("Updated review content")
# Save changes
page.get_by_role("button", name="Save Changes").click()
# Verify updates
expect(page.get_by_text("Updated Review Title")).to_be_visible()
expect(page.get_by_text("Updated review content")).to_be_visible()
expect(page.get_by_text("(edited)")).to_be_visible()

View File

@@ -1,165 +0,0 @@
from playwright.sync_api import expect, Page
def test_rides_list_page(page: Page):
# Navigate to rides page
page.goto("http://localhost:8000/rides/")
# Check rides list elements
expect(page.get_by_role("heading", name="Rides & Attractions")).to_be_visible()
expect(page.get_by_role("searchbox", name="Search rides")).to_be_visible()
# Check filter options
expect(page.get_by_role("combobox", name="Park")).to_be_visible()
expect(page.get_by_role("combobox", name="Type")).to_be_visible()
expect(page.get_by_role("combobox", name="Manufacturer")).to_be_visible()
expect(page.get_by_role("combobox", name="Status")).to_be_visible()
def test_ride_search(page: Page):
# Navigate to rides page
page.goto("http://localhost:8000/rides/")
# Search for a ride
search_box = page.get_by_role("searchbox", name="Search rides")
search_box.fill("Space Mountain")
search_box.press("Enter")
# Verify search results
expect(page.get_by_text("Space Mountain")).to_be_visible()
expect(page.get_by_text("Walt Disney World")).to_be_visible()
def test_ride_filters(page: Page):
# Navigate to rides page
page.goto("http://localhost:8000/rides/")
# Select park filter
page.get_by_role("combobox", name="Park").select_option("Walt Disney World")
# Select type filter
page.get_by_role("combobox", name="Type").select_option("Roller Coaster")
# Select manufacturer filter
page.get_by_role("combobox", name="Manufacturer").select_option("Vekoma")
# Verify filtered results
expect(page.get_by_text("Space Mountain")).to_be_visible()
expect(page.get_by_text("Roller Coaster")).to_be_visible()
expect(page.get_by_text("Vekoma")).to_be_visible()
def test_ride_detail_page(page: Page):
# Navigate to a specific ride page
page.goto("http://localhost:8000/rides/space-mountain-magic-kingdom/")
# Check ride details
expect(page.get_by_role("heading", name="Space Mountain")).to_be_visible()
expect(page.get_by_text("Park:")).to_be_visible()
expect(page.get_by_text("Walt Disney World")).to_be_visible()
expect(page.get_by_text("Type:")).to_be_visible()
expect(page.get_by_text("Roller Coaster")).to_be_visible()
expect(page.get_by_text("Manufacturer:")).to_be_visible()
expect(page.get_by_text("Vekoma")).to_be_visible()
# Check ride sections
expect(page.get_by_role("tab", name="Overview")).to_be_visible()
expect(page.get_by_role("tab", name="Stats")).to_be_visible()
expect(page.get_by_role("tab", name="Reviews")).to_be_visible()
expect(page.get_by_role("tab", name="Photos")).to_be_visible()
def test_ride_stats(page: Page):
# Navigate to ride page
page.goto("http://localhost:8000/rides/space-mountain-magic-kingdom/")
# Click on Stats tab
page.get_by_role("tab", name="Stats").click()
# Check stats are visible
expect(page.get_by_text("Height:")).to_be_visible()
expect(page.get_by_text("Length:")).to_be_visible()
expect(page.get_by_text("Speed:")).to_be_visible()
expect(page.get_by_text("Duration:")).to_be_visible()
expect(page.get_by_text("Height Requirement:")).to_be_visible()
def test_add_ride_review(page: Page):
# First login
page.goto("http://localhost:8000/accounts/login/")
page.get_by_label("Username").fill("testuser")
page.get_by_label("Password").fill("testpass123")
page.get_by_role("button", name="Sign In").click()
# Navigate to ride page
page.goto("http://localhost:8000/rides/space-mountain-magic-kingdom/")
# Click on Reviews tab
page.get_by_role("tab", name="Reviews").click()
# Click Write Review button
page.get_by_role("button", name="Write Review").click()
# Fill review form
page.get_by_label("Rating").select_option("5")
page.get_by_label("Title").fill("Best Coaster Ever")
page.get_by_label("Review").fill("Such a thrilling experience in the dark!")
# Submit review
page.get_by_role("button", name="Submit Review").click()
# Verify review appears
expect(page.get_by_text("Best Coaster Ever")).to_be_visible()
expect(page.get_by_text("Such a thrilling experience in the dark!")).to_be_visible()
def test_add_ride_photo(page: Page):
# First login
page.goto("http://localhost:8000/accounts/login/")
page.get_by_label("Username").fill("testuser")
page.get_by_label("Password").fill("testpass123")
page.get_by_role("button", name="Sign In").click()
# Navigate to ride page
page.goto("http://localhost:8000/rides/space-mountain-magic-kingdom/")
# Click on Photos tab
page.get_by_role("tab", name="Photos").click()
# Click Add Photo button
page.get_by_role("button", name="Add Photo").click()
# Upload photo
page.get_by_label("Photo").set_input_files("tests/fixtures/test_photo.jpg")
page.get_by_label("Caption").fill("Awesome ride entrance")
# Submit photo
page.get_by_role("button", name="Upload Photo").click()
# Verify photo appears
expect(page.get_by_text("Awesome ride entrance")).to_be_visible()
def test_ride_wait_times(page: Page):
# Navigate to ride page
page.goto("http://localhost:8000/rides/space-mountain-magic-kingdom/")
# Check wait time section
expect(page.get_by_text("Current Wait Time:")).to_be_visible()
expect(page.get_by_text("minutes")).to_be_visible()
# Check historical wait times
expect(page.get_by_text("Average Wait Times")).to_be_visible()
expect(page.locator("#wait-time-chart")).to_be_visible()
def test_ride_location(page: Page):
# Navigate to ride page
page.goto("http://localhost:8000/rides/space-mountain-magic-kingdom/")
# Check location section
expect(page.get_by_text("Location in Park")).to_be_visible()
expect(page.locator("#ride-location-map")).to_be_visible()
# Verify map marker
expect(page.locator(".ride-marker")).to_be_visible()