🚧 Save component stabilization follow-up

Expand generated component coverage with independent library histories,
meaningful mutation counts, varied geometry and variants, all text style
units, oracle corruption controls and pending-sync frontend replays.

Fix reflected descendants, partial size carry, WASM shape defaults,
deferred swap and sidebar text undo, grid visibility, explicit typography
ownership, metadata filtering and swapped placement through sync/detach.

Recorded validation after F219:
- Common JVM: 1,909 tests / 31,088 assertions; JS: 1,840 / 29,688.
- Frontend: 1,560 tests / 10,821 assertions.
- Backend: 1,610 tests / 8,104 assertions; exporter: 14 / 32.
- Applicable lint and formatting pass; golden data stays unchanged.

Benchmark ratios against the unchanged Phase 1e baseline:
- Main edits into 10/100/1,000 copies: 0.52/0.57/0.58.
- Three levels: 0.51; dependency chain: 0.52; library update: 0.58.
- Many shapes: 0.42; variant switch: 0.62. No regression flags.

This is a checkpoint. The fresh legacy-library gate at seed 712 fails
at program 351 (F221); its cause remains unclassified. The other four
large gates did not run. F220, F187, F214 and wider coverage remain open.

AI-assisted-by: gpt-6
This commit is contained in:
alonso.torres 2026-10-27 09:29:52 +01:00
parent 2b50fda318
commit 48a627e042
17 changed files with 1384 additions and 113 deletions

View File

@ -480,8 +480,8 @@
;; the copy leaves every copy level
(ctk/swapped? shape)
(if-let [root-id (cll/swap-content-root-id libraries shape)]
(update objects (:id shape) cli/rehead-swapped root-id)
(if-let [main (ctf/find-content-ref-shape file container libraries shape :include-deleted? true)]
(update objects (:id shape) cli/rehead-swapped main)
(detach-copy objects shape))
:else

View File

@ -122,7 +122,16 @@
(let [shape (ctn/get-shape container shape-id)]
(cll/shape-log :debug shape-id container
:msg "Detach instance" :shape-id shape-id :container (:id container))
(generate-detach-recursive changes container libraries shape-id true (true? (:component-root shape)))))
(let [changes (generate-detach-recursive changes container libraries shape-id true (true? (:component-root shape)))
objects (pcb/get-objects changes)
advanced (into []
(filter (fn [id]
(let [before (get-in container [:objects id])
after (get objects id)]
(and (ctk/swapped? after)
(not= (:shape-ref before) (:shape-ref after))))))
(cfh/get-children-ids (:objects container) shape-id))]
(cll/generate-sync-advanced-placement changes container libraries advanced))))
(defn- generate-detach-recursive
[changes container libraries shape-id first component-root?]
@ -154,16 +163,32 @@
(defn rehead-swapped
"Make a swapped head a plain copy of its own component, for when it leaves
every copy level."
[shape root-id]
(-> shape
(assoc :shape-ref root-id)
(ctk/remove-swap-group)))
every copy level. Keep placement inherited from the old position as
overrides when it differs from the new main."
[shape main]
(let [placement-groups (disj cll/placement-groups :geometry-group)
value (fn [source attr]
(case attr
:constraints-h (or (:constraints-h source) (gsh/default-constraints-h shape))
:constraints-v (or (:constraints-v source) (gsh/default-constraints-v shape))
:fixed-scroll (boolean (:fixed-scroll source))
(get source attr)))
groups (into #{}
(keep (fn [attr]
(let [group (ctk/resolve-sync-group (:type shape) attr)]
(when (and (contains? placement-groups group)
(not= (value shape attr) (value main attr)))
group))))
(keys ctk/sync-attrs))]
(cond-> (-> shape
(assoc :shape-ref (:id main))
(ctk/remove-swap-group))
(seq groups) (update :touched (fnil into #{}) groups))))
(defn- generate-rehead-swapped
[changes container libraries shape]
(if-let [root-id (cll/swap-content-root-id libraries shape)]
(pcb/update-shapes changes [(:id shape)] #(rehead-swapped % root-id))
(if-let [main (ctf/find-content-ref-shape nil container libraries shape :include-deleted? true)]
(pcb/update-shapes changes [(:id shape)] #(rehead-swapped % main))
(generate-detach-immediate changes container (:id shape) (atom #{}))))
(defn swapped-descendant-ids

View File

@ -415,9 +415,10 @@
changes)))
(defn generate-sync-transformed-placement
"Settle untouched swapped heads carried through a parent turn in the
same change group. Their position frame can have a different size from
their content, so a rigid turn alone does not settle their placement."
"Settle copy descendants after a reflection and untouched swapped heads
after a parent turn, in the transform's change group. Reflection can
leave descendant flip flags in another decomposition; swapped content
can have a different size from its position frame."
[changes file libraries page before ids]
(let [objects (pcb/get-objects changes)
orientation (fn [shape]
@ -425,11 +426,18 @@
(:rotation shape) (boolean (:flip-x shape)) (boolean (:flip-y shape))])
roots (into (d/ordered-set)
(keep (fn [id]
(let [shape (get objects id)]
(when (and (ctk/swapped? shape)
(not (ctk/touched-group? shape :geometry-group))
(not= (orientation (get before id)) (orientation shape)))
(:id (ctn/get-component-shape objects shape))))))
(let [shape (get objects id)
root (when (:component-id shape) (ctn/get-component-shape objects shape))
old (get before id)
reflected-head? (and (:component-id shape)
(:shape-ref shape)
(or (not= (boolean (:flip-x old)) (boolean (:flip-x shape)))
(not= (boolean (:flip-y old)) (boolean (:flip-y shape)))))]
(when (or reflected-head?
(and (ctk/swapped? shape)
(not (ctk/touched-group? shape :geometry-group))
(not= (orientation old) (orientation shape))))
(:id root)))))
ids)]
(reduce (fn [changes id]
(let [objects (pcb/get-objects changes)
@ -1425,12 +1433,20 @@
;; the dest root before syncing.
;; In case of subinstances, the comparison is always done with the
;; near component, because this is that we are syncing with.
origin-shape (reposition-shape origin-shape origin-root dest-root)
touched (get dest-shape :touched #{})
origin-shape (reposition-shape origin-shape origin-root dest-root)
touched (get dest-shape :touched #{})
;; Direct sync of a swapped head reads its content main. Its
;; placement comes from the replaced child in the enclosing main.
content-only? (and omit-touched?
(ctk/swapped? dest-shape)
(= (:id dest-shape) (:id dest-root)))
valid-attrs (when content-only?
(set/difference (set (keys ctk/sync-attrs)) placement-attrs))
[roperations uoperations]
(attr-operations dest-shape
#(sync-attr-operations dest-shape origin-shape touched omit-touched? %))]
#(when-not (and content-only? (contains? placement-attrs %))
(sync-attr-operations dest-shape origin-shape touched omit-touched? %)))]
(cond-> changes
(seq roperations)
@ -1440,7 +1456,7 @@
:always
(check-swapped-main dest-shape origin-shape)
:always
(generate-update-tokens container dest-shape origin-shape touched omit-touched? nil))))
(generate-update-tokens container dest-shape origin-shape touched omit-touched? valid-attrs))))
(defn- propagate-attrs
"Helper that puts the origin attributes (attrs) into dest but only if
@ -1509,6 +1525,28 @@
move? (gsh/move delta))
{:ignore-touched true}))))
(defn generate-sync-advanced-placement
"Settle the placement of swapped heads whose position reference advanced.
Read only the position frame; content may still use an older library."
[changes container libraries ids]
(reduce
(fn [changes id]
(let [objects (pcb/get-objects changes)
container (assoc container :objects objects)
shape (get objects id)
parent (get objects (:parent-id shape))
main (ctf/find-ref-shape nil container libraries shape
:include-deleted? true :with-context? true)
main-objects (:objects (:container (meta main)))
main-parent (get main-objects (:parent-id main))]
(if (and parent main-parent)
(let [placed (get (placed-like main-objects main-parent parent) (:id main))]
(generate-take-placement changes shape placed objects
(and (ctsl/any-layout-immediate-child? objects shape)
(not (ctsl/position-absolute? shape)))))
changes)))
changes ids))
(defn- update-swapped-placement
"Synchronizes a swapped copy head with the main shape it replaces, in the
attributes that place it in its parent."

View File

@ -86,9 +86,23 @@
(reduce check-shape changes mod-obj-changes)))
(defn touch-text-typography
"Applying a typography authors every unit it sets, even equal values.
Merely editing text content keeps the ordinary changed-unit rule."
[shape]
(if (and (= :text (:type shape)) (ctk/in-component-copy? shape))
(-> shape
(update :touched (fnil into #{})
#{:content-group :text-content-typography :text-content-family
:text-content-weight :text-content-size :text-content-line-height
:text-content-spacing :text-content-case})
(dissoc :remote-synced))
shape))
(defn generate-update-shapes
[changes ids update-fn objects {:keys [attrs changed-sub-attr changed-item-index ignore-tree ignore-touched with-objects? translation? skip-grid-reassignment?]}]
(let [changes (reduce
(let [before (or objects (pcb/lookup-objects changes))
changes (reduce
(fn [changes id]
;; a shape the transform leaves untouched changes only
;; as a consequence of it: no attribute touches
@ -104,11 +118,28 @@
;; explicitly.
grid-ids (when-not (or translation? skip-grid-reassignment?)
(->> ids (filter (partial ctl/grid-layout? objects))))
hidden-grid-ids
(when-not (or translation? skip-grid-reassignment?)
(let [after (pcb/get-objects changes)]
(into (d/ordered-set)
(keep (fn [id]
(let [old (get before id)
new (get after id)
parent-id (:parent-id new)]
(when (and (not= (boolean (:hidden old)) (boolean (:hidden new)))
(ctl/grid-layout? after parent-id))
parent-id))))
ids)))
changes (cond-> changes
(seq grid-ids)
(-> (pcb/update-shapes grid-ids ctl/assign-cell-positions {:with-objects? true})
(pcb/reorder-grid-children ids))
(seq hidden-grid-ids)
(-> (pcb/update-shapes hidden-grid-ids ctl/assign-cells
{:with-objects? true :ignore-touched true})
(pcb/reorder-grid-children hidden-grid-ids))
(not (true? ignore-touched))
(generate-unapply-tokens objects changed-sub-attr changed-item-index))]
changes))

View File

@ -89,7 +89,7 @@
(grc/rect->center selrect)
(or (:transform shape) (gmt/matrix)))))))
(defn- switch-fixed-layout-geom-change-value
(defn- switch-size-change-value
[prev-shape ; The shape before the switch
current-shape ; The shape after the switch (a clean copy)
origin-shape ; The original shape
@ -97,9 +97,9 @@
;; Each dimension keeps the copy's size when both variants agree on it,
;; and takes the new variant's otherwise (selrect and points follow)
(let [size (fn [dimension]
(let [prev (-> prev-shape :selrect dimension)
current (-> current-shape :selrect dimension)
origin (-> origin-shape :selrect dimension)]
(let [prev (get prev-shape dimension)
current (get current-shape dimension)
origin (get origin-shape dimension)]
(if (mth/close? origin current) prev current)))
width (size :width)
height (size :height)]
@ -109,17 +109,6 @@
(sized-geometry-value current-shape width height attr))))
(defn- switch-geom-change-value
[prev-shape current-shape attr]
;; Composite geometry stores absolute coordinates. When preserving a size
;; override across variants, keep the target variant's position and only carry
;; the previous dimensions; otherwise :x/:y can disagree with :selrect/:points.
(sized-geometry-value current-shape
(-> prev-shape :selrect :width)
(-> prev-shape :selrect :height)
attr))
(defn- equal-geometry?
"Returns true when the value of `attr` in `shape` is considered equal
to the corresponding value in `origin-shape`, ignoring positional
@ -239,21 +228,7 @@
skip?
(or skip-attr?
;; If we are going to reset the position data, skip the selrect attr
(and reset-pos-data? (= attr :selrect))
;; Avoid copying composite geometry attrs (:selrect/:points) when the
;; variant dimensions differ but neither sizing is :fix. Without this,
;; :width/:height are correctly skipped by the check above
;; but :selrect/:points would still carry the old override dimensions,
;; leaving the shape in an inconsistent state. When :fix sizing is
;; present, switch-fixed-layout-geom-change-value handles the composite
;; attrs and must NOT be bypassed. Path shapes are also handled
;; separately via switch-path-change-value.
(and (contains? #{:selrect :points} attr)
(not path-change?)
(not (or (= :fix (:layout-item-h-sizing previous-shape))
(= :fix (:layout-item-v-sizing previous-shape))))
(or (not (mth/close? (:width origin-ref-shape) (:width current-shape)))
(not (mth/close? (:height origin-ref-shape) (:height current-shape))))))
(and reset-pos-data? (= attr :selrect)))
attr-val
(when-not skip?
@ -278,14 +253,10 @@
origin-ref-shape
attr)
(and (or (= :fix (:layout-item-h-sizing previous-shape))
(= :fix (:layout-item-v-sizing previous-shape)))
(contains? #{:points :selrect :width :height} attr))
(switch-fixed-layout-geom-change-value previous-shape current-shape origin-ref-shape attr)
(and (contains? #{:points :selrect} attr)
(not path-change?))
(switch-geom-change-value previous-shape current-shape attr)
;; Both scalar dimensions and composite geometry must describe
;; the same result when only one dimension carries an override.
(contains? #{:points :selrect :width :height} attr)
(switch-size-change-value previous-shape current-shape origin-ref-shape attr)
:else
(get previous-shape attr)))]

View File

@ -1,6 +1,12 @@
(ns common-tests.logic.composable-gen-test
(:require
[app.common.files.changes-builder :as pcb]
[app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh]
[app.common.logic.shapes :as cls]
[app.common.logic.variants :as clv]
[app.common.schema.test :as smt]
[app.common.test-helpers.composable.comp.files :as cf]
[app.common.test-helpers.composable.comp.nodes :as n]
[app.common.test-helpers.composable.comp.runner :as r]
[app.common.test-helpers.composable.comp.setups :as setup]
@ -8,12 +14,515 @@
[app.common.test-helpers.composable.gen :as cg]
[app.common.test-helpers.composable.oracle :as oracle]
[app.common.test-helpers.composable.shadow :as shadow]
[app.common.test-helpers.composable.variants :as variants]
[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)
(t/deftest nesting-a-swapped-copy-in-a-blocked-main-authors-its-lock
(t/is (map? (cg/run {:world [2 0 {:library true :variants true :rich-variants true
:text true :text-styles true :layout nil :layout-copies true}]
:ops [[:style 3 2 1] [:swap 0 0 0 0] [:nest 0 0 0 0]
[:undo] [:redo]]}))))
(t/deftest nesting-lock-expectations-reject-a-missing-lock-or-override
(let [state (reduce cg/step
(cg/initial-state [2 0 {:library true :variants true :rich-variants true
:text true :text-styles true :layout nil :layout-copies true}])
[[:style 3 2 1] [:swap 0 0 0 0]])
id (get-in (cg/resolve-op (:situation state) (:model state) [:nest 0]) [:shape :id])
nested (-> state (cg/step [:nest 0]) cg/settle-state)
situation (:situation nested)
model (:model nested)
file (tm/file situation)
path [:data :pages-index (:id (thf/current-page file)) :objects id]
invariant (fn [file]
(try (oracle/check (tm/with-file situation file) model) nil
(catch #?(:clj Exception :cljs js/Error) error
(:invariant (ex-data error)))))]
(t/is (= {:blocked true} (get-in model [id :modifiable-group])))
(t/is (= :I9 (invariant (assoc-in file (conj path :blocked) false))))
(t/is (= :I3 (invariant (update-in file (conj path :touched) disj :modifiable-group))))))
(t/deftest generated-swap-can-target-a-loaded-library-component
(t/is (map? (cg/run {:world [2 0 {:library true :stale-libraries true
:library-variants true :variants true}]
:ops [[:delete 0] [:swap 3]]}))))
(t/deftest scalar-style-edits-author-their-own-group-and-propagate-from-mains
(doseq [property (range 14)]
(let [result (cg/run {:world [2 1 {:layout :flex}]
:ops [[:style 0 property 1 1] [:style 1 property 1 0]
[:sync] [:undo] [:redo]]})]
(t/is (pos? (get-in result [:coverage :random :style :changed] 0))
(str "style property " property)))))
(t/deftest frame-only-styles-target-frames-in-each-edit-scope
(let [situation (cg/world [2 1 {:library true :text true}])]
(doseq [property [5 6] scope [0 1 2]]
(let [resolved (cg/resolve-op situation {} [:style 1 property 1 scope])]
(t/is (= :frame (get-in resolved [:shape :type]))
(str "property " property ", scope " scope))))))
(t/deftest text-style-edits-cover-every-style-unit
(doseq [[unit group] (map-indexed vector
[:text-content-family :text-content-weight :text-content-size
:text-content-line-height :text-content-spacing :text-content-decoration
:text-content-case :text-content-fills :text-content-typography
:text-content-align :text-content-direction :text-content-valign])]
(let [result (cg/run {:world [2 1 {:text true :text-styles true}]
:ops [[:text-style 1 unit 1] [:sync] [:undo] [:redo]]})
id (thi/id :copy-child)]
(t/is (= 1 (get-in result [:coverage :random :text-style :changed])) (str group))
(t/is (contains? (get (:model result) id) group) (str group)))))
(t/deftest text-style-intent-rejects-a-dropped-main-commit
(doseq [unit (range 12)]
(let [initial (cg/initial-state [2 1 {:text true :text-styles true}])]
(t/is (= {:invariant :I9 :phase :requested-text}
(try (with-redefs [r/step (fn [situation _] situation)]
(cg/step initial [:text-style 0 unit 1]))
nil
(catch #?(:clj Exception :cljs js/Error) error
(select-keys (ex-data error) [:invariant :phase]))))
(str "text unit " unit)))))
(t/deftest library-dependencies-wait-for-each-consumers-acceptance
(let [initial (cg/initial-state [2 0 {:library true :stale-libraries true :library-dependency true}])
situation (:situation initial)
files (tm/aux-files situation)
source-id (some (fn [[id file]] (when (= "random-library" (:name file)) id)) files)
dependent-id (some (fn [[id file]] (when (= "dependent-library" (:name file)) id)) files)
source-shape (some #(when (and (= :rect (get-in % [:shape :type]))
(nil? (get-in % [:shape :shape-ref]))) (:shape %))
(cg/tree (tm/with-file situation (get files source-id))))
source-index (some #(when (= (:id source-shape)
(:id (:shape (cg/resolve-op situation {} [:library-edit % 0 1])))) %) (range 20))
dependent-child (some #(when (= (:id source-shape) (get-in % [:shape :shape-ref])) (:shape %))
(cg/tree (tm/with-file situation (get files dependent-id))))
copy-id (some #(when (= (:id dependent-child) (get-in % [:shape :shape-ref]))
(get-in % [:shape :id])) (cg/tree situation))
edited (-> initial (cg/step [:library-edit source-index 0 1]) cg/settle-state)
dependent-accepted (-> edited (cg/step [:library-accept 0]) cg/settle-state)
accepted (-> dependent-accepted (cg/step [:library-sync 0]) cg/settle-state)
fill #(get-in (tm/shape-by-id (:situation %) copy-id) [:fills 0 :fill-color])]
(t/is (some? dependent-child))
(t/is (some? copy-id))
(t/is (= setup/labeled-fill (fill edited)))
(t/is (= setup/labeled-fill (fill dependent-accepted)))
(t/is (= "#ff0000" (fill accepted)))
(t/is (map? (cg/run {:world [2 0 {:library true :stale-libraries true :library-dependency true}]
:ops [[:library-edit source-index 0 1] [:library-accept 0] [:library-sync 0]
[:library-undo 0] [:library-redo 0] [:undo] [:redo]]})))))
(t/deftest a-local-cascade-keeps-an-unaccepted-swaps-library-inputs
(let [program {:world [2 1 {:library true :stale-libraries true :library-dependency true}]
:ops [[:swap 1] [:swap 18] [:library-add-child 16] [:edit 0 1 1 :copy-head]]}
result (cg/run program)
situation (:situation result)
head-at #(some (fn [{:keys [path shape]}] (when (= [2 0] path) shape)) (cg/tree %))
head (head-at situation)
owner (:component-file head)
main-id (get-in (cf/all-files situation) [owner :data :components (:component-id head) :main-instance-id])
main #(tm/shape-by-id (tm/with-file situation (get % owner)) main-id)
advanced (cf/remember-subtree situation (:id (tm/file situation)) (:id head) (cf/all-files situation))]
(t/is (= 1 (count (:shapes head))))
(t/is (= 1 (count (:shapes (main (cf/reference-libraries situation head))))))
(t/is (= 2 (count (:shapes (main (cf/all-files situation))))))
(t/is (= :I4 (try (oracle/check advanced (:model result)) nil
(catch #?(:clj Exception :cljs js/Error) error (:invariant (ex-data error))))))
(let [accepted (cg/run (update program :ops conj [:library-sync 1]))]
(t/is (= 2 (count (:shapes (head-at (:situation accepted)))))))))
(t/deftest geometry-edits-cover-mains-copy-children-and-nested-copies
(doseq [action (range 6) scope (range 5)]
(let [result (cg/run {:world [2 2]
:ops [[:transform 0 action 3 scope] [:sync] [:undo] [:redo]]})]
(t/is (= 1 (get-in result [:coverage :random :transform :changed] 0))
(str "geometry action " action ", scope " scope)))))
(t/deftest hiding-a-grid-main-child-then-moving-its-main-stays-synced
(t/is (map? (cg/run {:world [2 1 {:text true :text-styles true :layout :grid}]
:ops [[:style 3 1 3 0] [:transform 0 0 0 0]]}))))
(t/deftest showing-a-hidden-grid-main-child-assigns-it-a-cell-again
(let [result (cg/run {:world [2 1 {:text true :text-styles true :layout :grid}]
:ops [[:style 3 1 1 0] [:style 3 1 0 0]]})
situation (:situation result)
shape (:shape (cg/resolve-op situation (:model result) [:style 3 1 0 0]))
parent (tm/shape-by-id situation (:parent-id shape))]
(t/is (false? (:hidden shape)))
(t/is (some #(some #{(:id shape)} (:shapes %)) (vals (:layout-grid-cells parent))))))
(t/deftest hiding-a-grid-copy-child-keeps-derived-cells-consistent
(t/is (map? (cg/run {:world [2 1 {:text true :text-styles true :layout :grid}]
:ops [[:style 6 1 3 0] [:transform 0 0 0 0]
[:undo] [:redo]]}))))
(t/deftest applying-a-typography-after-a-swap-is-already-fully-synced
(t/is (map? (cg/run {:world [2 0 {:library true :variants true :rich-variants true
:text true :text-styles true :layout nil :layout-copies true}]
:ops [[:swap 2] [:text-style 4 8 1] [:add-child 0] [:undo] [:undo] [:undo] [:redo] [:redo] [:redo]]}))))
(t/deftest detaching-after-a-nested-switch-keeps-placement-stable-through-sync
(t/is (map? (cg/run {:world [2 2 {:library true :variants true :rich-variants true
:text true :text-styles true :layout :flex :layout-copies true}]
:ops [[:nest 7 0 0 0] [:switch 3 0 0 0] [:style 3 7 1] [:detach 6 0 0 0]
[:undo] [:undo] [:undo] [:undo] [:redo] [:redo] [:redo] [:redo]]}))))
(t/deftest applying-typography-to-a-main-drops-a-mixed-copys-link-without-an-override
(t/is (map? (cg/run {:world [2 0 {:library true :variants true :rich-variants true
:text true :text-styles true :layout nil :layout-copies true}]
:ops [[:swap 0 0 0 0] [:text 23 3 1 0] [:text-style 22 8 1]
[:undo] [:undo] [:undo] [:redo] [:redo] [:redo]]}))))
(t/deftest typography-reference-oracle-rejects-wrong-retention-and-missing-inheritance
(doseq [mixed? [true false]]
(let [state (cond-> (cg/initial-state [2 0 {:text true :text-styles true}])
mixed? (cg/step [:text 1 1 1]))
state (-> state (cg/step [:text-style 0 8 1]) (update :situation r/settle))
situation (:situation state)
file (tm/file situation)
page (thf/current-page file)
copy (ths/get-shape file :copy-child)
content (-> (thtx/view (:content copy))
(thtx/restyle :typography (when mixed? :generated-typography))
thtx/content)
corrupted (tm/with-file situation
(assoc-in file [:data :pages-index (:id page) :objects (:id copy) :content] content))]
(t/is (nil? (oracle/check situation (:model state))))
(t/is (= :I4 (try (oracle/check corrupted (:model state)) nil
(catch #?(:clj Exception :cljs js/Error) error (:invariant (ex-data error)))))
(if mixed? "mixed styles must lose the reference" "fully inherited styles must keep the reference")))))
(t/deftest detaching-a-rotated-switched-copy-keeps-nested-placement-stable
(doseq [angle (range 4)]
(t/is (map? (cg/run {:world [2 0 {:library true :variants true :rich-variants true
:text true :text-styles true :layout nil :layout-copies true}]
:ops [[:duplicate 1 0 0 0] [:duplicate 1 0 0 0] [:switch 3 0 0 0]
[:rotate 5 0 0 angle] [:detach 5 0 0 0]
[:undo] [:undo] [:undo] [:undo] [:undo]
[:redo] [:redo] [:redo] [:redo] [:redo]]})))))
(t/deftest detaching-settles-new-placement-without-pulling-stale-content
(let [state (-> (reduce cg/step
(cg/initial-state [2 0 {:library true :variants true :rich-variants true
:text true :text-styles true :layout nil :layout-copies true}])
[[:duplicate 1 0 0 0] [:duplicate 1 0 0 0] [:switch 3 0 0 0] [:rotate 5]])
cg/settle-state)
situation (:situation state)
copy (:shape (first (filter #(= [:file 0 :page 0 5 0] (:path %)) (cg/forest situation))))
near (tm/shape-by-id situation (:shape-ref copy))
source-id (:shape-ref near)
stale (tm/with-file situation (ths/update-shape-by-id (tm/file situation) source-id :opacity 0.25))
detached (r/step stale (:op (cg/resolve-op stale (:model state) [:detach 5])))
head (tm/shape-by-id detached (:id copy))
swapped (tm/shape-by-id detached (first (:shapes head)))]
(t/is (= 0.25 (:opacity (tm/shape-by-id detached source-id))))
(t/is (= (:opacity copy) (:opacity head)) "detach must not accept the main's new content")
(t/is (= #{:swap-group} (:touched swapped)) "the placement correction stays inherited")))
(t/deftest applying-an-inherited-typography-authors-even-equal-units
(let [state (-> (cg/initial-state [2 0 {:text true :text-styles true}])
(cg/step [:text-style 0 8 1]) cg/settle-state)
before (tm/shape-by-id (:situation state) (thi/id :copy-child))
result (-> state (cg/step [:text-style 1 8 1]) cg/settle-state)
after (tm/shape-by-id (:situation result) (thi/id :copy-child))
groups #{:content-group :text-content-typography :text-content-family
:text-content-weight :text-content-size :text-content-line-height
:text-content-spacing :text-content-case}]
(t/is (= (thtx/view (:content before)) (thtx/view (:content after))))
(t/is (empty? (:touched before)))
(t/is (= groups (:touched after)))
(t/is (= groups (set (keys (get (:model result) (:id after))))))
(let [undone (-> result (cg/step [:undo]) cg/settle-state)]
(t/is (= (oracle/snapshot (:situation state)) (oracle/snapshot (:situation undone)))))
(t/is (= 2 (get-in result [:coverage :random :text-style :changed] 0))
"both the main's value edit and the copy's authorship count as mutations")))
(t/deftest deleted-variant-content-keeps-its-size-when-the-position-resizes
(t/is (map? (cg/run {:world [2 2 {:variants true :variant-diff false}]
:ops [[:switch 1] [:delete 0] [:restore 0] [:delete 1]
[:resize 0] [:undo] [:redo]]}))))
(defn- translate-result
[situation id]
(let [file (tm/file situation)
page (thf/current-page file)
changes (cls/generate-update-shapes (pcb/empty-changes nil (:id page)) [id]
#(gsh/move % (gpt/point 5 0)) (:objects page)
{:ignore-touched true})]
(tm/with-file situation (thf/apply-changes file changes))))
(t/deftest geometry-expectations-do-not-read-the-primary-result
(doseq [tuple [[:resize 0 0 1] [:rotate 0 0 1] [:transform 0 0 1 0]]]
(let [initial (cg/initial-state [2 1])
original r/step
invariant (try
(with-redefs [r/step (fn [situation op]
(let [result (original situation op)]
(if (:target op)
(translate-result result (tm/target-shape-id situation (:target op)))
result)))]
(cg/step initial tuple))
nil
(catch #?(:clj Exception :cljs js/Error) error
(select-keys (ex-data error) [:invariant :phase])))]
(t/is (= {:invariant :I9 :phase :requested-geometry} invariant)))))
(t/deftest authored-child-position-follows-its-parent-and-rejects-drift
(let [initial (cg/initial-state [2 1])
id (get-in (cg/resolve-op (:situation initial) {} [:transform 0 0 1 2]) [:shape :id])
authored (-> initial (cg/step [:transform 0 0 1 2]) cg/settle-state)
moved (-> authored (cg/step [:transform 0 0 1 4]) cg/settle-state)
broken (translate-result (:situation moved) id)]
(t/is (nil? (oracle/check (:situation moved) (:model moved))))
(t/is (= :I9 (try (oracle/check broken (:model moved) false) nil
(catch #?(:clj Exception :cljs js/Error) error (:invariant (ex-data error))))))))
(t/deftest pushed-authored-child-position-uses-the-main-frame
(t/is (map? (cg/run {:world [2 2 {:variants true :variant-diff false}]
:ops [[:transform 0 0 0 3] [:edit 1 0 1 1] [:update-main 1]]}))))
(t/deftest accepting-an-upstream-library-after-its-dependent-was-refreshed
(t/is (map? (cg/run {:world [2 0 {:library true :stale-libraries true :library-dependency true}]
:ops [[:library-edit 3 0 1] [:library-accept 0] [:library-sync 1]]}))))
(t/deftest detached-inherited-child-position-uses-the-copy-parent-frame
(t/is (map? (cg/run {:world [3 2 {:text true :layout nil}]
:ops [[:transform 1 0 0 2] [:nest 3] [:detach 2]]}))))
(t/deftest reflecting-a-rotated-copy-settles-descendant-flips
(t/is (map? (cg/run {:world [2 1 {:text true :layout :grid}]
:ops [[:rotate 1] [:transform 2 16 0 9]]}))))
(t/deftest swapping-after-a-resized-variant-keeps-child-placement
(t/is (map? (cg/run {:world [2 2 {:variants true :variant-diff false :rich-variants true
:text true :layout nil :layout-copies true}]
:ops [[:resize 0] [:switch 0] [:swap 0]]}))))
(t/deftest switching-after-a-main-move-and-child-removal-stays-settled
(t/is (map? (cg/run {:world [2 0 {:library true :variants true :rich-variants true :text true
:layout :flex :layout-copies true}]
:ops [[:delete 0] [:restore 0] [:transform 4 0 0 0] [:remove-child 8]
[:style 5 7 0 0] [:switch 4] [:rotate 0 2 0 0]]}))))
(t/deftest reflecting-a-rotated-nested-copy-settles-descendant-flips
(t/is (map? (cg/run {:world [2 1 {:text true :layout :grid}]
:ops [[:nest 11] [:rotate 1] [:transform 2 16 0 18]]}))))
(t/deftest detach-keeps-an-authored-swap-inside-a-surviving-copy
(t/is (map? (cg/run {:world [2 2 {:variants true :variant-diff false}]
:ops [[:switch 10] [:switch 0] [:detach 2]]}))))
(t/deftest reflecting-a-parent-keeps-an-authored-childs-relative-orientation
(t/is (map? (cg/run {:world [2 1]
:ops [[:transform 0 0 1 2] [:rotate 0] [:transform 0 4 0 4]
[:undo] [:redo]]}))))
(t/deftest variant-worlds-contain-distinct-structure-size-text-and-properties
(let [situation (cg/world [2 2 {:variants true :rich-variants true :text true
:layout :grid :layout-copies true}])
members (:members (n/variant-set situation "random-variants"))
roots (map #(tm/shape-by-id situation (thi/id (:root-label %))) members)
components (map #(get-in (tm/file situation) [:data :components (:component-id %)]) members)]
(t/is (= 4 (count members)))
(t/is (true? (every? #(= 3 (count (:variant-properties %))) components)))
(t/is (> (count (set (map (juxt :width :height) roots))) 1))
(t/is (> (count (set (map (comp count :shapes) roots))) 1))
(t/is (true? (every? (fn [root] (some #(= :text (:type (tm/shape-by-id situation %))) (:shapes root))) roots)))
(t/is (boolean (some #(and (:layout (:shape %))
(some (fn [id] (:component-id (tm/shape-by-id situation id)))
(:shapes (:shape %)))) (cg/tree situation))))))
(t/deftest nearest-variant-prefers-earlier-properties-and-rejects-a-wrong-choice
(let [initial (cg/initial-state [2 2 {:variants true :rich-variants true}])
situation (:situation initial)
file (tm/file situation)
members (:members (n/variant-set situation "random-variants"))
[a b _ d] (map #(get-in file [:data :components (:component-id %)]) members)
shape {:component-file (:id file) :component-id (:id a)}
items (cg/candidates situation {} :switch nil)
index (some (fn [[index entry]]
(when (and (= (:id a) (get-in entry [:shape :component-id]))
(= 0 (:variant-pos entry))
(= (:id b) (get-in entry [:destination :shape :component-id]))) index))
(map-indexed vector items))]
(t/is (= (:id b) (:id (variants/nearest file shape 0 "Large"))))
(t/is (some? index))
(t/is (= {:invariant :I9 :phase :requested-component}
(try (with-redefs [clv/find-switch-target (constantly d)]
(cg/step initial [:switch index]))
nil
(catch #?(:clj Exception :cljs js/Error) error
(select-keys (ex-data error) [:invariant :phase])))))))
(t/deftest switch-shadow-carries-compatible-text-style-units
(doseq [[new-size carry?] [[14 true] [22 false]]]
(let [content #(thtx/content [[["Same text" {:size %}]]])
root {:type :frame :name "Board" :width 100 :height 100 :rotation 0}
old-main (assoc root :id :old :shapes [:old-text])
new-main (assoc root :id :new :shapes [:new-text])
text {:type :text :name "Caption" :width 70 :height 25 :rotation 0}
before {:old old-main :old-text (assoc text :id :old-text :parent-id :old :content (content 14))
:copy (assoc root :id :copy :shape-ref :old :shapes [:copy-text])
:copy-text (assoc text :id :copy-text :shape-ref :old-text :parent-id :copy :content (content 18))}
after {:new new-main :new-text (assoc text :id :new-text :parent-id :new :content (content new-size))
:copy (assoc root :id :copy :shape-ref :new :shapes [:result-text])
:result-text (assoc text :id :result-text :shape-ref :new-text :parent-id :copy :content (content new-size))}
model {:copy-text {:content-group {} :text-content-size {:content (content 18)}}}
result (shadow/swap model before after :copy :old :new true)
expected (get-in result [:result-text :text-content-size])]
(t/is (= carry? (some? expected)))
(when carry?
(t/is (= {} (get-in result [:result-text :content-group])))
(t/is (false? (shadow/same-value? (:result-text after) :text-content-size expected)))))))
(t/deftest source-library-edits-wait-for-explicit-consumer-acceptance
(let [initial (cg/initial-state [2 1 {:library true :stale-libraries true}])
situation (:situation initial)
library (first (vals (tm/aux-files situation)))
source (:shape (first (filter #(and (= :rect (get-in % [:shape :type]))
(nil? (get-in % [:shape :shape-ref])))
(cg/tree (tm/with-file situation library)))))
copies (filter #(= (:id source) (get-in % [:shape :shape-ref])) (cg/tree situation))
copy-id (get-in (first copies) [:shape :id])
edited (-> initial (cg/step [:library-edit 0 0 1]) cg/settle-state)
source-after (get-in (cf/all-files (:situation edited))
[(:id library) :data :pages-index (first (get-in library [:data :pages]))
:objects (:id source)])
accepted (-> edited (cg/step [:library-sync]) cg/settle-state)
undone (-> accepted (cg/step [:undo]) cg/settle-state)
redone (-> undone (cg/step [:redo]) cg/settle-state)
fill #(get-in (tm/shape-by-id (:situation %) copy-id) [:fills 0 :fill-color])]
(t/is (seq copies))
(t/is (= "#ff0000" (get-in source-after [:fills 0 :fill-color])))
(t/is (= (get (oracle/snapshot situation) (:id (tm/file situation)))
(get (oracle/snapshot (:situation edited)) (:id (tm/file situation)))))
(t/is (= setup/labeled-fill (fill edited)))
(t/is (= "#ff0000" (fill accepted)))
(t/is (= setup/labeled-fill (fill undone)))
(t/is (= "#ff0000" (fill redone)))
(t/is (= 1 (get-in accepted [:coverage :random :library-sync :changed])))))
(t/deftest independent-source-edits-and-acceptance-have-cross-file-inverses
(let [result (cg/run {:world [2 1 {:library true :stale-libraries true}]
:ops [[:library-edit 0 0 1] [:library-undo] [:library-redo]
[:library-sync] [:undo] [:redo]]})]
(t/is (= 1 (get-in result [:coverage :random :library-edit :changed])))
(t/is (= 1 (get-in result [:coverage :random :library-sync :changed])))
(t/is (= 1 (count (tm/aux-files (:situation result)))))))
(t/deftest stale-copy-edits-survive-acceptance-and-reset-uses-the-loaded-main
(let [spec [2 1 {:library true :stale-libraries true}]
initial (cg/initial-state spec)
situation (:situation initial)
library-id (first (keys (tm/aux-files situation)))
candidates (cg/candidates situation {} :edit 2)
[index entry] (first (keep-indexed (fn [index entry]
(when (= :rect (get-in entry [:shape :type])) [index entry]))
candidates))
id (get-in entry [:shape :id])
parent (get-in entry [:shape :parent-id])
reset-index (first (keep-indexed #(when (= parent (get-in %2 [:shape :id])) %1)
(cg/candidates situation {} :reset nil)))
edited (-> initial (cg/step [:library-edit 0 0 1])
(cg/step [:edit index 0 2 2]) cg/settle-state)
accepted (-> edited (cg/step [:library-sync]) cg/settle-state)
reset (-> edited (cg/step [:reset reset-index]) cg/settle-state)
reset-accepted (-> reset (cg/step [:library-sync]) cg/settle-state)
fill #(get-in (tm/shape-by-id (:situation %) id) [:fills 0 :fill-color])]
(t/is (some? library-id))
(t/is (some? reset-index))
(t/is (= "#00ff00" (fill accepted)))
(t/is (= #{:fill-group} (set (:touched (tm/shape-by-id (:situation accepted) id)))))
(t/is (= "#ff0000" (fill reset)))
(t/is (= "#ff0000" (fill reset-accepted)))
(t/is (map? (cg/run {:world spec
:ops [[:library-edit 0 0 1] [:edit index 0 2 2]
[:reset reset-index] [:library-sync] [:undo] [:redo]]})))))
(t/deftest stale-copy-can-swap-before-accepting-the-library-update
(let [spec [2 1 {:library true :stale-libraries true}]
initial (cg/initial-state spec)
situation (:situation initial)
library-id (first (keys (tm/aux-files situation)))
index (first (keep-indexed #(when (= library-id (get-in %2 [:shape :component-file])) %1)
(cg/candidates situation {} :swap nil)))
result (cg/run {:world spec
:ops [[:library-edit 0 0 1] [:swap index]
[:library-sync] [:undo] [:redo]]})]
(t/is (some? index))
(t/is (= 1 (get-in result [:coverage :random :swap :changed])))
(t/is (= 1 (get-in result [:coverage :random :library-sync :changed])))))
(t/deftest pushing-a-local-override-does-not-accept-unrelated-source-edits
(let [spec [2 1 {:library true :stale-libraries true :library-variants true}]
initial (cg/initial-state spec)
situation (:situation initial)
{:keys [shape library-id]} (cg/resolve-op situation {} [:library-edit 1 0 1])
copy-id (some #(when (= (:id shape) (get-in % [:shape :shape-ref]))
(get-in % [:shape :id])) (cg/tree situation))
pushed (-> initial (cg/step [:library-edit 1 0 1])
(cg/step [:edit 0 1 1 2]) (cg/step [:update-main 0]) cg/settle-state)
after (:situation pushed)
source (tm/with-file after (get (tm/aux-files after) library-id))
reference (get (cf/reference-libraries after (:id (tm/file after)) copy-id) library-id)]
(t/is (some? copy-id))
(t/is (= setup/labeled-fill (get-in (tm/shape-by-id after copy-id) [:fills 0 :fill-color])))
(t/is (= setup/labeled-fill
(get-in (tm/shape-by-id (tm/with-file after reference) (:id shape)) [:fills 0 :fill-color])))
(t/is (= "#ff0000" (get-in (tm/shape-by-id source (:id shape)) [:fills 0 :fill-color])))
(t/is (= 1 (get-in pushed [:coverage :random :update-main :changed])))))
(t/deftest source-history-does-not-undo-consumer-edits
(t/is (map? (cg/run {:world [2 1 {:library true :stale-libraries true}]
:ops [[:library-edit 0 0 1] [:edit 0 1 1 2]
[:library-sync] [:library-undo] [:library-redo]
[:undo] [:undo] [:redo] [:redo]]}))))
(t/deftest no-op-acceptance-does-not-rewrite-an-earlier-edits-undo-baseline
(t/is (map? (cg/run {:world [2 0 {:library true :stale-libraries true}]
:ops [[:edit 1 0 2 2] [:library-edit 0 0 1]
[:library-sync] [:undo] [:undo] [:redo] [:redo]]}))))
(t/deftest coverage-distinguishes-random-changes-no-ops-and-skips
(let [result (cg/run {:world [2 0]
:ops [[:edit 0 0 1 1] [:edit 0 0 1 1]
[:restore 0] [:sync 0]]})]
(t/is (= {:attempted 2 :eligible 2 :changed 1 :no-op 1}
(select-keys (get-in result [:coverage :random :edit])
[:attempted :eligible :changed :no-op])))
(t/is (= {:attempted 1 :eligible 0 :skipped 1}
(select-keys (get-in result [:coverage :random :restore])
[:attempted :eligible :skipped])))
(t/is (= 1 (get-in result [:coverage :random :sync :no-op])))))
(t/deftest setup-does-not-count-as-random-mutation-coverage
(let [result (cg/run {:world [2 0]
:prefix [[:edit 0 0 1 1]]
:ops [[:restore 0] [:sync 0]]})]
(t/is (= 1 (get-in result [:coverage :setup :edit :changed])))
(t/is (nil? (get-in result [:coverage :random :edit])))
(t/is (= 1 (get-in result [:coverage :random :restore :skipped])))))
(t/deftest coverage-rejects-vacuous-random-tails-and-underrepresented-kinds
(doseq [counts [{:attempted 100 :eligible 0 :skipped 100}
{:attempted 100 :eligible 100 :no-op 100}]]
(t/is (seq (cg/coverage-errors {:setup {:edit {:changed 100}}
:random {:edit counts}}
[:edit]))))
(t/is (seq (cg/coverage-errors {:random {:edit {:attempted 1000 :changed 1000}
:reset {:attempted 1000 :changed 1 :no-op 999}}}
[:edit :reset])))
(t/is (empty? (cg/coverage-errors {:random {:edit {:attempted 10 :changed 10}
:sync {:attempted 10 :no-op 10}}}
[:edit :sync]))))
(t/deftest structure-and-text-operations-run-through-production-nodes
(let [result (cg/run {:world [2 0 {:text true :layout :flex}]
:ops [[:edit 0 0 1] [:add-child 0] [:remove-child 0]
@ -29,9 +538,9 @@
(smt/for [program cg/structure-program-gen]
(cg/check-program program coverage failure))
:max-size 30)
(println "Executed structure operations:" (pr-str @coverage))
(doseq [kind cg/structure-kinds]
(t/is (pos? (get @coverage kind 0)) (str "No executed " kind)))))
(println "Structure operation coverage:" (pr-str @coverage))
(t/is (empty? (cg/coverage-errors @coverage cg/structure-kinds))
(pr-str (cg/coverage-errors @coverage cg/structure-kinds)))))
(t/deftest partial-sync-keeps-independent-components-pending
(let [initial (cg/initial-state [3 0])
@ -72,9 +581,31 @@
(smt/for [program cg/library-program-gen]
(cg/check-program program coverage failure))
:max-size 30)
(println "Executed library operations:" (pr-str @coverage))
(doseq [kind [:edit :update-main :library-sync :undo :redo]]
(t/is (pos? (get @coverage kind 0)) (str "No executed " kind)))))
(println "Library operation coverage:" (pr-str @coverage))
(t/is (empty? (cg/coverage-errors @coverage cg/library-kinds))
(pr-str (cg/coverage-errors @coverage cg/library-kinds)))))
(t/deftest random-stale-library-compositions
(let [coverage (atom {})
failure (atom nil)]
(smt/check!
(smt/for [program cg/stale-library-program-gen]
(cg/check-program program coverage failure))
:max-size 30)
(println "Stale library operation coverage:" (pr-str @coverage))
(t/is (empty? (cg/coverage-errors @coverage cg/stale-library-kinds #{:sync}))
(pr-str (cg/coverage-errors @coverage cg/stale-library-kinds #{:sync})))))
(t/deftest random-library-dependency-compositions
(let [coverage (atom {})
failure (atom nil)]
(smt/check!
(smt/for [program cg/dependency-program-gen]
(cg/check-program program coverage failure))
:max-size 30)
(println "Library dependency operation coverage:" (pr-str @coverage))
(t/is (empty? (cg/coverage-errors @coverage cg/dependency-kinds #{:sync}))
(pr-str (cg/coverage-errors @coverage cg/dependency-kinds #{:sync})))))
(t/deftest update-main-moves-an-authored-swap-to-the-replaced-main-shape
(let [result (cg/run {:world [2 1 {:library true :variants true}]

View File

@ -1,6 +1,8 @@
(ns common-tests.logic.composable-oracle-test
(:require
[app.common.files.changes-builder :as pcb]
[app.common.files.helpers :as cfh]
[app.common.geom.matrix :as gmt]
[app.common.geom.modifiers :as gm]
[app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh]
@ -8,6 +10,8 @@
[app.common.logic.shapes :as cls]
[app.common.test-helpers.components :as thc]
[app.common.test-helpers.composable.comp.nodes :as n]
[app.common.test-helpers.composable.comp.runner :as r]
[app.common.test-helpers.composable.comp.setups :as setup]
[app.common.test-helpers.composable.core :as tm]
[app.common.test-helpers.composable.gen :as cg]
[app.common.test-helpers.composable.oracle :as oracle]
@ -16,11 +20,145 @@
[app.common.test-helpers.files :as thf]
[app.common.test-helpers.ids-map :as thi]
[app.common.test-helpers.shapes :as ths]
[app.common.types.component :as ctk]
[app.common.types.modifiers :as ctm]
[clojure.test :as t]))
(t/use-fixtures :each thi/test-fixture)
(t/deftest oracle-attribute-inventory-covers-every-sync-attribute-and-group
(let [specified (into #{}
(mapcat (fn [[group attrs]] (map #(vector % group) attrs)))
(merge-with into shadow/attributes shadow/specialized-attributes))
production (into #{}
(mapcat (fn [[attr group]]
(map #(vector attr %) (if (map? group) (vals group) [group]))))
ctk/sync-attrs)]
(t/is (= production specified))))
(t/deftest sync-equivalence-retains-nested-copy-head-placement
(let [initial (setup/nested-component-with-copy)
file (tm/file initial)
page (thf/current-page file)
id (:id (tm/role-shape initial :copy-instance))
changed (thf/apply-changes file
(cls/generate-update-shapes
(pcb/empty-changes nil (:id page))
(cons id (cfh/get-children-ids (:objects page) id))
#(gsh/move % (gpt/point 5 0))
(:objects page) {:ignore-touched true}))]
(t/is (not (oracle/equivalent? (oracle/canonical initial)
(oracle/canonical (tm/with-file initial changed)))))))
(t/deftest design-comparison-uses-the-false-default-for-fixed-scroll
(let [initial (setup/simple-component-with-labeled-copy)
with-value #(tm/with-file initial (-> (tm/file initial)
(ths/update-shape :copy-root :fixed-scroll %)
(ths/update-shape :copy-root :touched nil)))
disabled (with-value false)
enabled (with-value true)
touched (tm/with-file disabled (ths/update-shape (tm/file disabled) :copy-root :touched #{:constraints-group}))]
(t/is (oracle/equivalent? (oracle/canonical initial) (oracle/canonical disabled)))
(t/is (not (oracle/equivalent? (oracle/canonical initial) (oracle/canonical enabled))))
(t/is (not (oracle/equivalent? (oracle/canonical disabled) (oracle/canonical touched))))
(t/is (not= (oracle/snapshot initial) (oracle/snapshot disabled)))
(t/is (nil? (oracle/check disabled {})))
(t/is (= :I4 (try (oracle/check enabled {}) nil
(catch #?(:clj Exception :cljs js/Error) error (:invariant (ex-data error))))))))
(t/deftest backend-parity-follows-a-free-head-without-hiding-copy-drift
(let [initial (setup/nested-component-with-copy)
file (tm/file initial)
page (thf/current-page file)
objects (:objects page)
source (tm/resolve-shape initial :main2-nested-head)
copy (tm/role-shape initial :copy-instance)
move (fn [heads]
(tm/with-file initial
(thf/apply-changes
file (cls/generate-update-shapes
(pcb/empty-changes nil (:id page))
(mapcat #(cfh/get-children-ids-with-self objects (:id %)) heads)
#(gsh/move % (gpt/point 30 0)) objects {:ignore-touched true}))))
inherited (move [source copy])
drifted (move [copy])
parity {:relative-free-head-placement true}
strict {:free-head-placement false}]
(t/is (oracle/equivalent? (oracle/canonical initial parity) (oracle/canonical inherited parity)))
(t/is (not (oracle/equivalent? (oracle/canonical initial parity) (oracle/canonical drifted parity))))
(t/is (not (oracle/equivalent? (oracle/canonical initial strict) (oracle/canonical inherited strict))))
(t/is (not (oracle/equivalent? (oracle/canonical initial) (oracle/canonical inherited))))))
(t/deftest oracle-rejects-unmarked-differences-in-all-scalar-groups
(let [situation (setup/simple-component-with-labeled-copy)
file (tm/file situation)]
(doseq [[attr value] [[:hidden true] [:blocked true] [:r1 8]
[:strokes [{:stroke-color "#ff0000" :stroke-opacity 1
:stroke-width 2 :stroke-style :solid
:stroke-alignment :center}]]
[:shadow [{:id (thi/new-id! :shadow) :style :drop-shadow
:color {:color "#000000" :opacity 0.5}
:offset-x 2 :offset-y 2 :blur 4 :spread 0
:hidden false}]]
[:blur {:id (thi/new-id! :blur) :type :layer-blur :value 4 :hidden false}]
[:show-content true]]]
(t/testing (str attr)
(let [target (if (= attr :show-content) :copy-root :copy-child)
broken (-> file
(ths/update-shape target attr value)
(ths/update-shape target :touched nil))]
(t/is (= :I4 (try
(oracle/check (tm/with-file situation broken) {})
nil
(catch #?(:clj Exception :cljs js/Error) error
(:invariant (ex-data error)))))))))))
(t/deftest oracle-rejects-touched-on-mains-and-detached-shapes
(let [initial (setup/simple-component-with-labeled-copy)
detached (-> initial (r/step (n/detach :copy-root)) r/settle)]
(doseq [[situation label] [[initial :main-child] [detached :copy-child]]]
(let [file (tm/file situation)
page-id (:id (thf/current-page file))
broken (assoc-in file [:data :pages-index page-id :objects (thi/id label) :touched]
#{:fill-group})]
(t/is (thrown? #?(:clj Exception :cljs js/Error)
(oracle/check (tm/with-file situation broken) {} false)))))))
(t/deftest grid-visibility-expectations-still-reject-cell-corruption
(let [file (-> (thf/sample-file :file1)
(tho/add-frame :main-root (merge cls/initial-grid-layout {:width 300 :height 100}))
(tho/add-rect :main-first {:parent-label :main-root})
(tho/add-rect :main-second {:parent-label :main-root})
(tho/add-rect :main-third {:parent-label :main-root})
(tho/place-in-grid-columns :main-root 3 {1 :main-first 2 :main-second 3 :main-third})
(thc/make-component :component1 :main-root)
(thc/instantiate-component :component1 :copy-root
:children-labels [:copy-first :copy-second :copy-third]))
initial (tm/make-situation file)
page-id (:id (thf/current-page file))
first-child (ths/get-shape file :copy-first)
hidden (r/step initial (n/change-property :copy-first :hidden true))
model (shadow/edit {} first-child :hidden true)
cells-path [:data :pages-index page-id :objects (thi/id :copy-root) :layout-grid-cells]
cells (vals (get-in (tm/file hidden) cells-path))
occupied (first (filter (comp seq :shapes) cells))
empty-cell (first (remove (comp seq :shapes) cells))
corrupt (fn [cell f]
(tm/with-file hidden
(update-in (tm/file hidden) (conj cells-path (:id cell)) f)))
invariant (fn [situation]
(try (oracle/check situation model) nil
(catch #?(:clj Exception :cljs js/Error) error
(select-keys (ex-data error) [:invariant :group]))))]
(t/is (nil? (oracle/check hidden model)))
(doseq [[cell f] [[empty-cell #(assoc % :shapes [(thi/id :copy-first)])]
[occupied #(assoc % :shapes [])]
[occupied #(update % :column inc)]
[occupied #(update % :column-span inc)]
[occupied #(assoc % :position :auto)]]]
(t/is (= {:invariant :I4 :group :layout-grid-cells}
(invariant (corrupt cell f)))))))
(t/deftest oracle-accepts-layout-owned-fill-sizing
(doseq [layout [:flex :grid]]
(let [file (-> (thf/sample-file :file1)
@ -89,3 +227,31 @@
bad (move moved #{(thi/id :copy-child)} 5)]
(t/is (= (oracle/canonical situation) (oracle/canonical (tm/with-file situation moved))))
(t/is (not= (oracle/canonical situation) (oracle/canonical (tm/with-file situation bad))))))
(t/deftest matrix-comparison-does-not-reintroduce-derived-text-dimensions
(doseq [grow-type [:auto-height :auto-width]]
(let [file (-> (thf/sample-file :file)
(ths/add-sample-shape :text :type :text :grow-type grow-type
:width 70 :height 25))
page-id (:id (thf/current-page file))
path [:data :pages-index page-id :objects (thi/id :text)]
measured (update-in file path
#(gsh/transform-shape % (ctm/change-size %
(if (= grow-type :auto-width) 55 70)
17)))
changed (assoc-in measured (conj path :transform) (gmt/matrix 1 0 0 1 2 0))
stretched (assoc-in measured (conj path :transform) (gmt/matrix 1 0 0 1.1 0 0))
fixed-width (assoc-in measured (conj path :width) 60)
turn #(gsh/absolute-move (gsh/transform-shape % (n/geometry-modifiers % :rotate 45))
(gpt/point 0 0))
rotated (update-in file path turn)
rotated-measured (update-in measured path turn)
design #(oracle/canonical (tm/make-situation %))]
(t/is (oracle/equivalent? (design file) (design measured)))
(t/is (oracle/equivalent? (design rotated) (design rotated-measured)))
(t/is (not (oracle/equivalent? (design file) (design changed))))
(t/is (not (oracle/equivalent? (design file) (design stretched))))
(t/is (not= (oracle/snapshot (tm/make-situation file))
(oracle/snapshot (tm/make-situation measured))))
(when (= grow-type :auto-height)
(t/is (not (oracle/equivalent? (design file) (design fixed-width))))))))

View File

@ -164,6 +164,27 @@
(thf/validate-file!))]
(t/is (= :right (:constraints-h (ths/get-shape file :copy-star))))))
(t/deftest swapped-head-content-sync-keeps-the-replaced-childs-placement
(let [file (-> (setup)
(ths/update-shape :card-star :constraints-h :right)
(ths/update-shape :card-star :constraints-v :bottom)
(ths/update-shape :card-star :fixed-scroll true)
(ths/update-shape :heart-main :constraints-h :scale)
(ths/update-shape :heart-main :constraints-v :scale)
(ths/update-shape :heart-main :fixed-scroll false)
(ths/update-shape :heart-main :opacity 0.4)
(propagate :card))
placement #(select-keys (ths/get-shape % :copy-star)
[:constraints-h :constraints-v :fixed-scroll])
expected {:constraints-h :right :constraints-v :bottom :fixed-scroll true}
synced (-> file (propagate :heart) thf/validate-file!)
reversed (-> file (propagate :heart :card) thf/validate-file!)]
(t/is (= expected (placement file)))
(t/is (= expected (placement synced)))
(t/is (= (placement synced) (placement reversed)))
(t/is (= 0.4 (:opacity (ths/get-shape synced :copy-star))))
(t/is (= #{:swap-group} (:touched (ths/get-shape synced :copy-star))))))
(t/deftest moved-swapped-head-keeps-its-position
(let [file (-> (setup)
(move-shape :copy-star 5 5))
@ -306,6 +327,29 @@
(propagate :heart)
(tho/bottom-fill-color :copy-star))))))
(t/deftest detach-keeps-a-swapped-heads-inherited-placement-as-overrides
(let [initial (-> (setup)
(ths/update-shape :card-star :constraints-h :right)
(ths/update-shape :card-star :fixed-scroll true)
(propagate :card))
detached (detach initial :copy)
synced (-> detached (propagate :heart) thf/validate-file!)
head (ths/get-shape synced :copy-star)]
(t/is (= :right (:constraints-h head)))
(t/is (true? (:fixed-scroll head)))
(t/is (= #{:constraints-group} (:touched (ths/get-shape detached :copy-star))))
(t/is (= (:touched (ths/get-shape detached :copy-star)) (:touched head)))))
(t/deftest copied-swapped-head-keeps-its-placement-ownership
(let [initial (-> (setup)
(ths/update-shape :card-star :fixed-scroll true)
(propagate :card))
objects (copy-objects initial :copy-star)
head (get objects (thi/id :copy-star))]
(t/is (true? (:fixed-scroll head)))
(t/is (= (thi/id :heart-main) (:shape-ref head)))
(t/is (= #{:constraints-group} (:touched head)))))
(t/deftest detach-advances-a-deeper-swapped-head-by-position
(let [file (setup-two-levels)
dot (first-child file :outer-star)

View File

@ -1053,7 +1053,8 @@
(if-let [shape (get objects (:id shape))]
(let [ldata (dsh/lookup-file-data state file-id)
undo-id (js/Symbol)
undo-group (uuid/next)
undo-group (or (get-in state [:workspace-undo :transaction :undo-group])
(uuid/next))
[new-shape changes update-layout-ids]
(-> (pcb/empty-changes it (:id page))
@ -1080,7 +1081,8 @@
(dwtp/propagate-workspace-tokens)
(when (and (features/active-feature? state "render-wasm/v1")
(seq new-text-ids))
(dwwt/resize-wasm-text-all new-text-ids {:skip-component-sync? true})))
(dwwt/resize-wasm-text-all new-text-ids {:skip-component-sync? true
:undo-group undo-group})))
(not skip-layout?)
(rx/concat (rx/of (ptk/data-event :layout/update
{:ids update-layout-ids :undo-group undo-group})))

View File

@ -16,6 +16,7 @@
[app.common.geom.point :as gpt]
[app.common.geom.rect :as grc]
[app.common.geom.shapes :as gsh]
[app.common.logic.shapes :as cls]
[app.common.math :as mth]
[app.common.render-wasm.api.select :as wselect]
[app.common.transit :as t]
@ -132,8 +133,8 @@
(defn- await-font-faces
"Waits for missing WASM faces, then resizes the affected texts."
[stream face-keys ids]
(let [resize-opts {:stack-undo? true :undo-transation? false}
[stream face-keys ids & [opts]]
(let [resize-opts (merge {:stack-undo? true :undo-transation? false} opts)
resize-stream (->> (rx/from ids) (rx/map #(dwwt/resize-wasm-text % resize-opts)))]
(if (empty? face-keys)
resize-stream
@ -163,13 +164,13 @@
(defn- await-font-resize
"Waits for missing font faces, then resizes `ids`."
[stream ids]
[stream ids opts]
(if (empty? ids)
(rx/empty)
(->> (rx/of ::await-fonts)
(rx/mapcat
(fn [_]
(await-font-faces stream (pending-font-faces ids) ids))))))
(await-font-faces stream (pending-font-faces ids) ids opts))))))
(defn- await-html-font
"Keeps legacy DOM text pending while its new font is loading. The DOM
@ -634,7 +635,7 @@
(rx/empty)))))))
(defn update-root-attrs
[{:keys [id attrs]}]
[{:keys [id attrs undo-group]}]
(ptk/reify ::update-root-attrs
ptk/WatchEvent
(watch [_ state _]
@ -658,10 +659,10 @@
(cond (cfh/text-shape? shape) [id]
(cfh/group-shape? shape) (cfh/get-children-ids objects id))]
(rx/of (dwsh/update-shapes shape-ids update-fn))))))
(rx/of (dwsh/update-shapes shape-ids update-fn {:undo-group undo-group}))))))
(defn update-paragraph-attrs
[{:keys [id attrs]}]
[{:keys [id attrs undo-group]}]
(let [attrs (d/without-nils attrs)]
(ptk/reify ::update-paragraph-attrs
ptk/UpdateEvent
@ -685,10 +686,10 @@
(cfh/text-shape? shape) [id]
(cfh/group-shape? shape) (cfh/get-children-ids objects id))]
(rx/of (dwsh/update-shapes shape-ids update-fn))))))))
(rx/of (dwsh/update-shapes shape-ids update-fn {:undo-group undo-group}))))))))
(defn update-text-attrs
[{:keys [id attrs]}]
[{:keys [id attrs typography? undo-group]}]
(ptk/reify ::update-text-attrs
ptk/UpdateEvent
(update [_ state]
@ -696,7 +697,9 @@
ptk/WatchEvent
(watch [_ state _]
(when-not (some? (get-in state [:workspace-editor-state id]))
(if (some? (get-in state [:workspace-editor-state id]))
(when typography?
(rx/of (dwsh/update-shapes [id] cls/touch-text-typography {:undo-group undo-group})))
(let [objects (dsh/lookup-page-objects state)
shape (get objects id)
wasm? (features/active-feature? state "render-wasm/v1")
@ -711,11 +714,12 @@
;; `shape-text-contents` and overwrite per-run fills (e.g. line-height).
merge-shape
(fn [sh]
(let [updated-shape (txt/update-text-content sh update-node? d/txt-merge attrs)]
(let [updated-shape (cond-> (txt/update-text-content sh update-node? d/txt-merge attrs)
typography? cls/touch-text-typography)]
(when wasm?
(wasm.text-editor/cache-shape-text-content! (:id updated-shape) (:content updated-shape)))
updated-shape))]
(rx/of (dwsh/update-shapes shape-ids merge-shape)))))))
(rx/of (dwsh/update-shapes shape-ids merge-shape {:undo-group undo-group})))))))
(defn migrate-node
[node]
@ -1093,11 +1097,13 @@
(rx/empty))))))
(defn update-attrs
[id attrs]
[id attrs & {:keys [undo-group]}]
(ptk/reify ::update-attrs
ptk/WatchEvent
(watch [_ state stream]
(let [text-editor-instance (:workspace-editor state)
(let [undo-group (or undo-group (get-in state [:workspace-undo :transaction :undo-group]) (uuid/next))
resize-opts {:undo-group undo-group}
text-editor-instance (:workspace-editor state)
objects (dsh/lookup-page-objects state)
text-ids (resolve-text-ids objects id)
@ -1113,7 +1119,7 @@
(rx/concat
(let [attrs (select-keys attrs txt/root-attrs)]
(if-not (empty? attrs)
(rx/of (update-root-attrs {:id id :attrs attrs}))
(rx/of (update-root-attrs {:id id :attrs attrs :undo-group undo-group}))
(rx/empty)))
;; `:line-height` is stored on both the paragraph and its spans, and
@ -1134,7 +1140,7 @@
:update-name? true))
:else
(rx/of (update-paragraph-attrs {:id id :attrs attrs}))))
(rx/of (update-paragraph-attrs {:id id :attrs attrs :undo-group undo-group}))))
(let [attrs (select-keys attrs txt/text-node-attrs)]
(cond
@ -1149,7 +1155,7 @@
(rx/of (dwt-v3/v3-update-text-editor-styles id attrs)))
:else
(rx/of (update-text-attrs {:id id :attrs attrs}))))
(rx/of (update-text-attrs {:id id :attrs attrs :undo-group undo-group}))))
(when (and (features/active-feature? state "text-editor/v2")
(not (features/active-feature? state "text-editor-wasm/v1")))
@ -1172,10 +1178,10 @@
(let [auto-ids (into [] (remove #(= :fixed (:grow-type (get objects %)))) text-ids)]
(if (contains? attrs :font-id)
;; The geometry depends on the font, so wait until wasm has it.
(await-font-resize stream auto-ids)
(await-font-resize stream auto-ids resize-opts)
;; No font change: measurable right away.
(->> (rx/from auto-ids)
(rx/map dwwt/resize-wasm-text)))))
(rx/map #(dwwt/resize-wasm-text % resize-opts))))))
;; The legacy renderer re-measures these in the DOM on its own,
;; but font loading starts before that render commits.
@ -1203,12 +1209,13 @@
[ids attrs]
(ptk/reify ::update-all-attrs
ptk/WatchEvent
(watch [_ _ _]
(let [undo-id (js/Symbol)]
(watch [_ state _]
(let [undo-id (js/Symbol)
undo-group (or (get-in state [:workspace-undo :transaction :undo-group]) (uuid/next))]
(rx/concat
(rx/of (dwu/start-undo-transaction undo-id))
(->> (rx/from ids)
(rx/map #(update-attrs % attrs)))
(rx/map #(update-attrs % attrs :undo-group undo-group)))
(rx/of (dwu/commit-undo-transaction undo-id)))))))
(defn apply-typography
@ -1224,10 +1231,9 @@
(watch [_ state _]
(let [editor-state (:workspace-editor-state state)
ids (d/nilv ids (dsh/lookup-selected state))
attrs (-> typography
attrs (-> (select-keys typography txt/typography-fields)
(assoc :typography-ref-file file-id)
(assoc :typography-ref-id (:id typography))
(dissoc :id :name))
(assoc :typography-ref-id (:id typography)))
undo-id (js/Symbol)]
(rx/concat
@ -1235,7 +1241,7 @@
(->> (rx/from (seq ids))
(rx/map (fn [id]
(let [editor (get editor-state id)]
(update-text-attrs {:id id :editor editor :attrs attrs})))))
(update-text-attrs {:id id :editor editor :attrs attrs :typography? true})))))
(rx/of (dwu/commit-undo-transaction undo-id))))))))
(defn generate-typography-name

View File

@ -401,8 +401,9 @@
(def ^:private base-fields
"Base fields of the `Shape` record this proxy stands in for: `cr/defrecord`
nils them on dissoc instead of removing them, and the schema requires them."
#{:name :x :y :width :height :rotation :selrect :points
:transform :transform-inverse :parent-id :frame-id :flip-x :flip-y})
{:name nil :x nil :y nil :width nil :height nil :rotation nil
:selrect nil :points nil :transform nil :transform-inverse nil
:parent-id nil :frame-id nil :flip-x nil :flip-y nil})
(defn- impl-dissoc
[self k]
@ -444,11 +445,17 @@
"Instantiate a shape from a map. The delegate is an array map because
it takes far less memory than a hash map for shape-sized maps."
[attrs]
(let [arr (reduce-kv (fn [arr k v]
(when-not (or (= k :id) (= k :type))
(.push arr k v))
(let [;; the base fields first, as `(into base-fields attrs)` orders them
arr (reduce-kv (fn [arr k v]
(.push arr k (get attrs k v))
arr)
#js []
base-fields)
arr (reduce-kv (fn [arr k v]
(when-not (or (= k :id) (= k :type) (contains? base-fields k))
(.push arr k v))
arr)
arr
attrs)]
(ShapeProxy. (:id attrs)
(:type attrs)

View File

@ -11,25 +11,186 @@
down on purpose, so a step that resolved early would see a half-synced
file."
(:require
[app.common.files.changes-builder :as pcb]
[app.common.logic.shapes :as cls]
[app.common.math :as mth]
[app.common.test-helpers.components :as thc]
[app.common.test-helpers.composable.comp.nodes :as n]
[app.common.test-helpers.composable.comp.runner :as r]
[app.common.test-helpers.composable.comp.setups :as setup]
[app.common.test-helpers.composable.comp.undo-check :as uc]
[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.compositions :as tho]
[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]
[app.common.time :as ct]
[app.main.data.workspace.libraries :as dwl]
[app.main.data.workspace.reflow :as wrf]
[app.main.data.workspace.shapes :as dwsh]
[app.main.data.workspace.texts :as dwt]
[app.main.data.workspace.thumbnails-wasm :as dwthw]
[app.main.data.workspace.undo :as dwu]
[app.main.data.workspace.wasm-text :as dwwt]
[app.main.store :as st]
[app.render-wasm.api :as wasm]
[app.util.text-editor :as ted]
[beicon.v2.core :as rx]
[cljs.test :as t :include-macros true]
[clojure.test.check.generators :as gen]
[frontend-tests.composable-tests.interpreter :as ftm]
[frontend-tests.helpers.async :as ha]
[frontend-tests.helpers.mock :as mock]
[frontend-tests.helpers.wasm :as thw]
[potok.v2.core :as ptk]))
(t/use-fixtures :each ftm/fixture)
(t/deftest ^:async swapping-growing-text-undoes-with-the-component-choice
(let [features (:features @st/state)]
(thw/setup-wasm-mocks!)
(try
(await
(mock/with-mocks*
{wasm/text-editor-has-focus? (mock/stub (constantly false))
dwthw/render-thumbnail (mock/stub (fn [& _] (ptk/data-event ::thumbnail-skipped)))}
(doseq [action [:swap :switch :multi-swap]]
(let [file (-> (thf/sample-file :file)
(tho/add-frame :root-a)
(thc/make-component :a :root-a)
(tho/add-frame-with-text :root-b :text-b "hello")
(ths/update-shape :text-b :grow-type :auto-height)
(thc/make-component :b :root-b)
(thc/instantiate-component :a :copy)
(thc/instantiate-component :a :copy2))
situation (ftm/install! (tm/make-situation file))
before (ftm/snapshot)]
(st/emit! #(update % :features (fnil conj #{}) "render-wasm/v1"))
(t/is (= :settled
(await (ftm/await-step
[(if (= action :multi-swap)
(dwl/component-multi-swap [(ths/get-shape file :copy)
(ths/get-shape file :copy2)]
(:id file) (thi/id :b))
(dwl/component-swap (ths/get-shape file :copy)
(:id file) (thi/id :b) (= action :switch)))]))))
(let [after (ftm/snapshot)
root (ths/get-shape (ftm/current-file) :copy)
text (tm/shape-by-id (ftm/refresh-generated situation) (first (:shapes root)))]
(t/is (= (thi/id :b) (:component-id root)))
(t/is (mth/close? 20 (:height text)))
(t/is (empty? (:touched text)))
(t/is (= :settled (await (ftm/await-step [dwu/undo]))))
(t/is (uc/same-state? before (ftm/snapshot)) "one undo restores the old component")
(t/is (= :settled (await (ftm/await-step [dwu/redo]))))
(t/is (uc/same-state? after (ftm/snapshot)) "one redo restores the measured result"))))))
(finally
(thw/teardown-wasm-mocks!)
(st/emit! #(assoc % :features features))))))
(t/deftest ^:async applying-typography-settles-the-reference-and-undoes-in-one-step
(doseq [mode [:partial :inherited :editing-inherited]]
(let [expected [[{:line-height 1.6}
["Read the guide" {:family "Roboto" :weight 700 :italic true :size 22
:spacing 2 :case "uppercase" :typography :heading}]]]
file (-> (thf/sample-file :file1)
(ths/add-sample-typography :heading :font-id "gfont-roboto" :font-family "Roboto"
:font-variant-id "700italic" :font-weight "700"
:font-style "italic" :font-size "22"
:line-height "1.6" :letter-spacing "2"
:text-transform "uppercase" :path "Saved styles")
(thtx/add-text-component-with-copy (if (= mode :partial)
[[["Read the guide" {:size 22}]]]
expected)))
_ (ftm/install! (tm/make-situation file))
before (ftm/snapshot)
typography (get-in file [:data :typographies (thi/id :heading)])]
(when (= mode :editing-inherited)
(st/emit! #(assoc-in % [:workspace-editor-state (thi/id :copy-child)]
(-> (ths/get-shape file :copy-child) :content ted/import-content
ted/create-editor-state ted/editor-select-all))))
(t/is (= :settled
(await (ftm/await-step [(dwt/apply-typography #{(thi/id :copy-child)} typography (:id file))]))))
(let [after (ftm/snapshot)
after-file (ftm/current-file)
shape (ths/get-shape after-file :copy-child)
design #(oracle/canonical (tm/make-situation %) {:free-head-placement false})
main-edit (dwt/update-text-attrs {:id (thi/id :main-child) :attrs {:font-size "30"}})]
(t/is (= expected (thtx/view (:content shape))))
(t/is (= #{:content-group :text-content-typography :text-content-family
:text-content-weight :text-content-size :text-content-line-height
:text-content-spacing :text-content-case}
(:touched shape)))
(t/is (= :settled (await (ftm/await-step [dwu/undo]))))
(t/is (uc/same-state? before (ftm/snapshot)))
(t/is (= :settled (await (ftm/await-step [dwu/redo]))))
(t/is (uc/same-state? after (ftm/snapshot)))
(t/is (= :settled
(await (ftm/await-step [(dwl/sync-file (:id file) (:id file) :components (thi/id :component1))]))))
(t/is (oracle/equivalent? (design after-file) (design (ftm/current-file))))
(t/is (= :settled (await (ftm/await-step [main-edit]))))
(t/is (= expected (thtx/text-of (ftm/current-file) :copy-child))
"the applied typography keeps its size when the main changes")))))
(t/deftest ^:async sidebar-font-size-and-wasm-measurement-undo-together
(let [features (:features @st/state)
measured (atom nil)
font-size #(get-in % [:content :children 0 :children 0 :children 0 :font-size])]
(thw/setup-wasm-mocks!)
(try
(await
(mock/with-mocks*
{wasm/text-editor-has-focus? (mock/stub (constantly false))
wasm/set-shape-text-content (mock/stub (fn [_ content] (reset! measured content)))
wasm/get-text-dimensions (mock/stub (fn [] {:x 0 :y 0 :width 100 :max-width 100
:height (if (= "18" (font-size {:content @measured})) 29 35)}))
dwthw/render-thumbnail (mock/stub (fn [& _] (ptk/data-event ::thumbnail-skipped)))}
(let [text [[{:line-height 1.6}
["Read the guide" {:family "Roboto" :weight 700 :italic true :size 22
:spacing 2 :case "uppercase" :typography :heading}]]]
file (-> (thf/sample-file :file1)
(ths/add-sample-typography :heading :font-id "gfont-roboto" :font-family "Roboto"
:font-variant-id "700italic" :font-weight "700"
:font-style "italic" :font-size "22"
:line-height "1.6" :letter-spacing "2" :text-transform "uppercase")
(thtx/add-text-component-with-copy text))
_ (ftm/install! (tm/make-situation file))
typography (get-in file [:data :typographies (thi/id :heading)])]
(st/emit! #(update % :features (fnil conj #{}) "render-wasm/v1"))
(t/is (= :settled
(await (ftm/await-step [(dwwt/resize-wasm-text-all [(thi/id :main-child) (thi/id :copy-child)])
(dwt/apply-typography #{(thi/id :copy-child)} typography (:id file))]))))
(let [before (ftm/snapshot)]
(t/is (= :settled
(await (ftm/await-step [(dwt/update-all-attrs [(thi/id :main-child)]
{:font-size "18" :typography-ref-id nil
:typography-ref-file nil})]))))
(let [after (ftm/snapshot)]
(t/is (= "18" (font-size (ths/get-shape (ftm/current-file) :main-child))))
(t/is (= "22" (font-size (ths/get-shape (ftm/current-file) :copy-child))))
(t/is (mth/close? 35 (:height (ths/get-shape (ftm/current-file) :copy-child))))
(t/is (= :settled (await (ftm/await-step [dwu/undo]))))
(t/is (uc/same-state? before (ftm/snapshot)) "one undo restores styles and measured geometry")
(t/is (= :settled (await (ftm/await-step [dwu/redo]))))
(t/is (uc/same-state? after (ftm/snapshot)) "one redo restores styles and measured geometry"))))))
(finally
(thw/teardown-wasm-mocks!)
(st/emit! #(assoc % :features features))))))
(t/deftest ^:async hiding-a-grid-main-child-then-moving-its-main-stays-synced
(loop [live (ftm/start-generated (cg/world [2 1 {:text true :text-styles true :layout :grid}]))
tuples [[:style 3 1 3 0] [:transform 0 0 0 0]]]
(when-let [tuple (first tuples)]
(let [resolved (cg/resolve-op live {} tuple)
next-live (await (ftm/run-generated-step live (:op resolved)))]
(t/is (some? next-live))
(t/is (empty? (uc/failures next-live)))
(t/is (nil? (oracle/check next-live {})))
(recur next-live (rest tuples))))))
(def ^:private original "#abcdef")
(def ^:private red "#ff0000")
@ -63,6 +224,105 @@
(dwsh/update-shapes #{(thi/id :main-child)}
#(assoc % :fills (ths/sample-fills-color :fill-color color))))
(defn- ^:async pending-sync-burst
[seed undo-before-release]
(let [sync-file dwl/sync-file
release (rx/behavior-subject false)
tail (gen/generate (gen/vector (gen/tuple (gen/return :edit)
(gen/choose 0 30) (gen/choose 0 1)
(gen/choose 1 2) (gen/return 0))
2 8) 20 seed)
tuples (into [[:edit 1 0 1 0]] tail)
initial (cg/initial-state [2 (mod seed 3)])]
(try
(await
(mock/with-mocks*
{dwl/sync-file (deferred-sync-file sync-file
(fn [event]
;; The cascade is synchronous. Hold
;; completion, not its input state.
(rx/concat (rx/of event)
(->> release (rx/filter true?)
(rx/take 1) (rx/ignore)))))}
(let [live (ftm/start-generated (:situation initial))
result (reduce (fn [{:keys [state operations]} tuple]
(let [resolved (cg/resolve-op (:situation state) (:model state) tuple)]
{:state (-> state (cg/step tuple) cg/settle-state)
:operations (conj operations (:op resolved))}))
{:state initial :operations []} tuples)
operations (:operations result)]
(doseq [event (ftm/op->events (first operations) live)] (st/emit! event))
(await (ha/wait-for #(seq (wrf/pending)) "first edit opens the held sync"))
(doseq [op (rest operations)
event (ftm/op->events op live)]
(st/emit! event))
(t/is (seq (wrf/pending)) "later edits arrived while sync was pending")
(when undo-before-release (st/emit! dwu/undo))
(let [expected (cond-> (:state result)
undo-before-release (-> (cg/step [:undo]) cg/settle-state))]
(rx/push! release true)
(t/is (= :settled (await (ftm/await-step []))))
(oracle/check (ftm/refresh-generated live) (:model expected))
(t/is (uc/same-state? (oracle/snapshot (:situation expected))
(:files (ftm/snapshot)))
(str "seed " seed ", undo-before-release " undo-before-release))
(let [depth (r/undo-depth (:situation expected))
undone (loop [state expected remaining depth]
(if (zero? remaining)
state
(let [state (-> state (cg/step [:undo]) cg/settle-state)]
(t/is (= :settled (await (ftm/await-step [dwu/undo]))))
(t/is (uc/same-state? (oracle/snapshot (:situation state))
(:files (ftm/snapshot)))
(str "burst undo seed " seed ", remaining " remaining))
(recur state (dec remaining)))))]
(loop [state undone remaining depth]
(when (pos? remaining)
(let [state (-> state (cg/step [:redo]) cg/settle-state)]
(t/is (= :settled (await (ftm/await-step [dwu/redo]))))
(oracle/check (ftm/refresh-generated live) (:model state))
(t/is (uc/same-state? (oracle/snapshot (:situation state))
(:files (ftm/snapshot)))
(str "burst redo seed " seed ", remaining " remaining))
(recur state (dec remaining))))))))))
(finally
(ftm/uninstall!)
(rx/end! release)))))
(t/deftest ^:async seeded-edits-arrive-during-pending-sync
(doseq [seed (range 12)]
(await (pending-sync-burst seed false))))
(t/deftest ^:async seeded-undo-arrives-during-pending-sync
(doseq [seed (range 12)]
(await (pending-sync-burst seed true))))
(t/deftest ^:async library-notification-keeps-copies-stale-but-reset-uses-the-new-main
(let [situation (cg/world [2 1 {:library true}])
library (first (vals (tm/aux-files situation)))
page (thf/current-page library)
child (:shape (first (filter #(and (= :rect (get-in % [:shape :type]))
(nil? (get-in % [:shape :shape-ref])))
(cg/tree (tm/with-file situation library)))))
root (get-in page [:objects (:parent-id child)])
copies (filter #(= (:id child) (get-in % [:shape :shape-ref])) (cg/tree situation))
first-copy (:shape (first copies))
other-copy (:shape (second copies))
changes (cls/generate-update-shapes (pcb/empty-changes nil (:id page)) [(:id child)]
#(n/set-property % :fills red) (:objects page) {})
edited (thf/apply-changes library changes)
cascaded (r/sync-cascade edited {} [(:component-id root)])
changes (reduce pcb/concat-changes changes (:syncs cascaded))
live (ftm/start-generated situation)
fill (fn [id] (get-in (tm/shape-by-id (ftm/refresh-generated live) id) [:fills 0 :fill-color]))]
(t/is (= :settled (await (ftm/await-step [(dwl/ext-library-changed (:id library) (ct/now) 1
(:redo-changes changes))]))))
(t/is (= setup/labeled-fill (fill (:id first-copy))))
(t/is (= setup/labeled-fill (fill (:id other-copy))))
(t/is (= :settled (await (ftm/await-step [(dwl/reset-component (:parent-id first-copy))]))))
(t/is (= red (fill (:id first-copy))))
(t/is (= setup/labeled-fill (fill (:id other-copy))))))
(t/deftest ^:async edit-step-waits-for-slow-sync
(let [sync-file dwl/sync-file]
(await

View File

@ -10,6 +10,7 @@
[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 cthf]
[app.common.test-helpers.normalize :as thn]
[app.main.repo :as rp]
[beicon.v2.core :as rx]
@ -20,6 +21,58 @@
(t/use-fixtures :each ftm/fixture)
(defn- ^:async replay-program
"Replay a JVM-shrunk EDN program against the async frontend. The pure
runner chooses targets independently and both must make the same choices."
[{:keys [world ops] :as program}]
(try
(let [initial (cg/initial-state world)]
(loop [state initial
live (ftm/start-generated (:situation initial))
tuples ops]
(if-let [tuple (first tuples)]
(let [state (cg/settle-state state)
pure (:situation state)
live (ftm/refresh-generated live)
expected (cg/resolve-op pure (:model state) tuple)
actual (if (#{:undo :redo} (first tuple))
expected
(cg/resolve-op live (live-model state live) tuple))]
(t/is (= (:trace expected) (:trace actual)) (str "Replay changed a target: " tuple))
(let [next-live (if-let [op (:op actual)]
(await (ftm/run-generated-step live op))
(do
(t/is (= :settled (await (ftm/await-step []))))
(ftm/refresh-generated live)))
next-state (-> state (cg/step tuple) (cg/settle-state))]
(when-not next-live
(throw (ex-info "Frontend step failed" {:program program :tuple tuple})))
(when (and (:op actual) (#{:resize :rotate :transform} (first tuple)))
(oracle/check-requested-geometry
(:objects (cthf/current-page (tm/file next-live)))
(tm/shape-by-id next-live (get-in actual [:shape :id]))
(cg/requested-geometry live actual (first tuple))))
(try
(oracle/check next-live (live-model next-state next-live))
(catch :default error
(throw (ex-info (str "Frontend oracle at " tuple ": " (ex-message error))
(ex-data error) error))))
(let [parity {:relative-free-head-placement true}
expected (oracle/canonical (:situation next-state) parity)
actual (oracle/canonical next-live parity)]
(t/is (true? (oracle/equivalent? expected actual))
(str "Backend mismatch at " tuple "; replay " (pr-str program)
"; diff " (pr-str (thn/diff expected actual)))))
(t/is (empty? (uc/failures next-live)) (pr-str (uc/failures next-live)))
(recur next-state next-live (rest tuples))))
(let [checked (await (ftm/finish-generated live))]
(t/is (empty? (uc/failures checked)) (pr-str (uc/failures checked)))
(ftm/uninstall!)))))
(catch :default error
(ftm/uninstall!)
(t/is false (str (ex-message error) "\nReplay: " (pr-str program)
"\nDetails: " (pr-str (ex-data error)))))))
(defn- live-model
[state live]
(let [by-path (into {} (map (juxt :path (comp :id :shape))) (cg/tree live))]
@ -75,6 +128,53 @@
(t/is false (str (ex-message error) "\nReplay: " (pr-str program)
"\nDetails: " (pr-str (ex-data error)))))))
(t/deftest ^:async nesting-a-swapped-copy-in-a-blocked-main-authors-its-lock
(await (replay {:world [2 0 {:library true :variants true :rich-variants true
:text true :text-styles true :layout nil :layout-copies true}]
:ops [[:style 3 2 1] [:swap 0 0 0 0] [:nest 0 0 0 0]
[:undo] [:redo]]})))
(t/deftest ^:async detaching-a-rotated-switched-copy-keeps-nested-placement-stable
(await (replay {:world [2 0 {:library true :variants true :rich-variants true
:text true :text-styles true :layout nil :layout-copies true}]
:ops [[:duplicate 1 0 0 0] [:duplicate 1 0 0 0] [:switch 3 0 0 0]
[:rotate 5 0 0 0] [:detach 5 0 0 0]
[:undo] [:undo] [:undo] [:undo] [:undo]
[:redo] [:redo] [:redo] [:redo] [:redo]]})))
(t/deftest ^:async geometry-actions-replay-on-mains-and-copy-descendants
(doseq [action (range 6) scope (range 5)]
(await (replay {:world [2 2]
:ops [[:transform 0 action 3 scope] [:undo] [:redo]]}))))
(t/deftest ^:async text-style-units-replay-through-editor-commits
(doseq [unit (range 12)]
(await (replay {:world [2 1 {:text true :text-styles true}]
:ops [[:text-style 1 unit 1] [:undo] [:redo]]}))))
(t/deftest ^:async reflecting-a-rotated-copy-settles-descendant-flips
(await (replay {:world [2 1 {:text true :layout :grid}]
:ops [[:rotate 1] [:transform 2 16 0 9]]})))
(t/deftest ^:async swapping-after-a-resized-variant-keeps-child-placement
(await (replay {:world [2 2 {:variants true :variant-diff false :rich-variants true
:text true :layout nil :layout-copies true}]
:ops [[:resize 0] [:switch 0] [:swap 0]]})))
(t/deftest ^:async switching-after-a-main-move-and-child-removal-stays-settled
(await (replay {:world [2 0 {:library true :variants true :rich-variants true :text true
:layout :flex :layout-copies true}]
:ops [[:delete 0] [:restore 0] [:transform 4 0 0 0] [:remove-child 8]
[:style 5 7 0 0] [:switch 4] [:rotate 0 2 0 0]]})))
(t/deftest ^:async reflecting-a-rotated-nested-copy-settles-descendant-flips
(await (replay {:world [2 1 {:text true :layout :grid}]
:ops [[:nest 11] [:rotate 1] [:transform 2 16 0 18]]})))
(t/deftest ^:async detach-keeps-an-authored-swap-inside-a-surviving-copy
(await (replay {:world [2 2 {:variants true :variant-diff false}]
:ops [[:switch 10] [:switch 0] [:detach 2]]})))
(t/deftest ^:async seeded-programs-replay-through-the-frontend
(doseq [seed [712 20261022 1792691]]
(await (replay (gen/generate cg/program-gen 20 seed)))))
@ -86,6 +186,10 @@
(doseq [seed [712 20261022]]
(await (replay (gen/generate cg/structure-program-gen 10 seed)))))
(t/deftest ^:async moving-a-copy-child-uses-its-own-pre-edit-frame
(await (replay {:world [2 1]
:ops [[:transform 0 3 0 2] [:transform 0 0 2 2] [:undo] [:redo]]})))
(t/deftest ^:async nested-text-rotation-shrunk-regression
(await (replay {:world [2 0 {:text true}]
:ops [[:nest 0] [:detach 0] [:rotate 0]]})))
@ -184,6 +288,18 @@
[:resize 0 0 0 0] [:switch 2 0 0 0] [:rotate 1 0 0 0]
[:remove-child 0 0 0 0]]})))
(t/deftest ^:async applying-main-typography-drops-a-mixed-copys-link-without-an-override
(await (replay {:world [2 0 {:library true :variants true :rich-variants true
:text true :text-styles true :layout nil :layout-copies true}]
:ops [[:swap 0 0 0 0] [:text 23 3 1 0] [:text-style 22 8 1]
[:undo] [:undo] [:undo] [:redo] [:redo] [:redo]]})))
(t/deftest ^:async detaching-after-a-nested-switch-keeps-placement-stable-through-sync
(await (replay {:world [2 2 {:library true :variants true :rich-variants true
:text true :text-styles true :layout :flex :layout-copies true}]
:ops [[:nest 7 0 0 0] [:switch 3 0 0 0] [:style 3 7 1] [:detach 6 0 0 0]
[:undo] [:undo] [:undo] [:undo] [:redo] [:redo] [:redo] [:redo]]})))
(t/deftest ^:async generated-library-switch-keeps-overrides-from-a-deleted-near-main
(await (replay {:world [2 1 {:library true :variants true}]
:ops [[:edit 0 0 1 2] [:update-main 0] [:library-sync]

View File

@ -17,7 +17,9 @@
[app.common.data :as d]
[app.common.files.changes-builder :as pcb]
[app.common.files.tokens :as cfo]
[app.common.geom.rect :as grc]
[app.common.logic.shapes :as cls]
[app.common.test-helpers.composable.comp.files :as cf]
[app.common.test-helpers.composable.comp.nodes :as n]
[app.common.test-helpers.composable.comp.undo-check :as uc]
[app.common.test-helpers.composable.core :as tm]
@ -82,9 +84,8 @@
(declare uninstall!)
;; Whether shapes were WASM shape proxies before the running test. A test that
;; starts the WASM renderer leaves `cts/wasm-enabled?` on for the tests after
;; it, and a proxy leaves out the attributes that are nil or false, so the
;; cases run on shape records whatever ran before them.
;; starts the WASM renderer can leave `cts/wasm-enabled?` on for later tests.
;; Cases use records; renderer boundary tests opt into proxies explicitly.
(defonce ^:private wasm-shapes-before (atom nil))
(def fixture
@ -161,12 +162,16 @@
id (tm/target-shape-id situation target)
shape (tm/shape-by-id situation id)
{:keys [content name]} (n/text-edit-commit shape edit value)]
[(dwtx/v2-update-text-shape-content id content
:update-name? (some? name)
:name name
:finalize? true
:save-undo? true
:original-content (:content shape))])
(if-let [{typography-id :id file-id :file-id} (:typography op)]
[(dwtx/apply-typography #{id}
(get-in (cf/all-files situation) [file-id :data :typographies typography-id])
file-id)]
[(dwtx/v2-update-text-shape-content id content
:update-name? (some? name)
:name name
:finalize? true
:save-undo? true
:original-content (:content shape))]))
(instance? n/Rotate op)
;; the sidebar rotation, which decides what it touches in copies (check-delta)
@ -177,7 +182,7 @@
;; the sidebar position, in page coordinates
(let [{:keys [target dx dy]} op
id (tm/target-shape-id situation target)
{:keys [x y]} (:selrect (tm/shape-by-id situation id))]
{:keys [x y]} (grc/points->rect (:points (tm/shape-by-id situation id)))]
[(dwt/update-position id {:x (+ x dx) :y (+ y dy)} {:absolute? true})])
(instance? n/ChangeHeight op)
@ -185,10 +190,23 @@
(let [{:keys [target value]} op]
[(dwt/update-dimensions [(tm/target-shape-id situation target)] :height value)])
(instance? n/TransformShape op)
(let [{:keys [target action value]} op
id (tm/target-shape-id situation target)
shape (tm/shape-by-id situation id)]
(case action
:move (let [[dx dy] value
{:keys [x y]} (grc/points->rect (:points shape))]
[(dwt/update-position id {:x (+ x dx) :y (+ y dy)} {:absolute? true})])
(:width :height) [(dwt/update-dimensions [id] action value)]
:rotate [(dwt/increase-rotation [id] value {:delta? true})]
:flip-x [(dwt/flip-horizontal-selected [id])]
:flip-y [(dwt/flip-vertical-selected [id])]))
(instance? n/SwapShape op)
(let [{:keys [target to keep-touched?]} op]
[(dwl/component-swap (tm/shape-by-id situation (tm/target-shape-id situation target))
(:id (tm/file situation))
(n/swap-target-file-id situation to)
(n/swap-target-id situation to)
(boolean keep-touched?))])
@ -307,7 +325,7 @@
(instance? n/SyncFromLibrary op)
;; the library update the "library updated" dialog runs
[(dwl/sync-file (:current-file-id @st/state) (n/library-id situation))]
[(dwl/sync-file (:current-file-id @st/state) (or (:source op) (n/library-id situation)))]
(instance? n/Undo op)
(vec (repeat (:times op) dwu/undo))
@ -433,6 +451,24 @@
(recur (tm/record-choice situation op) (tm/choice-of op))
situation))
(defn- record-op
"`situation` with the live file and the application of the settled op unit
`op`: its choices first, then the op's own fields and its
`n/applied-result`, if any."
[situation op]
(let [before (tm/file situation)
situation (-> situation
(refresh-generated)
(record-choices op))
op (unwrap op)
record (cond-> (dissoc (into {} op) ::tm/id)
(and (instance? n/SyncFromLibrary op) (nil? (:source op)))
(dissoc :source)
(satisfies? n/IAppliedResult op)
(merge (n/applied-result op before (tm/file situation))))]
(tm/record-application situation op record)))
(defn- record-op
"`situation` with the live file and the application of the settled op unit
`op`: its choices first, then the op's own fields and its
@ -444,6 +480,9 @@
(record-choices op))
op (unwrap op)
record (cond-> (dissoc (into {} op) ::tm/id)
(and (instance? n/SyncFromLibrary op) (nil? (:source op)))
(dissoc :source)
(satisfies? n/IAppliedResult op)
(merge (n/applied-result op before (tm/file situation))))]
(tm/record-application situation op record)))

View File

@ -11,7 +11,10 @@
[cljs.test :as t :include-macros true]))
(def ^:private attrs
{:id (uuid/next) :type :rect :name "Rect" :x 10 :y 20})
"A shape with every base field, which the proxy always holds."
{:id (uuid/next) :type :rect :name "Rect" :x 10 :y 20 :width nil :height nil
:rotation nil :selrect nil :points nil :transform nil :transform-inverse nil
:parent-id nil :frame-id nil :flip-x nil :flip-y nil})
(t/deftest count-includes-id-and-type
(let [shape (wasm.shape/create-shape attrs)]

View File

@ -0,0 +1,30 @@
;; 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-test
(:require
[app.common.test-helpers.composable.gen :as cg]
[app.common.types.shape :as cts]
[app.common.uuid :as uuid]
[app.render-wasm.shape :as shape]
[cljs.test :as t]))
(t/deftest fresh-proxies-keep-the-records-base-fields
(let [attrs {:id (uuid/next) :type :rect :name "Rect" :opacity 0.5}
expected (into {} (cts/map->Shape attrs))
actual (shape/create-shape attrs)]
(t/is (= expected (into {} actual)))
(doseq [attr [:rotation :flip-x :flip-y :transform :transform-inverse]]
(t/testing (name attr)
(t/is (contains? actual attr))
(t/is (= expected (into {} (dissoc (assoc actual attr true) attr))))))))
(t/deftest reflected-nested-proxies-undo-without-adding-flip-fields
(with-redefs [cts/wasm-enabled? true
cts/wasm-create-shape shape/create-shape]
(let [result (cg/run {:world [2 1 {:text true :layout :grid}]
:ops [[:nest 11] [:rotate 1] [:transform 2 16 0 18]]})]
(t/is (= 3 (count (:trace result)))))))

View File

@ -128,6 +128,7 @@
[frontend-tests.render-wasm.process-objects-test]
[frontend-tests.render-wasm.serialization-test]
[frontend-tests.render-wasm.shape-proxy-test]
[frontend-tests.render-wasm.shape-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]
@ -350,6 +351,7 @@
'frontend-tests.render-wasm.process-objects-test
'frontend-tests.render-wasm.serialization-test
'frontend-tests.render-wasm.shape-proxy-test
'frontend-tests.render-wasm.shape-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