Three-level end-to-end suite, all deterministic (no retries, no sleeps, no unmocked network): - tests/e2e/api (209 tests): every route in clipwright/api/app.py + free_tools — health/config, uploads, process submit matrix + worker/webhook/ auto-retry/resume, status/source/download-all, edit/effects, transcript/EDL/ rerender, scenes/reframe, subtitle, hook, Postiz, thumbnails, free tools, and the security/path guards. - tests/e2e/pipeline (136 tests): every stage with real ffmpeg and stubbed Gemini/yt-dlp/ASR/ML — download, transcribe, scene detect, selection, layout, reframe/render, subtitles, hooks, watermark, thumbnails, plus the real CLI full pipeline via stub_env. - dashboard/e2e (19 Playwright specs): route-interception state machine covering every dashboard flow; one real-backend spec left test.fixme. - Foundation: tests/e2e/conftest.py (state isolation, no-network guard, ffmpeg media factory, disk-seeded jobs), FakePopen worker harness, child-process stub_env, architecture-consistent fixtures. - CI: unit + backend-e2e + dashboard-e2e jobs in the python+node container; ffmpeg + Playwright installed in-job; no setup-node/cache (act runner). Verified: unit 790 passed; API E2E 209 passed; pipeline E2E 136 passed; Playwright 19 passed / 1 skipped.
82 lines
2.9 KiB
Python
82 lines
2.9 KiB
Python
"""Phase-0 foundation smoke test.
|
|
|
|
Proves the shared E2E scaffolding works before the per-route lanes are built:
|
|
|
|
1. ``/health`` answers through the in-process ASGI client.
|
|
2. ``app_state`` gives each test a private ``jobs`` dict (isolation).
|
|
3. A disk-seeded completed job is recoverable the same way a restart recovers.
|
|
4. The session ``media_factory`` produces ffprobe-able fixture videos.
|
|
"""
|
|
|
|
import json
|
|
import subprocess
|
|
|
|
import pytest
|
|
|
|
pytestmark = pytest.mark.e2e
|
|
|
|
|
|
async def test_health_ok(client):
|
|
resp = await client.get("/health")
|
|
assert resp.status_code == 200
|
|
assert resp.json() == {"status": "ok"}
|
|
|
|
|
|
async def test_app_state_isolation_a(app_state):
|
|
# Fresh per test: nothing seeded this dict.
|
|
assert app_state.app.jobs == {}
|
|
app_state.app.jobs["isolation-a"] = {"status": "sentinel"}
|
|
|
|
|
|
async def test_app_state_isolation_b(app_state):
|
|
# If the previous test's write leaked, this dict would not be empty.
|
|
assert app_state.app.jobs == {}
|
|
app_state.app.jobs["isolation-b"] = {"status": "sentinel"}
|
|
|
|
|
|
async def test_disk_seeded_job_is_recoverable(app_state, seeded_job, client):
|
|
job_id = seeded_job(job_id="job-smoke", base="smoke", clips=1)
|
|
|
|
job = app_state.app.jobs[job_id]
|
|
assert job["status"] == "completed"
|
|
assert job["output_dir"] == str(app_state.out / job_id)
|
|
|
|
clips = job["result"]["clips"]
|
|
assert len(clips) == 1
|
|
assert clips[0]["video_url"].endswith("/smoke_clip_1.mp4")
|
|
|
|
clip_path = app_state.out / job_id / "smoke_clip_1.mp4"
|
|
assert clip_path.is_file() and clip_path.stat().st_size > 0
|
|
|
|
# The recovered clip is actually servable: this proves the /videos mount was
|
|
# repointed at the per-test output tree (it captures its directory at
|
|
# import time, so the app_state rebind has to move it explicitly).
|
|
resp = await client.get(clips[0]["video_url"])
|
|
assert resp.status_code == 200
|
|
assert resp.content
|
|
|
|
|
|
def _probe(path):
|
|
out = subprocess.run(
|
|
["ffprobe", "-v", "error", "-show_entries",
|
|
"format=duration:stream=codec_type", "-of", "json", str(path)],
|
|
capture_output=True, text=True, check=True,
|
|
)
|
|
return json.loads(out.stdout)
|
|
|
|
|
|
def test_media_factory_files_are_probeable(media_factory):
|
|
sixty = _probe(media_factory.sixty)
|
|
assert float(sixty["format"]["duration"]) == pytest.approx(60.0, abs=1.0)
|
|
assert {"video", "audio"} <= {s["codec_type"] for s in sixty["streams"]}
|
|
|
|
six = _probe(media_factory.six)
|
|
assert float(six["format"]["duration"]) == pytest.approx(6.0, abs=1.0)
|
|
assert {"video", "audio"} <= {s["codec_type"] for s in six["streams"]}
|
|
|
|
silent = _probe(media_factory.silent)
|
|
assert {s["codec_type"] for s in silent["streams"]} == {"video"}
|
|
|
|
cuts = _probe(media_factory.cuts)
|
|
assert float(cuts["format"]["duration"]) == pytest.approx(6.0, abs=1.0)
|
|
assert {"video"} <= {s["codec_type"] for s in cuts["streams"]}
|