feat(reports): align outgoing message counts
This commit is contained in:
@@ -595,7 +595,7 @@ func (h *AnalyticsHandler) OutgoingMessagesCount(c *gin.Context) {
|
||||
}
|
||||
groupBy := c.Query("group_by")
|
||||
if groupBy != "agent" && groupBy != "team" && groupBy != "inbox" && groupBy != "label" {
|
||||
response.AbortWithStatusError(c, http.StatusUnprocessableEntity, response.ErrBadRequest, "invalid group_by")
|
||||
c.Status(http.StatusUnprocessableEntity)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ func (s *AnalyticsHandlerTestSuite) SetupSuite() {
|
||||
accounts.GET("/reports/conversations", s.handler.Conversations)
|
||||
accounts.GET("/reports/conversations_summary", s.handler.ConversationsSummary)
|
||||
accounts.GET("/reports/inbox_label_matrix", s.handler.InboxLabelMatrix)
|
||||
accounts.GET("/reports/outgoing_messages_count", s.handler.OutgoingMessagesCount)
|
||||
s.router = r
|
||||
}
|
||||
|
||||
@@ -504,6 +505,15 @@ func (s *AnalyticsHandlerTestSuite) TestInboxLabelMatrix_ParsesFrontendFilters()
|
||||
s.Require().Len(payload["labels"], 1)
|
||||
}
|
||||
|
||||
func (s *AnalyticsHandlerTestSuite) TestOutgoingMessagesCount_InvalidGroupByReturnsEmptyUnprocessableEntity() {
|
||||
w := httptest.NewRecorder()
|
||||
req := httptest.NewRequest(http.MethodGet, "/api/v1/accounts/1/reports/outgoing_messages_count?since=1735689600&until=1735776000&group_by=bad", nil)
|
||||
s.router.ServeHTTP(w, req)
|
||||
|
||||
s.Equal(http.StatusUnprocessableEntity, w.Code)
|
||||
s.Empty(w.Body.String())
|
||||
}
|
||||
|
||||
// ========== Nil service guard ==========
|
||||
|
||||
func (s *AnalyticsHandlerTestSuite) TestNilService() {
|
||||
|
||||
Reference in New Issue
Block a user