import { describe, it, expect } from 'vitest'; import { detectMethodDirected, loadKnownNodes } from './observer-routing-detector.mjs'; const NODES = ['brainstorming', 'discovery-interview', 'systematic-debugging']; describe('detectMethodDirected', () => { it('detects a directive verb followed by a node name', () => { expect(detectMethodDirected('запусти discovery-interview по этой фиче', NODES)).toEqual({ directed: true, node: 'discovery-interview', }); }); it('detects "используй X"', () => { expect(detectMethodDirected('используй systematic-debugging здесь', NODES).directed).toBe(true); }); it('detects a /slash-command form', () => { expect(detectMethodDirected('сделай это через /brainstorming', NODES)).toEqual({ directed: true, node: 'brainstorming', }); }); it('does NOT flag a bare node mention without a directive verb', () => { expect(detectMethodDirected('почему ты выбрал brainstorming, а не план?', NODES).directed).toBe(false); }); it('does NOT flag a prompt with no node reference', () => { expect(detectMethodDirected('добавь колонку Город в таблицу', NODES).directed).toBe(false); }); it('is empty-input safe', () => { expect(detectMethodDirected('', NODES).directed).toBe(false); expect(detectMethodDirected(null, []).directed).toBe(false); }); }); describe('loadKnownNodes', () => { it('loads names, skips comments and blank lines', () => { const nodes = loadKnownNodes('tools/observer-known-nodes.txt'); expect(nodes).toContain('brainstorming'); expect(nodes).toContain('discovery-interview'); expect(nodes.every((n) => !n.startsWith('#') && n.length > 0)).toBe(true); }); it('returns an empty array for a missing file', () => { expect(loadKnownNodes('tools/does-not-exist.txt')).toEqual([]); }); });