Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion frontend/src/components/History/ScenarioHistory.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FluentProvider, webLightTheme } from '@fluentui/react-components'
import { act, render, screen, waitFor, within } from '@testing-library/react'
import { act, fireEvent, render, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'

import { useScenarioQueue } from '@/hooks/useScenarioQueue'
Expand Down Expand Up @@ -765,6 +765,21 @@ describe('ScenarioHistory', () => {
))
})

it('offers the QUEUED run status filter', async () => {
const onFiltersChange = jest.fn()
mockedScenariosApi.listRuns.mockResolvedValue({
items: [RUN],
pagination: { limit: 25, has_more: false },
})
renderHistory({ ...defaultProps, onFiltersChange })
await screen.findByTestId('scenario-history-table')

fireEvent.click(screen.getByTestId('scenario-status-filter'))
fireEvent.click(await screen.findByText('Queued'))

expect(onFiltersChange).toHaveBeenCalledWith({ ...DEFAULT_SCENARIO_HISTORY_FILTERS, statuses: ['QUEUED'] })
})

it('hides stale pagination while changed filters are loading', async () => {
let resolveFilteredRequest: ((value: Awaited<ReturnType<typeof scenariosApi.listRuns>>) => void) | undefined
mockedScenariosApi.listRuns
Expand Down
17 changes: 15 additions & 2 deletions frontend/src/components/History/scenarioHistoryFilters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,29 @@ describe('scenario history URL filters', () => {
})
})

it('ignores synthetic and invalid run states without dropping valid filters', () => {
it('ignores invalid run states without dropping valid filters', () => {
const params = new URLSearchParams('status=COMPLETED&status=QUEUED&status=UNKNOWN&operator=alice')

expect(scenarioHistoryFiltersFromSearchParams(params)).toEqual({
...DEFAULT_SCENARIO_HISTORY_FILTERS,
statuses: ['COMPLETED'],
statuses: ['COMPLETED', 'QUEUED'],
operator: ['alice'],
})
})

it('keeps a QUEUED-only status filter', () => {
const params = new URLSearchParams('status=QUEUED')

expect(scenarioHistoryFiltersFromSearchParams(params)).toEqual({
...DEFAULT_SCENARIO_HISTORY_FILTERS,
statuses: ['QUEUED'],
})
})

it('lists every persisted run state in backend order', () => {
expect(SCENARIO_RUN_STATES).toEqual(['CREATED', 'QUEUED', 'IN_PROGRESS', 'COMPLETED', 'FAILED', 'CANCELLED'])
})

it('round-trips every persisted run state', () => {
const filters = {
...DEFAULT_SCENARIO_HISTORY_FILTERS,
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/History/scenarioHistoryFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const DEFAULT_SCENARIO_HISTORY_FILTERS: ScenarioHistoryFilters = {

export const SCENARIO_RUN_STATES: readonly ScenarioRunState[] = [
'CREATED',
'QUEUED',
'IN_PROGRESS',
'COMPLETED',
'FAILED',
Expand Down
Loading