mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
* wip * add formatTimestamp for reports * add tests for formatTimestamp * fix type err * rm old chart logic * do not retry replication sources * update report config schema * use report config * fix charts, simplify config * sync charts * rm comment * usefilltimeseries * move chart upsell to its own component * cleanup v2 chart component * fix chartheader function format bug * make attributes dynamic * move types to its own file * update reportv2chart types * update reportv2 chart type * use new edgefn report * rm mock * rm old code * fix type err * fix type err * rename hook * return sql in dataprovider * add button to open in log explorer in chart header * fix type * fix chart type toggle * fix type error * export data transformation for testing * add tests for data transformation * rm dupped code * add report settings to edge fn report * rm mocked data * rename * fix type err * Apply suggestion from @joshenlim Co-authored-by: Joshen Lim <joshenlimek@gmail.com> * rm unnecessary div * rm unnecessary props from report upsell * cleaner query keys * move loadin/error/empty states to inside panel content to prevent layout shift * use card instead of panel * use buttontooltip in chartheader * use buttontooltips in buttons with tooltips * rm export default * rm export defualt * rm i from key * fix status code transformation * fix filltimeseries * add tests for filltimeseries * fix data transform * pass xaxis key to chart * refactor hover state to use timestamp not index * fix tests * fix areachart * fix barchart * fix chartheader * fix composedchart * fix stacked * fix type missing xaxiskey * type fix * Revert "refactor hover state to use timestamp not index" This reverts commitcfd7886460. * undo charthover changes, fix data aggregation * Revert "fix tests" This reverts commite5200a2035. * move transforms to testable functions, add tests * nit refactors and clean up * feat: add aws nimbus cloud provider (#38312) * feat: add aws nimbus cloud provider * Fix return type of useCustomContent hook --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com> * add utc plugin to dayjs * move plugins to vitest setup * rm customparser plugin --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com> Co-authored-by: Alaister Young <alaister@users.noreply.github.com>
68 lines
1.8 KiB
TypeScript
68 lines
1.8 KiB
TypeScript
import '@testing-library/jest-dom/vitest'
|
|
import { cleanup, configure } from '@testing-library/react'
|
|
import { createDynamicRouteParser } from 'next-router-mock/dist/dynamic-routes'
|
|
import { afterAll, afterEach, beforeAll, vi } from 'vitest'
|
|
import { routerMock } from './lib/route-mock'
|
|
import { mswServer } from './lib/msw'
|
|
import dayjs from 'dayjs'
|
|
import utc from 'dayjs/plugin/utc'
|
|
import timezone from 'dayjs/plugin/timezone'
|
|
import relativeTime from 'dayjs/plugin/relativeTime'
|
|
|
|
dayjs.extend(utc)
|
|
dayjs.extend(timezone)
|
|
dayjs.extend(relativeTime)
|
|
|
|
// Uncomment this if HTML in errors are being annoying.
|
|
//
|
|
// configure({
|
|
// getElementError: (message, container) => {
|
|
// const error = new Error(message ?? 'Element not found')
|
|
// error.name = 'ElementNotFoundError'
|
|
// return error
|
|
// },
|
|
// })
|
|
|
|
beforeAll(() => {
|
|
mswServer.listen({ onUnhandledRequest: `error` })
|
|
vi.mock('next/router', () => require('next-router-mock'))
|
|
vi.mock('next/navigation', async () => {
|
|
const actual = await vi.importActual('next/navigation')
|
|
return {
|
|
...actual,
|
|
useRouter: () => {
|
|
return {
|
|
push: vi.fn(),
|
|
replace: vi.fn(),
|
|
}
|
|
},
|
|
usePathname: () => vi.fn(),
|
|
useSearchParams: () => ({
|
|
get: vi.fn(),
|
|
}),
|
|
}
|
|
})
|
|
|
|
vi.mock('next/compat/router', () => require('next-router-mock'))
|
|
|
|
// Mock the useParams hook from common module globally
|
|
vi.mock('common', async (importOriginal: any) => {
|
|
const actual = await importOriginal()
|
|
return {
|
|
...(typeof actual === 'object' ? actual : {}),
|
|
useParams: () => ({ ref: 'default' }),
|
|
}
|
|
})
|
|
|
|
routerMock.useParser(createDynamicRouteParser(['/projects/[ref]']))
|
|
})
|
|
|
|
afterEach(() => {
|
|
mswServer.resetHandlers()
|
|
cleanup()
|
|
})
|
|
|
|
afterAll(() => {
|
|
mswServer.close()
|
|
})
|