@@ -160,6 +160,87 @@ describe('FormComponentConfig', () => {
160
160
expect ( screen . queryByText ( 'unsupportedProperty' ) ) . not . toBeInTheDocument ( ) ;
161
161
} ) ;
162
162
163
+ it ( 'should render CollapsiblePropertyEditor for the "sortOrder" property' , async ( ) => {
164
+ const user = userEvent . setup ( ) ;
165
+ render ( {
166
+ props : {
167
+ schema : {
168
+ ...InputSchema ,
169
+ properties : {
170
+ ...InputSchema . properties ,
171
+ sortOrder : {
172
+ type : 'array' ,
173
+ items : {
174
+ type : 'string' ,
175
+ enum : [ 'option1' , 'option2' ] ,
176
+ } ,
177
+ } ,
178
+ } ,
179
+ } ,
180
+ } ,
181
+ } ) ;
182
+ await user . click ( screen . getByText ( textMock ( 'ux_editor.component_properties.sortOrder' ) ) ) ;
183
+ expect (
184
+ screen . getByRole ( 'combobox' , {
185
+ name : textMock ( 'ux_editor.component_properties.sortOrder' ) ,
186
+ } ) ,
187
+ ) . toBeInTheDocument ( ) ;
188
+ } ) ;
189
+
190
+ it ( 'should render CollapsiblePropertyEditor for the "showValidations" property and EditStringValue for other properties' , ( ) => {
191
+ render ( {
192
+ props : {
193
+ schema : {
194
+ ...InputSchema ,
195
+ properties : {
196
+ ...InputSchema . properties ,
197
+ showValidations : {
198
+ type : 'array' ,
199
+ items : {
200
+ type : 'string' ,
201
+ enum : [ 'true' , 'false' ] ,
202
+ } ,
203
+ } ,
204
+ anotherProperty : {
205
+ type : 'array' ,
206
+ items : {
207
+ type : 'string' ,
208
+ enum : [ 'option1' , 'option2' ] ,
209
+ } ,
210
+ } ,
211
+ } ,
212
+ } ,
213
+ } ,
214
+ } ) ;
215
+ expect (
216
+ screen . getByText ( textMock ( 'ux_editor.component_properties.showValidations' ) ) ,
217
+ ) . toBeInTheDocument ( ) ;
218
+ } ) ;
219
+
220
+ it ( 'should render CollapsiblePropertyEditor for "preselectedOptionIndex" and EditNumberValue for other properties' , ( ) => {
221
+ render ( {
222
+ props : {
223
+ schema : {
224
+ ...InputSchema ,
225
+ properties : {
226
+ ...InputSchema . properties ,
227
+ preselectedOptionIndex : {
228
+ type : 'number' ,
229
+ enum : [ 0 , 1 , 2 ] ,
230
+ } ,
231
+ anotherNumberProperty : {
232
+ type : 'number' ,
233
+ description : 'A sample number property' ,
234
+ } ,
235
+ } ,
236
+ } ,
237
+ } ,
238
+ } ) ;
239
+ expect (
240
+ screen . getByText ( textMock ( 'ux_editor.component_properties.preselectedOptionIndex_button' ) ) ,
241
+ ) . toBeInTheDocument ( ) ;
242
+ } ) ;
243
+
163
244
it ( 'should not render property if it is null' , ( ) => {
164
245
render ( {
165
246
props : {
@@ -296,7 +377,8 @@ describe('FormComponentConfig', () => {
296
377
) . not . toBeInTheDocument ( ) ;
297
378
} ) ;
298
379
299
- it ( 'should only render array properties with items of type string AND enum values' , ( ) => {
380
+ it ( 'should only render array properties with items of type string AND enum values' , async ( ) => {
381
+ const user = userEvent . setup ( ) ;
300
382
render ( {
301
383
props : {
302
384
schema : {
@@ -320,6 +402,9 @@ describe('FormComponentConfig', () => {
320
402
} ,
321
403
} ,
322
404
} ) ;
405
+ await user . click (
406
+ screen . getByText ( textMock ( 'ux_editor.component_properties.supportedArrayProperty' ) ) ,
407
+ ) ;
323
408
expect (
324
409
screen . getByRole ( 'combobox' , {
325
410
name : textMock ( 'ux_editor.component_properties.supportedArrayProperty' ) ,
@@ -401,6 +486,54 @@ describe('FormComponentConfig', () => {
401
486
) ;
402
487
} ) ;
403
488
489
+ it ( 'should toggle close button and grid width text when the open and close buttons are clicked' , async ( ) => {
490
+ const user = userEvent . setup ( ) ;
491
+ render ( {
492
+ props : {
493
+ schema : InputSchema ,
494
+ } ,
495
+ } ) ;
496
+ const openGridButton = screen . getByRole ( 'button' , {
497
+ name : textMock ( 'ux_editor.component_properties.grid' ) ,
498
+ } ) ;
499
+ await user . click ( openGridButton ) ;
500
+ expect ( screen . getByText ( textMock ( 'ux_editor.component_properties.grid' ) ) ) . toBeInTheDocument ( ) ;
501
+ const widthText = screen . getByText ( textMock ( 'ux_editor.modal_properties_grid' ) ) ;
502
+ expect ( widthText ) . toBeInTheDocument ( ) ;
503
+
504
+ const closeGridButton = screen . getByRole ( 'button' , {
505
+ name : textMock ( 'general.close' ) ,
506
+ } ) ;
507
+ await user . click ( closeGridButton ) ;
508
+ expect ( closeGridButton ) . not . toBeInTheDocument ( ) ;
509
+ expect ( widthText ) . not . toBeInTheDocument ( ) ;
510
+ } ) ;
511
+
512
+ it ( 'should not render grid width text if grid button is not clicked' , async ( ) => {
513
+ const user = userEvent . setup ( ) ;
514
+ render ( {
515
+ props : {
516
+ schema : InputSchema ,
517
+ } ,
518
+ } ) ;
519
+ expect ( screen . queryByText ( textMock ( 'ux_editor.modal_properties_grid' ) ) ) . not . toBeInTheDocument ( ) ;
520
+ const openGridButton = screen . getByRole ( 'button' , {
521
+ name : textMock ( 'ux_editor.component_properties.grid' ) ,
522
+ } ) ;
523
+ await user . click ( openGridButton ) ;
524
+ expect ( screen . getByText ( textMock ( 'ux_editor.component_properties.grid' ) ) ) . toBeInTheDocument ( ) ;
525
+
526
+ const widthText = screen . getByText ( textMock ( 'ux_editor.modal_properties_grid' ) ) ;
527
+ expect ( widthText ) . toBeInTheDocument ( ) ;
528
+
529
+ const closeGridButton = screen . getByRole ( 'button' , {
530
+ name : textMock ( 'general.close' ) ,
531
+ } ) ;
532
+ await user . click ( closeGridButton ) ;
533
+ expect ( closeGridButton ) . not . toBeInTheDocument ( ) ;
534
+ expect ( widthText ) . not . toBeInTheDocument ( ) ;
535
+ } ) ;
536
+
404
537
const render = ( {
405
538
props = { } ,
406
539
queries = { } ,
0 commit comments