Files
supabase/apps/studio/components/interfaces/QueryInsights/QueryInsightsChart/QueryInsightsChart.utils.test.ts
kemal.earth 7ed8ab83a8 feat(studio): query insights improvements (#43109)
## 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>
2026-03-13 15:09:26 +00:00

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/)
})
})