37 lines
1.5 KiB
Dart
37 lines
1.5 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:flutter_app/core/network/api_repository.dart';
|
|
|
|
void main() {
|
|
group('AgentRunResult.fromApiData', () {
|
|
test('preserves and labels every completed tool step', () {
|
|
final result = AgentRunResult.fromApiData({
|
|
'result': 'الإجابة النهائية.',
|
|
'tool': 'search_knowledge',
|
|
'steps': [
|
|
{'tool': 'search_workspace', 'status': 'completed'},
|
|
{'tool': 'search_knowledge', 'status': 'completed'},
|
|
],
|
|
'files': ['lib/main.dart'],
|
|
});
|
|
|
|
expect(result.steps, hasLength(2));
|
|
expect(result.steps.first.label, 'البحث في مساحة العمل');
|
|
expect(result.steps.last.label, 'البحث في فهرس المعرفة');
|
|
expect(result.steps.last.statusLabel, 'اكتملت');
|
|
expect(result.answer, contains('1. البحث في مساحة العمل — اكتملت.'));
|
|
expect(result.answer, contains('2. البحث في فهرس المعرفة — اكتملت.'));
|
|
expect(result.answer, contains('الملفات المقروءة: lib/main.dart.'));
|
|
});
|
|
|
|
test('uses the legacy tool field when the API returns no steps', () {
|
|
final result = AgentRunResult.fromApiData({
|
|
'result': '391',
|
|
'tool': 'calculator',
|
|
});
|
|
|
|
expect(result.steps, isEmpty);
|
|
expect(result.answer, '391\n\nالأداة المستخدمة: الآلة الحاسبة المحلية.');
|
|
});
|
|
});
|
|
}
|