update
This commit is contained in:
@@ -135,7 +135,7 @@ func (s *AssignmentPolicyHandlerTestSuite) TestGetAccountPolicy_Success() {
|
||||
var resp map[string]interface{}
|
||||
s.Require().NoError(json.Unmarshal(w.Body.Bytes(), &resp))
|
||||
assert.Equal(s.T(), "Default", resp["name"])
|
||||
assert.Equal(s.T(), float64(1), resp["conversation_priority"])
|
||||
assert.Equal(s.T(), "longest_waiting", resp["conversation_priority"])
|
||||
assert.Equal(s.T(), true, resp["enabled"])
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ func (s *AssignmentPolicyHandlerTestSuite) TestGetAccountPolicy_Unauthorized() {
|
||||
// ==================== CreateAccountPolicy ====================
|
||||
|
||||
func (s *AssignmentPolicyHandlerTestSuite) TestCreateAccountPolicy_Success() {
|
||||
body := `{"name":"Default","assignment_order":0,"conversation_priority":1,"fair_distribution_limit":5,"fair_distribution_window":300,"enabled":true}`
|
||||
body := `{"name":"Default","assignment_order":"round_robin","conversation_priority":"longest_waiting","fair_distribution_limit":5,"fair_distribution_window":300,"enabled":true}`
|
||||
w := httptest.NewRecorder()
|
||||
req, _ := http.NewRequest("POST", "/api/v1/accounts/1/assignment_policy", bytes.NewBufferString(body))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
@@ -183,10 +183,29 @@ func (s *AssignmentPolicyHandlerTestSuite) TestCreateAccountPolicy_Success() {
|
||||
var resp map[string]interface{}
|
||||
s.Require().NoError(json.Unmarshal(w.Body.Bytes(), &resp))
|
||||
assert.Equal(s.T(), "Default", resp["name"])
|
||||
assert.Equal(s.T(), "round_robin", resp["assignment_order"])
|
||||
assert.Equal(s.T(), "longest_waiting", resp["conversation_priority"])
|
||||
assert.Equal(s.T(), float64(5), resp["fair_distribution_limit"])
|
||||
assert.Equal(s.T(), float64(300), resp["fair_distribution_window"])
|
||||
}
|
||||
|
||||
func (s *AssignmentPolicyHandlerTestSuite) TestCreateAccountPolicy_AcceptsFrontendEnumPayload() {
|
||||
body := `{"name":"test","description":"123123","enabled":true,"assignment_order":"balanced","conversation_priority":"earliest_created","fair_distribution_limit":100,"fair_distribution_window":3600}`
|
||||
w := httptest.NewRecorder()
|
||||
req, _ := http.NewRequest("POST", "/api/v1/accounts/1/assignment_policies", bytes.NewBufferString(body))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
s.router.ServeHTTP(w, req)
|
||||
|
||||
assert.Equal(s.T(), http.StatusOK, w.Code)
|
||||
|
||||
var resp map[string]interface{}
|
||||
s.Require().NoError(json.Unmarshal(w.Body.Bytes(), &resp))
|
||||
assert.Equal(s.T(), "balanced", resp["assignment_order"])
|
||||
assert.Equal(s.T(), "earliest_created", resp["conversation_priority"])
|
||||
assert.Equal(s.T(), float64(100), resp["fair_distribution_limit"])
|
||||
assert.Equal(s.T(), float64(3600), resp["fair_distribution_window"])
|
||||
}
|
||||
|
||||
func (s *AssignmentPolicyHandlerTestSuite) TestCreateAccountPolicy_InvalidJSON() {
|
||||
body := `{invalid json`
|
||||
w := httptest.NewRecorder()
|
||||
@@ -245,7 +264,7 @@ func (s *AssignmentPolicyHandlerTestSuite) TestUpdateAccountPolicy_Success() {
|
||||
}
|
||||
s.Require().NoError(s.db.Create(policy).Error)
|
||||
|
||||
body := `{"name":"Priority","fair_distribution_limit":10}`
|
||||
body := `{"name":"Priority","assignment_order":"balanced","conversation_priority":"longest_waiting","fair_distribution_limit":10}`
|
||||
w := httptest.NewRecorder()
|
||||
req, _ := http.NewRequest("PUT", "/api/v1/accounts/1/assignment_policy/"+uintToStr(policy.ID), bytes.NewBufferString(body))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
@@ -256,6 +275,8 @@ func (s *AssignmentPolicyHandlerTestSuite) TestUpdateAccountPolicy_Success() {
|
||||
var resp map[string]interface{}
|
||||
s.Require().NoError(json.Unmarshal(w.Body.Bytes(), &resp))
|
||||
assert.Equal(s.T(), "Priority", resp["name"])
|
||||
assert.Equal(s.T(), "balanced", resp["assignment_order"])
|
||||
assert.Equal(s.T(), "longest_waiting", resp["conversation_priority"])
|
||||
assert.Equal(s.T(), float64(10), resp["fair_distribution_limit"])
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user