Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable activities pending specs, address flakiness #17197

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 97 additions & 102 deletions spec/features/activities/work_package/activities_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,48 +299,45 @@
end

it "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")
end
end
end

Expand Down Expand Up @@ -457,93 +454,87 @@
wp_page.wait_for_activity_tab
end

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.")
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.")

# # 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")

# activity_tab.filter_journals(:only_comments)
activity_tab.filter_journals(:only_comments)

# # 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 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_changes)
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")
# activity_tab.expect_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(:all)
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")
end
end

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)
sleep 0.5 # avoid flaky test

# # 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")
sleep 0.5 # avoid flaky test

# # 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")
end
end
end
Expand Down Expand Up @@ -650,10 +641,17 @@
current_user { admin }

before do
# Speed up the polling interval for test duration
ENV["WORK_PACKAGES_ACTIVITIES_TAB_POLLING_INTERVAL_IN_MS"] = "1000"

wp_page.visit!
wp_page.wait_for_activity_tab
end

after do
ENV.delete("WORK_PACKAGES_ACTIVITIES_TAB_POLLING_INTERVAL_IN_MS")
end

it "shows the notification bubble", :aggregate_failures do
activity_tab.within_journal_entry(journal_mentioning_admin) do
activity_tab.expect_notification_bubble
Expand All @@ -663,9 +661,6 @@
it "removes the notification bubble after the comment is read", :aggregate_failures do
notificaton_for_admin.update!(read_ian: true)

wp_page.visit!
wp_page.wait_for_activity_tab

activity_tab.within_journal_entry(journal_mentioning_admin) do
activity_tab.expect_no_notification_bubble
end
Expand Down
3 changes: 2 additions & 1 deletion spec/support/components/work_packages/activities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def expect_notification_bubble
end

def expect_no_notification_bubble
expect(page).not_to have_test_selector("op-journal-unread-notification")
# Notifications depend on a polling mechanism, so we need to wait for the bubble to disappear
wait_for { page }.not_to have_test_selector("op-journal-unread-notification")
end

def expect_journal_container_at_bottom
Expand Down
Loading