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 move_work_package_spec.rb spec

Christophe Bliard203e102a33d5
diff --git a/spec/features/work_packages/bulk/move_work_package_spec.rb b/spec/features/work_packages/bulk/move_work_package_spec.rb
index 3b61c35aecb..a69c26496af 100644
--- a/spec/features/work_packages/bulk/move_work_package_spec.rb
+++ b/spec/features/work_packages/bulk/move_work_package_spec.rb
@@ -106,6 +106,18 @@ RSpec.describe "Moving a work package through Rails view", :js do
work_package.reload
expect(work_package.project_id).to eq(project2.id)
+ # Page displays the background job status dialog, then the job
+ # finishes and the dialog updates to "Successful update." with a
+ # redirect link. After 2 seconds it automatically clicks the link
+ # which navigates to /work_packages/:id which finally redirects to
+ # /projects/:project_identifier/work_packages/:id/activity
+ #
+ # The following lines wait for this job status dialog to be discarded.
+ expect(page).to have_text "Successful update."
+ # Clicking the link directly would save 2 seconds, but there is a bug
+ # which redirects back. Sleep 2 seconds instead until it's fixed
+ sleep 2 # TODO replace with: click_on(I18n.t("job_status_dialog.redirect_link"))
+
expect(page).to have_current_path "/projects/#{project2.identifier}/work_packages/#{work_package.id}/activity"
page.find_by_id("projects-menu", text: "Target")
end