@@ -41,6 +41,7 @@ describe('component: General', () => {
4141 policyServers : ( ) => ps ,
4242 policyServerOptions : ( ) => [ 'default' , 'custom-ps' ] ,
4343 isGlobal : ( ) => true ,
44+ hasValuesModule : ( ) => false ,
4445 showModeBanner : ( ) => false ,
4546 modeDisabled : ( ) => false
4647 }
@@ -79,6 +80,7 @@ describe('component: General', () => {
7980 policyServerOptions : ( ) => [ 'default' , 'custom-ps' ] ,
8081 isGlobal : ( ) => true ,
8182 isCreate : ( ) => true ,
83+ hasValuesModule : ( ) => false ,
8284 showModeBanner : ( ) => false ,
8385 modeDisabled : ( ) => false
8486 }
@@ -89,4 +91,65 @@ describe('component: General', () => {
8991
9092 expect ( radio ?. props ( ) . value ) . toStrictEqual ( 'protect' as string ) ;
9193 } ) ;
94+
95+ it ( 'should sync values-based OCI fields back into spec.module' , async ( ) => {
96+ const wrapper = shallowMount ( General , {
97+ props : {
98+ targetNamespace : 'default' ,
99+ value : {
100+ policy : {
101+ ...userGroupPolicy ,
102+ spec : {
103+ ...userGroupPolicy . spec ,
104+ module : 'ghcr.io/kubewarden/old-policy:v1'
105+ }
106+ }
107+ } ,
108+ moduleInfo : {
109+ registry : 'ghcr.io' ,
110+ repository : 'kubewarden/pod-privileged' ,
111+ tag : 'v1.0.0' ,
112+ source : 'values'
113+ }
114+ } ,
115+ global : {
116+ provide : { chartType : KUBEWARDEN . CLUSTER_ADMISSION_POLICY } ,
117+ mocks : {
118+ $fetchState : { pending : false } ,
119+ $store : {
120+ getters : {
121+ currentStore : ( ) => 'current_store' ,
122+ 'current_store/all' : jest . fn ( ) ,
123+ 'i18n/t' : jest . fn ( )
124+ } ,
125+ }
126+ } ,
127+ stubs : {
128+ NameNsDescription : { template : '<span />' } ,
129+ RadioGroup : { template : '<span />' } ,
130+ LabeledTooltip : { template : '<span />' } ,
131+ LabeledInput : { template : '<span />' }
132+ }
133+ } ,
134+ computed : {
135+ isCreate : ( ) => true ,
136+ policyServers : ( ) => [ ] ,
137+ policyServerOptions : ( ) => [ ] ,
138+ isGlobal : ( ) => true ,
139+ hasValuesModule : ( ) => true ,
140+ showModeBanner : ( ) => false ,
141+ modeDisabled : ( ) => false
142+ }
143+ } ) ;
144+
145+ await wrapper . setData ( {
146+ policyRegistry : 'registry.internal:5000' ,
147+ policyRepository : 'kubewarden/pod-privileged' ,
148+ policyTag : 'v2.0.0'
149+ } ) ;
150+
151+ wrapper . vm . syncModule ( ) ;
152+
153+ expect ( wrapper . vm . policy . spec . module ) . toBe ( 'registry.internal:5000/kubewarden/pod-privileged:v2.0.0' ) ;
154+ } ) ;
92155} ) ;
0 commit comments