ui overhaul
This commit is contained in:
@@ -177,7 +177,7 @@ func (h *Handler) updateCard(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
card, err := h.service.UpdateCard(r.Context(), id, app.CardPatch{
|
||||
Title: request.Title, Description: request.Description, Done: request.Done, ListID: request.ListID, Position: request.Position,
|
||||
Title: request.Title, Description: request.Description, ListID: request.ListID, Position: request.Position,
|
||||
})
|
||||
if err != nil {
|
||||
writeDomainError(w, err)
|
||||
|
||||
@@ -84,3 +84,42 @@ func TestJSONValidationAndLastListConflict(t *testing.T) {
|
||||
t.Fatalf("last list status = %d", got.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCardDoneFieldIsNotPartOfTheAPI(t *testing.T) {
|
||||
t.Parallel()
|
||||
handler := newHandler(t)
|
||||
var board struct {
|
||||
Lists []struct {
|
||||
ID int64 `json:"id"`
|
||||
} `json:"lists"`
|
||||
}
|
||||
if err := json.Unmarshal(request(t, handler, http.MethodGet, "/api/board", "", false).Body.Bytes(), &board); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(board.Lists) == 0 {
|
||||
t.Fatal("board has no lists")
|
||||
}
|
||||
|
||||
created := request(t, handler, http.MethodPost, "/api/lists/"+strconv.FormatInt(board.Lists[0].ID, 10)+"/cards", `{"title":"status comes from the list"}`, true)
|
||||
if created.Code != http.StatusCreated {
|
||||
t.Fatalf("create card status = %d, body %s", created.Code, created.Body)
|
||||
}
|
||||
var payload struct {
|
||||
Card map[string]json.RawMessage `json:"card"`
|
||||
}
|
||||
if err := json.Unmarshal(created.Body.Bytes(), &payload); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, exists := payload.Card["done"]; exists {
|
||||
t.Fatalf("card response unexpectedly contains done: %s", created.Body)
|
||||
}
|
||||
|
||||
cardID := payload.Card["id"]
|
||||
var id int64
|
||||
if err := json.Unmarshal(cardID, &id); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := request(t, handler, http.MethodPatch, "/api/cards/"+strconv.FormatInt(id, 10), `{"done":true}`, true); got.Code != http.StatusBadRequest {
|
||||
t.Fatalf("done patch status = %d, body %s", got.Code, got.Body)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ type createCardRequest struct {
|
||||
type updateCardRequest struct {
|
||||
Title *string `json:"title,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
Done *bool `json:"done,omitempty"`
|
||||
ListID *int64 `json:"list_id,omitempty"`
|
||||
Position *float64 `json:"position,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user