Show collapsible IP check cycles in the registry

This commit is contained in:
ayurishchev committed 2026-11-23 11:53:08 +03:00
1 parent 94124747ce
commit b58d5f5b82
16 files changed
+332 -36

No files matched your search

+32 -4
View File
@@ -637,8 +637,13 @@ func TestRegistryPageAndDetail(t *testing.T) {
TotalCycles: 2, LastResult: "pass", InQueue: false,
}
fake.registryChecks["9.9.9.9"] = []check{
{CycleID: 2, Source: "egress", CheckType: "https", Target: "https://example.test", Success: true, CheckedAt: now},
{CycleID: 1, Source: "egress", CheckType: "https", Target: "https://example.test", Success: false, CheckedAt: now},
{CycleID: 2, AttemptNumber: 1, Source: "egress", CheckType: "https", Target: "https://new.example.test", Success: true, CheckedAt: now},
{CycleID: 1, AttemptNumber: 1, Source: "egress", CheckType: "https", Target: "https://old.example.test", Success: false, CheckedAt: now.Add(-time.Hour)},
}
fake.registryEvents = []event{{CycleID: 2, EventType: "traceroute_result", OccurredAt: now, Payload: `{"output":"trace of cycle two"}`}}
fake.registryCycles = []registryCycle{
{CycleID: 2, RunID: 20, Verdict: "pass", AggregatedAt: &now},
{CycleID: 1, RunID: 19, Verdict: "partial", SelfCheckFailedOn: []string{"older-validator"}},
}
ts := newTestServer(t, caURL)
@@ -651,8 +656,31 @@ func TestRegistryPageAndDetail(t *testing.T) {
if !strings.Contains(detail, "9.9.9.9") {
t.Fatalf("expected detail page to show the address, got:\n%s", detail)
}
if !strings.Contains(detail, "https://example.test") {
t.Fatalf("expected detail page to list retained checks, got:\n%s", detail)
const collapsedCycle = `<details class="registry-cycle">`
cards := strings.Split(detail, collapsedCycle)
if len(cards) != 3 {
t.Fatalf("expected two initially collapsed cycles, got %d:\n%s", len(cards)-1, detail)
}
first, second, _ := strings.Cut(cards[2], "</details>")
for _, tc := range []struct {
card string
want []string
unrelated string
}{
{cards[1], []string{fmtTime(now), "Запуск №20", "Цикл №2", "Успешно 1 из 1", "https://new.example.test", "События", `class="trace-output">trace of cycle two`}, "older-validator"},
{first, []string{fmtTime(now.Add(-time.Hour)), "Запуск №19", "Цикл №1", "Успешно 0 из 1", "https://old.example.test", "Self-check не прошёл на: older-validator"}, "trace of cycle two"},
} {
for _, want := range tc.want {
if !strings.Contains(tc.card, want) {
t.Fatalf("expected %q in cycle card:\n%s", want, tc.card)
}
}
if strings.Contains(tc.card, tc.unrelated) {
t.Fatalf("found another cycle's data %q in:\n%s", tc.unrelated, tc.card)
}
}
if strings.Contains(second, "https://old.example.test") {
t.Fatal("historical check escaped its cycle card")
}
notFound := get(t, ts, "/registry/1.2.3.4")