2a182d7f17
Keep Esc and /stop scoped to the foreground turn while exposing an explicit stop-tasks operation for supported chat backends. Add the protocol, server routing, app command, and coverage for task stopping and unsupported harnesses.
97 lines
3.2 KiB
Dart
97 lines
3.2 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/chat/domain/chat_commands.dart';
|
|
|
|
void main() {
|
|
test('records the web command list verbatim and in order', () {
|
|
expect(chatCommands.map((command) => command.name), [
|
|
'new',
|
|
'close',
|
|
'rename',
|
|
'stop',
|
|
'stop_tasks',
|
|
'help',
|
|
]);
|
|
expect(chatCommands.map((command) => command.usage), [
|
|
'/new',
|
|
'/close',
|
|
'/rename <title>',
|
|
'/stop',
|
|
'/stop_tasks',
|
|
'/help',
|
|
]);
|
|
expect(chatCommands.map((command) => command.summary), [
|
|
'Clear the context: continue this chat in a fresh session',
|
|
'Finish this session for every client, keeping its history',
|
|
'Rename this session',
|
|
'Stop the turn that is running',
|
|
'Stop all background tasks in this chat',
|
|
'List every command',
|
|
]);
|
|
expect(
|
|
chatCommands.where((command) => command.takesArgument).map((c) => c.name),
|
|
['rename'],
|
|
);
|
|
});
|
|
|
|
test('a bare slash offers every recorded command', () {
|
|
expect(chatCommandSuggestions('/'), chatCommands);
|
|
expect(chatCommandSuggestions(' /'), chatCommands);
|
|
});
|
|
|
|
test('the name prefix filters case-insensitively', () {
|
|
expect(chatCommandSuggestions('/n').map((command) => command.name), [
|
|
'new',
|
|
]);
|
|
expect(chatCommandSuggestions('/re').map((command) => command.name), [
|
|
'rename',
|
|
]);
|
|
expect(chatCommandSuggestions('/CL').map((command) => command.name), [
|
|
'close',
|
|
]);
|
|
expect(chatCommandSuggestions('/s').map((command) => command.name), [
|
|
'stop',
|
|
]);
|
|
});
|
|
|
|
test('an argument, plain text or an unknown word offers nothing', () {
|
|
expect(chatCommandSuggestions('/close '), isEmpty);
|
|
expect(chatCommandSuggestions('/rename My chat'), isEmpty);
|
|
expect(chatCommandSuggestions('/zzz'), isEmpty);
|
|
expect(chatCommandSuggestions('hello'), isEmpty);
|
|
expect(chatCommandSuggestions(''), isEmpty);
|
|
});
|
|
|
|
test('the query is only the single slash word', () {
|
|
expect(chatCommandQuery('/Help'), 'help');
|
|
expect(chatCommandQuery(' /He'), 'he');
|
|
expect(chatCommandQuery('/help '), isNull);
|
|
expect(chatCommandQuery('help'), isNull);
|
|
});
|
|
|
|
test('the slash word carries any argument and is null without a slash', () {
|
|
expect(chatCommandWord('/close'), '/close');
|
|
expect(chatCommandWord(' /close now'), '/close');
|
|
expect(chatCommandWord('/rename My chat'), '/rename');
|
|
expect(chatCommandWord('plain'), isNull);
|
|
expect(chatCommandWord('/'), '/');
|
|
expect(chatCommandNamed('/CLOSE'), chatCommands[1]);
|
|
expect(chatCommandNamed('/close'), chatCommands[1]);
|
|
expect(chatCommandNamed('/rename My chat'), chatCommands[2]);
|
|
expect(chatCommandNamed('/zzz'), isNull);
|
|
expect(chatCommandNamed('/close now'), chatCommands[1]);
|
|
expect(chatCommandNamed('plain'), isNull);
|
|
});
|
|
|
|
test('the parsed reports keep the web client words', () {
|
|
expect(
|
|
chatUnknownCommandReport('/nope'),
|
|
'“/nope” is not a command, so nothing was sent to the agent. '
|
|
'Send it as a message, or cancel.',
|
|
);
|
|
expect(
|
|
chatCommandUnavailableReport('/close'),
|
|
'“/close” is not available yet, so nothing was sent to the agent.',
|
|
);
|
|
});
|
|
}
|