Add better handling on lagged ops on page-update.

This commit is contained in:
Andrey Antukh 2019-12-15 21:53:57 +01:00
parent 1a33c266e3
commit 3eff27b5c5
3 changed files with 37 additions and 10 deletions

View file

@ -117,13 +117,42 @@
;; (th/print-result! out)
(t/is (nil? (:error out)))
(t/is (= 1 (count (:result out))))
(t/is (= (:id data) (get-in out [:result 0 :page-id])))
(t/is (= 1 (count (get-in out [:result 0 :operations]))))
(t/is (= :add-shape (get-in out [:result 0 :operations 0 0])))
(t/is (= sid (get-in out [:result 0 :operations 0 1])))
(t/is (= 0 (count (:result out))))
;; (t/is (= 1 (count (:result out))))
;; (t/is (= (:id data) (get-in out [:result 0 :page-id])))
;; (t/is (= 1 (count (get-in out [:result 0 :operations]))))
;; (t/is (= :add-shape (get-in out [:result 0 :operations 0 0])))
;; (t/is (= sid (get-in out [:result 0 :operations 0 1])))
))
(t/deftest mutation-update-project-page-3
(let [user @(th/create-user db/pool 1)
proj @(th/create-project db/pool (:id user) 1)
file @(th/create-project-file db/pool (:id user) (:id proj) 1)
page @(th/create-project-page db/pool (:id user) (:id file) 1)
sid (uuid/next)
data {::sm/type :update-project-page
:id (:id page)
:version 0
:user (:id user)
:operations [[:add-shape sid {:id sid :type :rect}]]}
out1 (th/try-on! (sm/handle data))
out2 (th/try-on! (sm/handle data))]
;; (th/print-result! out1)
;; (th/print-result! out2)
(t/is (nil? (:error out1)))
(t/is (nil? (:error out2)))
(t/is (= 0 (count (:result out1))))
(t/is (= 1 (count (:result out2))))
(t/is (= (:id data) (get-in out2 [:result 0 :page-id])))
(t/is (= 1 (count (get-in out2 [:result 0 :operations]))))
(t/is (= :add-shape (get-in out2 [:result 0 :operations 0 0])))
(t/is (= sid (get-in out2 [:result 0 :operations 0 1])))
))
(t/deftest mutation-delete-project-page
(let [user @(th/create-user db/pool 1)