@@ -590,3 +590,80 @@ test('buildTechSummary handles results with no third_party_service_sizes field',
590590 assert . equal ( summary . third_party_service_counts [ 'Google Analytics' ] , 1 ) ;
591591 assert . deepEqual ( summary . third_party_service_total_bytes , { } ) ;
592592} ) ;
593+
594+ // ---------------------------------------------------------------------------
595+ // third_party_service_page_load_totals – buildTechSummary
596+ // ---------------------------------------------------------------------------
597+
598+ test ( 'buildTechSummary returns empty third_party_service_page_load_totals for empty results' , ( ) => {
599+ const summary = buildTechSummary ( [ ] ) ;
600+ assert . deepEqual ( summary . third_party_service_page_load_totals , { } ) ;
601+ } ) ;
602+
603+ test ( 'buildTechSummary accumulates page_load_count per service across successful results' , ( ) => {
604+ const results = [
605+ {
606+ url : 'https://site1.gov/' ,
607+ page_load_count : 5000000 ,
608+ scan_status : 'success' ,
609+ detected_technologies : {
610+ cms : null ,
611+ uswds : { detected : false , version : null } ,
612+ third_party_services : [ 'Google Analytics' , 'Google Fonts' ] ,
613+ third_party_service_sizes : { 'Google Analytics' : 30720 , 'Google Fonts' : 5120 }
614+ }
615+ } ,
616+ {
617+ url : 'https://site2.gov/' ,
618+ page_load_count : 2000000 ,
619+ scan_status : 'success' ,
620+ detected_technologies : {
621+ cms : null ,
622+ uswds : { detected : false , version : null } ,
623+ third_party_services : [ 'Google Analytics' ] ,
624+ third_party_service_sizes : { 'Google Analytics' : 20480 }
625+ }
626+ } ,
627+ {
628+ url : 'https://site3.gov/' ,
629+ page_load_count : 999999 ,
630+ scan_status : 'failed' ,
631+ detected_technologies : {
632+ cms : null ,
633+ uswds : { detected : false , version : null } ,
634+ third_party_services : [ 'Google Analytics' ] ,
635+ third_party_service_sizes : { 'Google Analytics' : 99999 }
636+ }
637+ }
638+ ] ;
639+ const summary = buildTechSummary ( results ) ;
640+ assert . equal ( summary . third_party_service_page_load_totals [ 'Google Analytics' ] , 7000000 ) ;
641+ assert . equal ( summary . third_party_service_page_load_totals [ 'Google Fonts' ] , 5000000 ) ;
642+ assert . equal ( summary . third_party_service_page_load_totals [ 'YouTube' ] , undefined ) ;
643+ } ) ;
644+
645+ test ( 'buildTechSummary treats missing page_load_count as 0 in page load totals' , ( ) => {
646+ const results = [
647+ {
648+ url : 'https://site1.gov/' ,
649+ scan_status : 'success' ,
650+ detected_technologies : {
651+ cms : null ,
652+ uswds : { detected : false , version : null } ,
653+ third_party_services : [ 'Google Analytics' ]
654+ }
655+ } ,
656+ {
657+ url : 'https://site2.gov/' ,
658+ page_load_count : 3000000 ,
659+ scan_status : 'success' ,
660+ detected_technologies : {
661+ cms : null ,
662+ uswds : { detected : false , version : null } ,
663+ third_party_services : [ 'Google Analytics' ]
664+ }
665+ }
666+ ] ;
667+ const summary = buildTechSummary ( results ) ;
668+ assert . equal ( summary . third_party_service_page_load_totals [ 'Google Analytics' ] , 3000000 ) ;
669+ } ) ;
0 commit comments