feat(agents): align index pagination
This commit is contained in:
@@ -137,6 +137,29 @@ func (s *AgentHandlerTestSuite) TestListOrdersByFullName() {
|
||||
assert.Equal(s.T(), "charlie", data[2]["name"])
|
||||
}
|
||||
|
||||
func (s *AgentHandlerTestSuite) TestListIgnoresPerPageLikeChatwoot() {
|
||||
for i := 0; i < 30; i++ {
|
||||
req := service.CreateAgentRequest{
|
||||
Email: fmt.Sprintf("full-list-%02d@test.com", i),
|
||||
Name: fmt.Sprintf("Full List %02d", i),
|
||||
Role: "agent",
|
||||
}
|
||||
w, c := s.makeRequest("POST", "/api/v1/accounts/1/agents", req, s.account.ID, s.user.ID)
|
||||
s.handler.Create(c)
|
||||
assert.Equal(s.T(), http.StatusOK, w.Code)
|
||||
}
|
||||
|
||||
w, c := s.makeRequest("GET", "/api/v1/accounts/1/agents?per_page=5", nil, s.account.ID, s.user.ID)
|
||||
s.handler.List(c)
|
||||
|
||||
assert.Equal(s.T(), http.StatusOK, w.Code)
|
||||
var data []map[string]interface{}
|
||||
json.Unmarshal(w.Body.Bytes(), &data)
|
||||
s.Require().Len(data, 30)
|
||||
assert.Equal(s.T(), "Full List 00", data[0]["name"])
|
||||
assert.Equal(s.T(), "Full List 29", data[29]["name"])
|
||||
}
|
||||
|
||||
func (s *AgentHandlerTestSuite) TestCreateAgent() {
|
||||
customRoleID := uint(7)
|
||||
req := service.CreateAgentRequest{
|
||||
|
||||
Reference in New Issue
Block a user