@@ -347,4 +347,203 @@ describe('addReportFooters', () => {
347347 expect . stringMatching ( / < s u b > < i > .* < \/ i > < \/ s u b > / )
348348 )
349349 } )
350+
351+ it ( 'should include build number with link when buildNumber and buildUrl are present' , ( ) => {
352+ const report : Report = {
353+ reportFormat : 'CTRF' ,
354+ specVersion : '1.0.0' ,
355+ results : {
356+ tool : { name : 'test' } ,
357+ summary : {
358+ tests : 0 ,
359+ passed : 0 ,
360+ failed : 0 ,
361+ skipped : 0 ,
362+ pending : 0 ,
363+ other : 0 ,
364+ start : 0 ,
365+ stop : 0
366+ } ,
367+ tests : [ ]
368+ } ,
369+ baseline : {
370+ reportId : 'baseline-123' ,
371+ commit : 'abcdef1234567890' ,
372+ buildNumber : 42 ,
373+ buildUrl : 'https://ci.example.com/builds/42'
374+ } ,
375+ extra : {
376+ reportConditionals : {
377+ includeFailedReportCurrentFooter : false ,
378+ includeFailedReportAllFooter : false ,
379+ includeFlakyReportCurrentFooter : false ,
380+ includeFlakyReportAllFooter : false ,
381+ includeSkippedReportCurrentFooter : false ,
382+ includeMeasuredOverFooter : false ,
383+ showFailedReports : false ,
384+ showFlakyReports : false ,
385+ showSkippedReports : false
386+ } as ReportConditionals
387+ }
388+ }
389+
390+ const inputs : Inputs = { } as Inputs
391+
392+ addReportFooters ( report , inputs , true )
393+
394+ expect ( mockCore . summary . addRaw ) . toHaveBeenCalledWith (
395+ expect . stringContaining ( '[Run: #42](https://ci.example.com/builds/42)' )
396+ )
397+ } )
398+
399+ it ( 'should include build number without link when buildNumber is present but buildUrl is missing' , ( ) => {
400+ const report : Report = {
401+ reportFormat : 'CTRF' ,
402+ specVersion : '1.0.0' ,
403+ results : {
404+ tool : { name : 'test' } ,
405+ summary : {
406+ tests : 0 ,
407+ passed : 0 ,
408+ failed : 0 ,
409+ skipped : 0 ,
410+ pending : 0 ,
411+ other : 0 ,
412+ start : 0 ,
413+ stop : 0
414+ } ,
415+ tests : [ ]
416+ } ,
417+ baseline : {
418+ reportId : 'baseline-123' ,
419+ commit : 'abcdef1234567890' ,
420+ buildNumber : 42
421+ } ,
422+ extra : {
423+ reportConditionals : {
424+ includeFailedReportCurrentFooter : false ,
425+ includeFailedReportAllFooter : false ,
426+ includeFlakyReportCurrentFooter : false ,
427+ includeFlakyReportAllFooter : false ,
428+ includeSkippedReportCurrentFooter : false ,
429+ includeMeasuredOverFooter : false ,
430+ showFailedReports : false ,
431+ showFlakyReports : false ,
432+ showSkippedReports : false
433+ } as ReportConditionals
434+ }
435+ }
436+
437+ const inputs : Inputs = { } as Inputs
438+
439+ addReportFooters ( report , inputs , true )
440+
441+ expect ( mockCore . summary . addRaw ) . toHaveBeenCalledWith (
442+ expect . stringContaining ( 'Run: #42' )
443+ )
444+ expect ( mockCore . summary . addRaw ) . not . toHaveBeenCalledWith (
445+ expect . stringContaining ( '[Run: #42]' )
446+ )
447+ } )
448+
449+ it ( 'should not include build info when only buildName is present (buildNumber required)' , ( ) => {
450+ const report : Report = {
451+ reportFormat : 'CTRF' ,
452+ specVersion : '1.0.0' ,
453+ results : {
454+ tool : { name : 'test' } ,
455+ summary : {
456+ tests : 0 ,
457+ passed : 0 ,
458+ failed : 0 ,
459+ skipped : 0 ,
460+ pending : 0 ,
461+ other : 0 ,
462+ start : 0 ,
463+ stop : 0
464+ } ,
465+ tests : [ ]
466+ } ,
467+ baseline : {
468+ reportId : 'baseline-123' ,
469+ commit : 'abcdef1234567890' ,
470+ buildName : 'main-build' ,
471+ buildUrl : 'https://ci.example.com/builds/main-build'
472+ } ,
473+ extra : {
474+ reportConditionals : {
475+ includeFailedReportCurrentFooter : false ,
476+ includeFailedReportAllFooter : false ,
477+ includeFlakyReportCurrentFooter : false ,
478+ includeFlakyReportAllFooter : false ,
479+ includeSkippedReportCurrentFooter : false ,
480+ includeMeasuredOverFooter : false ,
481+ showFailedReports : false ,
482+ showFlakyReports : false ,
483+ showSkippedReports : false
484+ } as ReportConditionals
485+ }
486+ }
487+
488+ const inputs : Inputs = { } as Inputs
489+
490+ addReportFooters ( report , inputs , true )
491+
492+ // Should only contain commit, not build info (since buildNumber is required)
493+ expect ( mockCore . summary . addRaw ) . toHaveBeenCalledWith (
494+ expect . stringContaining ( 'Comparison with baseline:' )
495+ )
496+ } )
497+
498+ it ( 'should use buildNumber when both buildNumber and buildName are present' , ( ) => {
499+ const report : Report = {
500+ reportFormat : 'CTRF' ,
501+ specVersion : '1.0.0' ,
502+ results : {
503+ tool : { name : 'test' } ,
504+ summary : {
505+ tests : 0 ,
506+ passed : 0 ,
507+ failed : 0 ,
508+ skipped : 0 ,
509+ pending : 0 ,
510+ other : 0 ,
511+ start : 0 ,
512+ stop : 0
513+ } ,
514+ tests : [ ]
515+ } ,
516+ baseline : {
517+ reportId : 'baseline-123' ,
518+ commit : 'abcdef1234567890' ,
519+ buildNumber : 99 ,
520+ buildName : 'old-build' ,
521+ buildUrl : 'https://ci.example.com/builds/99'
522+ } ,
523+ extra : {
524+ reportConditionals : {
525+ includeFailedReportCurrentFooter : false ,
526+ includeFailedReportAllFooter : false ,
527+ includeFlakyReportCurrentFooter : false ,
528+ includeFlakyReportAllFooter : false ,
529+ includeSkippedReportCurrentFooter : false ,
530+ includeMeasuredOverFooter : false ,
531+ showFailedReports : false ,
532+ showFlakyReports : false ,
533+ showSkippedReports : false
534+ } as ReportConditionals
535+ }
536+ }
537+
538+ const inputs : Inputs = { } as Inputs
539+
540+ addReportFooters ( report , inputs , true )
541+
542+ expect ( mockCore . summary . addRaw ) . toHaveBeenCalledWith (
543+ expect . stringContaining ( '[Run: #99]' )
544+ )
545+ expect ( mockCore . summary . addRaw ) . not . toHaveBeenCalledWith (
546+ expect . stringContaining ( 'old-build' )
547+ )
548+ } )
350549} )
0 commit comments