@@ -40,6 +40,8 @@ describe('Configurations Controller', () => {
40
40
getSlackRoles : ( ) => { } ,
41
41
getEnabledSandboxAudits : ( ) => [ ] ,
42
42
getSandboxAuditConfig : ( ) => null ,
43
+ getSandboxAudits : ( ) => null ,
44
+ setSandboxAudits : ( ) => { } ,
43
45
} ,
44
46
{
45
47
getVersion : ( ) => 2 ,
@@ -89,6 +91,13 @@ describe('Configurations Controller', () => {
89
91
if ( auditType === 'meta-tags' ) return { expire : '15' } ;
90
92
return null ;
91
93
} ,
94
+ getSandboxAudits : ( ) => ( {
95
+ enabledAudits : {
96
+ cwv : { expire : '10' } ,
97
+ 'meta-tags' : { expire : '15' } ,
98
+ } ,
99
+ } ) ,
100
+ setSandboxAudits : ( ) => { } ,
92
101
state : {
93
102
sandboxAudits : {
94
103
enabledAudits : {
@@ -264,6 +273,8 @@ describe('Configurations Controller', () => {
264
273
mockConfig = {
265
274
state : { } ,
266
275
updateSandboxAuditConfig : sandbox . stub ( ) ,
276
+ getSandboxAudits : sandbox . stub ( ) . returns ( { enabledAudits : { } } ) ,
277
+ setSandboxAudits : sandbox . stub ( ) ,
267
278
save : sandbox . stub ( ) . resolves ( mockConfig ) ,
268
279
} ;
269
280
@@ -384,27 +395,28 @@ describe('Configurations Controller', () => {
384
395
expect ( error . message ) . to . include ( 'Error updating sandbox configuration: Save failed' ) ;
385
396
} ) ;
386
397
387
- it ( 'should handle configuration with undefined state ' , async ( ) => {
398
+ it ( 'should handle configuration with null sandbox audits ' , async ( ) => {
388
399
context . attributes . authInfo . withProfile ( { is_admin : true } ) ;
389
400
390
- // Create a config without state property to test our fix
391
- const configWithoutState = {
401
+ // Create a config with null sandbox audits to test our fix
402
+ const configWithNullSandboxAudits = {
392
403
updateSandboxAuditConfig : sandbox . stub ( ) ,
404
+ getSandboxAudits : sandbox . stub ( ) . returns ( null ) ,
405
+ setSandboxAudits : sandbox . stub ( ) ,
393
406
save : sandbox . stub ( ) . resolves ( ) ,
394
407
} ;
395
- mockDataAccess . Configuration . findLatest . resolves ( configWithoutState ) ;
408
+ mockDataAccess . Configuration . findLatest . resolves ( configWithNullSandboxAudits ) ;
396
409
configurationsController = ConfigurationsController ( context ) ;
397
410
398
411
const result = await configurationsController . updateSandboxConfig ( {
399
412
data : { sandboxConfigs : { cwv : { expire : '10' } } } ,
400
413
} ) ;
401
414
const response = await result . json ( ) ;
402
415
403
- // Should initialize state and succeed
416
+ // Should succeed with null sandbox audits
404
417
expect ( result . status ) . to . equal ( 200 ) ;
405
- expect ( configWithoutState . state ) . to . deep . equal ( { } ) ;
406
- expect ( configWithoutState . updateSandboxAuditConfig ) . to . have . been . calledWith ( 'cwv' , { expire : '10' } ) ;
407
- expect ( configWithoutState . save ) . to . have . been . called ;
418
+ expect ( configWithNullSandboxAudits . updateSandboxAuditConfig ) . to . have . been . calledWith ( 'cwv' , { expire : '10' } ) ;
419
+ expect ( configWithNullSandboxAudits . save ) . to . have . been . called ;
408
420
expect ( response . message ) . to . equal ( 'Sandbox configurations updated successfully' ) ;
409
421
} ) ;
410
422
} ) ;
0 commit comments