File size: 2,684 Bytes
ea8c728
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from pathlib import Path


REPO_ROOT = Path(__file__).resolve().parents[1]
VIZ_TREE_HTML = REPO_ROOT / "shinka" / "webui" / "viz_tree.html"


def test_runtime_timeline_layout_reserves_space_for_legend():
    html = VIZ_TREE_HTML.read_text(encoding="utf-8")

    assert "function getRuntimeTimelineLayout(" in html
    assert "margin: { l: 150, r: 10, t: 60, b: 105 }" in html
    assert "laneCount = null" in html
    assert "layout.yaxis.range = [laneCount - 0.5, -0.5];" in html
    assert "orientation: 'h'" in html
    assert "xanchor: 'left'" in html
    assert "yanchor: 'bottom'" in html
    assert "y: 1.01" in html


def test_embeddings_heatmap_uses_scroll_wrapper_for_full_size_matrix():
    html = VIZ_TREE_HTML.read_text(encoding="utf-8")

    assert '.attr("id", "main-heatmap-scroll")' in html
    assert '.style("overflow", "auto")' in html
    assert '.style("width", "max-content")' in html


def test_embeddings_heatmap_requires_full_hydration_before_render():
    html = VIZ_TREE_HTML.read_text(encoding="utf-8")

    assert "function datasetHasCompleteEmbeddings(data)" in html
    assert "const programsNeedingEmbeddings = filteredData.filter(" in html
    assert "return programsNeedingEmbeddings.every(" in html
    assert "if (datasetHasCompleteEmbeddings(window.treeData)) {" in html
    assert "window.fullProgramDataByDb = window.fullProgramDataByDb || {};" in html
    assert "window.fullProgramDataByDb[window.currentDbPath] = fullData;" in html


def test_runtime_timeline_dedupes_source_jobs_and_deprioritizes_island_copies():
    html = VIZ_TREE_HTML.read_text(encoding="utf-8")

    assert "function getRuntimeTimelineRowPriority(row)" in html
    assert "isIslandCopy: Boolean(meta._spawned_island || meta._is_island_copy)" in html
    assert "const dedupeKey = row.sourceJobId || row.id;" in html
    assert "if (rowPriority > existingPriority)" in html


def test_throughput_tab_contains_runtime_and_utilization_sections():
    html = VIZ_TREE_HTML.read_text(encoding="utf-8")

    assert 'data-tab="throughput"' in html
    assert 'id="throughput"' in html
    assert 'id="throughput-summary"' in html
    assert 'id="throughput-runtime-plot"' in html
    assert 'id="throughput-occupancy-plot"' in html
    assert 'id="throughput-occupancy-percent-plot"' in html
    assert 'id="throughput-eval-distribution-plot"' in html
    assert 'id="throughput-completion-rate-plot"' in html
    assert 'id="throughput-duration-table"' in html
    assert 'id="throughput-utilization-table"' in html
    assert "function updateThroughputTab(selectedNodeId = null)" in html
    assert "function renderThroughputOccupancyPercentPlot(rows, capacities)" in html