feat(apps/chat): 新增 UI Schema 导航和路由导航工具
This commit is contained in:
@@ -37,7 +37,7 @@ void main() {
|
||||
'tool_call_id': 'call_1',
|
||||
'tool_name': 'calendar_read',
|
||||
'status': 'success',
|
||||
'result_summary': '找到 2 条结果',
|
||||
'result': '找到 2 条结果',
|
||||
});
|
||||
|
||||
expect(event, isA<ToolCallResultEvent>());
|
||||
|
||||
@@ -3,13 +3,6 @@ import 'package:social_app/features/chat/presentation/bloc/agent_stage.dart';
|
||||
|
||||
void main() {
|
||||
group('agent stage mapping', () {
|
||||
test('maps protocol step router to intent stage label', () {
|
||||
final stage = stageFromStepName('router');
|
||||
|
||||
expect(stage, AgentStage.intent);
|
||||
expect(stageLabel(stage), '意图识别中');
|
||||
});
|
||||
|
||||
test('maps protocol step worker to execution stage label', () {
|
||||
final stage = stageFromStepName('worker');
|
||||
|
||||
@@ -17,6 +10,13 @@ void main() {
|
||||
expect(stageLabel(stage), '任务执行中');
|
||||
});
|
||||
|
||||
test('maps protocol step memory to memory stage label', () {
|
||||
final stage = stageFromStepName('memory');
|
||||
|
||||
expect(stage, AgentStage.memory);
|
||||
expect(stageLabel(stage), '记忆提取中');
|
||||
});
|
||||
|
||||
test('uses processing label when step is unknown', () {
|
||||
final stage = stageFromStepName('unexpected');
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:social_app/features/chat/ui/navigation/ui_schema_navigation.dart';
|
||||
|
||||
void main() {
|
||||
test('buildUiSchemaNavigationTarget merges scalar params only', () {
|
||||
final target = buildUiSchemaNavigationTarget(
|
||||
path: '/calendar/dayweek',
|
||||
params: {
|
||||
'date': '2026-03-18',
|
||||
'from': 'home',
|
||||
'count': 2,
|
||||
'enabled': true,
|
||||
'ignored': {'nested': true},
|
||||
},
|
||||
);
|
||||
|
||||
expect(
|
||||
target,
|
||||
'/calendar/dayweek?date=2026-03-18&from=home&count=2&enabled=true',
|
||||
);
|
||||
});
|
||||
|
||||
test('isValidInternalNavigationPath follows protocol constraints', () {
|
||||
expect(isValidInternalNavigationPath('/todo/123/edit'), true);
|
||||
expect(isValidInternalNavigationPath('https://evil.com'), false);
|
||||
expect(isValidInternalNavigationPath('/todo/123?x=1'), false);
|
||||
expect(isValidInternalNavigationPath('/todo/:id'), false);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user