From 81e3f9c74fd129d6749e0706dd973910100ac6b9 Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Mon, 23 Nov 2026 01:37:40 +0000 Subject: [PATCH] fix(frontend): show load failures as errors and add a not-found route A failed request left the store error set while the view kept its own empty-list branch, so the page said nothing was cached. Every view now checks loading, then error, then content, and the retry button refetches. Unknown paths render a NotFound page with a link to the dashboard. The brand shares the sidebar left edge, and a stopped socket reads Live updates paused in a neutral tone; the client already retries with backoff. --- frontend/src/App.vue | 3 +- .../src/components/BypassManagementPanel.vue | 6 +- frontend/src/components/Dashboard.spec.ts | 17 +++ frontend/src/components/Dashboard.vue | 26 +++-- frontend/src/components/NotFound.vue | 26 +++++ frontend/src/components/PackageList.vue | 13 ++- frontend/src/components/Stats.spec.ts | 4 +- frontend/src/components/Stats.vue | 6 +- .../src/components/VulnerablePackages.vue | 5 + frontend/src/components/views.errors.spec.ts | 107 ++++++++++++++++++ frontend/src/components/views.smoke.spec.ts | 6 +- frontend/src/router/index.ts | 96 ++++++++-------- frontend/src/test/router.ts | 23 +--- 13 files changed, 253 insertions(+), 85 deletions(-) create mode 100644 frontend/src/components/NotFound.vue create mode 100644 frontend/src/components/views.errors.spec.ts diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 9895115..37d3c47 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -21,8 +21,9 @@ onMounted(() => { class="sr-only focus:not-sr-only focus:absolute focus:start-2 focus:top-2 focus:z-(--z-toast) focus:rounded-md focus:bg-primary focus:px-3 focus:py-2 focus:text-sm focus:text-primary-foreground" >Skip to main content + - + @@ -211,16 +220,19 @@ interface TimeSeriesStats { const timeSeriesData = ref(null) const chartLoading = ref(false) +const chartError = ref(null) // Fetch time-series data from API async function fetchTimeSeriesData() { chartLoading.value = true + chartError.value = null try { const response = await axios.get(`/api/stats/timeseries?period=${selectedPeriod.value}`) timeSeriesData.value = response.data } catch (err) { console.error('Failed to fetch time-series data:', err) timeSeriesData.value = null + chartError.value = err instanceof Error ? err.message : 'Failed to load download activity' } finally { chartLoading.value = false } diff --git a/frontend/src/components/NotFound.vue b/frontend/src/components/NotFound.vue new file mode 100644 index 0000000..7d89106 --- /dev/null +++ b/frontend/src/components/NotFound.vue @@ -0,0 +1,26 @@ + + + diff --git a/frontend/src/components/PackageList.vue b/frontend/src/components/PackageList.vue index 1080e89..5693d9c 100644 --- a/frontend/src/components/PackageList.vue +++ b/frontend/src/components/PackageList.vue @@ -16,16 +16,16 @@ + + - - { }) it('displays error message when error occurs', async () => { - const wrapper = mount(Stats) const store = usePackageStore() + vi.spyOn(store, 'fetchStats').mockResolvedValue() + const wrapper = mount(Stats) + store.loading = false store.error = 'Failed to fetch statistics' await wrapper.vm.$nextTick() diff --git a/frontend/src/components/Stats.vue b/frontend/src/components/Stats.vue index e9a1cf3..d6ea180 100644 --- a/frontend/src/components/Stats.vue +++ b/frontend/src/components/Stats.vue @@ -2,16 +2,16 @@
+ + - -