# Quick Start Guide: Integration Tests ## Prerequisites ```bash # Install dependencies (if not already installed) cd /home/ren/ios/MangaReader/backend npm install ``` ## Method 1: Using npm scripts (Recommended) ### Run individual tests: ```bash # Terminal 1: Start server npm start # Terminal 2: Run VPS flow test npm run test:vps # Terminal 3: Run concurrent downloads test npm run test:concurrent ``` ### Clean up test data: ```bash npm run test:clean ``` ## Method 2: Using the test runner script ### Basic commands: ```bash # Start server in background ./run-tests.sh start # Check server status ./run-tests.sh status # View server logs ./run-tests.sh logs # Run VPS flow test ./run-tests.sh vps-flow # Run concurrent downloads test ./run-tests.sh concurrent # Run all tests ./run-tests.sh all # Clean up test data ./run-tests.sh cleanup # Stop server ./run-tests.sh stop ``` ### Complete workflow (one command): ```bash ./run-tests.sh start && ./run-tests.sh all && ./run-tests.sh cleanup && ./run-tests.sh stop ``` ## Method 3: Manual execution ```bash # Terminal 1: Start server node server.js # Terminal 2: Run VPS flow test node test-vps-flow.js # Terminal 3: Run concurrent downloads test node test-concurrent-downloads.js ``` ## What Gets Tested ### VPS Flow Test (`test-vps-flow.js`) - ✓ Server health check - ✓ Chapter image scraping - ✓ Download to VPS storage - ✓ File verification - ✓ Storage statistics - ✓ Chapter deletion - ✓ Complete cleanup ### Concurrent Downloads Test (`test-concurrent-downloads.js`) - ✓ 5 chapters downloaded concurrently - ✓ No race conditions - ✓ No file corruption - ✓ Independent manifests - ✓ Concurrent deletion - ✓ Thread-safe operations ## Expected Output ### Success: ``` ✓ ALL TESTS PASSED ✓ No race conditions detected ✓ No file corruption found ✓ Storage handles concurrent access properly ``` ### Test Results: ``` Total Tests: 11 Passed: 11 Failed: 0 ``` ## Troubleshooting ### Port already in use: ```bash lsof -ti:3000 | xargs kill -9 ``` ### Server not responding: ```bash # Check if server is running ./run-tests.sh status # View logs ./run-tests.sh logs ``` ### Clean everything and start fresh: ```bash # Stop server ./run-tests.sh stop # Clean test data ./run-tests.sh cleanup # Remove logs rm -rf logs/ # Start fresh ./run-tests.sh start ``` ## Test Duration - **VPS Flow Test**: ~2-3 minutes - **Concurrent Test**: ~3-5 minutes Total time: ~5-8 minutes for both tests ## Files Created | File | Purpose | |------|---------| | `test-vps-flow.js` | End-to-end VPS flow tests | | `test-concurrent-downloads.js` | Concurrent download tests | | `run-tests.sh` | Test automation script | | `TEST_README.md` | Detailed documentation | | `TEST_QUICK_START.md` | This quick reference | ## Getting Help ```bash # Show test runner help ./run-tests.sh help # View detailed documentation cat TEST_README.md ``` ## Next Steps After tests pass: 1. ✓ Verify storage directory structure 2. ✓ Check image quality in downloaded chapters 3. ✓ Monitor storage stats in production 4. ✓ Set up CI/CD integration (see TEST_README.md) ## Storage Location Downloaded test chapters are stored in: ``` /home/ren/ios/MangaReader/storage/manga/one-piece_1695365223767/ ├── chapter_787/ ├── chapter_788/ ├── chapter_789/ ├── chapter_790/ └── chapter_791/ ``` Each chapter contains: - `page_001.jpg`, `page_002.jpg`, etc. - Downloaded images - `manifest.json` - Chapter metadata and image list