47 lines
1.9 KiB
JavaScript
47 lines
1.9 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { renderStatus } from './status-md-generator.mjs';
|
|
|
|
const baseInputs = (overrides = {}) => ({
|
|
now: '2026-05-19T10:00:00+03:00',
|
|
c1: { status: 'ok', detail: 'no drift' },
|
|
c2: { status: 'ok', detail: '0 version drift' },
|
|
c3: { status: 'ok', detail: 'last read today' },
|
|
c5: { status: 'ok', detail: 'coverage OK · registration OK' },
|
|
observer: { episodeCount: 12, observerErrors: 0, piiMatches: 0 },
|
|
...overrides,
|
|
});
|
|
|
|
describe('renderStatus', () => {
|
|
it('renders all 5 controllers + metrics', () => {
|
|
const md = renderStatus(baseInputs());
|
|
expect(md).toContain('# Brain Status');
|
|
expect(md).toContain('| C1 L1-watcher | ✅');
|
|
expect(md).toContain('| C2 Cross-ref consistency | ✅');
|
|
expect(md).toContain('| C3 Observer-of-observer | ✅');
|
|
expect(md).toContain('| C4 Сигнальный статус | ✅');
|
|
expect(md).toContain('| C5 Observer-coverage | ✅');
|
|
expect(md).toContain('12 episodes');
|
|
});
|
|
|
|
it('shows a warn status for the coverage controller', () => {
|
|
const md = renderStatus(baseInputs({ c5: { status: 'warn', detail: '3 commits, 0 episodes' } }));
|
|
expect(md).toContain('| C5 Observer-coverage | ⚠️');
|
|
});
|
|
|
|
it('shows the observer_error count in the metrics block', () => {
|
|
const md = renderStatus(baseInputs({ observer: { episodeCount: 4, observerErrors: 2, piiMatches: 0 } }));
|
|
expect(md).toContain('2 observer_error markers');
|
|
});
|
|
|
|
it('shows a red status for failing controllers', () => {
|
|
const md = renderStatus(baseInputs({ c1: { status: 'fail', detail: '2 plugins not formalized' } }));
|
|
expect(md).toContain('| C1 L1-watcher | 🔴');
|
|
});
|
|
|
|
it('mentions the capability-readiness behavioral rule', () => {
|
|
const md = renderStatus(baseInputs());
|
|
expect(md).toContain('capability-readiness');
|
|
expect(md).toContain('feedback_brain_unused_tools_not_problem');
|
|
});
|
|
});
|