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 flaky spec structured_meeting_crud_spec.rb

Christophe Bliarda9d3484641d7
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 3d2201a0848..0dfbaf2e667 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1781,6 +1781,7 @@ en:
issue_priority:
one: "Priority"
other: "Priorities"
+ meeting_participant: "Meeting participant"
member: "Member"
news: "News"
notification:
diff --git a/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb b/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb
index 1ec15b4c181..cd2f25ee265 100644
--- a/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb
+++ b/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb
@@ -84,11 +84,10 @@ RSpec.describe "Meetings CRUD",
end
meetings_page.click_create
+ expect_and_dismiss_flash(type: :success, message: I18n.t(:notice_successful_create))
end
it "can create a meeting and add agenda items" do
- expect_and_dismiss_flash(type: :success, message: "Successful creation")
-
# Can add and edit a single item
show_page.add_agenda_item do
fill_in "Title", with: "My agenda item"
@@ -262,8 +261,6 @@ RSpec.describe "Meetings CRUD",
end
it "shows an error toast trying to update an outdated item" do
- expect_flash(type: :success, message: "Successful creation")
-
# Can add and edit a single item
show_page.add_agenda_item do
fill_in "Title", with: "My agenda item"
@@ -285,8 +282,6 @@ RSpec.describe "Meetings CRUD",
end
it "can copy the meeting via the dialog form" do
- expect_flash(type: :success, message: "Successful creation")
-
show_page.add_agenda_item do
fill_in "Title", with: "My agenda item"
fill_in "Duration", with: "25"
@@ -312,7 +307,7 @@ RSpec.describe "Meetings CRUD",
click_on("op-meetings-header-action-trigger")
click_on "Copy"
# dynamically wait for the modal to be loaded
- expect(page).to have_text("Copy meeting")
+ show_page.expect_modal("Copy meeting")
end
fill_in "Title", with: ""
@@ -322,6 +317,7 @@ RSpec.describe "Meetings CRUD",
expect(page).to have_content "Title can't be blank."
fill_in "Title", with: "Some title"
click_on "Create meeting"
+ expect_and_dismiss_flash(type: :success, message: I18n.t(:notice_successful_create))
new_meeting = Meeting.last
copied_meeting_page = Pages::Meetings::Show.new(new_meeting)
@@ -372,8 +368,6 @@ RSpec.describe "Meetings CRUD",
context "when starting with empty sections" do
it "can add, edit and delete sections" do
- expect_flash(type: :success, message: "Successful creation")
-
# create the first section
show_page.add_section do
fill_in "Title", with: "First section"
diff --git a/modules/meeting/spec/support/pages/meetings/show.rb b/modules/meeting/spec/support/pages/meetings/show.rb
index 0b1742cb27b..77e0bd1f583 100644
--- a/modules/meeting/spec/support/pages/meetings/show.rb
+++ b/modules/meeting/spec/support/pages/meetings/show.rb
@@ -127,6 +127,8 @@ module Pages::Meetings
def expect_modal(...)
expect(page).to have_modal(...)
+ modal = find(:modal, ...)
+ wait_for_size_animation_completion(modal)
end
def expect_no_add_form
@@ -568,6 +570,7 @@ module Pages::Meetings
def start_meeting
page.within("#meetings-side-panel-state-component") do
click_on("Start meeting")
+ expect(page).to have_link("Close meeting")
end
end
diff --git a/spec/support/capybara/wait_helpers.rb b/spec/support/capybara/wait_helpers.rb
index 1caa208911b..cd4db4cff75 100644
--- a/spec/support/capybara/wait_helpers.rb
+++ b/spec/support/capybara/wait_helpers.rb
@@ -34,11 +34,19 @@ module WaitHelpers
# Useful to wait for a primer dialog to finish opening, as they have an
# opening animation.
#
- # @param selector [String] CSS selector for the element to wait for
+ # @param selector_or_element [String or Capybara::Node::Element] CSS selector or element to wait for
# @param wait [Integer] Optional maximum time to wait in seconds, defaults to
# Capybara's default wait time
- def wait_for_size_animation_completion(selector, wait: Capybara.default_max_wait_time)
- element = page.find(selector, wait:)
+ def wait_for_size_animation_completion(selector_or_element, wait: Capybara.default_max_wait_time)
+ element =
+ case selector_or_element
+ when String
+ page.find(selector_or_element, wait:)
+ when Capybara::Node::Element
+ selector_or_element
+ else
+ raise ArgumentError, "Invalid selector or element"
+ end
page.document.synchronize do
initial_position = page.evaluate_script("arguments[0].getBoundingClientRect()", element)
sleep 0.1 # Small delay to allow for animation