@@ -251,3 +251,108 @@ func TestChatMessages_RequiresChannelArg(t *testing.T) {
251251 assert .Error (t , cmd .Args (cmd , []string {}))
252252 assert .NoError (t , cmd .Args (cmd , []string {"chan-id" }))
253253}
254+
255+ // ── chat reply ──────────────────────────────────────────────────────
256+
257+ func TestChatReply (t * testing.T ) {
258+ tf := testutil .NewTestFactory (t )
259+
260+ var capturedBody map [string ]interface {}
261+ var capturedMethod string
262+ var capturedPath string
263+
264+ tf .HandleFuncV3 ("workspaces/12345/chat/messages/msg-abc/replies" , func (w http.ResponseWriter , r * http.Request ) {
265+ capturedMethod = r .Method
266+ capturedPath = r .URL .Path
267+ body , _ := io .ReadAll (r .Body )
268+ json .Unmarshal (body , & capturedBody )
269+ w .Header ().Set ("Content-Type" , "application/json" )
270+ w .Header ().Set ("X-RateLimit-Remaining" , "99" )
271+ w .WriteHeader (200 )
272+ w .Write ([]byte (`{
273+ "content": "Got it!",
274+ "type": "message",
275+ "date": 1700000000000,
276+ "user_id": "user1",
277+ "resolved": false,
278+ "links": {"reactions": "", "replies": "", "tagged_users": ""},
279+ "replies_count": 0
280+ }` ))
281+ })
282+
283+ cmd := NewCmdReply (tf .Factory )
284+ err := testutil .RunCommand (t , cmd , "msg-abc" , "Got it!" )
285+ require .NoError (t , err )
286+
287+ assert .Equal (t , "POST" , capturedMethod )
288+ assert .Contains (t , capturedPath , "/workspaces/12345/chat/messages/msg-abc/replies" )
289+ assert .Equal (t , "message" , capturedBody ["type" ])
290+ assert .Equal (t , "Got it!" , capturedBody ["content" ])
291+
292+ out := tf .OutBuf .String ()
293+ assert .Contains (t , out , "Reply sent" )
294+ assert .Contains (t , out , "msg-abc" )
295+ }
296+
297+ // ── chat react ──────────────────────────────────────────────────────
298+
299+ func TestChatReact (t * testing.T ) {
300+ tf := testutil .NewTestFactory (t )
301+
302+ var capturedBody map [string ]interface {}
303+ var capturedMethod string
304+ var capturedPath string
305+
306+ tf .HandleFuncV3 ("workspaces/12345/chat/messages/msg-abc/reactions" , func (w http.ResponseWriter , r * http.Request ) {
307+ capturedMethod = r .Method
308+ capturedPath = r .URL .Path
309+ body , _ := io .ReadAll (r .Body )
310+ json .Unmarshal (body , & capturedBody )
311+ w .Header ().Set ("Content-Type" , "application/json" )
312+ w .Header ().Set ("X-RateLimit-Remaining" , "99" )
313+ w .WriteHeader (200 )
314+ w .Write ([]byte (`{}` ))
315+ })
316+
317+ cmd := NewCmdReact (tf .Factory )
318+ err := testutil .RunCommand (t , cmd , "msg-abc" , "rocket" )
319+ require .NoError (t , err )
320+
321+ assert .Equal (t , "POST" , capturedMethod )
322+ assert .Contains (t , capturedPath , "/workspaces/12345/chat/messages/msg-abc/reactions" )
323+ assert .Equal (t , "rocket" , capturedBody ["reaction" ])
324+
325+ out := tf .OutBuf .String ()
326+ assert .Contains (t , out , "Reaction" )
327+ assert .Contains (t , out , "rocket" )
328+ assert .Contains (t , out , "msg-abc" )
329+ }
330+
331+ // ── chat delete ─────────────────────────────────────────────────────
332+
333+ func TestChatDelete (t * testing.T ) {
334+ tf := testutil .NewTestFactory (t )
335+
336+ var capturedMethod string
337+ var capturedPath string
338+
339+ tf .HandleFuncV3 ("workspaces/12345/chat/messages/msg-del" , func (w http.ResponseWriter , r * http.Request ) {
340+ capturedMethod = r .Method
341+ capturedPath = r .URL .Path
342+ w .Header ().Set ("Content-Type" , "application/json" )
343+ w .Header ().Set ("X-RateLimit-Remaining" , "99" )
344+ w .WriteHeader (200 )
345+ w .Write ([]byte (`{}` ))
346+ })
347+
348+ cmd := NewCmdDelete (tf .Factory )
349+ err := testutil .RunCommand (t , cmd , "msg-del" , "--yes" )
350+ require .NoError (t , err )
351+
352+ assert .Equal (t , "DELETE" , capturedMethod )
353+ assert .Contains (t , capturedPath , "/workspaces/12345/chat/messages/msg-del" )
354+
355+ out := tf .OutBuf .String ()
356+ assert .Contains (t , out , "deleted" )
357+ assert .Contains (t , out , "msg-del" )
358+ }
0 commit comments