|
|
@@ -284,6 +284,32 @@
|
|
|
(is (= #{[:block/uuid tag-uuid]}
|
|
|
(get-in inverse-outliner-ops [0 1 2 :template-blocks 0 :block/tags]))))))
|
|
|
|
|
|
+(deftest derive-history-outliner-ops-apply-template-captures-template-blocks-when-missing-in-op-test
|
|
|
+ (testing "apply-template forward op should capture concrete template-blocks even if original op omitted them"
|
|
|
+ (let [conn (db-test/create-conn-with-blocks
|
|
|
+ {:pages-and-blocks
|
|
|
+ [{:page {:block/title "page"}
|
|
|
+ :blocks [{:block/title "template"
|
|
|
+ :build/children [{:block/title "template child 1"}
|
|
|
+ {:block/title "template child 2"}]}
|
|
|
+ {:block/title "target"}]}]})
|
|
|
+ template (db-test/find-block-by-content @conn "template")
|
|
|
+ target (db-test/find-block-by-content @conn "target")
|
|
|
+ inserted-child-1-uuid (random-uuid)
|
|
|
+ inserted-child-2-uuid (random-uuid)
|
|
|
+ tx-data [{:e 900001 :a :block/uuid :v inserted-child-1-uuid :added true}
|
|
|
+ {:e 900002 :a :block/uuid :v inserted-child-2-uuid :added true}]
|
|
|
+ tx-meta {:outliner-op :apply-template
|
|
|
+ :outliner-ops [[:apply-template [(:db/id template)
|
|
|
+ (:db/id target)
|
|
|
+ {:sibling? true}]]]}
|
|
|
+ {:keys [forward-outliner-ops]}
|
|
|
+ (op-construct/derive-history-outliner-ops @conn @conn tx-data tx-meta)]
|
|
|
+ (is (= :apply-template (ffirst forward-outliner-ops)))
|
|
|
+ (is (= true (get-in forward-outliner-ops [0 1 2 :keep-uuid?])))
|
|
|
+ (is (= [inserted-child-1-uuid inserted-child-2-uuid]
|
|
|
+ (mapv :block/uuid (get-in forward-outliner-ops [0 1 2 :template-blocks])))))))
|
|
|
+
|
|
|
(deftest derive-history-outliner-ops-builds-delete-page-inverse-for-class-property-and-today-page-test
|
|
|
(testing "delete-page inverse restores hard-retracted class/property/today pages with stable db/ident"
|
|
|
(let [today (date-time-util/ms->journal-day (js/Date.))
|