Improve UI views for assets/components/failures and timeline details

This commit is contained in:
2026-02-15 23:26:12 +03:00
parent 929bf9c524
commit f9ff0e10ff
14 changed files with 1221 additions and 87 deletions

View File

@@ -3,6 +3,7 @@ package ingest
import (
"encoding/json"
"testing"
"time"
)
func TestObservationDetailsPayloadIncludesStatusCheckedAt(t *testing.T) {
@@ -64,3 +65,40 @@ func TestObservationDetailsPayloadIncludesStatusCheckedAt(t *testing.T) {
t.Fatalf("error_description = %v, want %v", gotErr, errorDescription)
}
}
func TestParseComponentStatusEventTime(t *testing.T) {
explicit := "2026-02-10T15:22:00Z"
component := HardwareComponent{
Status: statusCritical,
StatusChangedAt: &explicit,
StatusHistory: []HardwareStatusHistoryEntry{
{Status: "OK", ChangedAt: "2026-02-10T15:10:00Z"},
{Status: "CRITICAL", ChangedAt: "2026-02-10T15:18:00Z"},
},
}
actual := parseComponentStatusEventTime(component)
if actual == nil {
t.Fatalf("parseComponentStatusEventTime() = nil, want non-nil")
}
want, _ := time.Parse(time.RFC3339, explicit)
if !actual.Equal(want.UTC()) {
t.Fatalf("parseComponentStatusEventTime() = %s, want %s", actual.UTC().Format(time.RFC3339), want.UTC().Format(time.RFC3339))
}
}
func TestTimelineFallbackTime(t *testing.T) {
actual, _ := time.Parse(time.RFC3339, "2026-02-10T15:22:00Z")
collected, _ := time.Parse(time.RFC3339, "2026-02-10T15:30:00Z")
ingested, _ := time.Parse(time.RFC3339, "2026-02-10T15:40:00Z")
if got := timelineFallbackTime(&actual, collected, ingested); !got.Equal(actual.UTC()) {
t.Fatalf("timelineFallbackTime(actual, collected, ingested) = %s, want %s", got.Format(time.RFC3339), actual.UTC().Format(time.RFC3339))
}
if got := timelineFallbackTime(nil, collected, ingested); !got.Equal(collected.UTC()) {
t.Fatalf("timelineFallbackTime(nil, collected, ingested) = %s, want %s", got.Format(time.RFC3339), collected.UTC().Format(time.RFC3339))
}
if got := timelineFallbackTime(nil, time.Time{}, ingested); !got.Equal(ingested.UTC()) {
t.Fatalf("timelineFallbackTime(nil, zero, ingested) = %s, want %s", got.Format(time.RFC3339), ingested.UTC().Format(time.RFC3339))
}
}