feat(ui): audit, alert rules and the rule form say things in words (#5212)
#5212 "Plain labels: no raw ids, scopes, metric keys or unexplained jargon", batch 1: - Audit log: each action reads as a sentence ("paused monitor"), with the code as its tooltip. Detail shows flags as yes/no, lists joined, a run's scope by name, spans as spans, and no ids the entity column already gives. The filter is now a picker of areas. - Alert rules, history and Status say the condition in words: "is down", "Fullest disk >= 85%". Readings use metric_value, and history times use |ago. - Rule form: sources and metrics by name, the threshold's unit, "fires when it is down/up" for an up/down metric instead of 0.5, and a metric reference built from the catalog. - Schedules and Maintenance: viewers no longer see Run now, Pause, Edit, Delete or New. Intervals and next runs read as "every 2h" and "in 3h"; a scope reads "Every alert on Host agent". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -56,3 +56,33 @@ async def test_the_log_continues_itself_instead_of_a_load_more_link(app):
|
||||
'&action=host."') in more
|
||||
assert "Load more" not in more
|
||||
assert "data-scroll-more" not in last and "End of the list." in last
|
||||
|
||||
|
||||
def test_an_entry_reads_as_a_sentence_with_its_detail_in_words():
|
||||
"""#5212: no action codes, Python reprs or raw scopes on the page."""
|
||||
from steward.audit.service import action_text, detail_facts
|
||||
assert action_text("monitor.disabled") == "paused monitor"
|
||||
assert action_text("some.new_thing") == "some.new_thing" # unknown: its code
|
||||
facts = detail_facts({"rule_id": "r1", "check": False, "vars": ["a", "b"], "secret_vars": [],
|
||||
"scope": "steward:group:g1", "interval_seconds": 7200,
|
||||
"section": "ansible.credentials", "run_id": "abc", "limit": None,
|
||||
"carried": {"monitor_results": 12}},
|
||||
{"steward:group:g1": "group Docker Swarm"})
|
||||
said = {f["label"]: f["text"] for f in facts}
|
||||
assert said == {"dry run": "no", "variables": "a, b", "secret variables": "none",
|
||||
"scope": "group Docker Swarm", "every": "2h", "section": "Ansible: credentials",
|
||||
"run": "open", "history carried over": "monitor results 12"}
|
||||
assert [f["url"] for f in facts if f["label"] == "run"] == ["/ansible/runs/abc"]
|
||||
|
||||
|
||||
async def test_the_row_says_what_was_done_not_its_code(app):
|
||||
events = [{"event": _ev("monitor", "m1", "monitor.disabled"), "detail": {},
|
||||
"entity": {"label": "api check", "url": "/monitors/m1", "gone": False},
|
||||
"action": "paused monitor", "facts": [{"label": "dry run", "text": "no", "url": None}]}]
|
||||
async with app.test_request_context("/audit/"):
|
||||
from steward.audit.service import AREAS
|
||||
page = await render_template("audit/list.html", events=events, after=None,
|
||||
action_filter="monitor.", areas=AREAS)
|
||||
assert 'title="monitor.disabled">paused monitor</td>' in page
|
||||
assert "dry run</span>" in page and "False" not in page
|
||||
assert '<option value="monitor." selected>Monitors</option>' in page
|
||||
|
||||
Reference in New Issue
Block a user