|
|
@@ -335,3 +335,28 @@
|
|
|
|
|
|
(state/set-current-repo! nil)
|
|
|
(test-helper/destroy-test-db!))
|
|
|
+
|
|
|
+
|
|
|
+(deftest apply-remote-update-page-ops-test
|
|
|
+ (state/set-current-repo! test-helper/test-db)
|
|
|
+ (test-helper/reset-test-db!)
|
|
|
+ (let [conn (conn/get-db test-helper/test-db false)
|
|
|
+ repo test-helper/test-db
|
|
|
+ date-formatter (common-config/get-date-formatter (worker-state/get-config test-helper/test-db))
|
|
|
+ [page1-uuid] (repeatedly random-uuid)]
|
|
|
+ (testing "apply-remote-update-page-ops-test1"
|
|
|
+ (let [data-from-ws {:req-id "req-id" :t 1 :t-before 0
|
|
|
+ :affected-blocks
|
|
|
+ {page1-uuid {:op :update-page
|
|
|
+ :self page1-uuid
|
|
|
+ :page-name (str page1-uuid)
|
|
|
+ :original-name (str page1-uuid)}}}
|
|
|
+ update-page-ops (vals
|
|
|
+ (:update-page-ops-map
|
|
|
+ (#'rtc-core/affected-blocks->diff-type-ops repo (:affected-blocks data-from-ws))))]
|
|
|
+ (is (rtc-const/data-from-ws-validator data-from-ws))
|
|
|
+ (rtc-core/apply-remote-update-page-ops repo conn date-formatter update-page-ops)
|
|
|
+ (is (= page1-uuid (:block/uuid (d/entity @conn [:block/uuid page1-uuid])))))))
|
|
|
+
|
|
|
+ (state/set-current-repo! nil)
|
|
|
+ (test-helper/destroy-test-db!))
|