mirror of
https://github.com/supabase/supabase.git
synced 2026-06-20 22:06:04 +08:00
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? This introduces Query Insights. It's the first edition of possible future updates. This takes our old prototype and builds upon it for a more action driven insights view. --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Ali Waseem <waseema393@gmail.com>
33 lines
1012 B
TypeScript
33 lines
1012 B
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { isTimeMetric, formatTime } from './QueryInsightsChart.utils'
|
|
|
|
describe('isTimeMetric', () => {
|
|
it('returns true for p50 and p95', () => {
|
|
expect(isTimeMetric('p50')).toBe(true)
|
|
expect(isTimeMetric('p95')).toBe(true)
|
|
})
|
|
|
|
it('returns false for other keys', () => {
|
|
expect(isTimeMetric('calls')).toBe(false)
|
|
expect(isTimeMetric('count')).toBe(false)
|
|
expect(isTimeMetric('')).toBe(false)
|
|
expect(isTimeMetric('P50')).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('formatTime', () => {
|
|
it('formats a timestamp into a human-readable date string', () => {
|
|
const ts = new Date('2024-01-15T14:30:00Z').getTime()
|
|
const result = formatTime(ts)
|
|
expect(typeof result).toBe('string')
|
|
expect(result.length).toBeGreaterThan(0)
|
|
})
|
|
|
|
it('includes the month and day', () => {
|
|
const ts = new Date('2024-06-01T10:00:00Z').getTime()
|
|
const result = formatTime(ts)
|
|
expect(result).toMatch(/Jun/)
|
|
expect(result).toMatch(/1/)
|
|
})
|
|
})
|