File size: 3,163 Bytes
d6ee0a6
 
 
 
 
 
 
 
 
f4b92b8
d6ee0a6
ef2c57c
f4b92b8
 
 
 
d6ee0a6
ef2c57c
 
f4b92b8
ef2c57c
f4b92b8
 
 
 
ef2c57c
 
f4b92b8
ef2c57c
27716f7
ef2c57c
 
f4b92b8
 
 
 
 
 
 
 
 
 
 
 
bb5d2bb
 
 
 
 
 
 
 
 
 
 
 
f79a242
bb5d2bb
 
27716f7
 
 
 
 
 
03bed0b
e67c48b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
from pathlib import Path


def test_ui_avoids_long_dash_glyphs():
    text = Path("src/ragforge/ui.py").read_text(encoding="utf-8")
    assert "—" not in text
    assert "–" not in text


def test_ui_has_visible_indexing_query_and_eval_states():
    text = Path("src/ragforge/ui.py").read_text(encoding="utf-8")
    assert 'gr.Button(value="Building corpus..."' in text
    assert 'gr.Button(value="Processing..."' in text
    assert "Processing request..." in text
    assert "Running {level} evaluation..." in text
    assert "Please keep this tab open" in text
    assert "BrowserState" in text


def test_ui_prevents_duplicate_long_running_clicks():
    text = Path("src/ragforge/ui.py").read_text(encoding="utf-8")
    assert 'interactive=False' in text
    assert 'show_progress="hidden"' in text
    assert "begin_ask" in text
    assert "begin_eval" in text


def test_ui_exposes_layered_evaluation_and_diagnostics():
    text = Path("src/ragforge/ui.py").read_text(encoding="utf-8")
    for label in ["Focused QA", "Semantic planner", "Corpus overview", "Text2SQL", "Retrieval ablation", "Abstention", "Compare saved runs"]:
        assert label in text
    assert '["Quick", "Standard", "Deep"]' in text
    assert "Diagnostic findings" in text
    assert "Quality gates affecting the grade" in text


def test_architecture_api_tab_is_interactive_and_live():
    text = Path("src/ragforge/ui.py").read_text(encoding="utf-8")
    assert "Refresh runtime view" in text
    assert "Pipeline architecture" in text
    assert "Endpoint reference" in text
    assert "Copy-ready curl examples" in text
    assert "Runtime snapshot" in text
    assert "Evaluation architecture" in text


def test_ui_has_quota_safe_evaluation_controls_and_score_card_spacing():
    text = Path("src/ragforge/ui.py").read_text(encoding="utf-8")
    assert "Quota-safe pacing" in text
    assert "Target Gemini requests per minute" in text
    assert "Evaluation score card" in text
    assert "Evaluation scorecard" not in text


def test_architecture_snapshot_returns_complete_runtime_payload():
    text = Path("src/ragforge/ui.py").read_text(encoding="utf-8")
    assert '"ragforge_version": "1.8.0"' in text
    assert "return sid, runtime, curl, runtime_json" in text
    assert "curl = f\ndef _eval_frame" not in text


def test_ui_can_switch_saved_evaluations_without_rerunning():
    text = Path("src/ragforge/ui.py").read_text(encoding="utf-8")
    assert "View saved evaluation" in text
    assert "Refresh saved runs" in text
    assert "0 new Gemini requests were used" in text


def test_ui_exposes_copyable_evaluation_exports():
    text = Path("src/ragforge/ui.py").read_text(encoding="utf-8")
    assert "Copy / export evaluation tables" in text
    assert "Prepare table for copy / download" in text
    assert "Copy-ready table" in text
    assert "Evaluation report JSON" in text
    assert "pretty_json(report)" in text
    for label in [
        "Focused QA",
        "Semantic planner",
        "Corpus overview",
        "Text2SQL",
        "Retrieval ablation",
        "Abstention",
        "Compare saved runs",
    ]:
        assert label in text