Skip to content

Commit

Permalink
fix: outliner core failed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tiensonqin committed Jun 15, 2022
1 parent c907a95 commit a88a3c0
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions src/test/frontend/modules/outliner/core_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,9 @@
(defn transact-random-tree!
[]
(let [tree (gen-safe-tree)]
(transact-tree! tree)))
(if (seq tree)
(transact-tree! tree)
(transact-random-tree!))))

(defn get-datoms
[]
Expand All @@ -425,13 +427,9 @@
(defn get-random-block
[]
(let [datoms (->> (get-datoms)
(remove (fn [datom] (= 1 (:e datom)))))]
(if (seq datoms)
(let [id (:e (gen/generate (gen/elements datoms)))]
(db/pull test-db '[*] id))
(do
(transact-random-tree!)
(get-random-block)))))
(remove (fn [datom] (= 1 (:e datom)))))
id (:e (gen/generate (gen/elements datoms)))]
(db/pull test-db '[*] id)))

(defn get-random-successive-blocks
[]
Expand All @@ -458,9 +456,6 @@
(set/union old (set (map :block/uuid blocks)))))
(insert-blocks! blocks (get-random-block)))
(let [total (get-blocks-count)]
;; (when (not= total (count @*random-blocks))
;; (defonce wrong-db (db/get-db test-db))
;; (defonce random-blocks @*random-blocks))
(is (= total (count @*random-blocks))))))))

(deftest ^:long random-deletes
Expand Down Expand Up @@ -518,16 +513,17 @@
*random-blocks (atom c1)]
(dotimes [_i 100]
;; (prn "Random move indent/outdent: " i)
(let [blocks (gen-blocks)]
(let [new-blocks (gen-blocks)]
(swap! *random-blocks (fn [old]
(set/union old (set (map :block/uuid blocks)))))
(insert-blocks! blocks (get-random-block)))
(let [blocks (get-random-successive-blocks)]
(when (seq blocks)
(outliner-tx/transact! {:graph test-db}
(outliner-core/indent-outdent-blocks! blocks (gen/generate gen/boolean)))
(let [total (get-blocks-count)]
(is (= total (count @*random-blocks))))))))))
(set/union old (set (map :block/uuid new-blocks)))))
(insert-blocks! new-blocks (get-random-block))
(let [blocks (get-random-successive-blocks)
indent? (gen/generate gen/boolean)]
(when (seq blocks)
(outliner-tx/transact! {:graph test-db}
(outliner-core/indent-outdent-blocks! blocks indent?))
(let [total (get-blocks-count)]
(is (= total (count @*random-blocks)))))))))))

(deftest ^:long random-mixed-ops
(testing "Random mixed operations"
Expand Down

0 comments on commit a88a3c0

Please sign in to comment.