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
Code maintenance/61390 enable disabled specs in spec/features/activities/work_package/activities_spec.rb (#17952)
Kabiru Mwenjaaf04154ec8e7
diff --git a/spec/features/activities/work_package/activities_spec.rb b/spec/features/activities/work_package/activities_spec.rbindex 61dc33e5da5..5ba32149254 100644--- a/spec/features/activities/work_package/activities_spec.rb+++ b/spec/features/activities/work_package/activities_spec.rb@@ -331,48 +331,45 @@ RSpec.describe "Work package activity", :js, :with_cuprite doendit "shows and merges activities and comments correctly", :aggregate_failures do- pending "works locally but is flaky on CI, reason unknown"- fail-- # first_journal = work_package.journals.first+ first_journal = work_package.journals.first- # # initial journal entry is shown without changeset or comment- # activity_tab.within_journal_entry(first_journal) do- # activity_tab.expect_journal_details_header(text: admin.name)- # activity_tab.expect_no_journal_notes- # activity_tab.expect_no_journal_changed_attribute- # end+ # initial journal entry is shown without changeset or comment+ activity_tab.within_journal_entry(first_journal) do+ activity_tab.expect_journal_details_header(text: admin.name)+ activity_tab.expect_no_journal_notes+ activity_tab.expect_no_journal_changed_attribute+ end- # wp_page.update_attributes(subject: "A new subject")- # wp_page.expect_and_dismiss_toaster(message: "Successful update.")+ wp_page.update_attributes(subject: "A new subject") # rubocop:disable Rails/ActiveRecordAliases+ wp_page.expect_and_dismiss_toaster(message: "Successful update.")- # second_journal = work_package.journals.second- # # even when attributes are changed, the initial journal entry is still not showing any changeset- # activity_tab.within_journal_entry(second_journal) do- # activity_tab.expect_journal_details_header(text: member.name)- # activity_tab.expect_journal_changed_attribute(text: "Subject")- # end+ second_journal = work_package.journals.second+ # even when attributes are changed, the initial journal entry is still not showing any changeset+ activity_tab.within_journal_entry(second_journal) do+ activity_tab.expect_journal_details_header(text: member.name)+ activity_tab.expect_journal_changed_attribute(text: "Subject")+ end- # # merges the second journal entry with the comment made by the user right afterwards- # activity_tab.add_comment(text: "First comment")+ # merges the second journal entry with the comment made by the user right afterwards+ activity_tab.add_comment(text: "First comment")- # activity_tab.within_journal_entry(second_journal) do- # activity_tab.expect_no_journal_details_header- # activity_tab.expect_journal_notes_header(text: member.name)- # activity_tab.expect_journal_notes(text: "First comment")- # end+ activity_tab.within_journal_entry(second_journal) do+ activity_tab.expect_no_journal_details_header+ activity_tab.expect_journal_notes_header(text: member.name)+ activity_tab.expect_journal_notes(text: "First comment")+ end- # travel_to (Setting.journal_aggregation_time_minutes.to_i.minutes + 1.minute).from_now- # # the journals will not be merged due to the time difference+ travel_to (Setting.journal_aggregation_time_minutes.to_i.minutes + 1.minute).from_now+ # the journals will not be merged due to the time difference- # wp_page.update_attributes(subject: "A new subject!!!")+ wp_page.update_attributes(subject: "A new subject!!!") # rubocop:disable Rails/ActiveRecordAliases- # third_journal = work_package.journals.third+ third_journal = work_package.journals.third- # activity_tab.within_journal_entry(third_journal) do- # activity_tab.expect_journal_details_header(text: member.name)- # activity_tab.expect_journal_changed_attribute(text: "Subject")- # end+ activity_tab.within_journal_entry(third_journal) do+ activity_tab.expect_journal_details_header(text: member.name)+ activity_tab.expect_journal_changed_attribute(text: "Subject")+ endendend@@ -494,93 +491,84 @@ RSpec.describe "Work package activity", :js, :with_cuprite dowp_page.wait_for_activity_tabend- it "filters the activities based on type", :aggregate_failures do # rubocop:disable RSpec/RepeatedExample- pending "works locally but is flaky on CI, reason unknown"- fail-- # # add a non-comment journal entry by changing the work package attributes- # wp_page.update_attributes(subject: "A new subject")- # wp_page.expect_and_dismiss_toaster(message: "Successful update.")-- # # expect all journal entries- # activity_tab.expect_journal_notes(text: "First comment by admin")- # activity_tab.expect_journal_notes(text: "Second comment by admin")- # activity_tab.expect_journal_changed_attribute(text: "Subject")+ it "filters the activities based on type", :aggregate_failures do+ # add a non-comment journal entry by changing the work package attributes+ wp_page.update_attributes(subject: "A new subject") # rubocop:disable Rails/ActiveRecordAliases+ wp_page.expect_and_dismiss_toaster(message: "Successful update.")- # activity_tab.filter_journals(:only_comments)+ # expect all journal entries+ activity_tab.expect_journal_notes(text: "First comment by admin")+ activity_tab.expect_journal_notes(text: "Second comment by admin")+ activity_tab.expect_journal_changed_attribute(text: "Subject")- # # expect only the comments- # activity_tab.expect_journal_notes(text: "First comment by admin")- # activity_tab.expect_journal_notes(text: "Second comment by admin")- # activity_tab.expect_no_journal_changed_attribute(text: "Subject")+ activity_tab.filter_journals(:only_comments)- # activity_tab.filter_journals(:only_changes)+ # expect only the comments+ activity_tab.expect_journal_notes(text: "First comment by admin")+ activity_tab.expect_journal_notes(text: "Second comment by admin")+ activity_tab.expect_no_journal_changed_attribute(text: "Subject")- # # expect only the changes- # activity_tab.expect_no_journal_notes(text: "First comment by admin")- # activity_tab.expect_no_journal_notes(text: "Second comment by admin")- # activity_tab.expect_journal_changed_attribute(text: "Subject")+ activity_tab.filter_journals(:only_changes)- # activity_tab.filter_journals(:all)+ # expect only the changes+ activity_tab.expect_no_journal_notes(text: "First comment by admin")+ activity_tab.expect_no_journal_notes(text: "Second comment by admin")+ activity_tab.expect_journal_changed_attribute(text: "Subject")+ activity_tab.filter_journals(:all)- # # expect all journal entries- # activity_tab.expect_journal_notes(text: "First comment by admin")- # activity_tab.expect_journal_notes(text: "Second comment by admin")- # activity_tab.expect_journal_changed_attribute(text: "Subject")+ # expect all journal entries+ activity_tab.expect_journal_notes(text: "First comment by admin")+ activity_tab.expect_journal_notes(text: "Second comment by admin")+ activity_tab.expect_journal_changed_attribute(text: "Subject")- # # strip journal entries with comments and changesets down to the comments+ # strip journal entries with comments and changesets down to the comments- # # creating a journal entry with both a comment and a changeset- # activity_tab.add_comment(text: "Third comment by admin")- # wp_page.update_attributes(subject: "A new subject!!!")- # wp_page.expect_and_dismiss_toaster(message: "Successful update.")+ # creating a journal entry with both a comment and a changeset+ activity_tab.add_comment(text: "Third comment by admin")+ wp_page.update_attributes(subject: "A new subject!!!") # rubocop:disable Rails/ActiveRecordAliases+ wp_page.expect_and_dismiss_toaster(message: "Successful update.")- # latest_journal = work_package.journals.last+ latest_journal = work_package.journals.last- # activity_tab.within_journal_entry(latest_journal) do- # activity_tab.expect_journal_notes_header(text: admin.name)- # activity_tab.expect_journal_notes(text: "Third comment by admin")- # activity_tab.expect_journal_changed_attribute(text: "Subject")- # activity_tab.expect_no_journal_details_header- # end+ activity_tab.within_journal_entry(latest_journal) do+ activity_tab.expect_journal_notes_header(text: admin.name)+ activity_tab.expect_journal_notes(text: "Third comment by admin")+ activity_tab.expect_journal_changed_attribute(text: "Subject")+ activity_tab.expect_no_journal_details_header+ end- # activity_tab.filter_journals(:only_comments)+ activity_tab.filter_journals(:only_comments)- # activity_tab.within_journal_entry(latest_journal) do- # activity_tab.expect_journal_notes_header(text: admin.name)- # activity_tab.expect_journal_notes(text: "Third comment by admin")- # activity_tab.expect_no_journal_changed_attribute- # activity_tab.expect_no_journal_details_header- # end+ activity_tab.within_journal_entry(latest_journal) do+ activity_tab.expect_journal_notes_header(text: admin.name)+ activity_tab.expect_journal_notes(text: "Third comment by admin")+ activity_tab.expect_no_journal_changed_attribute+ activity_tab.expect_no_journal_details_header+ end- # activity_tab.filter_journals(:only_changes)+ activity_tab.filter_journals(:only_changes)- # activity_tab.within_journal_entry(latest_journal) do- # activity_tab.expect_no_journal_notes_header- # activity_tab.expect_no_journal_notes+ activity_tab.within_journal_entry(latest_journal) do+ activity_tab.expect_no_journal_notes_header+ activity_tab.expect_no_journal_notes- # activity_tab.expect_journal_details_header(text: admin.name)- # activity_tab.expect_journal_changed_attribute(text: "Subject")- # end+ activity_tab.expect_journal_details_header(text: admin.name)+ activity_tab.expect_journal_changed_attribute(text: "Subject")+ endend- it "resets an only_changes filter if a comment is added by the user", :aggregate_failures do # rubocop:disable RSpec/RepeatedExample- pending "works locally but is flaky on CI, reason unknown"- fail-- # activity_tab.filter_journals(:only_changes)- # sleep 0.5 # avoid flaky test+ it "resets an only_changes filter if a comment is added by the user", :aggregate_failures do+ activity_tab.filter_journals(:only_changes)- # # expect only the changes- # activity_tab.expect_no_journal_notes(text: "First comment by admin")- # activity_tab.expect_no_journal_notes(text: "Second comment by admin")+ # expect only the changes+ activity_tab.expect_no_journal_notes(text: "First comment by admin")+ activity_tab.expect_no_journal_notes(text: "Second comment by admin")- # # add a comment- # activity_tab.add_comment(text: "Third comment by admin")- # sleep 0.5 # avoid flaky test+ # add a comment+ activity_tab.add_comment(text: "Third comment by admin")- # # the only_changes filter should be reset- # activity_tab.expect_journal_notes(text: "Third comment by admin")+ # the only_changes filter should be reset+ activity_tab.expect_journal_notes(text: "Third comment by admin")endendenddiff --git a/spec/features/activities/work_package_activity_spec.rb b/spec/features/activities/work_package_activity_spec.rbindex f03abbea46c..5264004001f 100644--- a/spec/features/activities/work_package_activity_spec.rb+++ b/spec/features/activities/work_package_activity_spec.rb@@ -52,6 +52,11 @@ RSpec.describe "Work package activity", :js docontext "when the progress values are changed" dobefore do+ # set WORK_PACKAGES_ACTIVITIES_TAB_POLLING_INTERVAL_IN_MS from 10s to 1s+ # to speed up the polling interval for test duration+ # TODO: Redefine interval as a setting?+ ENV["WORK_PACKAGES_ACTIVITIES_TAB_POLLING_INTERVAL_IN_MS"] = "1000"+parent_page.visit!popover.openpopover.set_values(work: "100", remaining_time: "5")@@ -60,6 +65,10 @@ RSpec.describe "Work package activity", :js doparent_page.wait_for_activity_tabend+ after do+ ENV.delete("WORK_PACKAGES_ACTIVITIES_TAB_POLLING_INTERVAL_IN_MS")+ end+it "displays changed attributes in the activity tab", :aggregate_failures doactivity_tab.expect_journal_changed_attribute(text: "% Complete set to 95%")activity_tab.expect_journal_changed_attribute(text: "Work set to 100h")diff --git a/spec/support/components/work_packages/activities.rb b/spec/support/components/work_packages/activities.rbindex 792bf5c9f16..7cd28668ed1 100644--- a/spec/support/components/work_packages/activities.rb+++ b/spec/support/components/work_packages/activities.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -82,7 +84,10 @@ module Componentsenddef within_journal_entry(journal, &)- wait_for { page }.to have_test_selector("op-wp-journal-entry-#{journal.id}") # avoid flakyness+ retry_block(screenshot: true) do+ expect(page).to have_test_selector("op-wp-journal-entry-#{journal.id}")+ end+page.within_test_selector("op-wp-journal-entry-#{journal.id}", &)end@@ -312,8 +317,8 @@ module Componentsend# Ensure the journals are reloaded- # wait_for { page }.to have_test_selector("op-wp-journals-#{filter}-#{default_sorting}")- # the wait_for will not work as the selector will be switched to the target filter before the page is updated+ wait_for { page }.to have_test_selector("op-wp-journals-#{filter}-#{default_sorting}")+ # the wait_for will not work on it's own as the selector will be switched to the target filter before the page is updated# so we still need to wait statically unfortuntately to avoid flakynesssleep 1enddiff --git a/spec/support/pages/page.rb b/spec/support/pages/page.rbindex 36bc07829fc..c826871c334 100644--- a/spec/support/pages/page.rb+++ b/spec/support/pages/page.rb@@ -39,6 +39,7 @@ module Pagesinclude OpenProject::StaticRouting::UrlHelpersinclude Toasts::Expectationsinclude Flash::Expectations+ include RSpec::Waitinclude WaitHelpersdef current_page?diff --git a/spec/support/pages/work_packages/abstract_work_package.rb b/spec/support/pages/work_packages/abstract_work_package.rbindex 1acafdd7f55..bbf7f5e15df 100644--- a/spec/support/pages/work_packages/abstract_work_package.rb+++ b/spec/support/pages/work_packages/abstract_work_package.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -80,9 +82,9 @@ module Pagesenddef wait_for_activity_tab- expect(page).to have_test_selector("op-wp-activity-tab", wait: 10)- # wait for stimulus js component to be mounted- expect(page).to have_css('[data-test-selector="op-wp-activity-tab"][data-stimulus-controller-connected="true"]')+ wait_for { page }.to have_test_selector("op-wp-activity-tab")+ # ensure stimulus controller is mounted+ expect(page).to have_css('[data-stimulus-controller-connected="true"]')enddef expect_any_active_inline_edit_field