mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Problem A custom date range in a Storage report URL could show one window in the header and another in the charts. Refresh also left Database Size and several Auth charts showing cached results. ## Fix Use the selected window for all Storage report requests, run the Database Size query on refresh, and refresh Auth Usage, Errors and Latency alongside the shared API charts. ## How to test - Open Storage with a custom start and end time in the URL. Inspect the chart requests on load and after Refresh. Both sets should use those exact timestamps. - Refresh the Database report and check that the large objects query runs again. - Open Auth with a fixed range and press Shift+R. The Usage, Errors, Latency and API charts should request fresh data for the same range. Fixes [FE-5122](https://linear.app/supabase/issue/FE-5122).
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import { QueryClient } from '@tanstack/react-query'
|
|
import { act, waitFor } from '@testing-library/react'
|
|
import { HttpResponse } from 'msw'
|
|
import { expect, test } from 'vitest'
|
|
|
|
import { useDatabaseReport } from './database-report-query'
|
|
import { projectKeys } from '@/data/projects/keys'
|
|
import { replicaKeys } from '@/data/read-replicas/keys'
|
|
import { customRenderHook } from '@/tests/lib/custom-render'
|
|
import { addAPIMock } from '@/tests/lib/msw'
|
|
|
|
test('refresh loads updated database size data', async () => {
|
|
let size = 100
|
|
addAPIMock({
|
|
method: 'post',
|
|
path: '/platform/pg-meta/:ref/query',
|
|
response: () => HttpResponse.json<{ size: number }[]>([{ size }]),
|
|
})
|
|
const queryClient = new QueryClient({
|
|
defaultOptions: { queries: { retry: false, staleTime: Infinity } },
|
|
})
|
|
queryClient.setQueryData(projectKeys.detail('default'), {
|
|
ref: 'default',
|
|
connectionString: 'postgresql://test:password@localhost:5432/postgres',
|
|
})
|
|
queryClient.setQueryData(replicaKeys.list('default'), [])
|
|
const { result } = customRenderHook(() => useDatabaseReport(), { queryClient })
|
|
|
|
await waitFor(() => expect(result.current.data.largeObjects).toEqual([{ size: 100 }]))
|
|
|
|
size = 200
|
|
act(() => {
|
|
result.current.refresh()
|
|
})
|
|
|
|
await waitFor(() => expect(result.current.data.largeObjects).toEqual([{ size: 200 }]))
|
|
})
|