feat(teams): align frontend update routes
This commit is contained in:
@@ -160,6 +160,31 @@ func (s *TeamHandlerTestSuite) TestUpdate_Success() {
|
||||
assert.Equal(s.T(), false, payload["allow_auto_assign"])
|
||||
}
|
||||
|
||||
func (s *TeamHandlerTestSuite) TestUpdate_PatchRawPayloadSuccess() {
|
||||
team := &model.Team{AccountID: s.account.ID, Name: "patch-test-team", AllowAutoAssignment: true}
|
||||
s.Require().NoError(s.db.Create(team).Error)
|
||||
|
||||
r := gin.New()
|
||||
r.PATCH("/api/v1/accounts/:account_id/teams/:team_id", func(c *gin.Context) {
|
||||
s.authMiddleware(c)
|
||||
s.handler.Update(c)
|
||||
})
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
body := `{"name":"patched-team","description":"patched description","allow_auto_assign":false}`
|
||||
req, _ := http.NewRequest("PATCH", fmt.Sprintf("/api/v1/accounts/%d/teams/%d", s.account.ID, team.ID), bytes.NewBufferString(body))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
r.ServeHTTP(w, req)
|
||||
|
||||
assert.Equal(s.T(), http.StatusOK, w.Code)
|
||||
var payload map[string]any
|
||||
assert.NoError(s.T(), json.Unmarshal(w.Body.Bytes(), &payload))
|
||||
assert.NotContains(s.T(), payload, "success")
|
||||
assert.NotContains(s.T(), payload, "data")
|
||||
assert.Equal(s.T(), "patched-team", payload["name"])
|
||||
assert.Equal(s.T(), false, payload["allow_auto_assign"])
|
||||
}
|
||||
|
||||
func (s *TeamHandlerTestSuite) TestDelete_Success() {
|
||||
team := &model.Team{AccountID: s.account.ID, Name: "delete-test-team"}
|
||||
s.Require().NoError(s.db.Create(team).Error)
|
||||
|
||||
Reference in New Issue
Block a user