Updates
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import test from 'brittle'
|
||||
import { groupCatalog, sectionForChart, SECTIONS, TAXONOMY_VERSION } from '../shared/taxonomy.js'
|
||||
|
||||
test('taxonomy version and sections', (t) => {
|
||||
t.ok(TAXONOMY_VERSION >= 1)
|
||||
t.ok(SECTIONS.length >= 5)
|
||||
})
|
||||
|
||||
test('sectionForChart routes common prefixes', (t) => {
|
||||
t.is(sectionForChart('system.cpu', { context: 'system.cpu' }).id, 'system')
|
||||
t.is(sectionForChart('docker.cpu.abc', {}).id, 'containers')
|
||||
t.is(sectionForChart('nginx.connections', {}).id, 'applications')
|
||||
t.is(sectionForChart('ebpf.cachestat', {}).id, 'observability')
|
||||
t.is(sectionForChart('fleet.nodes', {}).id, 'fleet')
|
||||
t.is(sectionForChart('custom.weird', {}).id, 'other')
|
||||
})
|
||||
|
||||
test('groupCatalog filters and sorts', (t) => {
|
||||
const catalog = {
|
||||
'system.cpu': { title: 'CPU', context: 'system.cpu', family: 'cpu', priority: 100 },
|
||||
'system.ram': { title: 'RAM', context: 'system.ram', family: 'ram', priority: 200 },
|
||||
'nginx.connections': { title: 'Nginx', context: 'nginx.connections', family: 'nginx', priority: 50 },
|
||||
'zz.unknown': { title: 'Odd', context: 'zz.unknown', priority: 1 },
|
||||
}
|
||||
const { sections } = groupCatalog(catalog)
|
||||
t.ok(sections.some((s) => s.id === 'system' && s.count === 2))
|
||||
t.ok(sections.some((s) => s.id === 'applications' && s.count === 1))
|
||||
t.ok(sections.some((s) => s.id === 'other' && s.count === 1))
|
||||
|
||||
const filtered = groupCatalog(catalog, 'nginx')
|
||||
t.is(filtered.sections.length, 1)
|
||||
t.is(filtered.sections[0].groups[0].charts[0].id, 'nginx.connections')
|
||||
})
|
||||
Reference in New Issue
Block a user