Преглед на файлове

refactor: move ignored properties page to its own test

Moved it to ignored/ so that frontend import of test-exporter-graph isn't
always displaying warnings. Part of LOG-3092
Gabriel Horner преди 1 година
родител
ревизия
7ce983df24

+ 16 - 10
deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs

@@ -105,9 +105,10 @@
 (defn- import-files-to-db
 (defn- import-files-to-db
   "Import specific doc files for dev purposes"
   "Import specific doc files for dev purposes"
   [files conn options]
   [files conn options]
-  (let [doc-options (gp-exporter/build-doc-options {:macros {}} (merge options default-export-options))
-        files' (mapv #(hash-map :path %) files)]
-    (gp-exporter/export-doc-files conn files' <read-file doc-options)))
+  (p/let [doc-options (gp-exporter/build-doc-options {:macros {}} (merge options default-export-options))
+          files' (mapv #(hash-map :path %) files)
+          _ (gp-exporter/export-doc-files conn files' <read-file doc-options)]
+    {:import-state (:import-state doc-options)}))
 
 
 (defn- readable-properties
 (defn- readable-properties
   [db query-ent]
   [db query-ent]
@@ -144,13 +145,12 @@
       (is (= 14 (count (d/q '[:find ?b :where [?b :block/type "journal"]] @conn))))
       (is (= 14 (count (d/q '[:find ?b :where [?b :block/type "journal"]] @conn))))
 
 
       ;; Don't count pages like url.md that have properties but no content
       ;; Don't count pages like url.md that have properties but no content
-      (is (= 5
+      (is (= 4
              (count (->> (d/q '[:find [(pull ?b [:block/original-name :block/type]) ...]
              (count (->> (d/q '[:find [(pull ?b [:block/original-name :block/type]) ...]
                                 :where [?b :block/original-name] [_ :block/page ?b]] @conn)
                                 :where [?b :block/original-name] [_ :block/page ?b]] @conn)
                          (filter #(= ["page"] (:block/type %))))))
                          (filter #(= ["page"] (:block/type %))))))
           "Correct number of pages with block content")
           "Correct number of pages with block content")
-      (is (= 2 (count @(:ignored-properties import-state)))
-          "Only ignored properties should be related to :icon")
+      (is (= 0 (count @(:ignored-properties import-state))) "No ignored properties")
       (is (= 1 (count @assets))))
       (is (= 1 (count @assets))))
 
 
     (testing "logseq files"
     (testing "logseq files"
@@ -223,10 +223,6 @@
              (mapv :db/id (:block/refs (find-block-by-content @conn #"ref to"))))
              (mapv :db/id (:block/refs (find-block-by-content @conn #"ref to"))))
           "block with a block-ref has correct :block/refs")
           "block with a block-ref has correct :block/refs")
 
 
-      (is (= 2
-             (count (filter #(= :icon (:property %)) @(:ignored-properties import-state))))
-          "icon properties are visibly ignored in order to not fail import")
-
       (let [b (find-block-by-content @conn #"MEETING TITLE")]
       (let [b (find-block-by-content @conn #"MEETING TITLE")]
         (is (= {}
         (is (= {}
                (and b (readable-properties @conn b)))
                (and b (readable-properties @conn b)))
@@ -349,3 +345,13 @@
       (is (= [:user.class/Property]
       (is (= [:user.class/Property]
              (:block/tags (readable-properties @conn (find-page-by-name @conn "url"))))
              (:block/tags (readable-properties @conn (find-page-by-name @conn "url"))))
           "tagged page has configured tag imported as a class"))))
           "tagged page has configured tag imported as a class"))))
+
+(deftest-async export-file-with-ignored-properties
+  (p/let [file-graph-dir "test/resources/exporter-test-graph"
+          files (mapv #(node-path/join file-graph-dir %) ["ignored/icon-page.md"])
+          conn (d/create-conn db-schema/schema-for-db-based-graph)
+          _ (d/transact! conn (sqlite-create-graph/build-db-initial-data "{}"))
+          {:keys [import-state]} (import-files-to-db files conn {})]
+    (is (= 2
+           (count (filter #(= :icon (:property %)) @(:ignored-properties import-state))))
+        "icon properties are visibly ignored in order to not fail import")))

+ 0 - 0
deps/graph-parser/test/resources/exporter-test-graph/pages/icon page.md → deps/graph-parser/test/resources/exporter-test-graph/ignored/icon-page.md