Harden RC9 UX and performance states
GeoIntel release gates / Compile, test, contracts and builds (push) Canceled after 0s
GeoIntel release gates / Python and npm vulnerability policy (push) Canceled after 0s
GeoIntel release gates / GIS image, SBOM and container scan (push) Canceled after 0s

This commit is contained in:
Codex
2026-07-18 06:37:54 +02:00
parent 55685ba1bd
commit 9b0239747d
21 changed files with 845 additions and 25 deletions
@@ -0,0 +1,26 @@
import { describe, expect, it } from 'vitest'
import {
COVERAGE_RESPONSE_BUDGET_MS,
MAP_ANALYSIS_BUDGET_MS,
exceedsPerformanceBudget,
formatPerformanceDuration,
} from './performanceBudget'
describe('release performance budgets', () => {
it('keeps coverage stricter than complete map analysis', () => {
expect(COVERAGE_RESPONSE_BUDGET_MS).toBe(4_000)
expect(MAP_ANALYSIS_BUDGET_MS).toBe(15_000)
})
it('only marks completed work above its budget as slow', () => {
expect(exceedsPerformanceBudget(null, 4_000)).toBe(false)
expect(exceedsPerformanceBudget(4_000, 4_000)).toBe(false)
expect(exceedsPerformanceBudget(4_001, 4_000)).toBe(true)
})
it('formats timings for compact operator feedback', () => {
expect(formatPerformanceDuration(null)).toBeNull()
expect(formatPerformanceDuration(238)).toBe('238 ms')
expect(formatPerformanceDuration(1_250)).toBe('1,3 s')
})
})
+18
View File
@@ -0,0 +1,18 @@
export const COVERAGE_RESPONSE_BUDGET_MS = 4_000
export const MAP_ANALYSIS_BUDGET_MS = 15_000
export function exceedsPerformanceBudget(
durationMs: number | null,
budgetMs: number,
): boolean {
return durationMs !== null && durationMs > budgetMs
}
export function formatPerformanceDuration(durationMs: number | null): string | null {
if (durationMs === null) return null
if (durationMs < 1_000) return `${Math.max(1, Math.round(durationMs))} ms`
return `${(durationMs / 1_000).toLocaleString('nl-BE', {
maximumFractionDigits: 1,
minimumFractionDigits: 1,
})} s`
}