File size: 3,213 Bytes
b67c03f
 
 
bf2fa25
 
b67c03f
 
bf2fa25
 
 
 
 
 
 
b67c03f
 
bf2fa25
 
 
b67c03f
bf2fa25
b67c03f
 
 
 
 
bf2fa25
b67c03f
bf2fa25
 
b67c03f
 
 
 
bf2fa25
 
 
 
 
 
 
fab8b21
bf2fa25
 
b67c03f
 
bf2fa25
 
 
 
 
 
 
 
 
 
 
 
c125d4e
 
 
 
bf2fa25
 
 
 
 
c125d4e
bf2fa25
 
b67c03f
1f4efec
 
bf2fa25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fab8b21
bf2fa25
fab8b21
 
bf2fa25
 
fab8b21
bf2fa25
fab8b21
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
87
88
89
90
91
92
93
94
95
96
97
98
from pathlib import Path


def root() -> Path:
    return Path(__file__).resolve().parents[1]


def test_custom_ui_assets_exist():
    base = root()
    assert (base / "web" / "index.html").exists()
    assert (base / "web" / "static" / "app.css").exists()
    assert (base / "web" / "static" / "app.js").exists()
    assert (base / "web" / "static" / "progress.js").exists()
    assert (base / "web" / "static" / "runs.js").exists()


def test_app_registers_custom_routes_and_bridge_endpoints():
    content = (root() / "app.py").read_text(encoding="utf-8")
    assert "def register_custom_routes" in content
    for route in [
        '"/custom"',
        '"/api/me"',
        '"/api/bucket/status"',
        '"/api/bucket/create"',
        '"/api/build"',
        '"/api/validate"',
        '"/api/runs"',
        '"/api/runs/{run_id}/progress"',
        '"/api/runs/resumable"',
        '"/api/runs/{run_id}/view"',
    ]:
        assert route in content


def test_one_page_workspace_contains_core_sections():
    html = (root() / "web" / "index.html").read_text(encoding="utf-8")
    for text in [
        "New Build",
        "Active Run",
        "Runs Explorer",
        "Space Test",
                "Artifacts",
    ]:
        assert text in html


def test_one_page_workspace_keeps_required_ids_for_live_bridge():
    html = (root() / "web" / "index.html").read_text(encoding="utf-8")
    required_ids = [
        "launchBuild",
        "checkBucket",
        "createBucket",
        "launchValidate",
        "progressStatus",
        "timeline",
        "activityFeed",
        "runFilters",
        "runsTable",
        "activeOpenSpace",
        "activeOpenSettings",
        "activePrefillSpaceTest",
        "deleteActiveRun",
        "artifactList",
        "reportPreview",
        "spaceTestPreview",
        "metricsList",
        "manualActionPanel",
        "deleteValidationRun",
    ]
    for element_id in required_ids:
        assert element_id in html


def test_frontend_calls_real_bridge_endpoints_and_keeps_run_logic():
    app_js = (root() / "web" / "static" / "app.js").read_text(encoding="utf-8")
    runs_js = (root() / "web" / "static" / "runs.js").read_text(encoding="utf-8")
    progress_js = (root() / "web" / "static" / "progress.js").read_text(encoding="utf-8")
    for endpoint in ["/api/me", "/api/build", "/api/validate", "/api/bucket/status", "/api/bucket/create"]:
        assert endpoint in app_js
    assert "selectRun" in runs_js
    assert "renderRunDetail" in runs_js
    assert "renderRunViewModel" in progress_js
    assert "renderActivityFeed" in progress_js
    assert "renderDiagnostics" in progress_js


def test_css_contains_one_page_responsive_layout():
    css = (root() / "web" / "static" / "app.css").read_text(encoding="utf-8")
    compact = css.replace(" ", "")
    for snippet in [
        ".workspace-grid{display:grid;grid-template-columns:minmax(300px,420px)minmax(460px,1fr)minmax(300px,420px)",
        ".space-test-grid{display:grid;grid-template-columns:minmax(0,1fr)minmax(300px,450px)",
        "word-break:normal",
        ".run-row.selected",
        "@media(max-width:720px)",
    ]:
        assert snippet.replace(" ", "") in compact