Files
peardata/test/taxonomy-coverage.test.js
T
Raven Scott a7648dc090
CI / test (push) Successful in 1m1s
Release rolling / release (push) Successful in 6m59s
Updates
2026-07-18 20:32:05 -04:00

37 lines
1.2 KiB
JavaScript

import test from 'brittle'
import { getAllChartDefs } from '../shared/metrics.js'
import { sectionForChart, SECTIONS } from '../shared/taxonomy.js'
test('static catalog charts map into taxonomy sections', (t) => {
const defs = getAllChartDefs()
t.ok(defs.length > 20)
/** @type {Record<string, number>} */
const counts = Object.fromEntries(SECTIONS.map((s) => [s.id, 0]))
let other = 0
for (const def of defs) {
const sec = sectionForChart(def.id, def)
counts[sec.id] = (counts[sec.id] || 0) + 1
if (sec.id === 'other') other++
}
t.ok(counts.system > 0, 'system section should have charts')
// Most built-in charts should not dump into Other
const ratio = other / defs.length
t.ok(ratio < 0.35, `other ratio ${ratio.toFixed(2)} should stay under 35%`)
})
test('common plugin prefixes are classified', (t) => {
const samples = [
['system.cpu', 'system'],
['mem.available', 'system'],
['docker.cpu.x', 'containers'],
['zfs.arc', 'storage'],
['sensors.temp.cpu', 'hardware'],
['nginx.connections', 'applications'],
['ebpf.cachestat', 'observability'],
['fleet.nodes', 'fleet'],
]
for (const [id, want] of samples) {
t.is(sectionForChart(id, { context: id }).id, want, id)
}
})