|
| 1 | +# End-to-End Tests for Tailspin Shelter |
| 2 | + |
| 3 | +This directory contains Playwright end-to-end tests for the Tailspin Shelter website. |
| 4 | + |
| 5 | +## Test Files |
| 6 | + |
| 7 | +- `homepage.spec.ts` - Tests for the main homepage functionality |
| 8 | +- `about.spec.ts` - Tests for the about page |
| 9 | +- `dog-details.spec.ts` - Tests for individual dog detail pages |
| 10 | +- `api-integration.spec.ts` - Tests for API integration and error handling |
| 11 | + |
| 12 | +## Running Tests |
| 13 | + |
| 14 | +### Prerequisites |
| 15 | + |
| 16 | +Make sure you have installed dependencies: |
| 17 | +```bash |
| 18 | +npm install |
| 19 | +``` |
| 20 | + |
| 21 | +You also need Python 3 with Flask dependencies installed: |
| 22 | +```bash |
| 23 | +pip install -r ../server/requirements.txt |
| 24 | +``` |
| 25 | + |
| 26 | +### Running Tests |
| 27 | + |
| 28 | +```bash |
| 29 | +# Run all tests |
| 30 | +npm run test:e2e |
| 31 | + |
| 32 | +# Run tests with UI mode (for debugging) |
| 33 | +npm run test:e2e:ui |
| 34 | + |
| 35 | +# Run tests in headed mode (see browser) |
| 36 | +npm run test:e2e:headed |
| 37 | + |
| 38 | +# Debug tests |
| 39 | +npm run test:e2e:debug |
| 40 | +``` |
| 41 | + |
| 42 | +## Test Architecture |
| 43 | + |
| 44 | +Tests run against the real Flask server with a separate test database seeded with deterministic data. When Playwright starts, it: |
| 45 | + |
| 46 | +1. Seeds a test database (`e2e_test_dogshelter.db` in the server directory) with known dogs and breeds |
| 47 | +2. Starts the Flask server using the test database |
| 48 | +3. Starts the Astro dev server pointing at the Flask server |
| 49 | +4. Runs all e2e tests against the live application |
| 50 | + |
| 51 | +The test data is defined in `../server/utils/seed_test_database.py`. |
| 52 | + |
| 53 | +## Test Coverage |
| 54 | + |
| 55 | +The tests cover the following core functionality: |
| 56 | + |
| 57 | +### Homepage Tests |
| 58 | +- Page loads with correct title and content |
| 59 | +- Dog list displays properly |
| 60 | + |
| 61 | +### About Page Tests |
| 62 | +- About page content displays correctly |
| 63 | +- Navigation back to homepage works |
| 64 | + |
| 65 | +### Dog Details Tests |
| 66 | +- Navigation from homepage to dog details |
| 67 | +- Full dog details display correctly |
| 68 | +- Navigation back from dog details to homepage |
| 69 | +- Handling of invalid dog IDs |
| 70 | + |
| 71 | +### API Integration Tests |
| 72 | +- Dogs render correctly on the homepage |
| 73 | +- Dog details render correctly |
| 74 | +- 404 handling for non-existent dogs |
| 75 | +- Navigation from card to detail page |
| 76 | + |
| 77 | +## Configuration |
| 78 | + |
| 79 | +Tests are configured in `../playwright.config.ts` and automatically start the Flask and Astro servers before running tests. |
| 80 | + |
| 81 | +The tests run against: |
| 82 | +- Client (Astro): http://localhost:4321 |
| 83 | +- Server (Flask): http://localhost:5100 |
0 commit comments