🐛 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:
Eva Marco 2026-09-30 10:40:18 +02:00 committed by Andrés Moya
parent ab0238a049
commit cdde35fe56
3 changed files with 50 additions and 1 deletions

View File

@ -39,7 +39,8 @@
:add-typography :mod-typography :del-typography
:set-tokens-lib :set-token :set-token-set :set-token-theme :set-tokens-status
:set-own-tokens-status :rename-token-set-group :move-token-set
:move-token-set-group :set-base-font-size :set-tokens-source})
:move-token-set-group :set-base-font-size :set-tokens-source
:validate-shapes})
(defn- index-change?
[{:keys [type]}]

View File

@ -222,6 +222,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.component-thumbnails-test]
[frontend-tests.worker.exports-test]
@ -467,6 +468,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)

View 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)])))))