test: assert Trend panel renders on full repo page
This commit is contained in:
@@ -87,3 +87,37 @@ func TestUIRepoTrend_InvalidRangeFallsBackTo30d(t *testing.T) {
|
|||||||
t.Errorf("expected data-range=30d on invalid range fallback")
|
t.Errorf("expected data-range=30d on invalid range fallback")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestUIRepoPageRendersTrendPanel — full-page render path: seed 3
|
||||||
|
// history rows, fetch /hosts/{id}/repo, assert the Trend panel with
|
||||||
|
// SVG chart ID, class, and heading text appear embedded in the page.
|
||||||
|
func TestUIRepoPageRendersTrendPanel(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
_, baseURL, st := newTestServerWithUI(t)
|
||||||
|
cookie := loginAsAdmin(t, st)
|
||||||
|
hostID := makeHost(t, st, "h-trend-page")
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
now := time.Now().UTC()
|
||||||
|
for i := 0; i < 3; i++ {
|
||||||
|
day := now.AddDate(0, 0, -i).Format("2006-01-02")
|
||||||
|
v := int64(2000 + i*200)
|
||||||
|
c := int64(20 + i)
|
||||||
|
if err := st.UpsertHostRepoStatsHistory(ctx, hostID, day,
|
||||||
|
store.HostRepoStats{TotalSizeBytes: &v, SnapshotCount: &c}, now); err != nil {
|
||||||
|
t.Fatalf("seed %s: %v", day, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
body := getRepoPage(t, baseURL, hostID, cookie)
|
||||||
|
|
||||||
|
if !strings.Contains(body, `id="repo-trend-chart"`) {
|
||||||
|
t.Errorf("expected id=\"repo-trend-chart\" in full-page render")
|
||||||
|
}
|
||||||
|
if !strings.Contains(body, `class="repo-trend-chart"`) {
|
||||||
|
t.Errorf("expected class=\"repo-trend-chart\" in full-page render")
|
||||||
|
}
|
||||||
|
if !strings.Contains(body, ">Trend<") {
|
||||||
|
t.Errorf("expected panel heading '>Trend<' in full-page render")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user