@@ -31,7 +31,6 @@ describe('RecordReviewCompletionUseCase', () => {
3131 expect ( result ?. totalSuggestions ) . toBe ( 1 ) ;
3232 expect ( result ?. totalDurationMs ) . toBe ( 60000 ) ;
3333 expect ( result ?. latestScore ) . toBe ( 8 ) ;
34- expect ( result ?. averageScore ) . toBe ( 8 ) ;
3534 } ) ;
3635
3736 it ( 'should transition to pending-fix when blocking issues exist' , ( ) => {
@@ -80,12 +79,31 @@ describe('RecordReviewCompletionUseCase', () => {
8079 expect ( result ?. totalThreads ) . toBe ( 3 ) ;
8180 } ) ;
8281
83- it ( 'should compute average score across reviews' , ( ) => {
82+ it ( 'should record followup type separately' , ( ) => {
83+ const gateway = new InMemoryReviewRequestTrackingGateway ( ) ;
84+ const mr = TrackedMrFactory . create ( { id : 'mr-1' } ) ;
85+ gateway . create ( '/project' , mr ) ;
86+ const useCase = new RecordReviewCompletionUseCase ( gateway ) ;
87+
88+ const result = useCase . execute ( {
89+ projectPath : '/project' ,
90+ mrId : 'mr-1' ,
91+ reviewData : { ...reviewData , type : 'followup' } ,
92+ } ) ;
93+
94+ expect ( result ?. totalFollowups ) . toBe ( 1 ) ;
95+ expect ( result ?. totalReviews ) . toBe ( 0 ) ;
96+ } ) ;
97+
98+ it ( 'should set latestScore to the most recent review score' , ( ) => {
8499 const gateway = new InMemoryReviewRequestTrackingGateway ( ) ;
85100 const mr = TrackedMrFactory . create ( {
86101 id : 'mr-1' ,
87- reviews : [ { type : 'review' , timestamp : '2024-01-01T00:00:00Z' , durationMs : 1000 , score : 6 , blocking : 0 , warnings : 0 , suggestions : 0 , threadsClosed : 0 , threadsOpened : 0 } ] ,
102+ reviews : [
103+ { type : 'review' , timestamp : '2024-01-01T00:00:00Z' , durationMs : 1000 , score : 6 , blocking : 0 , warnings : 0 , suggestions : 0 , threadsClosed : 0 , threadsOpened : 0 } ,
104+ ] ,
88105 totalReviews : 1 ,
106+ latestScore : 6 ,
89107 } ) ;
90108 gateway . create ( '/project' , mr ) ;
91109 const useCase = new RecordReviewCompletionUseCase ( gateway ) ;
@@ -96,24 +114,39 @@ describe('RecordReviewCompletionUseCase', () => {
96114 reviewData : { ...reviewData , score : 10 } ,
97115 } ) ;
98116
99- expect ( result ?. averageScore ) . toBe ( 8 ) ;
100117 expect ( result ?. latestScore ) . toBe ( 10 ) ;
101118 } ) ;
102119
103- it ( 'should record followup type separately ' , ( ) => {
120+ it ( 'should update latestScore from followup ' , ( ) => {
104121 const gateway = new InMemoryReviewRequestTrackingGateway ( ) ;
105- const mr = TrackedMrFactory . create ( { id : 'mr-1' } ) ;
122+ const mr = TrackedMrFactory . create ( {
123+ id : 'mr-1' ,
124+ reviews : [
125+ { type : 'review' , timestamp : '2024-01-01T00:00:00Z' , durationMs : 1000 , score : 5 , blocking : 1 , warnings : 0 , suggestions : 0 , threadsClosed : 0 , threadsOpened : 1 } ,
126+ ] ,
127+ totalReviews : 1 ,
128+ latestScore : 5 ,
129+ openThreads : 1 ,
130+ totalThreads : 1 ,
131+ } ) ;
106132 gateway . create ( '/project' , mr ) ;
107133 const useCase = new RecordReviewCompletionUseCase ( gateway ) ;
108134
109135 const result = useCase . execute ( {
110136 projectPath : '/project' ,
111137 mrId : 'mr-1' ,
112- reviewData : { ...reviewData , type : 'followup' } ,
138+ reviewData : {
139+ type : 'followup' ,
140+ durationMs : 30000 ,
141+ score : 8 ,
142+ blocking : 0 ,
143+ warnings : 0 ,
144+ suggestions : 0 ,
145+ threadsClosed : 1 ,
146+ } ,
113147 } ) ;
114148
115- expect ( result ?. totalFollowups ) . toBe ( 1 ) ;
116- expect ( result ?. totalReviews ) . toBe ( 0 ) ;
149+ expect ( result ?. latestScore ) . toBe ( 8 ) ;
117150 } ) ;
118151
119152 it ( 'should return null for unknown MR' , ( ) => {
0 commit comments