test: comprehensive test coverage expansion (+965 tests)

Add 42 new test files covering all untested tool routes, image engine
internals, AI sidecar bridge, Zustand stores, and cross-format
compatibility. Expand e2e-docker suite with 7 spec files covering all
48 tools against a real Docker container.

Unit tests:
- Image engine: format detection, MIME mapping, metadata parsing, pipeline
- AI bridge: sidecar lifecycle, all 11 tool functions (mocked)
- Web stores: 14 Zustand stores (collage, settings, features, analytics, etc.)
- API helpers: format decoders, page range, file validation

Integration tests:
- 25 tool routes that had zero dedicated tests
- Cross-format matrix: 17 input formats x 3 tools
- Edge cases: zero-byte files, corrupted headers, path traversal, XSS, SQL injection
- Concurrent request handling and pipeline edge cases

E2E-Docker (Playwright against real container):
- 7 spec files: essential, adjustment, conversion, creative, utility, AI, pipeline
- Custom buildMultipart helper for multi-file tool uploads
- AI tools gracefully skip when sidecar not installed

Fixtures:
- Organized test media: formats/ (18 formats) + content/ (17 content types)
- Reduced from 3.1 GB unorganized samples to 33 MB structured fixtures

Bug fix:
- color-adjustments: gamma exposure used invalid single-param gamma() for
  positive values; fixed to use two-param gamma(gammaIn, gammaOut) form
This commit is contained in:
ashim-hq
2026-04-23 17:12:02 +08:00
parent 19df740880
commit babca4cf97
89 changed files with 19908 additions and 3 deletions
+13 -3
View File
@@ -73,9 +73,19 @@ async function processColorAdjustments(
image = await adjustContrast(image, { value: settings.contrast });
}
if (settings.exposure !== 0) {
// Map -100..+100 to gamma 3.0..0.33 (lower gamma = brighter midtones)
const gamma = 1 / (1 + settings.exposure / 100);
image = image.gamma(gamma);
// Sharp's gamma() accepts values between 1.0 and 3.0.
// Positive exposure → brighten midtones → apply gamma > 1.0 on output.
// Negative exposure → darken midtones → apply gamma > 1.0 on input.
// Map -100..+100 to a gamma range of 1.0..3.0 applied on the correct side.
const strength = Math.abs(settings.exposure) / 100;
const g = 1 + strength * 2; // 1.0..3.0
if (settings.exposure > 0) {
// Brighten: linearize at gamma 1.0, encode at higher gamma
image = image.gamma(1, g);
} else {
// Darken: linearize at higher gamma, encode at gamma 1.0
image = image.gamma(g, 1);
}
}
// Color