@@ -241,4 +241,41 @@ describe("handleDeleteSubmit", () => {
241241
242242 expect ( capturedFormData . get ( "is_inactive_checked" ) ) . toBe ( "true" ) ;
243243 } ) ;
244+
245+ test ( "uses PANEL_SEARCH_CONFIG for A2A agents refresh (partialPath and targetSelector)" , async ( ) => {
246+ const form = document . createElement ( "form" ) ;
247+ form . id = "test-form" ;
248+ form . action = "/test" ;
249+ document . body . appendChild ( form ) ;
250+
251+ const tableDiv = document . createElement ( "div" ) ;
252+ tableDiv . id = "agents-table" ; // Correct ID per PANEL_SEARCH_CONFIG
253+ document . body . appendChild ( tableDiv ) ;
254+
255+ const fetchMock = vi . fn ( ) . mockResolvedValue ( { ok : true } ) ;
256+ global . fetch = fetchMock ;
257+
258+ // Mock HTMX
259+ const htmxAjaxMock = vi . fn ( ) ;
260+ global . window . htmx = { ajax : htmxAjaxMock } ;
261+ global . window . ROOT_PATH = "" ;
262+
263+ const event = { preventDefault : vi . fn ( ) , target : form } ;
264+
265+ vi . spyOn ( window , "confirm" )
266+ . mockReturnValueOnce ( true )
267+ . mockReturnValueOnce ( false ) ;
268+
269+ await handleDeleteSubmit ( event , "agent" , "test-agent" , "a2a-agents" ) ;
270+
271+ // Verify HTMX was called with correct partial path (a2a/partial) and target selector (#agents-table)
272+ expect ( htmxAjaxMock ) . toHaveBeenCalledWith (
273+ 'GET' ,
274+ expect . stringContaining ( '/admin/a2a/partial' ) ,
275+ expect . objectContaining ( {
276+ target : '#agents-table' , // targetSelector from PANEL_SEARCH_CONFIG, not #a2a-agents-table
277+ swap : 'outerHTML'
278+ } )
279+ ) ;
280+ } ) ;
244281} ) ;
0 commit comments