Capture accumulated application, UI, CLI, regression tests and design documentation changes, including task project mapping and default CalDAV list naming. Keep deployment data, backups, local credentials and build artifacts out of Git. Move the Compose enrollment token to an ignored local environment file.
42 lines
1.6 KiB
Go
42 lines
1.6 KiB
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestPeriodicalNewPage(t *testing.T) {
|
|
s, token, domain, actor := periodicalFixture(t)
|
|
for _, kind := range []string{"blog", "diary"} {
|
|
route := "/v/" + kind + "/-/new"
|
|
if w := periodicalRequest(s, "", "GET", route, ""); w.Code != 303 {
|
|
t.Fatal("anonymous", w.Code)
|
|
}
|
|
if w := periodicalRequest(s, token, "GET", route, ""); w.Code != 404 {
|
|
t.Fatal("disabled", w.Code)
|
|
}
|
|
on := true
|
|
if err := s.store.ChangePeriodical(context.Background(), domain, actor, kind, &on, nil); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := s.store.SetConfigInDomain(domain, "editor_format_default", "markdown"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := s.store.SetConfigInDomain(domain, "editor_preview_default", "hidden"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
w := periodicalRequest(s, token, "GET", route, "")
|
|
if w.Code != 200 || !strings.Contains(w.Body.String(), `class="periodical-compose-page"`) || !strings.Contains(w.Body.String(), `id="edit-type" value="markdown"`) || !strings.Contains(w.Body.String(), `data-preview-default="hidden"`) || !strings.Contains(w.Body.String(), "/"+kind) || w.Header().Get("Cache-Control") != "private, no-store" {
|
|
t.Fatal(w.Code, w.Body.String())
|
|
}
|
|
w = periodicalRequest(s, token, "GET", route+"?edittype=html", "")
|
|
if w.Code != 200 || !strings.Contains(w.Body.String(), `id="edit-type" value="html"`) {
|
|
t.Fatal("explicit editor type was not honored")
|
|
}
|
|
if w := periodicalRequest(s, token, "POST", route, `{}`); w.Code != 403 {
|
|
t.Fatal("unsupported method", w.Code)
|
|
}
|
|
}
|
|
}
|