mirror of
https://github.com/penpot/penpot.git
synced 2026-10-29 14:00:37 +00:00
🐛 Skip shape validation in the page index worker
The page index worker applies the same changes to its own copy of the pages, which has no file id and no components. :validate-shapes changes then always failed there, so the worker logged "error updating page index" and stopped updating the snap and selection indexes of that page after any validated change. Drop :validate-shapes changes before applying them in the worker. AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
6c0233d0dd
commit
6e0a9e89d0
@ -40,6 +40,9 @@
|
||||
(let [tpoint (ct/tpoint-ms)]
|
||||
(try
|
||||
(let [old-page (dm/get-in @state [:pages-index page-id])
|
||||
;; The index only holds pages, without the file id nor its
|
||||
;; components, so shape validation can't run here
|
||||
changes (remove #(= :validate-shapes (:type %)) changes)
|
||||
new-page (-> state
|
||||
(swap! ch/process-changes changes false)
|
||||
(dm/get-in [:pages-index page-id]))
|
||||
|
||||
@ -157,6 +157,7 @@
|
||||
[frontend-tests.util-zip-test]
|
||||
[frontend-tests.util.code-gen-markup-svg-wasm-test]
|
||||
[frontend-tests.util.dom.dnd-test]
|
||||
[frontend-tests.worker-index-test]
|
||||
[frontend-tests.worker-snap-test]
|
||||
[frontend-tests.worker.exports-test]
|
||||
[goog.object :as gobj]))
|
||||
@ -327,6 +328,7 @@
|
||||
'frontend-tests.util.code-gen-markup-svg-wasm-test
|
||||
'frontend-tests.util.dom.dnd-test
|
||||
'frontend-tests.util-zip-test
|
||||
'frontend-tests.worker-index-test
|
||||
'frontend-tests.worker-snap-test])
|
||||
|
||||
(assert (every? find-ns-obj test-namespaces)
|
||||
|
||||
46
frontend/test/frontend_tests/worker_index_test.cljs
Normal file
46
frontend/test/frontend_tests/worker_index_test.cljs
Normal file
@ -0,0 +1,46 @@
|
||||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS SUBSIDIARY SL
|
||||
|
||||
(ns frontend-tests.worker-index-test
|
||||
(:require
|
||||
[app.common.files.changes-builder :as pcb]
|
||||
[app.common.test-helpers.compositions :as ctho]
|
||||
[app.common.test-helpers.files :as cthf]
|
||||
[app.common.test-helpers.ids-map :as cthi]
|
||||
[app.common.test-helpers.shapes :as cths]
|
||||
[app.common.types.shape :as cts]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.worker.impl :as impl]
|
||||
[app.worker.index :as index]
|
||||
[cljs.test :as t :include-macros true]))
|
||||
|
||||
(t/use-fixtures :each
|
||||
{:before cthi/reset-idmap!})
|
||||
|
||||
(t/deftest update-index-with-validate-shapes-changes
|
||||
;; The index only holds pages, without the file id nor its components, so
|
||||
;; a :validate-shapes change must not stop it from applying the others
|
||||
(let [;; ==== Setup
|
||||
file (-> (cthf/sample-file :file1)
|
||||
(ctho/add-simple-component :c01 :m01 :r01))
|
||||
page (cthf/current-page file)
|
||||
main (cths/get-shape file :m01)
|
||||
rect (cts/setup-shape {:id (uuid/next) :type :rect :name "Rect"
|
||||
:x 0 :y 0 :width 10 :height 10})
|
||||
|
||||
changes (-> (pcb/empty-changes nil (:id page))
|
||||
(pcb/with-objects (:objects page))
|
||||
(pcb/add-object rect)
|
||||
(pcb/validate-shapes (:id page) [(:id main)] "test"))
|
||||
|
||||
;; ==== Action
|
||||
_ (impl/handler {:cmd :index/initialize :page page})
|
||||
_ (impl/handler {:cmd :index/update
|
||||
:page-id (:id page)
|
||||
:changes (:redo-changes changes)})]
|
||||
|
||||
;; ==== Check
|
||||
(t/is (some? (get-in @index/state [:pages-index (:id page) :objects (:id rect)])))))
|
||||
Loading…
x
Reference in New Issue
Block a user