mirror of
https://github.com/penpot/penpot.git
synced 2025-06-01 16:11:40 +02:00
✨ Add better handling on lagged ops on page-update.
This commit is contained in:
parent
1a33c266e3
commit
3eff27b5c5
3 changed files with 37 additions and 10 deletions
|
@ -70,6 +70,3 @@
|
||||||
:extra-deps {deps-ancient {:mvn/version "RELEASE"}}}
|
:extra-deps {deps-ancient {:mvn/version "RELEASE"}}}
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -174,12 +174,13 @@
|
||||||
s.created_at, s.modified_at, s.user_id
|
s.created_at, s.modified_at, s.user_id
|
||||||
from project_page_snapshots as s
|
from project_page_snapshots as s
|
||||||
where s.page_id = $1
|
where s.page_id = $1
|
||||||
and s.version > $2")
|
and s.version > $2
|
||||||
|
and s.id != $3")
|
||||||
|
|
||||||
(defn- retrieve-lagged-operations
|
(defn- retrieve-lagged-operations
|
||||||
[conn snapshot params]
|
[conn snapshot params]
|
||||||
(let [sql sql:lagged-snapshots]
|
(let [sql sql:lagged-snapshots]
|
||||||
(-> (db/query conn [sql (:id params) (:version params)])
|
(-> (db/query conn [sql (:id params) (:version params) (:id snapshot)])
|
||||||
(p/then (partial mapv decode-row)))))
|
(p/then (partial mapv decode-row)))))
|
||||||
|
|
||||||
;; --- Mutation: Delete Page
|
;; --- Mutation: Delete Page
|
||||||
|
|
|
@ -117,13 +117,42 @@
|
||||||
|
|
||||||
;; (th/print-result! out)
|
;; (th/print-result! out)
|
||||||
(t/is (nil? (:error out)))
|
(t/is (nil? (:error out)))
|
||||||
(t/is (= 1 (count (:result out))))
|
(t/is (= 0 (count (:result out))))
|
||||||
(t/is (= (:id data) (get-in out [:result 0 :page-id])))
|
;; (t/is (= 1 (count (:result out))))
|
||||||
(t/is (= 1 (count (get-in out [:result 0 :operations]))))
|
;; (t/is (= (:id data) (get-in out [:result 0 :page-id])))
|
||||||
(t/is (= :add-shape (get-in out [:result 0 :operations 0 0])))
|
;; (t/is (= 1 (count (get-in out [:result 0 :operations]))))
|
||||||
(t/is (= sid (get-in out [:result 0 :operations 0 1])))
|
;; (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
|
(t/deftest mutation-delete-project-page
|
||||||
(let [user @(th/create-user db/pool 1)
|
(let [user @(th/create-user db/pool 1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue