@@ -201,6 +201,50 @@ def test_patch_review_in_dashboard_js(self):
201201 src = dash .read_text (encoding = "utf-8" )
202202 self .assertIn ("pollPatchReviewDetailed" , src )
203203
204+ # ── Reset endpoint ───────────────────────────────────────────────────
205+
206+ def test_reset_returns_ok (self ):
207+ resp = self .client .post ("/health/patch-review/reset" )
208+ self .assertEqual (resp .status_code , 200 )
209+ d = json .loads (resp .data )
210+ self .assertTrue (d ["ok" ])
211+
212+ def test_reset_deletes_stats_file (self ):
213+ import api .blueprints .patch_review as pr_mod
214+ with tempfile .TemporaryDirectory () as tmp :
215+ p = self ._write_stats (tmp , {"threshold_hits" : 5 , "total_rejections" : 2 ,
216+ "enabled" : True , "available" : True , "use_sdk" : True ,
217+ "max_rejections" : 3 , "rejected_subtasks" : [],
218+ "recent_reviews" : []})
219+ with patch .object (pr_mod , "_STATS_PATH" , p ):
220+ resp = self .client .post ("/health/patch-review/reset" )
221+ d = json .loads (resp .data )
222+ self .assertTrue (d ["reset" ])
223+ self .assertFalse (p .exists ())
224+
225+ def test_reset_missing_file_still_returns_ok (self ):
226+ import api .blueprints .patch_review as pr_mod
227+ with patch .object (pr_mod , "_STATS_PATH" , Path ("/nonexistent/x.json" )):
228+ resp = self .client .post ("/health/patch-review/reset" )
229+ d = json .loads (resp .data )
230+ self .assertTrue (d ["ok" ])
231+
232+ def test_reset_route_in_app (self ):
233+ rules = [r .rule for r in app .url_map .iter_rules ()]
234+ self .assertIn ("/health/patch-review/reset" , rules )
235+
236+ # ── /health/detailed includes patch_review ───────────────────────────
237+
238+ def test_health_detailed_includes_patch_review (self ):
239+ resp = self .client .get ("/health/detailed" )
240+ self .assertEqual (resp .status_code , 200 )
241+ d = json .loads (resp .data )
242+ self .assertIn ("patch_review" , d ["checks" ])
243+ pr = d ["checks" ]["patch_review" ]
244+ self .assertIn ("ok" , pr )
245+ self .assertIn ("threshold_hits" , pr )
246+ self .assertIn ("total_rejections" , pr )
247+
204248 def test_patch_review_div_in_dashboard_html (self ):
205249 html = (
206250 Path (__file__ ).resolve ().parents [1 ]
0 commit comments