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
[Op#40437]: wait for activity tab comments to load (#17055)
Kabiru Mwenja32f9763c23f3
diff --git a/app/components/work_packages/activities_tab/journals/index_component.html.erb b/app/components/work_packages/activities_tab/journals/index_component.html.erbindex df3573e39ee..aa761592d11 100644--- a/app/components/work_packages/activities_tab/journals/index_component.html.erb+++ b/app/components/work_packages/activities_tab/journals/index_component.html.erb@@ -1,6 +1,6 @@<%=component_wrapper(class: "work-packages-activities-tab-journals-index-component") do- flex_layout do |journals_index_wrapper_container|+ flex_layout(data: { test_selector: "op-wp-journals-#{filter}-#{journal_sorting}" }) do |journals_index_wrapper_container|journals_index_wrapper_container.with_row(classes: "work-packages-activities-tab-journals-index-component--journals-inner-container",mb: inner_container_margin_bottomdiff --git a/spec/features/activities/work_package/activities_spec.rb b/spec/features/activities/work_package/activities_spec.rbindex 2ef9fdb1161..8a9ec6b0c85 100644--- a/spec/features/activities/work_package/activities_spec.rb+++ b/spec/features/activities/work_package/activities_spec.rb@@ -370,7 +370,7 @@ RSpec.describe "Work package activity", :js, :with_cuprite, with_flag: { primeriversion: 2)# the comment is shown without browser reload- activity_tab.expect_journal_notes(text: "First comment by member")+ wait_for { page }.to have_test_selector("op-journal-notes-body", text: "First comment by member")# simulate comments made within the polling intervalcreate(:work_package_journal, user: member, notes: "Second comment by member", journable: work_package, version: 3)@@ -387,10 +387,8 @@ RSpec.describe "Work package activity", :js, :with_cuprite, with_flag: { primerifirst_journal.update!(notes: "First comment by member updated")- sleep 1 # avoid flaky test-# properly updates the comment when the comment is updated- activity_tab.expect_journal_notes(text: "First comment by member updated")+ wait_for { page }.to have_test_selector("op-journal-notes-body", text: "First comment by member updated")endend@@ -872,7 +870,6 @@ RSpec.describe "Work package activity", :js, :with_cuprite, with_flag: { primeri# auto-scrolls to the bottom when a new comment is added by the user# add a commentactivity_tab.add_comment(text: "New comment by admin")- activity_tab.expect_journal_notes(text: "New comment by admin") # wait for the comment to be addedactivity_tab.expect_journal_container_at_bottom# auto-scrolls to the bottom when a new comment is added by another user@@ -880,7 +877,8 @@ RSpec.describe "Work package activity", :js, :with_cuprite, with_flag: { primerilatest_journal_version = work_package.journals.last.versioncreate(:work_package_journal, user: member, notes: "New comment by member", journable: work_package,version: latest_journal_version + 1)- activity_tab.expect_journal_notes(text: "New comment by member") # wait for the comment to be added+ # wait for the comment to be added+ wait_for { page }.to have_test_selector("op-journal-notes-body", text: "New comment by member")sleep 1 # wait for auto scrolling to finishactivity_tab.expect_journal_container_at_bottomenddiff --git a/spec/support/components/work_packages/activities.rb b/spec/support/components/work_packages/activities.rbindex b6848487046..cab633769ee 100644--- a/spec/support/components/work_packages/activities.rb+++ b/spec/support/components/work_packages/activities.rb@@ -32,6 +32,7 @@ module Componentsinclude Capybara::DSLinclude Capybara::RSpecMatchersinclude RSpec::Matchers+ include RSpec::Waitattr_reader :work_package@@ -144,7 +145,6 @@ module Componentsenddef add_comment(text: nil, save: true)- # TODO: get rid of static sleepsleep 1 # otherwise the stimulus component is not mounted yet and the click does not workif page.find_test_selector("op-open-work-package-journal-form-trigger")@@ -160,7 +160,8 @@ module Componentsif savepage.within_test_selector("op-wp-journals-container") do- expect(page).to have_text(text)+ # wait for the comment to be loaded+ wait_for { page }.to have_test_selector("op-journal-notes-body", text:)endendend@@ -175,12 +176,12 @@ module Componentspage.find_test_selector("op-submit-work-package-journal-form").clickend- expect(page).to have_text(text)+ # wait for the comment to be loaded+ wait_for { page }.to have_test_selector("op-journal-notes-body", text:)endenddef quote_comment(journal)- # TODO: get rid of static sleepsleep 1 # otherwise the stimulus component is not mounted yet and the click does not workwithin_journal_entry(journal) do@@ -199,7 +200,7 @@ module Componentspage.all(".work-packages-activities-tab-journals-item-component--journal-notes-body").map(&:text)end- def filter_journals(filter)+ def filter_journals(filter, default_sorting: User.current.preference&.comments_sorting || "desc")page.find_test_selector("op-wp-journals-filter-menu").clickcase filter@@ -211,10 +212,11 @@ module Componentspage.find_test_selector("op-wp-journals-filter-show-only-changes").clickend- sleep 1 # wait for the journals to be reloaded, TODO: get rid of static sleep+ # Ensure the journals are reloaded+ wait_for { page }.to have_test_selector("op-wp-journals-#{filter}-#{default_sorting}")end- def set_journal_sorting(sorting)+ def set_journal_sorting(sorting, default_filter: :all)page.find_test_selector("op-wp-journals-sorting-menu").clickcase sorting@@ -224,7 +226,7 @@ module Componentspage.find_test_selector("op-wp-journals-sorting-desc").clickend- sleep 1 # wait for the journals to be reloaded, TODO: get rid of static sleep+ wait_for { page }.to have_test_selector("op-wp-journals-#{default_filter}-#{sorting}")endendenddiff --git a/spec/support/components/work_packages/emoji_reactions.rb b/spec/support/components/work_packages/emoji_reactions.rbindex ce4e53197cf..0917e203e52 100644--- a/spec/support/components/work_packages/emoji_reactions.rb+++ b/spec/support/components/work_packages/emoji_reactions.rb@@ -29,8 +29,6 @@module Componentsmodule WorkPackagesclass EmojiReactions < Activities- include RSpec::Wait-def add_first_emoji_reaction_for_journal(journal, emoji)within_journal_entry(journal) doclick_on "Add reaction"