diff --git a/.carve/ignore b/.carve/ignore index 80569056b1..251ed742fc 100644 --- a/.carve/ignore +++ b/.carve/ignore @@ -74,4 +74,4 @@ frontend.common.missionary/> (d/q '[:find (pull ?b [*]) :where [?b :block/title ""] [?p :block/name "page1"] @@ -69,7 +70,7 @@ :where [?b :block/parent] [?b :block/title] - [(missing? $ ?b :block/pre-block?)]] + [(missing? $ ?b :logseq.property/built-in?)]] @conn) (map (comp :block/title first)))] (is (= ["b1" "b2"] updated-blocks) "Block is deleted")))}))) @@ -77,12 +78,7 @@ (testing "backspace deletes empty block in embedded context" ;; testing embed at this layer doesn't require an embed block since ;; delete-block handles all the embed setup - (load-test-files [{:file/path "pages/page1.md" - :file/content "\n -- b1 -- b2 --"}]) - (p/let [conn (db/get-db test-helper/test-db false) + (p/let [conn (db/get-db test-helper/test-db-name-db-version false) block (->> (d/q '[:find (pull ?b [*]) :where [?b :block/title ""] [?p :block/name "page1"] @@ -96,7 +92,7 @@ :where [?b :block/parent] [?b :block/title] - [(missing? $ ?b :block/pre-block?)]] + [(missing? $ ?b :logseq.property/built-in?)]] @conn) (map (comp :block/title first)))] (is (= ["b1" "b2"] updated-blocks) "Block is deleted")))})))) diff --git a/src/test/frontend/handler/editor_test.cljs b/src/test/frontend/handler/editor_test.cljs index 530f656a23..baaff6b5a7 100644 --- a/src/test/frontend/handler/editor_test.cljs +++ b/src/test/frontend/handler/editor_test.cljs @@ -7,7 +7,7 @@ [frontend.test.helper :as test-helper] [frontend.util.cursor :as cursor])) -(use-fixtures :each test-helper/start-and-destroy-db) +(use-fixtures :each #(test-helper/start-and-destroy-db % {:db-graph? true})) (deftest extract-nearest-link-from-text-test (testing "Page, block and tag links" @@ -196,9 +196,10 @@ (deftest save-block! (testing "Saving blocks with and without properties" - (test-helper/load-test-files [{:file/path "foo.md" - :file/content "# foo"}]) - (let [repo test-helper/test-db + (test-helper/load-test-files [{:page {:block/title "foo"} + :blocks [{:block/title "foo" + :build/properties {:logseq.property/heading 1}}]}]) + (let [repo test-helper/test-db-name-db-version page-uuid (:block/uuid (db/get-page "foo")) block-uuid (:block/uuid (model/get-block-by-page-name-and-block-route-name repo (str page-uuid) "foo"))] (editor/save-block! repo block-uuid "# bar") diff --git a/src/test/frontend/handler/export_test.cljs b/src/test/frontend/handler/export_test.cljs index ad2cc3efc5..57ffd35ee7 100644 --- a/src/test/frontend/handler/export_test.cljs +++ b/src/test/frontend/handler/export_test.cljs @@ -7,29 +7,41 @@ [promesa.core :as p])) (def test-files - [{:file/path "pages/page1.md" - :file/content - (string/trim " -- 1 - id:: 61506710-484c-46d5-9983-3d1651ec02c8 - - 2 - id:: 61506711-5638-4899-ad78-187bdc2eaffc - - 3 - id:: 61506712-3007-407e-b6d3-d008a8dfa88b - - ((61506712-3007-407e-b6d3-d008a8dfa88b)) -- 4 - id:: 61506712-b8a7-491d-ad84-b71651c3fdab")} - {:file/path "pages/page2.md" - :file/content - (string/trim " -- 3 - id:: 97a00e55-48c3-48d8-b9ca-417b16e3a616 - - {{embed [[page1]]}}")}]) + (let [uuid-1 #uuid "61506710-484c-46d5-9983-3d1651ec02c8" + uuid-2 #uuid "61506711-5638-4899-ad78-187bdc2eaffc" + uuid-3 #uuid "61506712-3007-407e-b6d3-d008a8dfa88b" + uuid-4 #uuid "61506712-b8a7-491d-ad84-b71651c3fdab" + uuid-p2 #uuid "97a00e55-48c3-48d8-b9ca-417b16e3a616"] + [{:page {:block/title "page1"} + :blocks + [{:block/title "1" + :build/keep-uuid? true + :block/uuid uuid-1 + :build/children + [{:block/title "2" + :build/keep-uuid? true + :block/uuid uuid-2 + :build/children + [{:block/title "3" + :build/keep-uuid? true + :block/uuid uuid-3} + {:block/title (str "[[" uuid-3 "]]")}]}]} + + {:block/title "4" + :build/keep-uuid? true + :block/uuid uuid-4}]} + {:page {:block/title "page2"} + :blocks + [{:block/title "3" + :build/keep-uuid? true + :block/uuid uuid-p2 + :build/children + [{:block/title "{{embed [[page1]]}}"}]}]}])) (use-fixtures :once {:before (fn [] (async done - (test-helper/start-test-db!) + (test-helper/start-test-db! {:db-graph? true}) (p/let [_ (test-helper/load-test-files test-files)] (done)))) :after test-helper/destroy-test-db!}) @@ -43,7 +55,7 @@ - 1 - 2 - 3 - - 3") + - [[3]]") "61506710-484c-46d5-9983-3d1651ec02c8" (string/trim " @@ -51,38 +63,10 @@ - 1 - 2 - 3 - - 3 + - [[3]] - 4") "97a00e55-48c3-48d8-b9ca-417b16e3a616")) - -(deftest export-blocks-as-markdown-with-properties - (are [expect block-uuid-s] - (= expect (string/trim (export-text/export-blocks-as-markdown (state/get-current-repo) [(uuid block-uuid-s)] {}))) - (string/trim " -- 1 - id:: 61506710-484c-46d5-9983-3d1651ec02c8 - - 2 - id:: 61506711-5638-4899-ad78-187bdc2eaffc - - 3 - id:: 61506712-3007-407e-b6d3-d008a8dfa88b - - 3") - "61506710-484c-46d5-9983-3d1651ec02c8" - - (string/trim " -- 3 - id:: 97a00e55-48c3-48d8-b9ca-417b16e3a616 - - 1 - id:: 61506710-484c-46d5-9983-3d1651ec02c8 - - 2 - id:: 61506711-5638-4899-ad78-187bdc2eaffc - - 3 - id:: 61506712-3007-407e-b6d3-d008a8dfa88b - - 3 - - 4 - id:: 61506712-b8a7-491d-ad84-b71651c3fdab") - "97a00e55-48c3-48d8-b9ca-417b16e3a616")) - (deftest export-blocks-as-markdown-level> (d/q '[:find (pull ?b [*]) - :where [?b :block/pre-block? true]] - @conn) - ffirst) - _ (save-block! (-> pre-block - (update :block/properties dissoc :tags) - (update :block/properties-text-values dissoc :tags))) - updated-page (-> (d/q '[:find (pull ?bp [* {:block/alias [*]}]) - :where [?b :block/pre-block? true] - [?b :block/page ?bp]] - @conn) - ffirst)] - (is (nil? (:block/tags updated-page)) - "Page's tags are deleted")))) - ;;; Fuzzy tests (def init-id (atom 100))