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

Wait until body is reloaded

Oliver Güntherc7a0412f1f3c
diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb
index a8406c0a3ed..387b0b3693a 100644
--- a/app/views/layouts/base.html.erb
+++ b/app/views/layouts/base.html.erb
@@ -39,7 +39,12 @@ See COPYRIGHT and LICENSE files for more details.
<%= content_for(:header_tags) if content_for?(:header_tags) %>
<meta name="current_menu_item" content="<%= current_menu_item %>"/>
</head>
-<body class="<%= body_css_classes %> __overflowing_element_container __overflowing_body" data-relative_url_root="<%= root_path %>" data-overflowing-identifier=".__overflowing_body">
+<body
+ class="<%= body_css_classes %> __overflowing_element_container __overflowing_body"
+ data-relative_url_root="<%= root_path %>"
+ data-overflowing-identifier=".__overflowing_body"
+ data-rendered-at="<%= Time.zone.now.iso8601 %>"
+>
<%= render partial: 'warning_bar/warning_bar' %>
<noscript>
<div class="top-shelf">
diff --git a/spec/features/work_packages/bulk/copy_work_package_spec.rb b/spec/features/work_packages/bulk/copy_work_package_spec.rb
index 9f9742a0ae4..ac974ed5422 100644
--- a/spec/features/work_packages/bulk/copy_work_package_spec.rb
+++ b/spec/features/work_packages/bulk/copy_work_package_spec.rb
@@ -70,11 +70,12 @@ describe 'Copy work packages through Rails view', js: true do
context_menu.choose 'Bulk copy'
expect(page).to have_selector('#new_project_id')
- select_autocomplete page.find('[data-qa-selector="new_project_id"]'),
- query: project2.name,
- select_text: project2.name,
- results_selector: 'body'
-
+ expect_page_reload do
+ select_autocomplete page.find('[data-qa-selector="new_project_id"]'),
+ query: project2.name,
+ select_text: project2.name,
+ results_selector: 'body'
+ end
end
it 'sets the version on copy and leaves a note' do
diff --git a/spec/support/shared/expect_page_reload.rb b/spec/support/shared/expect_page_reload.rb
new file mode 100644
index 00000000000..e0e0dc22444
--- /dev/null
+++ b/spec/support/shared/expect_page_reload.rb
@@ -0,0 +1,40 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2022 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+# Method to wait for the body to be refreshed
+# due to a page reload
+
+def expect_page_reload
+ current_render = Time.parse page.find('body')['data-rendered-at']
+
+ yield
+
+ expect(page).to have_selector('body') do |body|
+ Time.parse(body['data-rendered-at']) > current_render
+ end
+end