kilo-loop/test/preflight.test.mjs

56 lines
1.6 KiB
JavaScript
Raw Permalink Normal View History

2026-09-13 16:29:03 +00:00
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { renderPreflight } from '../src/preflight.mjs'
const config = {
project: '/repo',
agent: 'code-design',
model: '',
iterations: 3,
sharedContext: false,
hitl: 'on-question',
auto: true,
dryRun: false,
host: '127.0.0.1',
port: 7999,
}
const goal = {
title: 'My goal',
description: 'do things',
source: '/repo/.kilocode-loop/goal.json',
stages: [
{ id: 's1', title: 'One', done: false },
{ id: 's2', title: 'Two', done: true },
],
}
test('renderPreflight shows the scenario, stages and dashboard url', () => {
const out = renderPreflight(config, goal, 'http://127.0.0.1:7999')
assert.match(out, /About to run/)
assert.match(out, /My goal/)
assert.match(out, /fresh session per iteration/)
assert.match(out, /\[ \] One/)
assert.match(out, /\[x\] Two/)
assert.match(out, /127\.0\.0\.1:7999/)
})
test('renderPreflight lists verify, safety and limits rows', () => {
const out = renderPreflight(
{ ...config, verify: 'pnpm test', guard: true, checkpoint: true, redact: true, maxCost: 2, review: true, reviewAgent: 'code', notify: 'https://ntfy.sh/x' },
goal,
'http://127.0.0.1:7999',
)
assert.match(out, /pnpm test/)
assert.match(out, /checkpoint on · guard on · redact on/)
assert.match(out, /cost ≤ \$2/)
assert.match(out, /on \(code\)/)
})
test('renderPreflight reflects shared context and dry-run mode', () => {
const out = renderPreflight({ ...config, sharedContext: true, dryRun: true }, goal, 'http://127.0.0.1:7999')
assert.match(out, /shared between iterations/)
assert.match(out, /DRY-RUN/)
})