🎯 Overview: Implemented complete VPS-based storage system allowing the iOS app to download and store manga chapters on the VPS for ad-free offline reading. 📦 Backend Changes: - Added storage.js service for managing chapter downloads (270 lines) - Updated server.js with 6 new storage endpoints: - POST /api/download - Download chapters to VPS - GET /api/storage/chapters/:mangaSlug - List downloaded chapters - GET /api/storage/chapter/:mangaSlug/:chapterNumber - Check download status - GET /api/storage/image/:mangaSlug/:chapterNumber/:pageIndex - Serve images - DELETE /api/storage/chapter/:mangaSlug/:chapterNumber - Delete chapters - GET /api/storage/stats - Get storage statistics - Fixed scraper.js Puppeteer compatibility issues (waitForTimeout, networkidle0) - Added comprehensive test suite: - test-vps-flow.js (13 tests - 100% pass rate) - test-concurrent-downloads.js (10 tests for parallel operations) - run-tests.sh automation script 📱 iOS App Changes: - Created APIConfig.swift with VPS connection settings - Created VPSAPIClient.swift service (727 lines) for backend communication - Updated MangaDetailView.swift with VPS download integration: - Cloud icon for VPS-available chapters - Upload button to download chapters to VPS - Progress indicators for active downloads - Bulk download options (last 10 or all chapters) - Updated ReaderView.swift to load images from VPS first - Progressive enhancement: app works without VPS, enhances when available ✅ Tests: - All 13 VPS flow tests passing (100%) - Tests verify: scraping, downloading, storage, serving, deletion, stats - Chapter 789 download test: 21 images, 4.68 MB - Concurrent download tests verify no race conditions 🔧 Configuration: - VPS URL: https://gitea.cbcren.online:3001 - Storage location: /home/ren/ios/MangaReader/storage/ - Static file serving: /storage path 📚 Documentation: - Added VPS_INTEGRATION_SUMMARY.md - Complete feature overview - Added CHANGES.md - Detailed code changes reference - Added TEST_README.md, TEST_QUICK_START.md, TEST_SUMMARY.md - Added APIConfig README with usage examples 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
3.5 KiB
3.5 KiB
Quick Start Guide: Integration Tests
Prerequisites
# Install dependencies (if not already installed)
cd /home/ren/ios/MangaReader/backend
npm install
Method 1: Using npm scripts (Recommended)
Run individual tests:
# 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:
npm run test:clean
Method 2: Using the test runner script
Basic commands:
# 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):
./run-tests.sh start && ./run-tests.sh all && ./run-tests.sh cleanup && ./run-tests.sh stop
Method 3: Manual execution
# 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:
lsof -ti:3000 | xargs kill -9
Server not responding:
# Check if server is running
./run-tests.sh status
# View logs
./run-tests.sh logs
Clean everything and start fresh:
# 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
# Show test runner help
./run-tests.sh help
# View detailed documentation
cat TEST_README.md
Next Steps
After tests pass:
- ✓ Verify storage directory structure
- ✓ Check image quality in downloaded chapters
- ✓ Monitor storage stats in production
- ✓ 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 imagesmanifest.json- Chapter metadata and image list