Mercurial
diff mrjunejune/test/README.md @ 94:092afa595764
[MrJuneJune] Added Integration tests.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Fri, 02 Jan 2026 18:13:32 -0800 |
| parents | |
| children | 1c446ab6f945 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mrjunejune/test/README.md Fri Jan 02 18:13:32 2026 -0800 @@ -0,0 +1,115 @@ +# MrJuneJune Integration Tests + +This directory contains comprehensive integration tests for all mrjunejune endpoints. + +## Test Structure + +### Test Files +- `integration_test.c` - Main integration test suite +- `create_snapshots.c` - Utility to generate/update snapshot files +- `shiba.webp` - Test image for image-to-webp conversion +- `test_avi.avi` - Test video for video-to-mp4 conversion + +### Snapshot Directory +- `snapshots/` - Contains expected HTTP responses for GET endpoints + +## Endpoints Tested + +### GET Endpoints (200 OK with Snapshot Verification) +- `/` - Home page +- `/resume` - Resume page +- `/tools` - Tools page +- `/tools/markdown_to_html` - Markdown to HTML converter +- `/tools/file_converter` - File converter tool + +### GET Endpoints (301 Redirects) +- `/index.html` → `/` +- `/resume/index.html` → `/resume` +- `/tools/index.html` → `/tools` +- `/tools/markdown_to_html/index.html` → `/tools/markdown_to_html` +- `/tools/file_converter/index.html` → `/tools/file_converter` + +### GET Endpoints (404 Not Found) +- `/nonexistent` +- `/does/not/exist` +- `/missing.html` + +### POST Endpoints +- `/api/convert/image-to-webp` - Converts images to WebP format + - Tests file upload, conversion, and download + - Verifies Content-Type: image/webp +- `/api/convert/video-to-mp4` - Converts videos to MP4 format + - Tests file upload, conversion, and download + - Verifies Content-Type: video/mp4 + +### Download Endpoint +- `/api/download/:filename` - Download converted files + - Tested automatically as part of POST conversion tests + +## Running Tests + +### First Time Setup - Create Snapshots +Before running tests for the first time, generate snapshots: + +```bash +bazel run //mrjunejune:create_snapshots +``` + +This will: +1. Start the mrjunejune server +2. Make HTTP requests to all GET endpoints +3. Save responses to `snapshots/` directory +4. Stop the server + +### Run Integration Tests +```bash +bazel test //mrjunejune:integration_test +``` + +This will: +1. Start the mrjunejune server on port 6969 +2. Test all GET endpoints against their snapshots +3. Test POST conversion endpoints with real file uploads +4. Verify downloads work correctly +5. Report pass/fail for each test + +### View Test Output +```bash +bazel test //mrjunejune:integration_test --test_output=all +``` + +## Test Coverage + +✓ All 10 registered endpoints are tested +✓ Snapshot testing for HTML responses +✓ File upload and conversion testing +✓ Download functionality testing +✓ Error handling (404 responses) +✓ Redirect testing (301 responses) + +## Updating Tests + +### When HTML Changes +If you modify any HTML templates: + +```bash +# Regenerate snapshots +bazel run //mrjunejune:create_snapshots + +# Run tests to verify +bazel test //mrjunejune:integration_test +``` + +### When Adding New Endpoints +1. Update `main.c` with new route +2. Add test case to `integration_test.c` +3. Add snapshot config to `create_snapshots.c` (for GET) +4. Regenerate snapshots +5. Run tests + +## Notes + +- Tests require FFmpeg to be installed for video/image conversion tests +- Server runs on port 6969 during tests +- Test files are cleaned up automatically after download +- Converted files are stored in `/tmp/` during tests