fix(webui): resilient dashboard polling (SF7)

useDashboardStore.refresh() used Promise.all across overview/usage/
targets: one route rejecting threw before any of the three state
fields were assigned, so a single flaky GET /admin/api/targets blanked
the already-working Providers and Usage views too.

Switched to Promise.allSettled with per-section assignment: a
fulfilled result updates its own field, a rejected one leaves the
PREVIOUS value in place rather than nulling it. lastUpdated still
advances on a partial success (some fresh data did arrive); error
names which section(s) failed. A 401/403 on any section still defers
to the auth store exactly as before (AdminApiError check unchanged).

Added dashboard.spec.ts — the first Pinia store under vitest in this
package (a store needs no DOM, so it fits the existing 'node'
environment without pulling in jsdom); vite.config.ts's own test-scope
comment updated to say so.
This commit is contained in:
2026-08-21 19:16:32 +01:00
parent 8afb903227
commit a25ebf0567
3 changed files with 187 additions and 22 deletions
+10 -6
View File
@@ -33,12 +33,16 @@ export default defineConfig({
modulePreload: { polyfill: false },
},
test: {
// Deliberately narrow: only lib/'s pure modules (search-expand.ts,
// usage-search.ts) are under vitest right now (webui's test infra
// starts here, on purpose — no snapshot/DOM/component testing this
// round). 'node' is enough since neither module touches browser
// globals; jsdom is not pulled in as a dependency for modules that
// don't need it.
// Deliberately narrow: lib/'s pure modules (search-expand.ts,
// usage-search.ts) plus, since review round 2 (v0.21), stores/
// dashboard.ts's own refresh() action — a Pinia store is plain
// reactive state and actions, no DOM or component mount involved, so
// it fits this same environment. Still no snapshot/DOM/component
// (.vue mount) testing. 'node' is enough since nothing under test
// touches a real browser global — dashboard.spec.ts mocks lib/api.ts
// entirely, so even sessionStorage access (auth.ts) never actually
// runs; jsdom is not pulled in as a dependency for modules that don't
// need it.
environment: 'node',
include: ['src/**/*.spec.ts'],
},