Selaa lähdekoodia

fix: undo redo tests

Tienson Qin 1 vuosi sitten
vanhempi
sitoutus
1e835d2b98

+ 1 - 1
src/test/frontend/handler/db_based/property_test.cljs

@@ -31,7 +31,7 @@
 ;; batch-remove-property!
 ;; upsert-property!
 ;; update-property!
-(deftest ^:large-vars/cleanup-todo ^:wip block-property-test
+(deftest ^:large-vars/cleanup-todo block-property-test
   (testing "Add a property to a block"
     (db-property-handler/set-block-property! repo fbid :user.property/property-1 "value" {:property-type :string})
     (let [block (db/entity [:block/uuid fbid])

+ 1 - 1
src/test/frontend/worker/rtc/rtc_fns_test.cljs

@@ -451,7 +451,7 @@ server: ;; remove 2
 
 ;; TODO: add back once page merge get supported
 (comment
-  (deftest ^:wip same-name-two-pages-merge-test
+  (deftest same-name-two-pages-merge-test
     (let [repo (state/get-current-repo)
           conn (conn/get-db repo false)
           date-formatter (common-config/get-date-formatter (worker-state/get-config repo))

+ 18 - 16
src/test/frontend/worker/undo_redo_test.cljs

@@ -198,8 +198,9 @@
         (is (= origin-graph-block-set (get-db-block-set @conn)))))))
 
 (defn- print-page-stat
-  [db page-uuid page-name]
-  (let [blocks (ldb/get-page-blocks db page-name {})]
+  [db page-uuid]
+  (let [page (d/entity db [:block/uuid page-uuid])
+        blocks (ldb/get-page-blocks db (:db/id page) {})]
     (pp/pprint
      {:block-count (count blocks)
       :undo-op-count (count (get-in @(:undo/repo->page-block-uuid->undo-ops @worker-state/*state)
@@ -208,8 +209,9 @@
                                     [test-helper/test-db-name-db-version page-uuid]))})))
 
 (defn- print-page-blocks-tree
-  [db page-uuid page-name]
-  (let [blocks (ldb/get-page-blocks db page-name {})]
+  [db page-uuid]
+  (let [page (d/entity db [:block/uuid page-uuid])
+        blocks (ldb/get-page-blocks db (:db/id page) {})]
     (prn ::page-block-tree)
     (pp/pprint
      (walk/postwalk
@@ -222,7 +224,7 @@
       (otree/blocks->vec-tree test-helper/test-db-name-db-version db
                               blocks page-uuid)))))
 
-(deftest undo-redo-outliner-op-gen-test
+(deftest ^:wip undo-redo-outliner-op-gen-test
   (try
     (let [conn (db/get-db false)]
       (loop [num 100]
@@ -233,11 +235,11 @@
                 (recur (dec num)))
             (recur (dec num)))))
       (println "================ random inserts ================")
-      (print-page-stat @conn page-uuid "test")
+      (print-page-stat @conn page-uuid)
       (undo-all conn page-uuid)
-      (print-page-stat @conn page-uuid "test")
+      (print-page-stat @conn page-uuid)
       (redo-all conn page-uuid)
-      (print-page-stat @conn page-uuid "test")
+      (print-page-stat @conn page-uuid)
 
       (loop [num 1000]
         (when (> num 0)
@@ -247,11 +249,11 @@
                 (recur (dec num)))
             (recur (dec num)))))
       (println "================ random moves ================")
-      (print-page-stat @conn page-uuid "test")
+      (print-page-stat @conn page-uuid)
       (undo-all conn page-uuid)
-      (print-page-stat @conn page-uuid "test")
+      (print-page-stat @conn page-uuid)
       (redo-all conn page-uuid)
-      (print-page-stat @conn page-uuid "test")
+      (print-page-stat @conn page-uuid)
 
       (loop [num 100]
         (when (> num 0)
@@ -261,18 +263,18 @@
                 (recur (dec num)))
             (recur (dec num)))))
       (println "================ random deletes ================")
-      (print-page-stat @conn page-uuid "test")
+      (print-page-stat @conn page-uuid)
       (undo-all conn page-uuid)
-      (print-page-stat @conn page-uuid "test")
+      (print-page-stat @conn page-uuid)
       (try (redo-all conn page-uuid)
            (catch :default e
-             (print-page-blocks-tree @conn page-uuid "test")
+             (print-page-blocks-tree @conn page-uuid)
              (throw e)))
-      (print-page-stat @conn page-uuid "test"))
+      (print-page-stat @conn page-uuid))
     (catch :default e
       (let [data (ex-data e)]
         (fs-node/writeFileSync "debug.json" (sqlite-util/write-transit-str data))
-        (throw (ex-info "stop now" {}))))))
+        (throw e)))))