API: Add additional fields to label and subject edit forms #383 #3168

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-01-17 02:55:07 +01:00
parent d786a8225d
commit 0ada8d1095
99 changed files with 1241 additions and 1101 deletions

View File

@@ -10,10 +10,10 @@ import (
)
func TestUpdateLabel(t *testing.T) {
t.Run("successful request", func(t *testing.T) {
t.Run("Success", func(t *testing.T) {
app, router, _ := NewApiTest()
UpdateLabel(router)
r := PerformRequestWithBody(app, "PUT", "/api/v1/labels/ls6sg6b1wowuy3c7", `{"Name": "Updated01", "Priority": 2}`)
r := PerformRequestWithBody(app, "PUT", "/api/v1/labels/ls6sg6b1wowuy3c7", `{"Name": "Updated01", "Priority": 2, "Favorite": true}`)
val := gjson.Get(r.Body.String(), "Name")
assert.Equal(t, "Updated01", val.String())
val2 := gjson.Get(r.Body.String(), "CustomSlug")
@@ -21,14 +21,14 @@ func TestUpdateLabel(t *testing.T) {
assert.Equal(t, http.StatusOK, r.Code)
})
t.Run("invalid request", func(t *testing.T) {
t.Run("InvalidRequest", func(t *testing.T) {
app, router, _ := NewApiTest()
UpdateLabel(router)
r := PerformRequestWithBody(app, "PUT", "/api/v1/labels/ls6sg6b1wowuy3c7", `{"Name": 123, "Priority": 4, "Uncertainty": 80}`)
assert.Equal(t, http.StatusBadRequest, r.Code)
})
t.Run("not found", func(t *testing.T) {
t.Run("NotFound", func(t *testing.T) {
app, router, _ := NewApiTest()
UpdateLabel(router)
r := PerformRequestWithBody(app, "PUT", "/api/v1/labels/xxx", `{"Name": "Updated01", "Priority": 4, "Uncertainty": 80}`)