From 31493b15258e1e34d77b70daeb3ddea30ba953e0 Mon Sep 17 00:00:00 2001 From: Eva Marco Date: Thu, 1 Oct 2026 14:02:34 +0200 Subject: [PATCH] :bug: 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 --- .../logic/transform_in_variant_test.cljs | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/frontend/test/frontend_tests/logic/transform_in_variant_test.cljs b/frontend/test/frontend_tests/logic/transform_in_variant_test.cljs index 9a6786cac9..5c674e117f 100644 --- a/frontend/test/frontend_tests/logic/transform_in_variant_test.cljs +++ b/frontend/test/frontend_tests/logic/transform_in_variant_test.cljs @@ -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))))