penpot/frontend/test/frontend_tests/data/changes_test.cljs
alonso.torres eee28e36bb ♻️ Tidy the composable suite and make its cases stricter
A review of the suite after the new operations:
- Dead helpers and duplicate nodes go; the lineage reset and swap
  nodes are constructors of reset and swap-shape.
- Repeated helpers are shared: grid boards (tho/add-grid-frame,
  tho/place-in-grid-columns), n/nested-head-under, n/child-shape,
  r/sync-cascade (the benchmark uses it too), the frontend fixture and
  fill helpers, and the plugin getMainComponent.
- Runner tests that repeated cases B, C and D go.
- Comments say what the code does, and the wrong ones are fixed.
- Case K's remote edit painted red on red and its unedited variants
  asserted nothing; it starts grey and every variant asserts.
- F43 is pinned in one case, AJ, by the value one undo leaves. L, M, Q
  and K get real frame sizes, since their pins depended on when the
  100 ms layout buffer flushed.
- make-nested-component takes a level count and depth-sweep gives each
  depth once, so K, Q, R, T and W stop running depth 1 twice.
- The completion-contract tests no longer depend on fixed pauses or
  on how the watcher batches its events.

Benchmark against the baseline (lower quantile): ratios 0.92 to 1.03,
no world flagged.
2026-10-28 15:47:15 +01:00

38 lines
1.7 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 frontend-tests.data.changes-test
(:require
[app.common.files.changes-builder :as pcb]
[app.common.test-helpers.composable.comp.setups :as setup]
[app.common.test-helpers.ids-map :as thi]
[app.main.data.changes :as dch]
[app.main.store :as st]
[app.plugins.reflow :as pwrf]
[cljs.test :as t :include-macros true]
[frontend-tests.composable-tests.interpreter :as ftm]))
(t/use-fixtures :each ftm/fixture)
(t/deftest change-without-page-leaves-the-pages-alone
(t/async done
(ftm/install! (setup/simple-component-with-copy))
(let [file (ftm/current-file)
pages (set (keys (get-in file [:data :pages-index])))
changes (-> (pcb/empty-changes)
(pcb/with-library-data (:data file))
(pcb/update-component (thi/id :component1)
#(assoc % :annotation "Note")))]
(st/emit! (dch/commit-changes {:redo-changes (:redo-changes changes)
:undo-changes (:undo-changes changes)}))
(-> (pwrf/wait-for-layout-update nil 2000)
(.then (fn []
(let [data (:data (ftm/current-file))]
(t/is (= "Note" (get-in data [:components (thi/id :component1) :annotation])))
(t/is (= pages (set (keys (:pages-index data))))))))
(.catch #(t/is false (str "the commit did not settle: " %)))
(.finally done)))))