diff --git a/cmd/owl/web/editor_test.go b/cmd/owl/web/editor_test.go index 171e18c..38ae2cb 100644 --- a/cmd/owl/web/editor_test.go +++ b/cmd/owl/web/editor_test.go @@ -151,3 +151,34 @@ func TestEditorPostWithSession(t *testing.T) { assertions.AssertStatus(t, rr, http.StatusFound) assertions.AssertEqual(t, rr.Header().Get("Location"), post.FullUrl()) } + +func TestEditorPostWithSessionNote(t *testing.T) { + repo, user := getSingleUserTestRepo() + user.ResetPassword("testpassword") + sessionId := user.CreateNewSession() + + csrfToken := "test_csrf_token" + + // Create Request and Response + form := url.Values{} + form.Add("type", "note") + form.Add("content", "testcontent") + form.Add("csrf_token", csrfToken) + + req, err := http.NewRequest("POST", user.EditorUrl(), strings.NewReader(form.Encode())) + req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + req.Header.Add("Content-Length", strconv.Itoa(len(form.Encode()))) + req.AddCookie(&http.Cookie{Name: "csrf_token", Value: csrfToken}) + req.AddCookie(&http.Cookie{Name: "session", Value: sessionId}) + assertions.AssertNoError(t, err, "Error creating request") + rr := httptest.NewRecorder() + router := main.SingleUserRouter(&repo) + router.ServeHTTP(rr, req) + + posts, _ := user.AllPosts() + assertions.AssertEqual(t, len(posts), 1) + post := posts[0] + + assertions.AssertStatus(t, rr, http.StatusFound) + assertions.AssertEqual(t, rr.Header().Get("Location"), post.FullUrl()) +} diff --git a/embed/editor/editor.html b/embed/editor/editor.html index 237a463..8165445 100644 --- a/embed/editor/editor.html +++ b/embed/editor/editor.html @@ -13,11 +13,19 @@

- +
Write Note - TODO +
+

Create New Note

+ + + + +

+ +
\ No newline at end of file