mirror of
https://github.com/penpot/penpot.git
synced 2026-10-30 06:20:32 +00:00
A coverage run found sync paths that no test ran. New cases, in both runners: - AK: update main into a grid main. With a swapped child the main's cells keep the copy child's id (F49, pinned). - AL: update main after renaming the copy root and its child. - AM: update main of a swap inside a group. The copy child keeps a swap slot that names a removed main child (F16, pinned). - AN: a copy flex child's margin override through a main edit, a reset and update main. The frontend round trip of the main edit shows F43 with real sizes (pinned). - AO: a copy dropped into a grid cell of a main. Its undo shows F41 (pinned). - AP: a library main deletes a middle child. - AQ: a main change reaches a copy nested in a sub-board. Also: the frontend interpreter sends the real reset event instead of installing a file; a test undoes and redoes an undo entry without a group, which only release builds store; a test confirms F50, a copy text touched only in :content-group losing its override (pinned).
76 lines
3.1 KiB
Clojure
76 lines
3.1 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.workspace-undo-test
|
|
"Tests undo and redo of an undo entry with no undo group. The entry schema
|
|
requires a group, but release builds elide the check, so a commit that
|
|
passes a nil `:undo-group` stores such an entry; undo and redo take a
|
|
branch of their own for it."
|
|
(:require
|
|
[app.common.files.changes-builder :as pcb]
|
|
[app.common.logic.shapes :as cls]
|
|
[app.common.test-helpers.composable.comp.setups :as setup]
|
|
[app.common.test-helpers.files :as thf]
|
|
[app.common.test-helpers.ids-map :as thi]
|
|
[app.common.test-helpers.shapes :as ths]
|
|
[app.main.data.changes :as dch]
|
|
[app.main.data.workspace.undo :as dwu]
|
|
[app.main.store :as st]
|
|
[cljs.test :as t :include-macros true]
|
|
[frontend-tests.composable-tests.interpreter :as ftm]
|
|
[potok.v2.core :as ptk]))
|
|
|
|
(t/use-fixtures :each ftm/fixture)
|
|
|
|
(def ^:private red "#ff0000")
|
|
|
|
(defn- fill-main-child-changes
|
|
"The changes that fill the main child of the live file `color`."
|
|
[color]
|
|
(let [page (thf/current-page (ftm/current-file))]
|
|
(cls/generate-update-shapes (pcb/empty-changes nil (:id page))
|
|
#{(thi/id :main-child)}
|
|
#(assoc % :fills (ths/sample-fills-color :fill-color color))
|
|
(:objects page)
|
|
{})))
|
|
|
|
(defn- push-entry-without-group
|
|
"An event that adds `changes` to the undo stack as an entry with no undo
|
|
group, as a release build stores a commit whose `:undo-group` is nil."
|
|
[changes]
|
|
(ptk/reify ::push-entry-without-group
|
|
ptk/UpdateEvent
|
|
(update [_ state]
|
|
(update state :workspace-undo
|
|
(fn [undo]
|
|
(let [items (conj (vec (:items undo))
|
|
{:undo-changes (:undo-changes changes)
|
|
:redo-changes (:redo-changes changes)
|
|
:tags #{}})]
|
|
(assoc undo :items items :index (dec (count items)))))))))
|
|
|
|
(defn- undo-index
|
|
[]
|
|
(get-in @st/state [:workspace-undo :index]))
|
|
|
|
(t/deftest ^:async undo-and-redo-an-entry-without-undo-group
|
|
(ftm/install! (setup/simple-component-with-labeled-copy))
|
|
(let [changes (fill-main-child-changes red)]
|
|
(await (ftm/await-step [(dch/commit-changes {:redo-changes (:redo-changes changes)
|
|
:undo-changes (:undo-changes changes)
|
|
:save-undo? false})
|
|
(push-entry-without-group changes)]))
|
|
(t/is (= red (ftm/fill-of :main-child)))
|
|
(t/is (= 0 (undo-index)))
|
|
|
|
(t/is (= :settled (await (ftm/await-step [dwu/undo]))))
|
|
(t/is (= setup/labeled-fill (ftm/fill-of :main-child)))
|
|
(t/is (= -1 (undo-index)))
|
|
|
|
(t/is (= :settled (await (ftm/await-step [dwu/redo]))))
|
|
(t/is (= red (ftm/fill-of :main-child)))
|
|
(t/is (= 0 (undo-index)))))
|