Skip to content

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

fix first batch of tests

Klaus Zanders3b3ee5110aea
diff --git a/modules/reporting/spec/features/support/components/cost_reports_base_table.rb b/modules/reporting/spec/features/support/components/cost_reports_base_table.rb
index 88611e39871..e34585e4b11 100644
--- a/modules/reporting/spec/features/support/components/cost_reports_base_table.rb
+++ b/modules/reporting/spec/features/support/components/cost_reports_base_table.rb
@@ -34,6 +34,7 @@ module Components
include Capybara::RSpecMatchers
include RSpec::Matchers
include Flash::Expectations
+ include Redmine::I18n
attr_reader :time_logging_modal
@@ -57,19 +58,22 @@ module Components
expect(page).to have_css("#{row_selector(row)} .units", text: value)
end
- def edit_time_entry(new_value, row)
+ def edit_time_entry(row, hours:)
SeleniumHubWaiter.wait
page.find("#{row_selector(row)} .icon-edit").click
time_logging_modal.is_visible true
- time_logging_modal.update_field "hours", new_value
- time_logging_modal.work_package_is_missing false
+ time_logging_modal.change_hours(hours)
+ # time_logging_modal.work_package_is_missing false
- time_logging_modal.perform_action "Save"
+ time_logging_modal.submit
SeleniumHubWaiter.wait
+ # TODO: ensure page reload ... should happen automatically and does so in the browser
+ page.refresh
+
expect_action_icon "edit", row
- expect_value new_value, row
+ expect_value l_hours(hours), row
end
def edit_cost_entry(new_value, row, cost_entry_id)
diff --git a/modules/reporting/spec/features/update_entries_spec.rb b/modules/reporting/spec/features/update_entries_spec.rb
index 783639f3e18..15322f32c0a 100644
--- a/modules/reporting/spec/features/update_entries_spec.rb
+++ b/modules/reporting/spec/features/update_entries_spec.rb
@@ -75,7 +75,7 @@ RSpec.describe "Updating entries within the cost report", :js, :selenium do
table.expect_action_icon "edit", 1
table.expect_action_icon "delete", 1
- table.edit_time_entry 2, 1
+ table.edit_time_entry 1, hours: 2
table.delete_entry 1
table.rows_count 0
diff --git a/spec/features/support/components/time_logging_modal.rb b/spec/features/support/components/time_logging_modal.rb
index 0d48bd11487..94d7aa70b4f 100644
--- a/spec/features/support/components/time_logging_modal.rb
+++ b/spec/features/support/components/time_logging_modal.rb
@@ -31,37 +31,39 @@ module Components
include Capybara::DSL
include Capybara::RSpecMatchers
include RSpec::Matchers
-
- attr_reader :activity_field,
- :comment_field,
- :hours_field,
- :spent_on_field,
- :work_package_field,
- :user_field
-
- def initialize
- @activity_field = EditField.new(page, "time_entry[activity_id]")
- @comment_field = EditField.new(page, "time_entry[comment]")
- @hours_field = EditField.new(page, "time_entry[hours]")
- @spent_on_field = EditField.new(page, "time_entry[spent_on]")
- @work_package_field = EditField.new(page, "time_entry[work_package_id]")
- @user_field = EditField.new(page, "time_entry[user_id]")
- end
+ include ::Components::Autocompleter::AutocompleteHelpers
def is_visible(visible)
if visible
within modal_container do
- expect(page)
- .to have_text(I18n.t("js.button_log_time"))
+ expect(page).to have_text(I18n.t("button_log_time"))
end
else
expect(page).to have_no_css "dialog#time-entry-dialog"
end
end
+ def change_hours(value)
+ within modal_container do
+ fill_in "time_entry_hours", with: value
+ end
+ end
+
+ def submit
+ within modal_container do
+ click_on I18n.t("button_log_time")
+ end
+ end
+
+ def cancel
+ within modal_container do
+ click_on I18n.t("button_cancel")
+ end
+ end
+
def has_field_with_value(field, value)
within modal_container do
- expect(page).to have_field field_identifier(field), with: value, visible: :all
+ expect(page).to have_field "#time_entry_#{field}", with: value, visible: :all
end
end
@@ -133,10 +135,6 @@ module Components
private
- def field_object(field_name)
- send(:"#{field_name}_field")
- end
-
def modal_container
page.find("dialog#time-entry-dialog")
end