@@ -753,10 +753,26 @@ describe('Container Router', () => {
753753 describe ( 'getContainerRecentStatus' , ( ) => {
754754 test ( 'should return the latest status per container using recent audit entries' , ( ) => {
755755 auditStore . getRecentEntries . mockReturnValue ( [
756- { containerName : 'api' , action : 'update-failed' } ,
757- { containerName : 'api' , action : 'update-applied' } ,
758- { containerName : 'worker' , action : 'update-applied' } ,
759- { containerName : 'cache' , action : 'update-available' } ,
756+ {
757+ containerName : 'api' ,
758+ containerIdentityKey : 'edge-a::docker-prod::api' ,
759+ action : 'update-failed' ,
760+ } ,
761+ {
762+ containerName : 'api' ,
763+ containerIdentityKey : 'edge-a::docker-prod::api' ,
764+ action : 'update-applied' ,
765+ } ,
766+ {
767+ containerName : 'worker' ,
768+ containerIdentityKey : 'edge-b::docker-prod::worker' ,
769+ action : 'update-applied' ,
770+ } ,
771+ {
772+ containerName : 'cache' ,
773+ containerIdentityKey : '::local::cache' ,
774+ action : 'update-available' ,
775+ } ,
760776 { containerName : 'ignore-me' , action : 'container-update' } ,
761777 ] ) ;
762778
@@ -772,7 +788,20 @@ describe('Container Router', () => {
772788 cache : 'pending' ,
773789 worker : 'updated' ,
774790 } ,
791+ statusesByIdentity : {
792+ '::local::cache' : 'pending' ,
793+ 'edge-a::docker-prod::api' : 'failed' ,
794+ 'edge-b::docker-prod::worker' : 'updated' ,
795+ } ,
775796 } ) ;
797+ const contractValidation = validateOpenApiJsonResponse ( {
798+ path : '/api/containers/recent-status' ,
799+ method : 'get' ,
800+ statusCode : '200' ,
801+ payload : res . json . mock . calls [ 0 ] [ 0 ] ,
802+ } ) ;
803+ expect ( contractValidation . valid ) . toBe ( true ) ;
804+ expect ( contractValidation . errors ) . toStrictEqual ( [ ] ) ;
776805 } ) ;
777806
778807 test ( 'should ignore invalid entries and empty container names' , ( ) => {
@@ -781,6 +810,16 @@ describe('Container Router', () => {
781810 { action : 'update-failed' } ,
782811 { containerName : ' ' , action : 'update-failed' } ,
783812 { containerName : 'trim-me' , action : 'update-applied' } ,
813+ {
814+ containerName : 'duplicate-name' ,
815+ containerIdentityKey : 'edge-a::docker-a::duplicate-name' ,
816+ action : 'update-failed' ,
817+ } ,
818+ {
819+ containerName : 'duplicate-name' ,
820+ containerIdentityKey : 'edge-b::docker-b::duplicate-name' ,
821+ action : 'update-applied' ,
822+ } ,
784823 ] ) ;
785824
786825 const handler = getHandler ( 'get' , '/recent-status' ) ;
@@ -790,8 +829,13 @@ describe('Container Router', () => {
790829 expect ( res . status ) . toHaveBeenCalledWith ( 200 ) ;
791830 expect ( res . json ) . toHaveBeenCalledWith ( {
792831 statuses : {
832+ 'duplicate-name' : 'failed' ,
793833 'trim-me' : 'updated' ,
794834 } ,
835+ statusesByIdentity : {
836+ 'edge-a::docker-a::duplicate-name' : 'failed' ,
837+ 'edge-b::docker-b::duplicate-name' : 'updated' ,
838+ } ,
795839 } ) ;
796840 } ) ;
797841
@@ -803,7 +847,7 @@ describe('Container Router', () => {
803847 handler ( { query : { } } , res ) ;
804848
805849 expect ( res . status ) . toHaveBeenCalledWith ( 200 ) ;
806- expect ( res . json ) . toHaveBeenCalledWith ( { statuses : { } } ) ;
850+ expect ( res . json ) . toHaveBeenCalledWith ( { statuses : { } , statusesByIdentity : { } } ) ;
807851 } ) ;
808852 } ) ;
809853
0 commit comments