mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
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.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
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'])
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,6 @@
|
||||
const SEVERITY: Record<string, number> = { open: 3, 'half-open': 2, degraded: 1, closed: 0 }
|
||||
|
||||
/** Sort rank of a breaker status, most severe highest; unknown states rank below closed. */
|
||||
export function statusRank(status: string): number {
|
||||
return SEVERITY[status] ?? -1
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import { loadState } from '@/lib/load-state'
|
||||
import { pageWindow } from '@/lib/paging'
|
||||
import { sortThenSlice } from '@/lib/table-sort'
|
||||
import type { SortSpec } from '@/lib/table-sort'
|
||||
import { statusRank } from '@/lib/breaker-severity'
|
||||
import { breakerRows, ratePercentSeries } from '@/lib/provider-rate'
|
||||
import type { BreakerRow } from '@/lib/provider-rate'
|
||||
import { scopeId } from '@/lib/scope'
|
||||
@@ -31,6 +32,7 @@ const MAX_AXIS_LABELS = 6
|
||||
interface BreakerView extends BreakerRow {
|
||||
until: string
|
||||
status: string
|
||||
statusRank: number
|
||||
}
|
||||
|
||||
const dashboard = useDashboardStore()
|
||||
@@ -137,6 +139,7 @@ const breakers = computed<BreakerView[]>(() => {
|
||||
...r,
|
||||
until: r.state === 'open' ? formatUntil(r.openUntil) || 'due' : '',
|
||||
status: r.degraded ? 'degraded' : r.state,
|
||||
statusRank: statusRank(r.degraded ? 'degraded' : r.state),
|
||||
}))
|
||||
})
|
||||
const phone = ref(false)
|
||||
@@ -148,7 +151,8 @@ const breakerPageSize = computed(() => (phone.value ? BREAKER_PAGE_SIZE_PHONE :
|
||||
const breakerPage = ref(1)
|
||||
const breakerWindow = computed(() => pageWindow(breakers.value.length, breakerPageSize.value, breakerPage.value - 1))
|
||||
const breakerSort = ref<SortSpec | null>(null)
|
||||
const breakerPaged = computed(() => sortThenSlice(breakers.value, breakerSort.value, breakerPageSize.value, breakerWindow.value.index))
|
||||
const breakerSortSpec = computed<SortSpec | null>(() => (breakerSort.value?.key === 'status' ? { ...breakerSort.value, key: 'statusRank' } : breakerSort.value))
|
||||
const breakerPaged = computed(() => sortThenSlice(breakers.value, breakerSortSpec.value, breakerPageSize.value, breakerWindow.value.index))
|
||||
function onBreakerSort(next: SortSpec | null): void {
|
||||
breakerSort.value = next
|
||||
breakerPage.value = 1
|
||||
|
||||
@@ -10,7 +10,6 @@ import { sortThenSlice } from '@/lib/table-sort'
|
||||
import type { SortSpec } from '@/lib/table-sort'
|
||||
import { wbColumns } from '@/lib/wb-columns'
|
||||
import RouterPanel from '@/panels/RouterPanel.vue'
|
||||
import { useFiltersStore } from '@/stores/filters'
|
||||
import { useModelsStore } from '@/stores/models'
|
||||
import { useNavStore } from '@/stores/nav'
|
||||
import StateView from '@/widgets/StateView.vue'
|
||||
@@ -30,15 +29,10 @@ interface Row {
|
||||
escalations: number | null
|
||||
}
|
||||
|
||||
const filters = useFiltersStore()
|
||||
const models = useModelsStore()
|
||||
const nav = useNavStore()
|
||||
|
||||
onMounted(() => void models.fetch())
|
||||
watch(
|
||||
() => filters.range,
|
||||
() => void models.fetch(),
|
||||
)
|
||||
|
||||
const rows = computed<Row[]>(() =>
|
||||
models.routers.map((r) => ({
|
||||
|
||||
@@ -18,7 +18,7 @@ function onOpen(open: boolean): void {
|
||||
<SheetTitle class="truncate">{{ title }}</SheetTitle>
|
||||
<SheetDescription class="sr-only">{{ kind }} details for {{ title }}</SheetDescription>
|
||||
</SheetHeader>
|
||||
<div class="min-w-0 flex-1 overflow-y-auto">
|
||||
<div class="min-w-0 flex-1 overflow-y-auto" data-panel-scroll>
|
||||
<slot />
|
||||
</div>
|
||||
</SheetContent>
|
||||
|
||||
Reference in New Issue
Block a user