Align GoChat with Chatwoot frontend contracts
This commit is contained in:
@@ -70,6 +70,7 @@ func (s *AssignableAgentHandlerTestSuite) SetupSuite() {
|
||||
// Register route matching the handler's expected URL pattern
|
||||
accountGroup := r.Group("/api/v1/accounts/:account_id")
|
||||
{
|
||||
accountGroup.GET("/assignable_agents", s.handler.List)
|
||||
inboxes := accountGroup.Group("/inboxes/:inbox_id")
|
||||
{
|
||||
inboxes.GET("/assignable_agents", s.handler.List)
|
||||
@@ -277,6 +278,33 @@ func (s *AssignableAgentHandlerTestSuite) TestList_MultipleInboxIDsQueryParam()
|
||||
s.Len(data, 2)
|
||||
}
|
||||
|
||||
func (s *AssignableAgentHandlerTestSuite) TestList_StandaloneResourceUsesFrontendInboxIDsQuery() {
|
||||
w := httptest.NewRecorder()
|
||||
req, _ := http.NewRequest("GET",
|
||||
fmt.Sprintf("/api/v1/accounts/%d/assignable_agents?inbox_ids[]=%d&inbox_ids[]=%d",
|
||||
s.account.ID, s.inbox1.ID, s.inbox2.ID), nil)
|
||||
s.router.ServeHTTP(w, req)
|
||||
|
||||
s.Equal(http.StatusOK, w.Code)
|
||||
|
||||
data := s.decodeAssignablePayload(w)
|
||||
s.Len(data, 2)
|
||||
for _, item := range data {
|
||||
agent := item.(map[string]interface{})
|
||||
s.Contains(agent, "id")
|
||||
s.Equal(float64(s.account.ID), agent["account_id"])
|
||||
s.Contains(agent, "availability_status")
|
||||
s.Contains(agent, "available_name")
|
||||
s.Contains(agent, "auto_offline")
|
||||
s.Contains(agent, "confirmed")
|
||||
s.Contains(agent, "email")
|
||||
s.Contains(agent, "provider")
|
||||
s.Contains(agent, "role")
|
||||
s.Contains(agent, "thumbnail")
|
||||
s.Contains(agent, "custom_role_id")
|
||||
}
|
||||
}
|
||||
|
||||
func (s *AssignableAgentHandlerTestSuite) TestList_MultipleInboxIDsQueryParams_NoIntersection() {
|
||||
// Request inbox1 + inbox3 via query param. inbox3 has no members.
|
||||
// Intersection of {user1, user2} ∩ {} = {} (empty).
|
||||
|
||||
Reference in New Issue
Block a user