mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-25 15:03:46 +00:00
Major additions: - Complete Next.js studio application with 1600+ components - Docker support (Dockerfile.combined, docker-compose.yml) - GCP deployment documentation and benchmarks - SQL benchmark scripts for performance testing - Sentry integration for monitoring - Comprehensive test suite and mocks Studio features: - Dashboard and admin interfaces - Data visualization components - Authentication and user management - API integration with RuVector backend - Static data and public assets 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { formatDuration } from './QueryPerformance.utils'
|
|
import { calculatePercentilesFromHistogram } from './WithMonitor/WithMonitor.utils'
|
|
|
|
describe('formatDuration', () => {
|
|
it('should format seconds', () => {
|
|
expect(formatDuration(1000)).toBe('1.00s')
|
|
expect(formatDuration(30000)).toBe('30.00s')
|
|
})
|
|
|
|
it('should format minutes and seconds', () => {
|
|
expect(formatDuration(60000)).toBe('1m')
|
|
expect(formatDuration(125000)).toBe('2m 5s')
|
|
})
|
|
|
|
it('should format hours, minutes and seconds', () => {
|
|
expect(formatDuration(3600000)).toBe('1h')
|
|
expect(formatDuration(3661000)).toBe('1h 1m 1s')
|
|
})
|
|
|
|
it('should format days, hours, minutes and seconds', () => {
|
|
expect(formatDuration(86400000)).toBe('1d')
|
|
expect(formatDuration(90061000)).toBe('1d 1h 1m 1s')
|
|
})
|
|
})
|
|
|
|
describe('calculatePercentilesFromHistogram', () => {
|
|
it('should return zero for empty histogram', () => {
|
|
const result = calculatePercentilesFromHistogram([])
|
|
expect(result.p95).toBe(0)
|
|
})
|
|
|
|
it('should return valid p95 for typical distribution', () => {
|
|
const result = calculatePercentilesFromHistogram([10, 20, 30, 20, 10, 10])
|
|
expect(result.p95).toBeGreaterThan(0)
|
|
expect(result.p95).toBeGreaterThanOrEqual(result.p50)
|
|
})
|
|
|
|
it('should return consistent p95 for same input', () => {
|
|
const histogram = [10, 20, 30, 20, 10, 10]
|
|
const result1 = calculatePercentilesFromHistogram(histogram)
|
|
const result2 = calculatePercentilesFromHistogram(histogram)
|
|
expect(result1.p95).toBe(result2.p95)
|
|
})
|
|
})
|