mirror of
https://github.com/penpot/penpot.git
synced 2026-10-29 14:00:37 +00:00
🐛 Keep page-less changes from adding a nil page
Applying a commit locally rebuilds the object indices of every page its
changes name. Changes that touch no page, such as :mod-component, name
none, and their nil page id was rebuilt too: the file data in the store
gained a page under a nil key holding {:objects nil}. Every component
touch after an edit to a main added it, and undo never removed it.
Rebuild the indices only for the page ids the changes carry.
This commit is contained in:
parent
a4d42c72db
commit
ded39ee2df
@ -75,7 +75,7 @@
|
||||
(not-empty)))
|
||||
|
||||
(def ^:private xf:map-page-id
|
||||
(map :page-id))
|
||||
(keep :page-id))
|
||||
|
||||
(def ^:private wasm-structural-change-types
|
||||
#{:add-obj :mov-objects})
|
||||
|
||||
43
frontend/test/frontend_tests/data/changes_test.cljs
Normal file
43
frontend/test/frontend_tests/data/changes_test.cljs
Normal file
@ -0,0 +1,43 @@
|
||||
;; 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]))
|
||||
|
||||
;; The component watcher schedules thumbnail renders that reach `window`,
|
||||
;; absent headless (see `ftm/install-thumbnail-noop!`).
|
||||
(t/use-fixtures :each
|
||||
{:before (fn []
|
||||
(thi/reset-idmap!)
|
||||
(ftm/install-thumbnail-noop!))
|
||||
:after ftm/restore-thumbnail!})
|
||||
|
||||
(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)))))
|
||||
@ -10,6 +10,7 @@
|
||||
[frontend-tests.composable-tests.comp.sync-test]
|
||||
[frontend-tests.composable-tests.completion-contract-test]
|
||||
[frontend-tests.copy-as-svg-test]
|
||||
[frontend-tests.data.changes-test]
|
||||
[frontend-tests.data.comments-filters-test]
|
||||
[frontend-tests.data.dashboard-test]
|
||||
[frontend-tests.data.event-test]
|
||||
@ -171,6 +172,7 @@
|
||||
'frontend-tests.composable-tests.comp.sync-test
|
||||
'frontend-tests.composable-tests.completion-contract-test
|
||||
'frontend-tests.copy-as-svg-test
|
||||
'frontend-tests.data.changes-test
|
||||
'frontend-tests.data.comments-filters-test
|
||||
'frontend-tests.data.dashboard-test
|
||||
'frontend-tests.data.event-test
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user