@@ -295,15 +295,16 @@ describe('ConfigurationModel', () => {
295295 queues : { test : 'test' } ,
296296 jobs : [ ] ,
297297 handlers : { } ,
298- sandboxAudits : {
299- enabledAudits : {
300- cwv : {
301- expire : '5' ,
302- } ,
303- 'alt-text' : { } ,
298+ } ;
299+ // Set sandboxAudits using the proper attribute setter
300+ instance . setSandboxAudits ( {
301+ enabledAudits : {
302+ cwv : {
303+ expire : '5' ,
304304 } ,
305+ 'alt-text' : { } ,
305306 } ,
306- } ;
307+ } ) ;
307308 } ) ;
308309
309310 it ( 'checks if audit is enabled for sandbox' , ( ) => {
@@ -341,15 +342,98 @@ describe('ConfigurationModel', () => {
341342 } ) ;
342343
343344 it ( 'returns empty array when no sandbox audits configured' , ( ) => {
344- delete instance . state . sandboxAudits ;
345+ instance . setSandboxAudits ( null ) ;
345346 expect ( instance . getEnabledSandboxAudits ( ) ) . to . deep . equal ( [ ] ) ;
346347 } ) ;
347348
348349 it ( 'handles updating non-existent sandbox config' , ( ) => {
349- delete instance . state . sandboxAudits ;
350+ instance . setSandboxAudits ( null ) ;
350351 instance . updateSandboxAuditConfig ( 'new-audit' , { expire : '5' } ) ;
351352 expect ( instance . getSandboxAuditConfig ( 'new-audit' ) ) . to . deep . equal ( { expire : '5' } ) ;
352353 } ) ;
354+
355+ it ( 'handles getSandboxAuditConfig when sandboxAudits is null' , ( ) => {
356+ instance . setSandboxAudits ( null ) ;
357+ expect ( instance . getSandboxAuditConfig ( 'any-audit' ) ) . to . be . null ;
358+ } ) ;
359+
360+ it ( 'handles getSandboxAuditConfig when sandboxAudits is undefined' , ( ) => {
361+ instance . setSandboxAudits ( undefined ) ;
362+ expect ( instance . getSandboxAuditConfig ( 'any-audit' ) ) . to . be . null ;
363+ } ) ;
364+
365+ it ( 'handles getSandboxAuditConfig when enabledAudits is null' , ( ) => {
366+ instance . setSandboxAudits ( { enabledAudits : null } ) ;
367+ expect ( instance . getSandboxAuditConfig ( 'any-audit' ) ) . to . be . null ;
368+ } ) ;
369+
370+ it ( 'handles getEnabledSandboxAudits when sandboxAudits is null' , ( ) => {
371+ instance . setSandboxAudits ( null ) ;
372+ expect ( instance . getEnabledSandboxAudits ( ) ) . to . deep . equal ( [ ] ) ;
373+ } ) ;
374+
375+ it ( 'handles getEnabledSandboxAudits when sandboxAudits is undefined' , ( ) => {
376+ instance . setSandboxAudits ( undefined ) ;
377+ expect ( instance . getEnabledSandboxAudits ( ) ) . to . deep . equal ( [ ] ) ;
378+ } ) ;
379+
380+ it ( 'handles getEnabledSandboxAudits when enabledAudits is null' , ( ) => {
381+ instance . setSandboxAudits ( { enabledAudits : null } ) ;
382+ expect ( instance . getEnabledSandboxAudits ( ) ) . to . deep . equal ( [ ] ) ;
383+ } ) ;
384+
385+ it ( 'handles isAuditEnabledForSandbox when sandboxAudits is null' , ( ) => {
386+ instance . setSandboxAudits ( null ) ;
387+ expect ( instance . isAuditEnabledForSandbox ( 'any-audit' ) ) . to . be . false ;
388+ } ) ;
389+
390+ it ( 'handles isAuditEnabledForSandbox when sandboxAudits is undefined' , ( ) => {
391+ instance . setSandboxAudits ( undefined ) ;
392+ expect ( instance . isAuditEnabledForSandbox ( 'any-audit' ) ) . to . be . false ;
393+ } ) ;
394+
395+ it ( 'handles isAuditEnabledForSandbox when enabledAudits is null' , ( ) => {
396+ instance . setSandboxAudits ( { enabledAudits : null } ) ;
397+ expect ( instance . isAuditEnabledForSandbox ( 'any-audit' ) ) . to . be . false ;
398+ } ) ;
399+
400+ it ( 'handles removeSandboxAuditConfig when sandboxAudits is null' , ( ) => {
401+ instance . setSandboxAudits ( null ) ;
402+ // Should not throw error when trying to remove from null sandboxAudits
403+ instance . removeSandboxAuditConfig ( 'any-audit' ) ;
404+ expect ( instance . getSandboxAudits ( ) ) . to . be . null ;
405+ } ) ;
406+
407+ it ( 'handles removeSandboxAuditConfig when sandboxAudits is undefined' , ( ) => {
408+ instance . setSandboxAudits ( undefined ) ;
409+ // Should not throw error when trying to remove from undefined sandboxAudits
410+ instance . removeSandboxAuditConfig ( 'any-audit' ) ;
411+ expect ( instance . getSandboxAudits ( ) ) . to . be . undefined ;
412+ } ) ;
413+
414+ it ( 'handles removeSandboxAuditConfig when enabledAudits is null' , ( ) => {
415+ instance . setSandboxAudits ( { enabledAudits : null } ) ;
416+ // Should not throw error when trying to remove from null enabledAudits
417+ instance . removeSandboxAuditConfig ( 'any-audit' ) ;
418+ expect ( instance . getSandboxAudits ( ) ) . to . deep . equal ( { enabledAudits : null } ) ;
419+ } ) ;
420+ } ) ;
421+
422+ describe ( 'Handler Management' , ( ) => {
423+ it ( 'handles disableHandlerForSite when handler is not enabled' , ( ) => {
424+ const mockSite = {
425+ getId : ( ) => 'site2' ,
426+ getOrganizationId : ( ) => 'org2' ,
427+ } ;
428+ // Should not throw error when trying to disable non-enabled handler
429+ expect ( ( ) => instance . disableHandlerForSite ( 'cwv' , mockSite ) ) . to . not . throw ( ) ;
430+ } ) ;
431+
432+ it ( 'handles disableHandlerForOrg when handler is not enabled' , ( ) => {
433+ const mockOrg = { getId : ( ) => 'org2' } ;
434+ // Should not throw error when trying to disable non-enabled handler
435+ expect ( ( ) => instance . disableHandlerForOrg ( 'cwv' , mockOrg ) ) . to . not . throw ( ) ;
436+ } ) ;
353437 } ) ;
354438
355439 describe ( 'save' , ( ) => {
0 commit comments