fix(ui): load each overview panel once

The download trend, leaderboards and scanner health sat inside the
stats loading branch. A stats refresh unmounted and remounted them,
so every panel fetched its data twice on each visit.
This commit is contained in:
2026-11-24 02:19:44 +00:00
parent 48bd654839
commit 7b8ff467b8
2 changed files with 22 additions and 6 deletions
+9
View File
@@ -46,6 +46,15 @@ async function open() {
}
describe('Overview', () => {
it('fetches each panel once while the stats load', async () => {
await open()
const urls = vi.mocked(axios.get).mock.calls.map(([url]) => String(url))
const count = (prefix: string) => urls.filter((u) => u.startsWith(prefix)).length
expect(count('/api/stats/timeseries')).toBe(1)
expect(count('/api/analytics/trending')).toBe(1)
expect(urls.filter((u) => u.includes('layout=rows')).length).toBe(1)
})
it('counts each verdict from the stats', async () => {
const { wrapper, problems } = await open()
expect(problems).toEqual([])
+13 -6
View File
@@ -40,17 +40,25 @@
<template #icon><Icon :icon="tile.icon" :class="VERDICT_TEXT[tile.verdict]" /></template>
</KpiTile>
</StatGroup>
</template>
<div class="grid items-start gap-6 xl:grid-cols-3">
<CacheCapacity :used="displayStats?.total_size ?? 0" :max-size="displayStats?.max_cache_size ?? 0" :registries="registries" />
<DownloadTrend class="xl:col-span-2" />
</div>
<!-- Outside the stats loading chain: a stats refresh must not remount these and refetch their data. -->
<div class="grid items-start gap-6 xl:grid-cols-3">
<CacheCapacity
v-if="displayStats"
:used="displayStats.total_size ?? 0"
:max-size="displayStats.max_cache_size ?? 0"
:registries="registries"
/>
<LoadingState v-else-if="loading" variant="card" label="Loading cache capacity..." />
<DownloadTrend class="xl:col-span-2" />
</div>
<TopPackages />
<div class="grid gap-6 lg:grid-cols-2">
<ScannerHealth />
<Card class="min-w-0" data-testid="ws-event-feed">
<Card v-if="!(error && !displayStats)" class="min-w-0" data-testid="ws-event-feed">
<CardHeader>
<CardTitle as="h2">Live activity</CardTitle>
<CardDescription>What the proxy just did.</CardDescription>
@@ -67,7 +75,6 @@
</CardContent>
</Card>
</div>
</template>
</div>
</template>