@@ -207,6 +207,53 @@ describe("StatsTab index modal", () => {
207207 await new Promise ( ( r ) => setTimeout ( r , 400 ) ) ;
208208 expect ( browseCalls ( ) ) . toBe ( before ) ;
209209 } ) ;
210+
211+ it ( "posts empty ADR content when deleting an existing ADR" , async ( ) => {
212+ let saved : unknown = null ;
213+ mockProjectsFetch ( ( url , init ) => {
214+ if ( url === "/rpc" ) {
215+ const body = JSON . parse ( String ( init ?. body ) ) ;
216+ const tool = body . params ?. name ;
217+ const result = tool === "list_projects"
218+ ? {
219+ projects : [ {
220+ name : "demo" ,
221+ root_path : "/repo" ,
222+ indexed_at : "2026-01-01T00:00:00Z" ,
223+ } ] ,
224+ }
225+ : { node_labels : [ ] , edge_types : [ ] , total_nodes : 0 , total_edges : 0 } ;
226+ return new Response ( JSON . stringify ( {
227+ result : { content : [ { text : JSON . stringify ( result ) } ] } ,
228+ } ) , { status : 200 , headers : { "Content-Type" : "application/json" } } ) ;
229+ }
230+ if ( url . startsWith ( "/api/adr" ) ) {
231+ if ( init ?. method === "POST" ) {
232+ saved = JSON . parse ( String ( init . body ) ) ;
233+ return new Response ( JSON . stringify ( { ok : true } ) , {
234+ status : 200 ,
235+ headers : { "Content-Type" : "application/json" } ,
236+ } ) ;
237+ }
238+ return new Response ( JSON . stringify ( {
239+ has_adr : true ,
240+ content : "old decision text" ,
241+ updated_at : "2026-01-01" ,
242+ } ) , { status : 200 , headers : { "Content-Type" : "application/json" } } ) ;
243+ }
244+ return undefined ;
245+ } ) ;
246+
247+ render ( < StatsTab onSelectProject = { ( ) => { } } /> ) ;
248+ fireEvent . click ( await screen . findByRole ( "button" , { name : "ADR" } ) ) ;
249+ expect ( await screen . findByDisplayValue ( "old decision text" ) ) . toBeInTheDocument ( ) ;
250+
251+ fireEvent . click ( screen . getByRole ( "button" , { name : "Delete" } ) ) ;
252+
253+ await waitFor ( ( ) => {
254+ expect ( saved ) . toEqual ( { project : "demo" , content : "" } ) ;
255+ } ) ;
256+ } ) ;
210257} ) ;
211258
212259describe ( "IndexProgress" , ( ) => {
0 commit comments