diff --git a/frontend/src/app/main/ui/workspace/context_menu.cljs b/frontend/src/app/main/ui/workspace/context_menu.cljs index 7e7423b7b0..b65061072c 100644 --- a/frontend/src/app/main/ui/workspace/context_menu.cljs +++ b/frontend/src/app/main/ui/workspace/context_menu.cljs @@ -602,7 +602,7 @@ (when (and prototype? is-frame?) (if-let [flow (ctp/get-frame-flow flows (-> shapes first :id))] [:> menu-entry* {:title (tr "workspace.shape.menu.delete-flow-start") - :on-click (do-remove-flow flow)}] + :on-click #(do-remove-flow flow)}] [:> menu-entry* {:title (tr "workspace.shape.menu.flow-start") :on-click do-add-flow}])))) diff --git a/frontend/test/frontend_tests/runner.cljs b/frontend/test/frontend_tests/runner.cljs index 58bf75b0b4..a4c9e6fed0 100644 --- a/frontend/test/frontend_tests/runner.cljs +++ b/frontend/test/frontend_tests/runner.cljs @@ -187,6 +187,7 @@ [frontend-tests.ui.comment-input-ime-test] [frontend-tests.ui.comments-clustering-test] [frontend-tests.ui.comments-position-modifier-test] + [frontend-tests.ui.context-menu-prototype-test] [frontend-tests.ui.dashboard-import-linking-test] [frontend-tests.ui.drawarea-test] [frontend-tests.ui.ds-controls-numeric-input-test] @@ -443,6 +444,7 @@ 'frontend-tests.ui.comment-input-ime-test 'frontend-tests.ui.comments-clustering-test 'frontend-tests.ui.comments-position-modifier-test + 'frontend-tests.ui.context-menu-prototype-test 'frontend-tests.ui.dashboard-import-linking-test 'frontend-tests.ui.drawarea-test 'frontend-tests.ui.ds-controls-numeric-input-test diff --git a/frontend/test/frontend_tests/ui/context_menu_prototype_test.cljs b/frontend/test/frontend_tests/ui/context_menu_prototype_test.cljs new file mode 100644 index 0000000000..1b41fca5b1 --- /dev/null +++ b/frontend/test/frontend_tests/ui/context_menu_prototype_test.cljs @@ -0,0 +1,45 @@ +;; 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.ui.context-menu-prototype-test + (:require + ["react-dom/server" :as rds] + [app.common.uuid :as uuid] + [app.main.refs :as refs] + [app.main.store :as st] + [app.main.ui.workspace.context-menu :as cm] + [app.util.i18n :as i18n] + [cljs.test :as t :include-macros true] + [cuerdas.core :as str] + [frontend-tests.helpers.mock :as mock] + [okulary.core :as l] + [rumext.v2 :as mf])) + +(defn- render-menu + "Render the prototype entries for `frame`, returning the markup and the + events emitted while rendering." + [flows frame] + (let [events (atom []) + markup (with-redefs [refs/workspace-page-flows (l/atom flows) + refs/options-mode-global (l/atom :prototype) + st/emit! (mock/stub (fn [& emitted] (swap! events into emitted))) + i18n/tr (mock/stub (fn [key] key))] + (rds/renderToStaticMarkup + (mf/element @#'cm/context-menu-prototype* #js {:shapes [frame]})))] + {:markup markup :events @events})) + +(t/deftest a-flow-start-board-menu-offers-removing-the-flow-without-removing-it + (let [frame-id (uuid/next) + flow-id (uuid/next) + flows {flow-id {:id flow-id :name "Flow 1" :starting-frame frame-id}} + {:keys [markup events]} (render-menu flows {:id frame-id :type :frame})] + (t/is (str/includes? markup "workspace.shape.menu.delete-flow-start")) + (t/is (= [] events)))) + +(t/deftest a-plain-board-menu-offers-a-flow-start + (let [{:keys [markup events]} (render-menu {} {:id (uuid/next) :type :frame})] + (t/is (str/includes? markup "workspace.shape.menu.flow-start")) + (t/is (= [] events))))