From 8d7e275b6bae14d8e8899da81efd7f6514bb1e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Torr=C3=B3?= Date: Wed, 4 Nov 2026 13:01:05 +0100 Subject: [PATCH] :bug: Count id and type in the wasm shape proxy (#12793) The proxy counted one entry fewer than it yields, so it was never equal to a plain map with the same entries. Count both fields and test it. --- frontend/src/app/render_wasm/shape.cljs | 2 +- .../render_wasm/shape_proxy_test.cljs | 24 +++++++++++++++++++ frontend/test/frontend_tests/runner.cljs | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 frontend/test/frontend_tests/render_wasm/shape_proxy_test.cljs diff --git a/frontend/src/app/render_wasm/shape.cljs b/frontend/src/app/render_wasm/shape.cljs index 1d2980d6c9..dfbcf37bb4 100644 --- a/frontend/src/app/render_wasm/shape.cljs +++ b/frontend/src/app/render_wasm/shape.cljs @@ -77,7 +77,7 @@ c/ICounted (-count [_] - (+ 1 (count delegate))) + (+ 2 (count delegate))) c/IKVReduce (-kv-reduce [_ f init] diff --git a/frontend/test/frontend_tests/render_wasm/shape_proxy_test.cljs b/frontend/test/frontend_tests/render_wasm/shape_proxy_test.cljs new file mode 100644 index 0000000000..276be80d53 --- /dev/null +++ b/frontend/test/frontend_tests/render_wasm/shape_proxy_test.cljs @@ -0,0 +1,24 @@ +;; 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.render-wasm.shape-proxy-test + (:require + [app.common.uuid :as uuid] + [app.render-wasm.shape :as wasm.shape] + [cljs.test :as t :include-macros true])) + +(def ^:private attrs + {:id (uuid/next) :type :rect :name "Rect" :x 10 :y 20}) + +(t/deftest count-includes-id-and-type + (let [shape (wasm.shape/create-shape attrs)] + (t/is (= (count attrs) (count shape))) + (t/is (= (count shape) (count (seq shape)))))) + +(t/deftest equals-plain-map-with-same-entries + (let [shape (wasm.shape/create-shape attrs)] + (t/is (= shape attrs)) + (t/is (= attrs shape)))) diff --git a/frontend/test/frontend_tests/runner.cljs b/frontend/test/frontend_tests/runner.cljs index 70b1ef0a47..c0fee67ec6 100644 --- a/frontend/test/frontend_tests/runner.cljs +++ b/frontend/test/frontend_tests/runner.cljs @@ -94,6 +94,7 @@ [frontend-tests.render-dimensions-test] [frontend-tests.render-wasm.process-objects-test] [frontend-tests.render-wasm.serialization-test] + [frontend-tests.render-wasm.shape-proxy-test] [frontend-tests.render-wasm.text-editor-apply-styles-test] [frontend-tests.render-wasm.text-editor-caret-color-test] [frontend-tests.render-wasm.text-editor-content-range-test] @@ -273,6 +274,7 @@ 'frontend-tests.plugins.value-objects-test 'frontend-tests.render-wasm.process-objects-test 'frontend-tests.render-wasm.serialization-test + 'frontend-tests.render-wasm.shape-proxy-test 'frontend-tests.render-wasm.text-editor-apply-styles-test 'frontend-tests.render-wasm.text-editor-caret-color-test 'frontend-tests.render-wasm.text-editor-content-range-test