Files
bare-operating-system/packages/bare-os-coreutils/test/p2p-suite-bundles.test.mjs
T
Raven Scott ddebf42f1c
Release rolling / release (push) Successful in 9m38s
TUI Updates p2
2026-08-12 22:55:38 -04:00

83 lines
1.9 KiB
JavaScript

import test from 'brittle'
import { readFile } from 'node:fs/promises'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
const __dirname = dirname(fileURLToPath(import.meta.url))
const coreutilsRoot = join(__dirname, '..')
const kernelBin = join(__dirname, '../../../kernel/bin')
async function read(p) {
return readFile(p, 'utf8')
}
test('p2p TUI bins include ctx.tui.run after build', async (t) => {
const names = [
'swarmtop',
'dhttop',
'swarmmap',
'routeview',
'holepunch-view'
]
for (const name of names) {
const src = await read(join(kernelBin, name))
t.ok(src.includes('ctx.tui.run'), name + ' uses ctx.tui.run')
t.ok(
src.includes('bareP2pCreateSimpleTuiApp'),
name + ' includes TEA factory'
)
}
})
test('p2p suite commands include shared envelope helper in kernel bins', async (t) => {
const names = [
'swarmtop',
'meshdrop',
'taskmesh',
'peernote',
'hypershell-board',
'p2ping',
'dhtscan',
'dhttop',
'swarmdoctor',
'swarmmap',
'peerdiscover',
'p2ptrace',
'peerctl',
'routeview',
'holepunch-view'
]
for (const name of names) {
const src = await read(join(kernelBin, name))
t.ok(src.includes('BARE_P2P_SUITE_PREFIX'), name + ' includes p2p preamble')
t.ok(
src.includes('async function run(ctx, argv)'),
name + ' includes run()'
)
}
})
test('p2p suite man pages exist', async (t) => {
const pages = [
'swarmtop',
'meshdrop',
'taskmesh',
'peernote',
'hypershell-board',
'p2ping',
'dhtscan',
'dhttop',
'swarmdoctor',
'swarmmap',
'peerdiscover',
'p2ptrace',
'peerctl',
'routeview',
'holepunch-view'
]
for (const page of pages) {
const body = await read(join(coreutilsRoot, 'man/pages', page + '.json'))
t.ok(body.includes('"name": "' + page + '"'), page + ' man page present')
}
})