@@ -54,7 +54,9 @@ describe('CtdToTemplateConverter', () => {
5454 // Tags include 'openchoreo', the component name, and workloadType
5555 expect ( result . metadata . tags ) . toEqual ( [
5656 'openchoreo' ,
57- 'simple-service' ,
57+ 'component-type' ,
58+ 'simple' ,
59+ 'service' ,
5860 'deployment' ,
5961 ] ) ;
6062
@@ -119,7 +121,9 @@ describe('CtdToTemplateConverter', () => {
119121 // Even without explicit tags, should have inferred tags from name and workloadType
120122 expect ( result . metadata . tags ) . toEqual ( [
121123 'openchoreo' ,
122- 'simple-service' ,
124+ 'component-type' ,
125+ 'simple' ,
126+ 'service' ,
123127 'deployment' ,
124128 ] ) ;
125129 } ) ;
@@ -182,7 +186,7 @@ describe('CtdToTemplateConverter', () => {
182186
183187 // Check UI fields
184188 expect ( parameters [ 0 ] . properties . component_name [ 'ui:field' ] ) . toBe (
185- 'ComponentNamePicker ' ,
189+ 'EntityNamePicker ' ,
186190 ) ;
187191 expect ( parameters [ 0 ] . properties . organization_name [ 'ui:disabled' ] ) . toBe (
188192 true ,
@@ -255,7 +259,7 @@ describe('CtdToTemplateConverter', () => {
255259 expect ( props . enableBackup . type ) . toBe ( 'boolean' ) ;
256260 expect ( props . enableBackup . default ) . toBe ( true ) ;
257261 // Booleans now use default checkbox/switch widgets; no explicit radio widget
258- expect ( props . enableBackup [ 'ui:widget' ] ) . toBeUndefined ( ) ;
262+ expect ( props . enableBackup [ 'ui:widget' ] ) . toBe ( 'radio' ) ;
259263 } ) ;
260264
261265 it ( 'should handle nested objects' , ( ) => {
@@ -438,10 +442,9 @@ describe('CtdToTemplateConverter', () => {
438442
439443 // Should have Component Metadata + CI/CD Setup + Traits sections
440444 // (CTD config section skipped due to empty properties)
441- expect ( parameters ) . toHaveLength ( 3 ) ;
445+ expect ( parameters ) . toHaveLength ( 2 ) ;
442446 expect ( parameters [ 0 ] . title ) . toBe ( 'Component Metadata' ) ;
443- expect ( parameters [ 1 ] . title ) . toBe ( 'CI/CD Setup' ) ;
444- expect ( parameters [ 2 ] . title ) . toBe ( 'Traits' ) ;
447+ expect ( parameters [ 1 ] . title ) . toBe ( 'Addons' ) ;
445448 } ) ;
446449
447450 it ( 'should generate CI Setup section with workflow configuration when CTD has allowedWorkflows' , ( ) => {
@@ -475,8 +478,8 @@ describe('CtdToTemplateConverter', () => {
475478
476479 // Check CI/CD Setup section (third section)
477480 const ciSetupSection = parameters [ 2 ] ;
478- expect ( ciSetupSection . title ) . toBe ( 'CI/CD Setup' ) ;
479- expect ( ciSetupSection . required ) . toEqual ( [ 'autoDeploy' , ' useBuiltInCI'] ) ;
481+ expect ( ciSetupSection . title ) . toBe ( 'CI Setup' ) ;
482+ expect ( ciSetupSection . required ) . toEqual ( [ 'useBuiltInCI' ] ) ;
480483
481484 // Check useBuiltInCI property
482485 expect ( ciSetupSection . properties . useBuiltInCI ) . toBeDefined ( ) ;
@@ -485,46 +488,46 @@ describe('CtdToTemplateConverter', () => {
485488 'Use Built-in CI in OpenChoreo' ,
486489 ) ;
487490 // Uses SwitchField as ui:field for boolean switches
488- expect ( ciSetupSection . properties . useBuiltInCI [ 'ui:field' ] ) . toBe (
491+ expect ( ciSetupSection . properties . autoDeploy [ 'ui:field' ] ) . toBe (
489492 'SwitchField' ,
490493 ) ;
491494
492- // Check dependencies structure uses oneOf with two branches
495+ // Check dependencies structure uses allOf with two branches
493496 expect ( ciSetupSection . dependencies . useBuiltInCI ) . toBeDefined ( ) ;
494- expect ( ciSetupSection . dependencies . useBuiltInCI . oneOf ) . toBeDefined ( ) ;
495- expect ( ciSetupSection . dependencies . useBuiltInCI . oneOf ) . toHaveLength ( 2 ) ;
497+ expect ( ciSetupSection . dependencies . useBuiltInCI . allOf ) . toBeDefined ( ) ;
498+ expect ( ciSetupSection . dependencies . useBuiltInCI . allOf ) . toHaveLength ( 2 ) ;
496499
497500 // Check true case (when CI is enabled)
498- const trueCase = ciSetupSection . dependencies . useBuiltInCI . oneOf [ 0 ] ;
499- expect ( trueCase . properties . useBuiltInCI . const ) . toBe ( true ) ;
501+ const trueCase = ciSetupSection . dependencies . useBuiltInCI . allOf [ 0 ] ;
502+ expect ( trueCase . then . properties . useBuiltInCI . const ) . toBe ( true ) ;
500503
501504 // Workflow fields present
502- expect ( trueCase . properties . workflow_name ) . toBeDefined ( ) ;
503- expect ( trueCase . properties . workflow_parameters ) . toBeDefined ( ) ;
505+ expect ( trueCase . then . properties . workflow_name ) . toBeDefined ( ) ;
506+ expect ( trueCase . then . properties . workflow_parameters ) . toBeDefined ( ) ;
504507
505508 // Check workflow_name has enum from allowedWorkflows
506- expect ( trueCase . properties . workflow_name . enum ) . toEqual ( [
509+ expect ( trueCase . then . properties . workflow_name . enum ) . toEqual ( [
507510 'nodejs-build' ,
508511 'docker-build' ,
509512 ] ) ;
510- expect ( trueCase . properties . workflow_name [ 'ui:field' ] ) . toBe (
513+ expect ( trueCase . then . properties . workflow_name [ 'ui:field' ] ) . toBe (
511514 'BuildWorkflowPicker' ,
512515 ) ;
513516
514517 // Check workflow_parameters uses custom UI field
515- expect ( trueCase . properties . workflow_parameters [ 'ui:field' ] ) . toBe (
518+ expect ( trueCase . then . properties . workflow_parameters [ 'ui:field' ] ) . toBe (
516519 'BuildWorkflowParameters' ,
517520 ) ;
518521
519522 // Check required fields when CI is enabled - only workflow fields now
520- expect ( trueCase . required ) . toEqual ( [
523+ expect ( trueCase . then . required ) . toEqual ( [
521524 'workflow_name' ,
522525 'workflow_parameters' ,
523526 ] ) ;
524527
525528 // Check false case (when CI is disabled)
526- const falseCase = ciSetupSection . dependencies . useBuiltInCI . oneOf [ 1 ] ;
527- expect ( falseCase . properties . useBuiltInCI . const ) . toBe ( false ) ;
529+ const falseCase = ciSetupSection . dependencies . useBuiltInCI . allOf [ 1 ] ;
530+ expect ( falseCase . then . properties . useBuiltInCI . const ) . toBe ( false ) ;
528531 } ) ;
529532
530533 it ( 'should not include CI Setup section when CTD has no allowedWorkflows' , ( ) => {
@@ -553,22 +556,13 @@ describe('CtdToTemplateConverter', () => {
553556 const result = converter . convertCtdToTemplateEntity ( ctd , 'test-org' ) ;
554557 const parameters = result . spec ?. parameters as any [ ] ;
555558
556- // Should have 4 sections: Component Metadata, CTD Configuration, CI/CD Setup, and Traits
557- expect ( parameters ) . toHaveLength ( 4 ) ;
559+ // Should have 3 sections: Component Metadata, CTD Configuration, and Traits (no CI Setup when no allowedWorkflows)
560+ expect ( parameters ) . toHaveLength ( 3 ) ;
558561
559562 // Verify section titles
560563 expect ( parameters [ 0 ] . title ) . toBe ( 'Component Metadata' ) ;
561564 expect ( parameters [ 1 ] . title ) . toContain ( 'Configuration' ) ;
562- expect ( parameters [ 2 ] . title ) . toBe ( 'CI/CD Setup' ) ;
563- expect ( parameters [ 3 ] . title ) . toBe ( 'Traits' ) ;
564-
565- // CI/CD Setup should be present but workflow_name should not have an enum when no allowedWorkflows
566- const ciSetup = parameters . find ( p => p . title === 'CI/CD Setup' ) ;
567- expect ( ciSetup ) . toBeDefined ( ) ;
568- expect (
569- ciSetup ! . dependencies . useBuiltInCI . oneOf [ 0 ] . properties . workflow_name
570- . enum ,
571- ) . toBeUndefined ( ) ;
565+ expect ( parameters [ 2 ] . title ) . toBe ( 'Addons' ) ;
572566 } ) ;
573567 } ) ;
574568
0 commit comments