mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
fix: ci tests
This commit is contained in:
@@ -702,6 +702,18 @@
|
||||
tx-data')
|
||||
tx-data)))
|
||||
|
||||
(def ^:private non-retractable-block-attrs
|
||||
#{:block/created-at :block/updated-at :block/title})
|
||||
|
||||
(defn- drop-non-retractable-attr-datoms
|
||||
[tx-data]
|
||||
(remove (fn [item]
|
||||
(and (vector? item)
|
||||
(>= (count item) 3)
|
||||
(= :db/retract (first item))
|
||||
(contains? non-retractable-block-attrs (nth item 2))))
|
||||
tx-data))
|
||||
|
||||
(defn- sanitize-tx-data
|
||||
[db tx-data local-deleted-ids]
|
||||
(let [sanitized-tx-data (->> tx-data
|
||||
@@ -709,7 +721,7 @@
|
||||
(remove (fn [item]
|
||||
(or (= :db/retractEntity (first item))
|
||||
(and (= :db/retract (first item))
|
||||
(contains? #{:block/created-at :block/updated-at :block/title}
|
||||
(contains? non-retractable-block-attrs
|
||||
(nth item 2)))
|
||||
(contains? local-deleted-ids (get-lookup-id (last item))))))
|
||||
;; Notice: rebase should generate larger tx-id than reverse tx
|
||||
@@ -1240,6 +1252,7 @@
|
||||
(if-let [conn (worker-state/get-datascript-conn repo)]
|
||||
(let [tx-data (->> tx-data*
|
||||
(db-normalize/remove-retract-entity-ref @conn)
|
||||
drop-non-retractable-attr-datoms
|
||||
(#(drop-anonymous-temp-entity-datoms @conn %)))
|
||||
local-txs (pending-txs repo)
|
||||
reversed-tx-data (get-reverse-tx-data local-txs)
|
||||
|
||||
@@ -697,6 +697,26 @@
|
||||
(is (empty? (map :entity (:errors validation)))
|
||||
(str (:errors validation)))))))))
|
||||
|
||||
(deftest ^:long remote-retract-required-page-attr-is-ignored-test
|
||||
(testing "remote tx retracting required page attrs should be ignored"
|
||||
(let [{:keys [conn parent]} (setup-parent-child)
|
||||
page (:block/page parent)
|
||||
page-id (:db/id page)
|
||||
updated-at (:block/updated-at page)
|
||||
malformed-tx [[:db/retract page-id :block/updated-at updated-at]]]
|
||||
(with-datascript-conns conn nil
|
||||
(fn []
|
||||
(is (nil? (try
|
||||
(#'db-sync/apply-remote-tx! test-repo nil malformed-tx)
|
||||
nil
|
||||
(catch :default e
|
||||
e))))
|
||||
(let [page' (d/entity @conn page-id)
|
||||
validation (db-validate/validate-local-db! @conn)]
|
||||
(is (number? (:block/updated-at page')))
|
||||
(is (empty? (map :entity (:errors validation)))
|
||||
(str (:errors validation)))))))))
|
||||
|
||||
(deftest ^:long offload-large-title-test
|
||||
(testing "large titles are offloaded to object storage with placeholder"
|
||||
(async done
|
||||
|
||||
Reference in New Issue
Block a user