mirror of
https://github.com/penpot/penpot.git
synced 2026-11-19 16:40:38 +00:00
The composable interpreter treated a step as done after a 60 ms gap
with no commits, and treated its 2 s timeout as done too. Slow sync or
reflow work could finish after the step, so a case could assert on a
half-synced file.
Each event step now waits, as the plugin waitForLayoutUpdate does,
until every pending work tracked by the reflow registry has drained:
the watcher's sync wait, the sync it starts, and layout and text
reflow. A step that does not drain within 2 s fails the test and names
the work still pending, and the next variant starts with nothing
pending.
The tests cover an edit with a deliberately slow sync, undo and redo
steps that must wait for the watcher's touch-component, translation
and derived commits, a sync that never finishes, and a restart of the
edit watchers, which must keep the undo entries of an edit the same.
Also in this commit:
- 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.
- Check undo and redo of every step in the composable cases. The composable
cases tested undo only where a case asked for it, so a change generator with a
wrong inverse, or a step that splits into several undo entries, went
unnoticed.
- Add operations and cases to the composable component suites. The composable
runners could edit, add, remove and move children, swap and switch, but not
run the other component operations.
- Test component validation, repair and library asset sync.
- Add a component sync benchmark with a recorded baseline. The coming refactors
and fixes change sync code, and a slowdown must be seen and explained in the
commit that causes it.
- Tidy the composable suite and make its cases stricter.
- Test the component sync paths no test reached. A coverage run found sync paths
that no test ran.
- Test variant events, token sync and switch overrides. The variant events had
almost no frontend tests, and several switch, paste, token and restore paths
never ran.
- Test the file and container helpers and the library events. The component
helpers of types/file and types/container and the library events of the
workspace had the lowest coverage left.
38 lines
1.7 KiB
Clojure
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)))))
|