@@ -355,6 +355,96 @@ body:
355
355
` ,
356
356
wantErr : "body[0](checkboxes), option[1]: can not require a hidden checkbox" ,
357
357
},
358
+ {
359
+ name : "dropdown default is not an integer" ,
360
+ content : `
361
+ name: "test"
362
+ about: "this is about"
363
+ body:
364
+ - type: dropdown
365
+ id: "1"
366
+ attributes:
367
+ label: Label of dropdown
368
+ description: Description of dropdown
369
+ multiple: true
370
+ options:
371
+ - Option 1 of dropdown
372
+ - Option 2 of dropdown
373
+ - Option 3 of dropdown
374
+ default: "def"
375
+ validations:
376
+ required: true
377
+ ` ,
378
+ wantErr : "body[0](dropdown): 'default' should be an int" ,
379
+ },
380
+ {
381
+ name : "dropdown default is out of range" ,
382
+ content : `
383
+ name: "test"
384
+ about: "this is about"
385
+ body:
386
+ - type: dropdown
387
+ id: "1"
388
+ attributes:
389
+ label: Label of dropdown
390
+ description: Description of dropdown
391
+ multiple: true
392
+ options:
393
+ - Option 1 of dropdown
394
+ - Option 2 of dropdown
395
+ - Option 3 of dropdown
396
+ default: 3
397
+ validations:
398
+ required: true
399
+ ` ,
400
+ wantErr : "body[0](dropdown): the value of 'default' is out of range" ,
401
+ },
402
+ {
403
+ name : "dropdown without default is valid" ,
404
+ content : `
405
+ name: "test"
406
+ about: "this is about"
407
+ body:
408
+ - type: dropdown
409
+ id: "1"
410
+ attributes:
411
+ label: Label of dropdown
412
+ description: Description of dropdown
413
+ multiple: true
414
+ options:
415
+ - Option 1 of dropdown
416
+ - Option 2 of dropdown
417
+ - Option 3 of dropdown
418
+ validations:
419
+ required: true
420
+ ` ,
421
+ want : & api.IssueTemplate {
422
+ Name : "test" ,
423
+ About : "this is about" ,
424
+ Fields : []* api.IssueFormField {
425
+ {
426
+ Type : "dropdown" ,
427
+ ID : "1" ,
428
+ Attributes : map [string ]any {
429
+ "label" : "Label of dropdown" ,
430
+ "description" : "Description of dropdown" ,
431
+ "multiple" : true ,
432
+ "options" : []any {
433
+ "Option 1 of dropdown" ,
434
+ "Option 2 of dropdown" ,
435
+ "Option 3 of dropdown" ,
436
+ },
437
+ },
438
+ Validations : map [string ]any {
439
+ "required" : true ,
440
+ },
441
+ Visible : []api.IssueFormFieldVisible {api .IssueFormFieldVisibleForm , api .IssueFormFieldVisibleContent },
442
+ },
443
+ },
444
+ FileName : "test.yaml" ,
445
+ },
446
+ wantErr : "" ,
447
+ },
358
448
{
359
449
name : "valid" ,
360
450
content : `
@@ -399,6 +489,7 @@ body:
399
489
- Option 1 of dropdown
400
490
- Option 2 of dropdown
401
491
- Option 3 of dropdown
492
+ default: 1
402
493
validations:
403
494
required: true
404
495
- type: checkboxes
@@ -475,6 +566,7 @@ body:
475
566
"Option 2 of dropdown" ,
476
567
"Option 3 of dropdown" ,
477
568
},
569
+ "default" : 1 ,
478
570
},
479
571
Validations : map [string ]any {
480
572
"required" : true ,
0 commit comments