ui overhaul
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user