fix(overview): expose each health check state in text

This commit is contained in:
Joseph Doherty
2026-11-13 16:20:42 -05:00
parent 73e69ef2b8
commit be1ce9ef3a
2 changed files with 37 additions and 1 deletions
@@ -77,8 +77,9 @@
@foreach (var entry in Entries) @foreach (var entry in Entries)
{ {
<div class="check-row"> <div class="check-row">
<span class="check-dot @DotClass(entry.Value.Status)"></span> <span class="check-dot @DotClass(entry.Value.Status)" aria-hidden="true"></span>
<span class="check-name">@entry.Key</span> <span class="check-name">@entry.Key</span>
<span class="check-state s-@DotClass(entry.Value.Status)">@CheckStatusLabel(entry.Value.Status)</span>
<span class="check-desc">@entry.Value.Description</span> <span class="check-desc">@entry.Value.Description</span>
</div> </div>
} }
@@ -391,6 +392,12 @@
/// </summary> /// </summary>
private string? HistorianPoolClass => HistorianPools.Any(p => p.Failures > 0) ? "bad" : null; private string? HistorianPoolClass => HistorianPools.Any(p => p.Failures > 0) ? "bad" : null;
private static string CheckStatusLabel(string? status) => status switch
{
"Healthy" or "Degraded" or "Unhealthy" => status,
_ => "Unknown",
};
private static string DotClass(string? status) => status switch private static string DotClass(string? status) => status switch
{ {
"Healthy" => "ok", "Healthy" => "ok",
@@ -49,6 +49,35 @@ public class InstanceCardTests : BunitContext
.Add(c => c.Now, Now) .Add(c => c.Now, Now)
.Add(c => c.IsLeader, isLeader)); .Add(c => c.IsLeader, isLeader));
[Theory]
[InlineData("Healthy", "Healthy", "ok")]
[InlineData("Degraded", "Degraded", "warn")]
[InlineData("Unhealthy", "Unhealthy", "bad")]
[InlineData(null, "Unknown", "idle")]
[InlineData("FutureState", "Unknown", "idle")]
[InlineData("", "Unknown", "idle")]
public void CheckRow_ExposesItsStatusWithoutInferringDescription(
string? status, string label, string stateClass)
{
var report = new ZbHealthReport
{
Status = "Degraded",
Entries = new Dictionary<string, ZbHealthEntry>
{
["database"] = new() { Status = status, Description = "remote <description>" },
},
};
var cut = Render(Card(report: report));
var row = cut.Find(".check-row");
var state = row.QuerySelector(".check-state");
Assert.NotNull(state);
Assert.Equal(label, state.TextContent);
Assert.Contains($"s-{stateClass}", state.ClassList);
Assert.Equal("true", row.QuerySelector(".check-dot")!.GetAttribute("aria-hidden"));
Assert.Equal("remote <description>", row.QuerySelector(".check-desc")!.TextContent);
Assert.Empty(row.QuerySelectorAll("description"));
}
[Theory] [Theory]
[InlineData(InstanceStatus.Up, "up", "Up")] [InlineData(InstanceStatus.Up, "up", "Up")]
[InlineData(InstanceStatus.Degraded, "degraded", "Degraded")] [InlineData(InstanceStatus.Degraded, "degraded", "Degraded")]