feat(conversations): align typing events

This commit is contained in:
2026-06-07 11:43:59 +08:00
parent 5ae2d7fec9
commit 83878eb606
6 changed files with 130 additions and 46 deletions
@@ -728,11 +728,28 @@ func (s *ConversationHandlerTestSuite) TestToggleTyping_InvalidConversationID()
assert.Equal(s.T(), http.StatusBadRequest, w.Code)
}
func (s *ConversationHandlerTestSuite) TestToggleTyping_MissingFields() {
func (s *ConversationHandlerTestSuite) TestToggleTyping_MissingFieldsIsNoopSuccess() {
w := httptest.NewRecorder()
req, _ := http.NewRequest("POST", fmt.Sprintf("/api/v1/accounts/%d/conversations/%d/toggle_typing", s.testAccount.ID, s.testConv.ID), bytes.NewBufferString(`{}`))
req.Header.Set("Content-Type", "application/json")
s.router.ServeHTTP(w, req)
assert.Equal(s.T(), http.StatusOK, w.Code)
assert.Empty(s.T(), w.Body.String())
}
func (s *ConversationHandlerTestSuite) TestToggleTyping_EmptyBodyIsNoopSuccess() {
w := httptest.NewRecorder()
req, _ := http.NewRequest("POST", fmt.Sprintf("/api/v1/accounts/%d/conversations/%d/toggle_typing", s.testAccount.ID, s.testConv.ID), nil)
s.router.ServeHTTP(w, req)
assert.Equal(s.T(), http.StatusOK, w.Code)
assert.Empty(s.T(), w.Body.String())
}
func (s *ConversationHandlerTestSuite) TestToggleTyping_InvalidJSON() {
w := httptest.NewRecorder()
req, _ := http.NewRequest("POST", fmt.Sprintf("/api/v1/accounts/%d/conversations/%d/toggle_typing", s.testAccount.ID, s.testConv.ID), bytes.NewBufferString(`{`))
req.Header.Set("Content-Type", "application/json")
s.router.ServeHTTP(w, req)
assert.Equal(s.T(), http.StatusBadRequest, w.Code)
}