History (#5316): - Transitions fold into episodes (steward/alerts/episodes.py): each stretch out of quiet, the worst state it reached, how long it lasted, its worst reading against the rule ('3m 21s (fires above 3m)'), who was told across its changes, and its Ansible runs. The changes themselves fold under it. - An episode cut by paging says so ('cleared later (above)', 'earlier'). - For one rule: a verdict ('Fired 4 times in the last 7d, 1h 2m in all') and no Rule column. Notified and Action show only when the range has any. Tests: - The confirm guard looks for a confirm( call, not the word in the comment that says it is gone (lesson #4365). - The Hosts viewer test looks for the add-host dialog by id, since every page now carries the confirm dialog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -68,14 +68,19 @@ def test_a_viewer_reads_the_alert_history(app):
|
||||
page = await resp.get_data(as_text=True)
|
||||
assert "Alert History" in page and 'href="/alerts/"' in page # crumbs back to Alerts
|
||||
assert f"hot {tag}" in page and f"cold-note-{tag}" in page and f"old-{tag}" not in page
|
||||
assert "CPU 98%" in page and "fires when CPU > 90%" in page
|
||||
# One episode per stretch out of quiet (#5316): its worst reading against
|
||||
# the rule, who was told across its changes, the changes folded under it.
|
||||
assert '98% <span class="tone-dim">(fires above 90%)</span>' in page
|
||||
assert "email failed" in page and f"mx-{tag}: timed out" in page and "webhook sent" in page
|
||||
assert f"muted · patch-{tag}" in page and "No CPU reading" in page
|
||||
assert f"muted · patch-{tag}" in page and "No CPU reading" in page and "2 changes of state" in page
|
||||
assert "<th>Rule</th>" in page and "<th>Notified</th>" in page and "<th>Action</th>" not in page
|
||||
|
||||
resp = await client.get(f"/alerts/history?range=24h&rule={hot_id}", headers={"HX-Request": "true"})
|
||||
rows = await resp.get_data(as_text=True)
|
||||
assert "<html" not in rows and "<table" in rows
|
||||
assert f"old-{tag}" in rows and f"cold-note-{tag}" not in rows
|
||||
assert "<th>Rule</th>" not in rows # one rule: no column for it
|
||||
assert "Fired 1 time</strong> in the last 24h" in rows # its verdict
|
||||
|
||||
# The next page as the reader scrolls: only older rows, without the table
|
||||
# around them, and the list says where it ends (#5211).
|
||||
@@ -84,7 +89,8 @@ def test_a_viewer_reads_the_alert_history(app):
|
||||
"range": "24h", "rule": hot_id, "before": cursor(now - timedelta(minutes=3), "")})
|
||||
older = await resp.get_data(as_text=True)
|
||||
assert resp.status_code == 200 and "<table" not in older
|
||||
assert "CPU 98%" in older and f"old-{tag}" in older and f"patch-{tag}" not in older
|
||||
assert "98%" in older and f"old-{tag}" in older and f"patch-{tag}" not in older
|
||||
assert "cleared later (above)" in older # its end is on the newer page
|
||||
assert "End of the list." in older and "data-scroll-more" not in older
|
||||
|
||||
# The rules list links each rule to its history.
|
||||
|
||||
Reference in New Issue
Block a user