From f7b753758c932c65b9ca7858654a77cc792ac90c Mon Sep 17 00:00:00 2001 From: Gabriel Horner Date: Mon, 8 Jul 2024 09:51:29 -0400 Subject: [PATCH] fix: tests with outdated :block/type assertions also fix lint --- deps/db/test/logseq/db/sqlite/build_test.cljs | 4 ++-- deps/graph-parser/test/logseq/graph_parser/cli_test.cljs | 4 ++-- .../test/logseq/graph_parser/exporter_test.cljs | 9 +++++---- .../test/logseq/graph_parser/extract_test.cljs | 2 +- deps/graph-parser/test/logseq/graph_parser_test.cljs | 2 +- src/main/frontend/components/page.cljs | 1 - 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/deps/db/test/logseq/db/sqlite/build_test.cljs b/deps/db/test/logseq/db/sqlite/build_test.cljs index 1414ee0e0..47e99b187 100644 --- a/deps/db/test/logseq/db/sqlite/build_test.cljs +++ b/deps/db/test/logseq/db/sqlite/build_test.cljs @@ -14,13 +14,13 @@ [{:page {:block/original-name "page1"} :blocks [{:block/content "Jrue Holiday" :build/tags [:Person]}]} {:page {:block/original-name "Jayson Tatum" :build/tags [:Person]}}])] - (is (= {:block/tags [{:block/original-name "Person", :block/type ["class"]}]} + (is (= {:block/tags [{:block/original-name "Person", :block/type ["class" "page"]}]} (first (d/q '[:find [(pull ?b [{:block/tags [:block/original-name :block/type]}]) ...] :where [?b :block/content "Jrue Holiday"]] @conn))) "Person class is created and correctly associated to a block") - (is (= {:block/tags [{:block/original-name "Person", :block/type ["class"]}]} + (is (= {:block/tags [{:block/original-name "Person", :block/type ["class" "page"]}]} (first (d/q '[:find [(pull ?b [{:block/tags [:block/original-name :block/type]}]) ...] :where [?b :block/original-name "Jayson Tatum"]] @conn))) diff --git a/deps/graph-parser/test/logseq/graph_parser/cli_test.cljs b/deps/graph-parser/test/logseq/graph_parser/cli_test.cljs index fb0a2974b..e61f5508e 100644 --- a/deps/graph-parser/test/logseq/graph_parser/cli_test.cljs +++ b/deps/graph-parser/test/logseq/graph_parser/cli_test.cljs @@ -32,7 +32,7 @@ (docs-graph-helper/docs-graph-assertions @conn graph-dir files) (testing "Additional counts" - (is (= 47996 (count (d/datoms @conn :eavt))) "Correct datoms count")) + (is (= 48766 (count (d/datoms @conn :eavt))) "Correct datoms count")) (testing "Asts" (is (seq asts) "Asts returned are non-zero") @@ -150,7 +150,7 @@ (let [graph-dir "tmp/file-and-db-graph" ;; pages and their blocks which are being tested pages-to-blocks - {{:block/name "page1"} + {{:block/name "page1" :block/type ["page"]} [{:block/content "block 1"} {:block/content "block 2"}] {:block/name "jul 20th, 2023" :block/type #{"journal"} :block/journal-day 20230720} [{:block/content "b1"} {:block/content "b2"}]} diff --git a/deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs b/deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs index 0398081e0..cd5530e5a 100644 --- a/deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs +++ b/deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs @@ -144,7 +144,8 @@ (is (= 9 (count (d/q '[:find ?b :where [?b :block/type "journal"]] @conn)))) ;; Count includes Contents and page references (is (= 9 - (count (d/q '[:find (pull ?b [*]) :where [?b :block/original-name ?name] (not [?b :block/type])] @conn)))) + (count (->> (d/q '[:find [(pull ?b [:block/original-name :block/type]) ...] :where [?b :block/original-name]] @conn) + (filter #(= ["page"] (:block/type %))))))) (is (= 1 (count @assets)))) (testing "logseq files" @@ -242,7 +243,7 @@ "tagged block tag converts tag to page ref") (is (= [(:db/id tag-page)] (map :db/id (:block/refs block))) "tagged block has correct refs") - (is (and tag-page (not (:block/type tag-page))) + (is (and tag-page (not (contains? (set (:block/type tag-page)) "class"))) "tag page is not a class") (is (= {:logseq.property/page-tags #{"Movie"}} @@ -263,7 +264,7 @@ (is (= ["class"] (:block/type tag-page)) "configured tag page in :tag-classes is a class") - (is (and another-tag-page (not (:block/type another-tag-page))) + (is (and another-tag-page (not (contains? (set (:block/type another-tag-page)) "class"))) "unconfigured tag page is not a class") (is (= {:block/tags [:user.class/Movie]} @@ -280,7 +281,7 @@ tag-page (find-page-by-name @conn "Movie")] (is (= (:block/content block) "The Creator") "tagged block with configured tag strips tag from content") - (is (= ["class"] (:block/type tag-page)) + (is (= ["class" "page"] (:block/type tag-page)) "configured tag page derived from :property-classes is a class") (is (nil? (find-page-by-name @conn "type")) "No page exists for configured property") diff --git a/deps/graph-parser/test/logseq/graph_parser/extract_test.cljs b/deps/graph-parser/test/logseq/graph_parser/extract_test.cljs index 4dd2fc0ed..6f338d505 100644 --- a/deps/graph-parser/test/logseq/graph_parser/extract_test.cljs +++ b/deps/graph-parser/test/logseq/graph_parser/extract_test.cljs @@ -143,6 +143,6 @@ page (first pages)] (is (= (get-in page [:block/file :file/path]) "/whiteboards/foo.edn")) (is (= (:block/name page) "foo")) - (is (= (:block/type page) "whiteboard")) + (is (= (:block/type page) #{"whiteboard" "page"})) (is (= (:block/original-name page) "Foo")) (is (every? #(= (:block/parent %) [:block/uuid #uuid "a846e3b4-c41d-4251-80e1-be6978c36d8c"]) blocks)))) diff --git a/deps/graph-parser/test/logseq/graph_parser_test.cljs b/deps/graph-parser/test/logseq/graph_parser_test.cljs index f373ac879..7d5ed1b2a 100644 --- a/deps/graph-parser/test/logseq/graph_parser_test.cljs +++ b/deps/graph-parser/test/logseq/graph_parser_test.cljs @@ -95,7 +95,7 @@ parent (:block/page (ffirst blocks))] (is (= {:block/name "foo" :block/original-name "Foo" - :block/type ["whiteboard"] + :block/type ["page" "whiteboard"] :block/file {:file/path "/whiteboards/foo.edn"}} parent) "parsed block in the whiteboard page has correct parent page")))) diff --git a/src/main/frontend/components/page.cljs b/src/main/frontend/components/page.cljs index 709320bfc..79de9a787 100644 --- a/src/main/frontend/components/page.cljs +++ b/src/main/frontend/components/page.cljs @@ -43,7 +43,6 @@ [logseq.graph-parser.mldoc :as gp-mldoc] [logseq.common.util :as common-util] [logseq.common.util.page-ref :as page-ref] - [medley.core :as medley] [promesa.core :as p] [reitit.frontend.easy :as rfe] [rum.core :as rum]