mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-24 05:43:58 +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>
73 lines
2.5 KiB
TypeScript
73 lines
2.5 KiB
TypeScript
import { formatFilterURLParams, formatSortURLParams } from 'components/grid/SupabaseGrid.utils'
|
|
import { describe, test, expect } from 'vitest'
|
|
|
|
// Sort URL syntax: `column:order`
|
|
describe('SupabaseGrid.utils: formatSortURLParams', () => {
|
|
test('should return an array of sort options based on URL params', () => {
|
|
const mockInput = ['id:asc', 'name:desc']
|
|
const output = formatSortURLParams('fakeTable', mockInput)
|
|
expect(output).toStrictEqual([
|
|
{ table: 'fakeTable', column: 'id', ascending: true },
|
|
{ table: 'fakeTable', column: 'name', ascending: false },
|
|
])
|
|
})
|
|
test('should reject any malformed sort options based on URL params', () => {
|
|
const mockInput = ['id', 'name:asc', ':asc']
|
|
const output = formatSortURLParams('fakeTable', mockInput)
|
|
expect(output).toStrictEqual([
|
|
{
|
|
table: 'fakeTable',
|
|
column: 'name',
|
|
ascending: true,
|
|
},
|
|
])
|
|
})
|
|
})
|
|
|
|
// Filter URL syntax: `column:operatorAbbreviation:value`
|
|
describe('SupabaseGrid.utils: formatFilterURLParams', () => {
|
|
test('should return an array of filter options based on URL params', () => {
|
|
const mockInput = ['id:gte:20', 'id:lte:40']
|
|
const output = formatFilterURLParams(mockInput)
|
|
expect(output).toHaveLength(2)
|
|
expect(output[0]).toStrictEqual({
|
|
column: 'id',
|
|
operator: '>=',
|
|
value: '20',
|
|
})
|
|
expect(output[1]).toStrictEqual({
|
|
column: 'id',
|
|
operator: '<=',
|
|
value: '40',
|
|
})
|
|
})
|
|
test('should format filters for timestamps correctly', () => {
|
|
const mockInput = ['created_at:gte:2022-05-30 03:00:00']
|
|
const output = formatFilterURLParams(mockInput)
|
|
expect(output[0]).toStrictEqual({
|
|
column: 'created_at',
|
|
operator: '>=',
|
|
value: '2022-05-30 03:00:00',
|
|
})
|
|
})
|
|
test('should reject any malformed filter options based on URL params', () => {
|
|
const mockInput = ['id', ':gte', ':50', 'id:eq:10']
|
|
const output = formatFilterURLParams(mockInput)
|
|
expect(output).toHaveLength(1)
|
|
})
|
|
test('should reject any filter options with unrecognized operator', () => {
|
|
const mockInput = ['id:meme:40', 'name:eq:town']
|
|
const output = formatFilterURLParams(mockInput)
|
|
expect(output).toHaveLength(1)
|
|
})
|
|
test('should allow filter options to have empty value based on URL params', () => {
|
|
const mockInput = ['id:ilike:']
|
|
const output = formatFilterURLParams(mockInput)
|
|
expect(output).toHaveLength(1)
|
|
expect(output[0]).toStrictEqual({
|
|
column: 'id',
|
|
operator: '~~*',
|
|
value: '',
|
|
})
|
|
})
|
|
})
|