Files
SnapOtter/docker/docker-compose.test.yml
T
SnapOtter 1f5b222267 test: fix docker test-image env and container-specific test guards
Make the full pnpm test:docker suite pass the env-dependent tests (~85 failures):
- Dockerfile.test: ENV LD_LIBRARY_PATH=/usr/local/lib so the built libheif 1.21 is not shadowed by the base image's older system libheif (heif-dec failed with an undefined-symbol error -> 'No HEIF decoder found' on 72 HEIF tests); add libjxl-tools (JXL) and ghostscript + the ImageMagick policy.xml EPS allow-edit.
- docker-compose.test.yml: SYNC_WAIT_MS=30000 so sync-wait image tools do not fall back to 202 under single-container contention (10 tests).
- install_feature.py: guard tarfile.extractall(filter='data') behind Python>=3.12 (bookworm ships 3.11); the manual entry guards already protect.
- feature-status.test.ts / docker-file-secrets.test.ts: skip the two cases that cannot hold inside the container (/.dockerenv always present; root bypasses chmod). Verified on host: all still pass.
2026-06-17 14:28:41 +08:00

104 lines
3.5 KiB
YAML

###############################################################################
# Test infrastructure - run with:
# docker compose -f docker/docker-compose.test.yml up --build --abort-on-container-exit
###############################################################################
name: snapotter-test
services:
# ── Unit + Integration tests ─────────────────────────────────────────────
test-unit:
build:
context: ..
dockerfile: docker/Dockerfile.test
container_name: SnapOtter-test-unit
command: ["pnpm", "test:ci"]
environment:
- NODE_ENV=test
- AUTH_ENABLED=true
- DEFAULT_USERNAME=admin
- DEFAULT_PASSWORD=admin
- DATABASE_URL=postgres://snapotter:snapotter@postgres:5432/snapotter_test
# Tells tests/global-setup.ts to use these servers instead of spawning
# testcontainers (no docker daemon inside the test container).
- TEST_DATABASE_URL=postgres://snapotter:snapotter@postgres:5432/snapotter_test
- TEST_REDIS_URL=redis://redis:6379
- REDIS_URL=redis://redis:6379
- WORKSPACE_PATH=/tmp/test-workspace
- MAX_MEGAPIXELS=100
- RATE_LIMIT_PER_MIN=1000
# Single constrained container; give sync-wait tools more headroom before
# the factory falls back to async 202 (default is 8s).
- SYNC_WAIT_MS=30000
tmpfs:
- /tmp/test-workspace
- /tmp
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
# ── E2E tests (Playwright against full app) ─────────────────────────────
test-e2e:
build:
context: ..
dockerfile: docker/Dockerfile.test
container_name: SnapOtter-test-e2e
# Visual project is excluded: linux baselines are managed by the
# update-visual-baselines workflow, not generated inside the container.
command:
[
"sh",
"-c",
"npx playwright install --with-deps chromium && pnpm playwright test --project=chromium && pnpm playwright test --project=chromium-serial --workers=1",
]
environment:
- NODE_ENV=test
- AUTH_ENABLED=true
- DEFAULT_USERNAME=admin
- DEFAULT_PASSWORD=admin
- DATABASE_URL=postgres://snapotter:snapotter@postgres:5432/snapotter_test
- REDIS_URL=redis://redis:6379
- WORKSPACE_PATH=/tmp/test-workspace
- MAX_MEGAPIXELS=100
- RATE_LIMIT_PER_MIN=1000
- CI=true
tmpfs:
- /tmp/test-workspace
- /tmp
depends_on:
test-unit:
condition: service_completed_successfully
postgres:
condition: service_healthy
redis:
condition: service_healthy
postgres:
image: postgres:17-alpine
container_name: SnapOtter-test-postgres
environment:
POSTGRES_USER: snapotter
POSTGRES_PASSWORD: snapotter
POSTGRES_DB: snapotter_test
healthcheck:
test: ["CMD-SHELL", "pg_isready -U snapotter"]
interval: 10s
timeout: 5s
retries: 12
start_period: 15s
tmpfs:
- /var/lib/postgresql/data
redis:
image: redis:8-alpine
container_name: SnapOtter-test-redis
command: ["redis-server", "--maxmemory-policy", "noeviction", "--appendonly", "no"]
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 12
start_period: 10s
tmpfs:
- /data