feat: sites and authors integration into existing screens (& formated all frontend files kinda accidentally)
This commit is contained in:
1 parent
3d81d2c717
commit
6b8990c55e
239 files changed
+9194
-1354
No files matched your search
@@ -100,9 +100,10 @@ func TestAuthorUseCases(t *testing.T) {
|
||||
authors.fail.failNextWith("Create", author.ErrSlugTaken)
|
||||
uc := useCases.NewCreateMyAuthorUseCase(authors, users, discardRecorder)
|
||||
|
||||
created, err := uc.Create(context.Background(), 1)
|
||||
result, err := uc.Create(context.Background(), 1)
|
||||
created := result.Author
|
||||
|
||||
if err != nil || created.Slug != "marta-alves-2" {
|
||||
if err != nil || created.Slug != "marta-alves-2" || !result.SlugAdjusted {
|
||||
t.Errorf("created %+v %v", created, err)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -60,9 +60,10 @@ func TestAuthorUseCaseGuards(t *testing.T) {
|
||||
}
|
||||
uc := useCases.NewCreateMyAuthorUseCase(authors, users, discardRecorder)
|
||||
|
||||
created, err := uc.Create(context.Background(), 1)
|
||||
result, err := uc.Create(context.Background(), 1)
|
||||
created := result.Author
|
||||
|
||||
if err != nil || created.Slug != author.SlugWithSuffix(base, 50) {
|
||||
if err != nil || created.Slug != author.SlugWithSuffix(base, 50) || !result.SlugAdjusted {
|
||||
t.Errorf("created %+v %v", created, err)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -420,7 +420,7 @@ func TestAuthorsBackendOwnAuthor(t *testing.T) {
|
||||
rec := e.as(t, authorEditorID, http.MethodPost, "/v1/author/me", "")
|
||||
|
||||
body := decodeAuthorBody(t, rec)
|
||||
if rec.Code != http.StatusCreated || body["name"] != c.name || body["slug"] != c.slug || body["user_id"] != float64(authorEditorID) || body["is_linked"] != true {
|
||||
if rec.Code != http.StatusCreated || body["name"] != c.name || body["slug"] != c.slug || body["user_id"] != float64(authorEditorID) || body["is_linked"] != true || body["slug_adjusted"] != false {
|
||||
t.Errorf("status %d body %v", rec.Code, body)
|
||||
}
|
||||
})
|
||||
@@ -446,7 +446,7 @@ func TestAuthorsBackendOwnAuthor(t *testing.T) {
|
||||
|
||||
rec := e.as(t, authorEditorID, http.MethodPost, "/v1/author/me", "")
|
||||
|
||||
if body := decodeAuthorBody(t, rec); rec.Code != http.StatusCreated || body["slug"] != "marta-alves-3" {
|
||||
if body := decodeAuthorBody(t, rec); rec.Code != http.StatusCreated || body["slug"] != "marta-alves-3" || body["slug_adjusted"] != true {
|
||||
t.Errorf("status %d body %v", rec.Code, body)
|
||||
}
|
||||
})
|
||||
@@ -459,9 +459,20 @@ func TestAuthorsBackendOwnAuthor(t *testing.T) {
|
||||
|
||||
rec := e.as(t, authorEditorID, http.MethodPost, "/v1/author/me", "")
|
||||
|
||||
slug, _ := decodeAuthorBody(t, rec)["slug"].(string)
|
||||
if rec.Code != http.StatusCreated || utf8.RuneCountInString(slug) > 100 || !strings.HasSuffix(slug, "-2") {
|
||||
t.Errorf("status %d slug %q", rec.Code, slug)
|
||||
body := decodeAuthorBody(t, rec)
|
||||
slug, _ := body["slug"].(string)
|
||||
if rec.Code != http.StatusCreated || utf8.RuneCountInString(slug) > 100 || !strings.HasSuffix(slug, "-2") || body["slug_adjusted"] != true {
|
||||
t.Errorf("status %d slug %q body %v", rec.Code, slug, body)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Only the own-author creation carries slug_adjusted", func(t *testing.T) {
|
||||
e := newAuthorEnv(t)
|
||||
|
||||
rec := e.as(t, apiKeyOwnerId, http.MethodPost, "/v1/author/", `{"name": "Camille Roche"}`)
|
||||
|
||||
if _, present := decodeAuthorBody(t, rec)["slug_adjusted"]; rec.Code != http.StatusCreated || present {
|
||||
t.Errorf("status %d body %s", rec.Code, rec.Body.String())
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user