import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/features/chat/domain/chat_commands.dart'; import 'package:pipelines_app/features/chat/domain/chat_harness_commands.dart'; void main() { final harness = chatHarnessCommandsFromWire([ { 'name': 'code-review', 'description': ' Review the diff ', 'argument_hint': '[low|high]', }, {'name': '/probe-skill'}, {'name': 'anthropic-skills:pdf', 'description': 'PDF'}, {'name': 'Code-Review', 'description': 'duplicate'}, {'name': 'two words'}, {'name': ''}, {'name': 'help', 'description': 'shadowed'}, ]); test('wire entries become harness commands with usage and summary', () { expect(harness.map((command) => command.name), [ 'code-review', 'probe-skill', 'anthropic-skills:pdf', 'help', ]); final review = harness.first; expect(review.fromHarness, isTrue); expect(review.takesArgument, isTrue); expect(review.summary, 'Review the diff'); expect(review.usage, '/code-review [low|high]'); expect(harness[1].usage, '/probe-skill'); expect(chatHarnessCommandsFromWire(const []), isEmpty); }); test('suggestions list recorded commands first, then matching skills', () { final all = chatCommandSuggestions('/', harness); expect(all.take(chatCommands.length), chatCommands); expect(all.skip(chatCommands.length).map((command) => command.name), [ 'code-review', 'probe-skill', 'anthropic-skills:pdf', ]); expect(chatCommandSuggestions('/CODE', harness).single.name, 'code-review'); expect( chatCommandSuggestions('/pdf', harness).single.name, 'anthropic-skills:pdf', ); expect(chatCommandSuggestions('/code-review x', harness), isEmpty); // Without harness commands the recorded list is unchanged. expect(chatCommandSuggestions('/'), chatCommands); }); test('a harness command is named only when no recorded command is', () { expect( chatHarnessCommandNamed('/code-review low', harness)?.name, 'code-review', ); expect( chatHarnessCommandNamed('/Probe-Skill', harness)?.name, 'probe-skill', ); expect(chatHarnessCommandNamed('/help', harness), isNull); expect(chatHarnessCommandNamed('/code', harness), isNull); expect(chatHarnessCommandNamed('plain', harness), isNull); }); }