71 lines
2.0 KiB
Dart
71 lines
2.0 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:kouyu_english/core/ai_service.dart';
|
|
import 'package:kouyu_english/core/models.dart';
|
|
|
|
void main() {
|
|
test('AI capability registry exposes stable bounded contracts', () {
|
|
final descriptors = AiService.instance.capabilities.descriptors;
|
|
|
|
expect(descriptors.map((item) => item.id).toSet(), {
|
|
'speech-transcription',
|
|
'lexicon-explanation',
|
|
'dialogue-coach',
|
|
'answer-evaluation',
|
|
'review-generation',
|
|
});
|
|
expect(
|
|
descriptors.map((item) => item.id).toSet(),
|
|
hasLength(descriptors.length),
|
|
);
|
|
expect(descriptors, everyElement(isA<AiCapabilityDescriptor>()));
|
|
expect(
|
|
descriptors,
|
|
everyElement(
|
|
predicate<AiCapabilityDescriptor>(
|
|
(item) => item.promptVersion > 0 && item.outputContract.isNotEmpty,
|
|
),
|
|
),
|
|
);
|
|
expect(
|
|
{for (final item in descriptors) item.id: item.promptVersion},
|
|
{
|
|
'speech-transcription': 1,
|
|
'lexicon-explanation': 2,
|
|
'dialogue-coach': 3,
|
|
'answer-evaluation': 2,
|
|
'review-generation': 2,
|
|
},
|
|
);
|
|
});
|
|
|
|
test(
|
|
'lexicon capability routes through the existing validated service',
|
|
() async {
|
|
final result = await AiService.instance.capabilities.lexicon
|
|
.analyzeSentence(
|
|
provider: AiProviderType.mock,
|
|
endpoint: '',
|
|
model: '',
|
|
text: "I'd like to check in, please.",
|
|
);
|
|
|
|
expect(result, isNotNull);
|
|
expect(result!.translation, isNotEmpty);
|
|
expect(result.provider, 'mock');
|
|
},
|
|
);
|
|
|
|
test('dialogue capability preserves mock fallback behavior', () async {
|
|
final result = await AiService.instance.capabilities.dialogue.reply(
|
|
provider: AiProviderType.mock,
|
|
endpoint: '',
|
|
model: '',
|
|
history: const [],
|
|
aiGoal: 'Ask the learner how they are.',
|
|
learnerTask: 'Say how they feel.',
|
|
);
|
|
|
|
expect(result, isNull);
|
|
});
|
|
}
|