|
|
@@ -22,7 +22,8 @@
|
|
|
|
|
|
(deftest create-namespace-pages
|
|
|
(let [conn (db-test/create-conn-with-blocks
|
|
|
- {:classes {:class1 {}}
|
|
|
+ {:properties {:property1 {:block/schema {:type :default}}}
|
|
|
+ :classes {:class1 {}}
|
|
|
:pages-and-blocks [{:page {:block/title "page1"}}]})]
|
|
|
|
|
|
(testing "Valid workflows"
|
|
|
@@ -30,12 +31,17 @@
|
|
|
child-page (d/entity @conn [:block/uuid child-uuid])
|
|
|
;; Create a 2nd child page using existing parent pages
|
|
|
[_ child-uuid2] (worker-db-page/create! conn "foo/bar/baz2" {:split-namespace? true})
|
|
|
- child-page2 (d/entity @conn [:block/uuid child-uuid2])]
|
|
|
+ child-page2 (d/entity @conn [:block/uuid child-uuid2])
|
|
|
+ ;; Create a child page for a class
|
|
|
+ [_ child-uuid3] (worker-db-page/create! conn "c1/c2" {:split-namespace? true :class? true})
|
|
|
+ child-page3 (d/entity @conn [:block/uuid child-uuid3])]
|
|
|
(is (= ["foo" "bar"] (map :block/title (ldb/get-page-parents child-page)))
|
|
|
"Child page with new parent has correct parents")
|
|
|
(is (= (map :block/uuid (ldb/get-page-parents child-page))
|
|
|
(map :block/uuid (ldb/get-page-parents child-page2)))
|
|
|
"Child page with existing parents has correct parents")
|
|
|
+ (is (= ["Root Tag" "c1"] (map :block/title (ldb/get-classes-parents [child-page3])))
|
|
|
+ "Child class with new parent has correct parents")
|
|
|
|
|
|
(worker-db-page/create! conn "foo/class1/baz3" {:split-namespace? true})
|
|
|
(is (= #{"class" "page"}
|
|
|
@@ -51,6 +57,23 @@
|
|
|
"Page can't have a class parent")
|
|
|
(is (thrown-with-msg?
|
|
|
js/Error
|
|
|
- #"can't include \"/"
|
|
|
- (worker-db-page/create! conn "foo/bar" {}))
|
|
|
- "Page can't have a class parent"))))
|
|
|
+ #"Cannot create"
|
|
|
+ (worker-db-page/create! conn "property1/page" {:split-namespace? true}))
|
|
|
+ "Page can't have a property parent")
|
|
|
+ (is (thrown-with-msg?
|
|
|
+ js/Error
|
|
|
+ #"Cannot create"
|
|
|
+ (worker-db-page/create! conn "property1/class" {:split-namespace? true :class? true}))
|
|
|
+ "Class can't have a property parent"))))
|
|
|
+
|
|
|
+(deftest create-page
|
|
|
+ (let [conn (db-test/create-conn)
|
|
|
+ [_ page-uuid] (worker-db-page/create! conn "fooz" {})]
|
|
|
+ (is (= "fooz" (:block/title (d/entity @conn [:block/uuid page-uuid])))
|
|
|
+ "Valid page created")
|
|
|
+
|
|
|
+ (is (thrown-with-msg?
|
|
|
+ js/Error
|
|
|
+ #"can't include \"/"
|
|
|
+ (worker-db-page/create! conn "foo/bar" {}))
|
|
|
+ "Page can't have '/'n title")))
|