@@ -112,6 +112,39 @@ describe('GitOps - Push New', () => {
112112 expect ( group . description ) . toBe ( 'New Group Description' ) ;
113113 } ) ;
114114
115+ test ( 'GITOPS_SUITE - Should push changes - New Group for environment' , async ( ) => {
116+ const token = generateToken ( '30s' ) ;
117+
118+ const lastUpdate = Date . now ( ) ;
119+ const req = await request ( app )
120+ . post ( '/gitops/v1/push' )
121+ . set ( 'Authorization' , `Bearer ${ token } ` )
122+ . send ( {
123+ environment : 'staging' ,
124+ changes : [ {
125+ action : 'NEW' ,
126+ diff : 'GROUP' ,
127+ path : [ ] ,
128+ content : {
129+ name : 'New Group Staging' ,
130+ description : 'New Group Description' ,
131+ activated : true
132+ }
133+ } ]
134+ } )
135+ . expect ( 200 ) ;
136+
137+ expect ( req . body . message ) . toBe ( 'Changes applied successfully' ) ;
138+ expect ( req . body . version ) . toBeGreaterThan ( lastUpdate ) ;
139+
140+ // Check if the changes were applied
141+ const group = await GroupConfig . findOne ( { name : 'New Group Staging' , domain : domainId } ) . lean ( ) . exec ( ) ;
142+ expect ( group ) . not . toBeNull ( ) ;
143+ expect ( group . activated [ 'staging' ] ) . toBe ( true ) ;
144+ expect ( group . activated [ EnvType . DEFAULT ] ) . toBeDefined ( ) ;
145+ expect ( group . description ) . toBe ( 'New Group Description' ) ;
146+ } ) ;
147+
115148 test ( 'GITOPS_SUITE - Should push changes - New Group and Switcher' , async ( ) => {
116149 const token = generateToken ( '30s' ) ;
117150
@@ -189,6 +222,40 @@ describe('GitOps - Push New', () => {
189222 expect ( config . components ) . toHaveLength ( 0 ) ;
190223 } ) ;
191224
225+ test ( 'GITOPS_SUITE - Should push changes - New Switcher for environment' , async ( ) => {
226+ const token = generateToken ( '30s' ) ;
227+
228+ const lastUpdate = Date . now ( ) ;
229+ const req = await request ( app )
230+ . post ( '/gitops/v1/push' )
231+ . set ( 'Authorization' , `Bearer ${ token } ` )
232+ . send ( {
233+ environment : 'staging' ,
234+ changes : [ {
235+ action : 'NEW' ,
236+ diff : 'CONFIG' ,
237+ path : [
238+ 'Group Test'
239+ ] ,
240+ content : {
241+ key : 'NEW_SWITCHER_STAGING' ,
242+ activated : true
243+ }
244+ } ]
245+ } )
246+ . expect ( 200 ) ;
247+
248+ expect ( req . body . message ) . toBe ( 'Changes applied successfully' ) ;
249+ expect ( req . body . version ) . toBeGreaterThan ( lastUpdate ) ;
250+
251+ // Check if the changes were applied
252+ const config = await Config . findOne ( { key : 'NEW_SWITCHER_STAGING' , domain : domainId } ) . lean ( ) . exec ( ) ;
253+ expect ( config ) . not . toBeNull ( ) ;
254+ expect ( config . activated [ 'staging' ] ) . toBe ( true ) ;
255+ expect ( config . activated [ EnvType . DEFAULT ] ) . toBeDefined ( ) ;
256+ expect ( config . components ) . toHaveLength ( 0 ) ;
257+ } ) ;
258+
192259 test ( 'GITOPS_SUITE - Should push changes - New Switcher and Relay' , async ( ) => {
193260 const token = generateToken ( '30s' ) ;
194261
0 commit comments