diff --git a/backend/deps.edn b/backend/deps.edn index 422baadde..6ffc92cdd 100644 --- a/backend/deps.edn +++ b/backend/deps.edn @@ -70,6 +70,3 @@ :extra-deps {deps-ancient {:mvn/version "RELEASE"}}} }} - - - diff --git a/backend/src/uxbox/services/mutations/project_pages.clj b/backend/src/uxbox/services/mutations/project_pages.clj index 191f654ca..9208f3a6d 100644 --- a/backend/src/uxbox/services/mutations/project_pages.clj +++ b/backend/src/uxbox/services/mutations/project_pages.clj @@ -174,12 +174,13 @@ s.created_at, s.modified_at, s.user_id from project_page_snapshots as s where s.page_id = $1 - and s.version > $2") + and s.version > $2 + and s.id != $3") (defn- retrieve-lagged-operations [conn snapshot params] (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))))) ;; --- Mutation: Delete Page diff --git a/backend/test/uxbox/tests/test_services_project_pages.clj b/backend/test/uxbox/tests/test_services_project_pages.clj index 2c8036a7d..06bff02a7 100644 --- a/backend/test/uxbox/tests/test_services_project_pages.clj +++ b/backend/test/uxbox/tests/test_services_project_pages.clj @@ -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)