Files
traefik-llmgateway/webui/src/lib/breaker-severity.spec.ts
T
lukaszraczylo ec9df6a92d fix(webui): router fixture consistency and panel screenshots
Router escalation fixtures now scale tiers, reasons and outcomes with requests, and the shadow classifier differs from live. The harness captures each panel's full scroll height, runs checks on the expanded panel, and samples smartrouter/uni. RoutersPage no longer refetches on range change. The breaker State column sorts by severity.
2026-11-25 11:52:37 +00:00

20 lines
922 B
TypeScript

import { describe, expect, it } from 'vitest'
import { statusRank } from './breaker-severity'
import { sortThenSlice } from './table-sort'
describe('statusRank', () => {
it('ranks open > half-open > degraded > closed', () => {
expect(statusRank('open')).toBeGreaterThan(statusRank('half-open'))
expect(statusRank('half-open')).toBeGreaterThan(statusRank('degraded'))
expect(statusRank('degraded')).toBeGreaterThan(statusRank('closed'))
})
it('ranks an unknown state below closed so it never reads as severe', () => {
expect(statusRank('mystery')).toBeLessThan(statusRank('closed'))
})
it('sorts severity-first, not alphabetically', () => {
const rows = ['closed', 'open', 'degraded', 'half-open'].map((s) => ({ s, rank: statusRank(s) }))
expect(sortThenSlice(rows, { key: 'rank', direction: 'desc' }, 10, 0).map((r) => r.s)).toEqual(['open', 'half-open', 'degraded', 'closed'])
})
})