view mrjunejune/test/README.md @ 126:e7899c93da77

Remove playground.
author June Park <parkjune1995@gmail.com>
date Thu, 08 Jan 2026 18:03:34 -0800
parents 1c446ab6f945
children
line wrap: on
line source

# 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
```