@@ -38,11 +38,21 @@ describe('validatePolicyForm', () => {
3838 expect ( errors . display_name ) . toBeDefined ( ) ;
3939 } ) ;
4040
41+ it ( 'rejects whitespace-only display_name' , ( ) => {
42+ const errors = validatePolicyForm ( { ...valid ( ) , display_name : ' ' } ) ;
43+ expect ( errors . display_name ) . toBeDefined ( ) ;
44+ } ) ;
45+
4146 it ( 'requires rego_code' , ( ) => {
4247 const errors = validatePolicyForm ( { ...valid ( ) , rego_code : '' } ) ;
4348 expect ( errors . rego_code ) . toBeDefined ( ) ;
4449 } ) ;
4550
51+ it ( 'rejects whitespace-only rego_code' , ( ) => {
52+ const errors = validatePolicyForm ( { ...valid ( ) , rego_code : ' ' } ) ;
53+ expect ( errors . rego_code ) . toBeDefined ( ) ;
54+ } ) ;
55+
4656 it ( 'validates priority range' , ( ) => {
4757 const tooLow = validatePolicyForm ( { ...valid ( ) , priority : '0' } ) ;
4858 expect ( tooLow . priority ) . toBeDefined ( ) ;
@@ -52,6 +62,23 @@ describe('validatePolicyForm', () => {
5262
5363 const ok = validatePolicyForm ( { ...valid ( ) , priority : '500' } ) ;
5464 expect ( ok . priority ) . toBeUndefined ( ) ;
65+
66+ const decimal = validatePolicyForm ( { ...valid ( ) , priority : '500.5' } ) ;
67+ expect ( decimal . priority ) . toBeDefined ( ) ;
68+
69+ const empty = validatePolicyForm ( { ...valid ( ) , priority : '' } ) ;
70+ expect ( empty . priority ) . toBeDefined ( ) ;
71+ } ) ;
72+
73+ it ( 'rejects description longer than 255 characters' , ( ) => {
74+ const errors = validatePolicyForm ( {
75+ ...valid ( ) ,
76+ description : 'a' . repeat ( 256 ) ,
77+ } ) ;
78+ expect ( errors . description ) . toBeDefined ( ) ;
79+
80+ const ok = validatePolicyForm ( { ...valid ( ) , description : 'a' . repeat ( 255 ) } ) ;
81+ expect ( ok . description ) . toBeUndefined ( ) ;
5582 } ) ;
5683
5784 it ( 'accepts only GLOBAL or USER as policy_type' , ( ) => {
0 commit comments