Remove historical analytics from the registry page

This commit is contained in:
ayurishchev committed 2026-11-23 12:11:03 +03:00
1 parent b58d5f5b82
commit 7eeb8c4ae9
16 files changed
+16 -794

No files matched your search

+9 -74
View File
@@ -613,81 +613,16 @@ func TestRegistryBreakdownChartAndProxy(t *testing.T) {
}
}
// The trend chart of /registry: its frame is on the page only with a direction
// and carries the period; the data block is a separate request that passes just
// the subnet, direction, protocol and period to control-api.
func TestRegistryTrendBlock(t *testing.T) {
fake, ts := analyticsFake(t)
now := time.Now().UTC()
fake.trend = registryTrend{Group: "target", Runs: []trendRun{{ID: 4, StartedAt: now, Addresses: 3}, {ID: 5, StartedAt: now, Addresses: 3}},
Series: []trendSeries{{Key: "https://a.test", Label: "a.test", Points: []trendPoint{{RunID: 5, Total: 3, OK: 2}}}}}
page := get(t, ts, "/registry?direction=egress&protocol=https&subnet=9.9.9.0/24&trend_from=2026-09-01&trend_view=count&run=1&q=9")
for _, want := range []string{`id="registry-trend-panel"`, "Динамика по запускам · Egress · https", `value="2026-09-01"`, `name="trend_view" value="count"`,
`hx-get="/registry/trend?direction=egress&protocol=https&subnet=9.9.9.0%2F24&trend_from=2026-09-01"`} {
if !strings.Contains(page, want) {
t.Errorf("expected %q in the page", want)
func TestRegistryOmitsHistoricalAnalytics(t *testing.T) {
_, ts := analyticsFake(t)
page := get(t, ts, "/registry?direction=egress&protocol=https&trend_from=2026-09-01&trend_to=2026-09-30&trend_view=count")
for _, marker := range []string{"/registry/trend", "/registry/always-pass", "registry-trend.js", "chart.umd.min.js",
"Динамика по запускам", "Всегда проходили", `type="date"`, `name="trend_view"`} {
if strings.Contains(page, marker) {
t.Errorf("registry page still includes %q", marker)
}
}
if strings.Contains(get(t, ts, "/registry?protocol=https"), `id="registry-trend-panel"`) {
t.Error("no trend frame without a direction")
}
frag := get(t, ts, "/registry/trend?direction=egress&protocol=https&run=1&q=9&trend_to=2026-09-30&trend_to_x=1")
if !strings.Contains(frag, `data-trend="`) || !strings.Contains(frag, "a.test") || !strings.Contains(frag, "2 из 3") {
t.Errorf("fragment lacks the data: %s", frag)
}
fake.mu.Lock()
req := fake.trendReqs[len(fake.trendReqs)-1]
fake.mu.Unlock()
if !strings.Contains(req, "direction=egress") || !strings.Contains(req, "to=2026-09-30") || strings.Contains(req, "run=") || strings.Contains(req, "q=") {
t.Errorf("trend request %q", req)
}
if frag = get(t, ts, "/registry/trend?protocol=https"); strings.Contains(frag, "data-trend") || !strings.Contains(frag, "Выберите направление") {
t.Errorf("no direction: %s", frag)
}
}
// The "always passed" tile of /registry: its slot is in the trend frame only
// with a direction; the fragment is a button with the numbers, passes the
// search and the period to control-api (not the run or the status), and the
// list and CSV proxies need a direction.
func TestRegistryAlwaysPassTile(t *testing.T) {
fake, ts := analyticsFake(t)
first, last := time.Date(2026, 9, 1, 10, 0, 0, 0, time.UTC), time.Date(2026, 9, 30, 10, 0, 0, 0, time.UTC)
fake.alwaysPass = registryAlwaysPass{Runs: 22, FirstRunAt: &first, LastRunAt: &last, Addresses: 8, AlwaysPass: 3}
page := get(t, ts, "/registry?direction=egress&protocol=https&q=9&trend_from=2026-09-01")
if !strings.Contains(page, `hx-get="/registry/always-pass?direction=egress&protocol=https&q=9&trend_from=2026-09-01"`) {
t.Errorf("no tile slot in the page")
}
if strings.Contains(get(t, ts, "/registry?protocol=https"), `id="registry-always-pass"`) {
t.Error("no tile slot without a direction")
}
frag := get(t, ts, "/registry/always-pass?direction=egress&protocol=https&q=9&run=1&status=fail&trend_from=2026-09-01")
for _, want := range []string{`class="ap-tile"`, `aria-label="Всегда проходили: 3 из 8 адресов, 37,5 %`, "из 8 адресов · 37,5 %", "за 22 запуска, 2026-09-01 — 2026-09-30", `data-ap-qs="`} {
if !strings.Contains(frag, want) {
t.Errorf("expected %q in %s", want, frag)
}
}
fake.mu.Lock()
req := fake.alwaysPassReqs[len(fake.alwaysPassReqs)-1]
fake.mu.Unlock()
if !strings.Contains(req, "q=9") || !strings.Contains(req, "from=2026-09-01") || strings.Contains(req, "run=") || strings.Contains(req, "last_result") {
t.Errorf("always-pass request %q", req)
}
if frag = get(t, ts, "/registry/always-pass?protocol=https"); strings.Contains(frag, "ap-tile") || !strings.Contains(frag, "Выберите направление") {
t.Errorf("no direction: %s", frag)
}
if body := get(t, ts, "/registry/always-pass/list?direction=egress&protocol=https&trend_to=2026-09-30"); !strings.Contains(body, "1.2.3.4") {
t.Errorf("list proxy: %s", body)
}
if body := get(t, ts, "/registry/always-pass/csv?direction=egress&protocol=https"); !strings.Contains(body, "1.2.3.4") {
t.Errorf("csv proxy: %s", body)
}
if resp, err := http.Get(ts.URL + "/registry/always-pass/list?protocol=https"); err != nil || resp.StatusCode != http.StatusBadRequest {
t.Errorf("list without a direction: %v %v", resp, err)
if !strings.Contains(page, `id="registry-breakdown"`) {
t.Error("registry page is missing the summary of checks for the selected slice")
}
}