mirror of
https://github.com/penpot/penpot.git
synced 2026-10-29 14:00:37 +00:00
🐛 Wait for the delayed focus in transform-in-variant test
transform-in-variant focuses the first property field 250ms after the transformation. The test ended before that, and the delayed effect ran during a later test, where dom/get-element failed as there is no document in the test runner. Each run, a different test failed. Wait for the focus-property event, and stub dom/get-element meanwhile. AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
8a3dd86c72
commit
31493b1525
@ -12,9 +12,12 @@
|
||||
[app.common.test-helpers.shapes :as cths]
|
||||
[app.common.types.component :as ctk]
|
||||
[app.main.data.workspace.variants :as dwv]
|
||||
[app.util.dom :as dom]
|
||||
[beicon.v2.core :as rx]
|
||||
[cljs.test :as t :include-macros true]
|
||||
[frontend-tests.helpers.pages :as thp]
|
||||
[frontend-tests.helpers.state :as ths]))
|
||||
[frontend-tests.helpers.state :as ths]
|
||||
[potok.v2.core :as ptk]))
|
||||
|
||||
(t/use-fixtures :each
|
||||
{:before thp/reset-idmap!})
|
||||
@ -22,20 +25,32 @@
|
||||
(t/deftest transform-component-in-variant
|
||||
"Ctrl+K on a component main turns it into a variant. Each step of the event
|
||||
chain is validated, so a validation error here fails the test through the
|
||||
store error handler."
|
||||
store error handler.
|
||||
|
||||
At the end the event focuses the first property field, 250ms later. Wait
|
||||
for it, so it does not run during another test, and stub the DOM lookup,
|
||||
as there is no document in the test runner."
|
||||
(t/async
|
||||
done
|
||||
(let [;; ==== Setup
|
||||
file (-> (cthf/sample-file :file1)
|
||||
(ctho/add-simple-component :c01 :m01 :r01))
|
||||
store (ths/setup-store file)
|
||||
main (cths/get-shape file :m01)
|
||||
file (-> (cthf/sample-file :file1)
|
||||
(ctho/add-simple-component :c01 :m01 :r01))
|
||||
store (ths/setup-store file)
|
||||
main (cths/get-shape file :m01)
|
||||
|
||||
get-element dom/get-element
|
||||
done' (fn []
|
||||
(set! dom/get-element get-element)
|
||||
(done))
|
||||
stopper #(rx/filter (ptk/type? ::dwv/focus-property) %)
|
||||
|
||||
;; ==== Action
|
||||
events [(dwv/transform-in-variant (:id main))]]
|
||||
events [(dwv/transform-in-variant (:id main))]]
|
||||
|
||||
(set! dom/get-element (constantly nil))
|
||||
|
||||
(ths/run-store
|
||||
store done events
|
||||
store done' events
|
||||
(fn [new-state]
|
||||
(let [;; ==== Get
|
||||
file' (ths/get-file-from-state new-state)
|
||||
@ -47,4 +62,5 @@
|
||||
(t/is (ctk/is-variant-container? container'))
|
||||
(t/is (= (:id container') (:variant-id main')))
|
||||
(t/is (= (:id container') (:variant-id comp')))
|
||||
(t/is (= 1 (count (:variant-properties comp'))))))))))
|
||||
(t/is (= 1 (count (:variant-properties comp'))))))
|
||||
stopper))))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user