Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions heart/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -2397,7 +2397,13 @@ def _render_html(board: Board) -> str:
refreshed_at=board.refreshed_at,
refresh_url=(f"https://github.com/{gh_owner}/{repo_name}/actions/workflows/heart-health.yml"
if gh_owner else None))
return f"""<!doctype html>
observed_states = {section.state for section in board.sections}
observed_status = ("red" if FAIL in observed_states else
"yellow" if WARN in observed_states else
"stale" if board.stale else
"unknown" if UNOBS in observed_states or not observed_states else
"green" if OK in observed_states else "unknown")
return t_.section_layout(f"""<!doctype html>
<html lang="en"><head><meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>PyAutoHeart Dashboard — {word}</title>
Expand Down Expand Up @@ -2428,7 +2434,8 @@ def _render_html(board: Board) -> str:
{_boards_nav_html()}
<script>{t_.JS}</script><script>{_COPY_JS}</script>
</body></html>
"""
""", {"observed-checks": {"status": observed_status,
"label": "Observed: " + observed_status, "count": len(board.sections)}})


def to_dict(board: Board) -> dict[str, Any]:
Expand Down
23 changes: 23 additions & 0 deletions tests/test_dashboard_disclosures.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,26 @@ def test_repair_rows_copy_exact_prompts_without_toggling_prompt_disclosures():
assert next(details.find('pre')).text() == plan['prompt']
assert button.text() == '' and list(button.find('svg'))
assert any(p.attrs.get('aria-live') == 'polite' for p in section.find('p'))


def test_observed_summary_uses_check_states_not_release_verdict():
cases = [
([dashboard.OK], False, 'green'),
([dashboard.OK, dashboard.WARN], False, 'yellow'),
([dashboard.WARN, dashboard.FAIL, dashboard.UNOBS], True, 'red'),
([dashboard.OK], True, 'stale'),
([dashboard.OK, dashboard.UNOBS], False, 'unknown'),
([], False, 'unknown'),
]
for states, stale, expected in cases:
board = dashboard.build_board(make_snapshot(), make_verdict(), now=FRESH_NOW)
board.stale = stale
board.sections = [dashboard.Section(str(i), 'Check', state, 'Summary')
for i, state in enumerate(states)]
root = Page(dashboard._render_html(board)).root
section = next(root.find('details', 'board-section'))
summary = next(section.find('summary'))
assert 'Observed checks' in summary.text()
assert 'Observed: ' + expected in summary.text()
assert next(summary.find(cls='section-status-' + expected))
assert 'open' not in section.attrs
Loading