mirror of
https://github.com/supabase/supabase.git
synced 2026-10-15 22:29:11 +03:00
* default to 69mins add 3 hours opt * Enhance Reports Datepicker Helpers with Plan Availability - Introduced `ReportsDatetimeHelper` interface to include `availableIn` property for plan-specific availability. - Updated existing datepicker helpers to specify availability for different plans. - Renamed 'Last 30 days' to 'Last 28 days' for consistency. - Added `createFilteredDatePickerHelpers` function to filter helpers based on the user's plan. * Refactor Datepicker Helpers in API Overview Report - Replaced the usage of `REPORTS_DATEPICKER_HELPERS` with the new `createFilteredDatePickerHelpers` function to enhance plan-specific filtering. - This change streamlines the datepicker helper logic based on user plan availability. * Refactor Storage Report Datepicker Helpers - Updated the Storage Report component to use `createFilteredDatePickerHelpers` for plan-specific datepicker logic. - This change simplifies the datepicker helper implementation and enhances maintainability. * fix test
35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
import { screen } from '@testing-library/react'
|
|
import { beforeAll, test, vi } from 'vitest'
|
|
|
|
import { ApiReport } from 'pages/project/[ref]/reports/api-overview'
|
|
import { render } from '../../../helpers'
|
|
|
|
// [Joshen] Mock data for ApiReport is in __mocks__/hooks/useApiReport
|
|
// I don't think this is an ideal set up as the mock data is not clear in this file itself
|
|
// But this is the method that worked for me after hours of wrangling with jest.spyOn and jest.mock
|
|
// which for some reason none of them worked when I was trying to mock the data within the file itself
|
|
// I'd be keen to see how we can do this better if anyone is more familiar to jest 🙏
|
|
|
|
beforeAll(() => {
|
|
vi.mock('nuqs', async () => {
|
|
let queryValue = 'example'
|
|
return {
|
|
useQueryState: () => [queryValue, (v: string) => (queryValue = v)],
|
|
parseAsBoolean: {
|
|
withDefault: () => true,
|
|
},
|
|
}
|
|
})
|
|
})
|
|
|
|
test(`Render static elements`, async () => {
|
|
render(<ApiReport dehydratedState={{}} />)
|
|
await screen.findByText('Total Requests')
|
|
await screen.findByText('Response Errors')
|
|
await screen.findByText('Response Speed')
|
|
await screen.findByText('Network Traffic')
|
|
await screen.findByText(/Last 60 minutes/)
|
|
await screen.findByText(/Add filter/)
|
|
await screen.findByText(/All Requests/)
|
|
})
|