瀏覽代碼

add create tag test

Tienson Qin 1 周之前
父節點
當前提交
787372c174
共有 2 個文件被更改,包括 22 次插入13 次删除
  1. 20 12
      clj-e2e/test/logseq/e2e/plugins_basic_test.clj
  2. 2 1
      src/main/logseq/api/editor.cljs

+ 20 - 12
clj-e2e/test/logseq/e2e/plugins_basic_test.clj

@@ -270,16 +270,15 @@
         ":logseq.class/Page"
         (-> (ls-api-call! :editor.getBlock (first (get result "tags")))
             (get "ident"))))))
+
   (testing "create page with properties"
     (let [result (ls-api-call! :editor.createPage "Test page 2"
                                {:px1 "test"
                                 :px2 1
-                                ;; :px3 "Page 1"
-                                ;; :px4 ["Page 2" "Page 3"]
-                                }
-                               ;; {:schema {:px3 "page"
-                               ;;           :px4 "page"}}
-                               )
+                                :px3 "Page 1"
+                                :px4 ["Page 2" "Page 3"]}
+                               {:schema {:px3 {:type "page"}
+                                         :px4 {:type "page"}}})
           page (ls-api-call! :editor.getBlock "Test page 2")]
       (is (= "Test page 2" (get result "title")))
       (is
@@ -292,9 +291,18 @@
                         (get "title"))))
       (is (= 1 (-> (ls-api-call! :editor.getBlock (get-in page [(->plugin-ident "px2") "id"]))
                    (get ":logseq.property/value"))))
-      ;; (let [page-1 (ls-api-call! :editor.getBlock (get-in page [(->plugin-ident "px3") "id"]))]
-      ;;   (is (= "page 1" (get page-1 "name"))))
-      ;; (is (= ["page 2" "page 3"] (map #(-> (ls-api-call! :editor.getBlock %)
-      ;;                                      (get "name"))
-      ;;                                 (map #(get % "id") (get page (->plugin-ident "px4"))))))
-      )))
+      (let [page-1 (ls-api-call! :editor.getBlock (get-in page [(->plugin-ident "px3") "id"]))]
+        (is (= "page 1" (get page-1 "name"))))
+      (is (= ["page 2" "page 3"] (map #(-> (ls-api-call! :editor.getBlock %)
+                                           (get "name"))
+                                      (map #(get % "id") (get page (->plugin-ident "px4"))))))))
+
+  (testing "create tag page"
+    (let [result (ls-api-call! :editor.createPage "Tag new"
+                               {}
+                               {:class true})]
+      (is
+       (=
+        ":logseq.class/Tag"
+        (-> (ls-api-call! :editor.getBlock (first (get result "tags")))
+            (get "ident")))))))

+ 2 - 1
src/main/logseq/api/editor.cljs

@@ -126,7 +126,7 @@
    this
    (let [properties (bean/->clj properties)
          db-based? (config/db-based-graph?)
-         {:keys [redirect format journal schema]} (bean/->clj opts)]
+         {:keys [redirect format journal schema class]} (bean/->clj opts)]
      (p/let [page (<get-block name {:children? false})
              new-page (when-not page
                         (page-handler/<create!
@@ -134,6 +134,7 @@
                          (cond->
                           {:redirect? (if (boolean? redirect) redirect true)
                            :journal? journal
+                           :class? class
                            :format format}
                            (not db-based?)
                            (assoc :properties properties))))