OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add feature specs for Esc key dismiss strategy
Kabiru Mwenja50e32dd35d8b
diff --git a/spec/features/activities/work_package/activity_tab_comment_editor_spec.rb b/spec/features/activities/work_package/activity_tab_comment_editor_spec.rbnew file mode 100644index 00000000000..6e09de34ace--- /dev/null+++ b/spec/features/activities/work_package/activity_tab_comment_editor_spec.rb@@ -0,0 +1,76 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require "spec_helper"++RSpec.describe "Work package activity tab comment editor",+ :js,+ :with_cuprite,+ with_flag: { comments_with_restricted_visibility: true } do+ let(:project) { create(:project) }+ let(:admin) { create(:admin) }+ let(:work_package) { create(:work_package, project:, author: admin) }++ let(:wp_page) { Pages::FullWorkPackage.new(work_package, project) }+ let(:activity_tab) { Components::WorkPackages::Activities.new(work_package) }++ describe "Dismiss strategy" do+ current_user { admin }++ before do+ wp_page.visit!+ wp_page.wait_for_activity_tab+ end++ context "when editor content is empty" do+ it "is dismissable via keyboard Esc" do+ activity_tab.add_comment(text: "Sample text", save: false)+ activity_tab.clear_comment++ activity_tab.expect_focus_on_editor+ activity_tab.dismiss_comment_editor_with_esc++ expect(page).not_to have_test_selector("op-work-package-journal-form-element")+ end+ end++ context "when editor content is not empty" do+ it "is not dismissable via keyboard Esc" do+ activity_tab.add_comment(text: "Sample text", save: false)++ activity_tab.expect_focus_on_editor+ activity_tab.dismiss_comment_editor_with_esc++ activity_tab.expect_focus_on_editor+ expect(page).to have_test_selector("op-work-package-journal-form-element")+ end+ end+ end+enddiff --git a/spec/support/components/work_packages/activities.rb b/spec/support/components/work_packages/activities.rbindex d9d4933408f..517ffc416dd 100644--- a/spec/support/components/work_packages/activities.rb+++ b/spec/support/components/work_packages/activities.rb@@ -300,6 +300,10 @@ module Componentsexpect(page).to have_test_selector("op-work-package-journal-form-element")end+ def dismiss_comment_editor_with_esc+ page.find_test_selector("op-work-package-journal-form-element").send_keys(:escape)+ end+def get_all_comments_as_arraypage.all(".work-packages-activities-tab-journals-item-component--journal-notes-body").map(&:text)end