fix(webui): compact config viewer, clear unknown helper sel, harness port guard

This commit is contained in:
2026-11-25 11:52:38 +00:00
parent 1f8bdd8777
commit 945621a3c5
9 changed files with 123 additions and 16 deletions
+19 -1
View File
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
import { filterSections, splitConfigSections } from '@/lib/config-sections'
import { filterSections, initialFold, splitConfigSections } from '@/lib/config-sections'
const YAML = ['admin:', ' enabled: true', 'agents:', ' a:', ' url: x', ' b:', ' url: y', '"odd/key":', ' v: 1', 'redis:', ' addr: r'].join('\n')
@@ -42,3 +42,21 @@ describe('filterSections', () => {
expect(filterSections(s, 'zzz')).toEqual([])
})
})
describe('initialFold', () => {
const big = (key: string, n: number) => [`${key}:`, ...Array.from({ length: n - 1 }, (_, i) => ` k${i}: v`)].join('\n')
const secs = splitConfigSections([big('small', 8), big('medium', 9), big('large', 40)].join('\n'))
it('collapses sections over 8 lines and keeps small ones open', () => {
expect([...initialFold(secs, {})].sort()).toEqual(['large', 'medium'])
})
it('keeps the hash target open', () => {
expect([...initialFold(secs, { target: 'large' })]).toEqual(['medium'])
})
it('keeps filter matches open', () => {
expect([...initialFold(secs, { filter: 'med' })]).toEqual(['large'])
})
it('ignores a blank filter and an unknown target', () => {
expect([...initialFold(secs, { filter: ' ', target: 'nope' })].sort()).toEqual(['large', 'medium'])
})
})