diff --git a/frontend/src/app/main/data/changes.cljs b/frontend/src/app/main/data/changes.cljs index bd8afa6ff7..df0fc760c9 100644 --- a/frontend/src/app/main/data/changes.cljs +++ b/frontend/src/app/main/data/changes.cljs @@ -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}) diff --git a/frontend/test/frontend_tests/data/changes_test.cljs b/frontend/test/frontend_tests/data/changes_test.cljs new file mode 100644 index 0000000000..11783fde85 --- /dev/null +++ b/frontend/test/frontend_tests/data/changes_test.cljs @@ -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))))) diff --git a/frontend/test/frontend_tests/runner.cljs b/frontend/test/frontend_tests/runner.cljs index 2ec569d1c5..ec982cde90 100644 --- a/frontend/test/frontend_tests/runner.cljs +++ b/frontend/test/frontend_tests/runner.cljs @@ -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