feat(apps/chat): 新增 UI Schema 导航和路由导航工具

This commit is contained in:
zl-q
2026-03-19 00:51:57 +08:00
parent bfc3096199
commit 81cbc14219
8 changed files with 113 additions and 103 deletions
@@ -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);
});
}