mirror of
https://github.com/penpot/penpot.git
synced 2026-11-22 18:30:34 +00:00
After a reflection, copy descendants are settled through a sync proposal from their mains so their flip flags take the decomposition sync gives. The proposal reads the loaded main. A dependent library main nesting a copy whose child the upstream library flipped, not yet accepted there, was flipped; mirrored twice, the pending flip gave the child the same corners, so the footprint check accepted it and the child lost its reflection. Accept a proposal only where it keeps the shape's corners and transform, so it can change only how rotation and flips decompose that transform. A third re-run of the seed-20261101 library dependency property found this; it also fails on earlier commits. The program regression fails before the fix and passes after it. Full common passes lint, JVM, JavaScript and formatting: JVM 2079 tests / 33875 assertions; JavaScript 2015 / 32526. All six component properties pass 40 programs each at seed 712 in both runtimes. Compare lower-quantile milliseconds with the saved baseline; keep that baseline unchanged. The machine/JVM warning makes ratios rough. No world is flagged. World Baseline Now Ratio Main into 10 copies 1.790 1.007 0.56 Main into 100 copies 15.415 8.691 0.56 Main into 1000 copies 153.086 87.750 0.57 Three nesting levels 35.215 19.121 0.54 Dependency chain 68.931 36.243 0.53 Library update 83.083 46.041 0.55 Many plain shapes 4.837 2.219 0.46 Variant switch 32.052 20.574 0.64 AI-assisted-by: claude-opus-5-5
113 lines
5.6 KiB
Clojure
113 lines
5.6 KiB
Clojure
;; 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 common-tests.logic.source-gen-test
|
|
(:require
|
|
[app.common.test-helpers.composable.comp.files :as cf]
|
|
[app.common.test-helpers.composable.comp.runner :as r]
|
|
[app.common.test-helpers.composable.core :as tm]
|
|
[app.common.test-helpers.composable.gen :as cg]
|
|
[app.common.test-helpers.composable.oracle :as oracle]
|
|
[app.common.test-helpers.files :as thf]
|
|
[app.common.test-helpers.ids-map :as thi]
|
|
[app.common.test-helpers.shapes :as ths]
|
|
[app.common.test-helpers.texts :as thtx]
|
|
[clojure.test :as t]))
|
|
|
|
(t/use-fixtures :each thi/test-fixture)
|
|
|
|
(def source-world
|
|
[2 1 {:library true :stale-libraries true :library-text true :text true :text-styles true}])
|
|
|
|
(t/deftest a-transform-does-not-accept-pending-library-content-or-structure
|
|
(doseq [[edit index] [[[:library-text 0 1 1] 8]
|
|
[[:library-text 0 0 1] 8]
|
|
[[:library-edit 0 0 1] 4]
|
|
[[:library-add-child 0] 4]]]
|
|
(t/is (map? (cg/run {:world [2 0 {:library true :stale-libraries true :library-text true}]
|
|
:ops [edit [:transform index 3 3 4] [:undo] [:redo]
|
|
[:library-sync]]}))
|
|
(str edit))))
|
|
|
|
(t/deftest a-reflection-does-not-accept-a-pending-library-size
|
|
;; The dependent main nests a copy of a source main whose width is pending.
|
|
(t/is (map? (cg/run {:world [2 0 {:library true :stale-libraries true
|
|
:library-dependency true :library-text true}]
|
|
:ops [[:library-transform 3 1 4 0] [:library-transform 0 4 4 0]
|
|
[:library-undo] [:library-redo]]}))))
|
|
|
|
(t/deftest a-reflection-does-not-accept-a-pending-library-flip
|
|
;; The dependent main nests a copy whose child the source flipped; the
|
|
;; dependent library has not accepted that flip.
|
|
(t/is (map? (cg/run {:world [2 0 {:library true :stale-libraries true
|
|
:library-dependency true :library-text true}]
|
|
:ops [[:library-remove-child 0 0 0 0] [:library-transform 0 4 4 1]
|
|
[:library-transform 0 4 4 0] [:library-undo] [:library-redo]]}))))
|
|
|
|
(t/deftest source-transforms-keep-consumers-stale-until-acceptance
|
|
(doseq [action (range 6) scope [0 1]]
|
|
(let [initial (cg/initial-state source-world)
|
|
situation (:situation initial)
|
|
tuple [:library-transform 0 action 4 scope]
|
|
resolved (cg/resolve-op situation {} tuple)
|
|
owner (:library-id resolved)]
|
|
(t/is (some? (:op resolved)) (str "source transform " action ", scope " scope))
|
|
(when (:op resolved)
|
|
(let [edited (-> initial (cg/step tuple) cg/settle-state)
|
|
source (get (oracle/snapshot (:situation edited)) owner)]
|
|
(t/is (not= (get (oracle/snapshot situation) owner) source))
|
|
(t/is (= (dissoc (oracle/snapshot situation) owner)
|
|
(dissoc (oracle/snapshot (:situation edited)) owner)))
|
|
(t/is (zero? (r/undo-depth (:situation edited))))
|
|
(t/is (map? (cg/run {:world source-world
|
|
:ops [tuple [:library-sync] [:undo] [:redo]
|
|
[:library-undo] [:library-redo] [:library-sync]]}))))))))
|
|
|
|
(t/deftest source-text-edits-cover-letters-and-every-style-unit
|
|
(doseq [tuple (into [[:library-text 0 0 1]]
|
|
(map #(vector :library-text-style 0 % 1) (range 12)))]
|
|
(let [initial (cg/initial-state source-world)
|
|
situation (:situation initial)
|
|
resolved (cg/resolve-op situation {} tuple)
|
|
owner (:library-id resolved)]
|
|
(t/is (some? (:op resolved)) (str tuple))
|
|
(when (:op resolved)
|
|
(let [edited (-> initial (cg/step tuple) cg/settle-state)]
|
|
(t/is (not= (get (oracle/snapshot situation) owner)
|
|
(get (oracle/snapshot (:situation edited)) owner)))
|
|
(t/is (= (dissoc (oracle/snapshot situation) owner)
|
|
(dissoc (oracle/snapshot (:situation edited)) owner)))
|
|
(t/is (zero? (r/undo-depth (:situation edited))))
|
|
(t/is (map? (cg/run {:world source-world
|
|
:ops [tuple [:library-sync] [:undo] [:redo]
|
|
[:library-undo] [:library-redo] [:library-sync]]}))))))))
|
|
|
|
(t/deftest source-intent-checks-reject-a-dropped-primary-edit
|
|
(doseq [tuple [[:library-transform 0 1 4 0]
|
|
[:library-transform 0 3 1 1]
|
|
[:library-text 0 0 1]
|
|
[:library-text-style 0 2 1]]]
|
|
(let [initial (cg/initial-state source-world)]
|
|
(t/is (= :I9
|
|
(try
|
|
(with-redefs [r/step (fn [situation _] situation)]
|
|
(cg/step initial tuple))
|
|
nil
|
|
(catch #?(:clj Exception :cljs js/Error) error
|
|
(:invariant (ex-data error)))))
|
|
(str "dropped source intent " tuple)))))
|
|
|
|
(t/deftest source-text-fixture-does-not-reuse-consumer-shape-ids
|
|
(let [situation (cg/world source-world)
|
|
entries (cg/forest situation)
|
|
ids (map (comp :id :shape) entries)
|
|
source-texts (for [[_ library] (tm/aux-files situation)
|
|
entry (cg/tree (tm/with-file situation library))
|
|
:when (= :text (get-in entry [:shape :type]))]
|
|
entry)]
|
|
(t/is (= (count ids) (count (set ids))))
|
|
(t/is (seq source-texts))))
|