Files
supabase/apps/studio/components/interfaces/Settings/Logs/Logs.timeRange.test.ts
Joshen Lim 17f21bf6a8 Joshenlim/fe 4510 auditlogs filterbar for account logs (#51790)
## Context

Replaces the individual filters on the Account audit logs page with the
filter bar to match a consistent UX across log surfaces
<img width="1206" height="360" alt="image"
src="https://github.com/user-attachments/assets/c5bdfd7e-3277-4695-b9fc-1791df8720c7"
/>

Also uses the `supportOperators` param for the `FilterBar` to support
"OR" based operations when filtering for projects
<img width="1219" height="97" alt="image"
src="https://github.com/user-attachments/assets/d4748e6c-d1f3-4f23-b767-e0f4bb1c0a1c"
/>

The main changes for the `FilterBar` component made in this PR (which
would be more relevant for the design team) are:
- Added a divider between the options and "New group" 
  - Originally didn't have a divider
- So there's a clearer distinction that the "New group" isn't a option
to set as the value for
- Add a new `defaultGroupOperator` prop
  - Originally defaults to `AND`
- However, in the context of Audit Logs when filtering for projects,
you'd expect `OR` to be the default to filter across several projects
(`AND` wouldn't make sense here)
2026-10-16 13:30:19 +08:00

25 lines
769 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, expect, it } from 'vitest'
import { parseTimeRange, serializeTimeRange } from './Logs.timeRange'
const range: [Date, Date] = [new Date('2026-09-22T02:00:00Z'), new Date('2026-09-22T03:00:00Z')]
describe('serializeTimeRange / parseTimeRange', () => {
it('round-trips a date range', () => {
expect(parseTimeRange(serializeTimeRange(range))).toEqual(range)
})
it.each([
undefined,
null,
'',
'invalid',
'2026-09-22T02:00:00Z',
'invalid – 2026-09-22T03:00:00Z',
'2026-09-22T03:00:00Z – 2026-09-22T02:00:00Z',
'2026-09-22T02:00:00Z – 2026-09-22T03:00:00Z – 2026-09-22T04:00:00Z',
])('rejects an invalid or incomplete range: %s', (value) => {
expect(parseTimeRange(value)).toBeUndefined()
})
})