feat: complete leave approval MVP
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import 'package:aioa_mobile/core/forms/schema/form_schema.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
test('parses server data and UI schemas into safe control models', () {
|
||||
final definition = DynamicFormDefinition.fromJson({
|
||||
'key': 'leave-request',
|
||||
'version': 1,
|
||||
'dataSchema': {
|
||||
r'$id': 'leave-request-v1',
|
||||
'title': '请假申请',
|
||||
'required': ['type'],
|
||||
'properties': {
|
||||
'type': {
|
||||
'type': 'string',
|
||||
'enum': ['PERSONAL', 'SICK'],
|
||||
},
|
||||
},
|
||||
},
|
||||
'uiSchema': {
|
||||
'description': '远程定义',
|
||||
'sections': [
|
||||
{
|
||||
'title': '请假信息',
|
||||
'controls': [
|
||||
{
|
||||
'field': 'type',
|
||||
'label': '请假类型',
|
||||
'control': 'select',
|
||||
'optionLabels': {'PERSONAL': '事假'},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
expect(definition.dataSchema.id, 'leave-request-v1');
|
||||
expect(definition.dataSchema.required, {'type'});
|
||||
expect(definition.dataSchema.properties['type']!.enumValues, [
|
||||
'PERSONAL',
|
||||
'SICK',
|
||||
]);
|
||||
expect(
|
||||
definition.uiSchema.sections.single.controls.single.control,
|
||||
FormControlType.select,
|
||||
);
|
||||
});
|
||||
|
||||
test('unknown controls cannot enter the renderer whitelist', () {
|
||||
expect(
|
||||
() => FormControlType.values.byName('remoteScript'),
|
||||
throwsA(isA<ArgumentError>()),
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user