File size: 2,339 Bytes
62d71a5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b9e006f
 
62d71a5
 
 
94713cb
62d71a5
 
94713cb
62d71a5
 
 
 
 
 
95e7bb1
 
62d71a5
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]


def test_smoke_accepts_image_like_gradio_results_and_keeps_latency_event_aliases():
    worker = (ROOT / "src" / "worker_payload.py").read_text(encoding="utf-8")
    assert "type_hints" in worker
    assert "pil." in worker
    assert "recommended_zero_gpu_duration_seconds" in worker
    assert "recommended_zerogpu_duration_seconds" in worker


def test_frontend_latency_reads_zero_gpu_duration_aliases():
    app = (ROOT / "web" / "static" / "app.js").read_text(encoding="utf-8")
    fn = app.split("function readRunLatencyPayload", 1)[1].split("function renderActiveLatency", 1)[0]
    assert "recommended_zero_gpu_duration_seconds" in fn
    assert "recommended_zerogpu_duration_seconds" in fn
    assert "numberFromEvents" in fn


def test_progress_poll_refreshes_actions_documents_and_recovery_live():
    app = (ROOT / "web" / "static" / "app.js").read_text(encoding="utf-8")
    refresh = app.split("function refreshProgress", 1)[1].split("function numberFromEvents", 1)[0]
    assert "renderActiveRunActions({...p.summary,bucket_source:p.bucket_source},p)" in refresh
    assert "renderRunDocuments({...p,summary:{...p.summary,bucket_source:p.bucket_source}})" in refresh
    assert "renderAgentRecovery(p)" in refresh


def test_prefill_helper_still_detects_validation_events_but_button_is_best_effort():
    runs = (ROOT / "web" / "static" / "runs.js").read_text(encoding="utf-8")
    assert "function runHasValidationResult(detail={},summaryOverride={})" in runs
    assert "const canPrefill=Boolean(targetSpace)" in runs
    assert "summary.observed_latency_seconds" in runs
    assert "generation_smoke" in runs


def test_run_document_buttons_trust_backend_presence_from_progress_payload():
    runs = (ROOT / "web" / "static" / "runs.js").read_text(encoding="utf-8")
    assert "traceDocState('traces/raw'" in runs
    assert "traceDocState('traces/redacted'" in runs
    assert "byId.get('smoke').present&&byId.get('smoke').url" in runs


def test_summary_exposes_latency_and_zero_gpu_duration_aliases():
    bucket = (ROOT / "src" / "bucket.py").read_text(encoding="utf-8")
    assert '"recommended_zero_gpu_duration_seconds"' in bucket
    assert '"recommended_zerogpu_duration_seconds"' in bucket
    assert '"observed_latency_seconds"' in bucket