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
Fix flaky spec
Christophe Bliarddca3349fc59f
diff --git a/.rubocop.yml b/.rubocop.ymlindex 97c693f210e..4844bdfb944 100644--- a/.rubocop.yml+++ b/.rubocop.yml@@ -25,6 +25,12 @@ AllCops:Exclude:- '**/node_modules/**/*'+# Disable it as it is deprecated+# From https://docs.rubocop.org/rubocop-capybara/cops_capybara.html#capybaraclicklinkorbuttonstyle+# "This cop is deprecated. We plan to remove this in the next major version update to 3.0."+Capybara/ClickLinkOrButtonStyle:+ Enabled: false+FactoryBot/ConsistentParenthesesStyle:Enabled: falsediff --git a/modules/costs/spec/features/cost_entries/add_cost_entry_spec.rb b/modules/costs/spec/features/cost_entries/add_cost_entry_spec.rbindex ed6e6b39dd1..d7879c83bda 100644--- a/modules/costs/spec/features/cost_entries/add_cost_entry_spec.rb+++ b/modules/costs/spec/features/cost_entries/add_cost_entry_spec.rb@@ -70,12 +70,8 @@ RSpec.describe "Work Package cost fields", :js doit "does not show read-only fields" dofull_view.visit!- # Go to add cost entry page- SeleniumHubWaiter.wait- find("#action-show-more-dropdown-menu .button").click- find(".menu-item", text: "Log unit costs").click+ full_view.select_log_unit_costs_action- SeleniumHubWaiter.wait# Set single value, should update suffixselect "A", from: "cost_entry_cost_type_id"fill_in "cost_entry_units", with: "1"@@ -116,15 +112,12 @@ RSpec.describe "Work Package cost fields", :js doI18n.locale = :defull_view.visit!+ full_view.select_log_unit_costs_action- # Go to add cost entry page- SeleniumHubWaiter.wait- find("#action-show-more-dropdown-menu .button").click- find(".menu-item", text: I18n.t(:button_log_costs)).click+ fill_in CostEntry.human_attribute_name(:units), with: "1,42"+ expect(page).to have_css("#cost_entry_costs", text: "1,42 EUR")- SeleniumHubWaiter.wait- fill_in "cost_entry_units", with: "1,42"- select "B", from: "cost_entry_cost_type_id"+ select "B", from: CostEntry.human_attribute_name(:cost_type)expect(page).to have_css("#cost_entry_unit_name", text: "B plural")expect(page).to have_css("#cost_entry_costs", text: "2,84 EUR")@@ -174,11 +167,7 @@ RSpec.describe "Work Package cost fields", :js doexpect(placeholder_user).to be_presentexpect(Principal.possible_assignee(project).to_a).to include placeholder_userfull_view.visit!-- # Go to add cost entry page- SeleniumHubWaiter.wait- find("#action-show-more-dropdown-menu .button").click- find(".menu-item", text: I18n.t(:button_log_costs)).click+ full_view.select_log_unit_costs_actionSeleniumHubWaiter.waitexpect(page).to have_no_css("#cost_entry_user_id option", text: placeholder_user.name, visible: :all)diff --git a/spec/support/pages/work_packages/cost_entries.rb b/spec/support/pages/work_packages/cost_entries.rbnew file mode 100644index 00000000000..399eed12d00--- /dev/null+++ b/spec/support/pages/work_packages/cost_entries.rb@@ -0,0 +1,46 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 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 "support/pages/page"++module Pages+ module WorkPackages+ class CostEntries < Page+ # Wait for the :spent_on date field to be loaded. It's backed by a+ # flatpickr instance.+ #+ # The javascript on the "Log unit costs" creation page won't work until+ # this date field is correctly loaded and displayed+ def wait_for_spent_on_date_field_to_be_loaded+ page.has_field?(CostEntry.human_attribute_name(:spent_on))+ end+ end+ end+enddiff --git a/spec/support/pages/work_packages/full_work_package.rb b/spec/support/pages/work_packages/full_work_package.rbindex 6c9aa88b7a9..f298d41ff8d 100644--- a/spec/support/pages/work_packages/full_work_package.rb+++ b/spec/support/pages/work_packages/full_work_package.rb@@ -87,6 +87,13 @@ module Pagesendend+ def select_log_unit_costs_action+ SeleniumHubWaiter.wait+ click_button(I18n.t("js.button_more"))+ find(:menuitem, text: I18n.t(:button_log_costs)).click+ Pages::WorkPackages::CostEntries.new.wait_for_spent_on_date_field_to_be_loaded+ end+def wait_for_activity_tabexpect(page).to have_test_selector("op-wp-activity-tab", wait: 10)# wait for stimulus js component to be mounted