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
Switch `projects_index_spec` to cuprite
Aaron Contreras48324e3b9907
diff --git a/spec/features/projects/projects_index_spec.rb b/spec/features/projects/projects_index_spec.rbindex 4bdc2e78e60..0939bb7c114 100644--- a/spec/features/projects/projects_index_spec.rb+++ b/spec/features/projects/projects_index_spec.rb@@ -30,6 +30,7 @@ require 'spec_helper'RSpec.describe 'Projects index page',js: true,+ with_cuprite: true,with_settings: { login_required?: false } doshared_let(:admin) { create(:admin) }@@ -83,9 +84,9 @@ RSpec.describe 'Projects index page',endend- describe 'restricts project visibility' do- describe 'for a anonymous user' do- it 'only public projects shall be visible' do+ describe 'project visibility restriction' do+ context 'for an anonymous user' do+ specify 'only public projects shall be visible' doRole.anonymousvisit projects_path@@ -97,7 +98,7 @@ RSpec.describe 'Projects index page',endend- describe 'for project members', with_ee: %i[custom_fields_in_projects_list] do+ context 'for project members', with_ee: %i[custom_fields_in_projects_list] doshared_let(:user) docreate(:user,member_in_project: development_project,@@ -107,7 +108,7 @@ RSpec.describe 'Projects index page',lastname: 'Turing')end- it 'only public project or those the user is member of shall be visible' do+ specify 'only public projects or those the user is a member of shall be visible' doRole.non_memberlogin_as(user)visit projects_path@@ -122,14 +123,14 @@ RSpec.describe 'Projects index page',endend- describe 'for admins' do+ context 'for admins' dobefore doproject.update(created_at: 7.days.ago, description: 'I am a nice project')newsend- it 'test that all projects are visible' do+ specify 'all projects are visible' dologin_as(admin)visit projects_path@@ -163,7 +164,7 @@ RSpec.describe 'Projects index page',endend- it 'test that flash sortBy is being escaped' do+ specify 'flash sortBy is being escaped' dologin_as(admin)visit projects_path(sortBy: "[[\"><script src='/foobar.js'></script>\",\"\"]]")@@ -177,8 +178,8 @@ RSpec.describe 'Projects index page',endend- describe 'without valid Enterprise token' do- it 'CF columns and filters are not visible' do+ context 'without valid Enterprise token' do+ specify 'CF columns and filters are not visible' doload_and_open_filters admin# CF's columns are not present:@@ -188,15 +189,15 @@ RSpec.describe 'Projects index page',endend- describe 'with valid Enterprise token', with_ee: %i[custom_fields_in_projects_list] do- it 'CF columns and filters are not visible by default' do+ context 'with valid Enterprise token', with_ee: %i[custom_fields_in_projects_list] do+ specify 'CF columns and filters are not visible by default' doload_and_open_filters admin# CF's columns are not shown due to settingexpect(page).not_to have_text(custom_field.name.upcase)end- it 'CF columns and filters are visible when added to settings' do+ specify 'CF columns and filters are visible when added to settings' doSetting.enabled_projects_columns += [custom_field.column_name, invisible_custom_field.column_name]load_and_open_filters admin@@ -211,8 +212,8 @@ RSpec.describe 'Projects index page',endend- describe 'with a filter set' do- it 'onlies show the matching projects and filters' do+ context 'with a filter set' do+ it 'only shows the matching projects and filters' doload_and_open_filters adminprojects_page.set_filter('name_and_identifier',@@ -229,25 +230,25 @@ RSpec.describe 'Projects index page',endend- describe 'when paginating' do+ context 'when paginating' dobefore doallow(Setting).to receive(:per_page_options_array).and_return([1, 5])end- it 'keeps applying filters and order' do+ it 'keeps applying filters and orders' doload_and_open_filters admin- SeleniumHubWaiter.waitprojects_page.set_filter('name_and_identifier','Name or identifier','doesn\'t contain',['Plain'])click_on 'Apply'+ wait_for_reload# Sorts ASC by name- SeleniumHubWaiter.waitclick_on 'Sort by "Name"'+ wait_for_reload# Results should be filtered and ordered ASC by nameexpect(page).to have_text(development_project.name)@@ -256,11 +257,10 @@ RSpec.describe 'Projects index page',expect(page).not_to have_text(public_project.name) # as it is on the second page# Changing the page size to 5 and back to 1 should not change the filters (which we test later on the second page)- SeleniumHubWaiter.waitfind('.op-pagination--options .op-pagination--item', text: '5').click # click page size '5'- SeleniumHubWaiter.wait+ wait_for_reloadfind('.op-pagination--options .op-pagination--item', text: '1').click # return back to page size '1'- SeleniumHubWaiter.wait+ wait_for_reloadclick_on '2' # Go to pagination page 2# On page 2 you should see the second page of the filtered set ordered ASC by name@@ -270,8 +270,8 @@ RSpec.describe 'Projects index page',expect(page).not_to have_text(development_project.name) # That one should be on page 1# Sorts DESC by name- SeleniumHubWaiter.waitclick_on 'Ascending sorted by "Name"'+ wait_for_reload# On page 2 the same filters should still be intact but the order should be DESC on nameexpect(page).to have_text(development_project.name)@@ -281,8 +281,8 @@ RSpec.describe 'Projects index page',expect(page).to have_selector('.sort.desc', text: 'NAME')# Sending the filter form again what implies to compose the request freshly- SeleniumHubWaiter.waitclick_on 'Apply'+ wait_for_reload# We should see page 1, resetting pagination, as it is a new filter, but keeping the DESC order on the project# name@@ -294,25 +294,24 @@ RSpec.describe 'Projects index page',endend- describe 'when filter of type' do- it 'Name and identifier gives results in both, name and identifier' do+ context 'when filter of type' do+ specify 'Name and identifier gives results in both, name and identifier' doload_and_open_filters admin# Filter on model attribute 'name'- SeleniumHubWaiter.waitprojects_page.set_filter('name_and_identifier','Name or identifier','doesn\'t contain',['Plain'])click_on 'Apply'+ wait_for_reloadexpect(page).to have_text(development_project.name)expect(page).to have_text(public_project.name)expect(page).not_to have_text(project.name)# Filter on model attribute 'identifier'- SeleniumHubWaiter.waitremove_filter('name_and_identifier')projects_page.set_filter('name_and_identifier',@@ -321,6 +320,7 @@ RSpec.describe 'Projects index page',['plain-project'])click_on 'Apply'+ wait_for_reloadexpect(page).to have_text(project.name)expect(page).not_to have_text(development_project.name)@@ -340,7 +340,7 @@ RSpec.describe 'Projects index page',parent: parent_project)end- it 'filter on "status", archive and unarchive' do+ specify 'filter on "status", archive and unarchive' doload_and_open_filters admin# value selection defaults to "active"'@@ -352,9 +352,10 @@ RSpec.describe 'Projects index page',expect(page).to have_text('Development project')expect(page).to have_text('Public project')- SeleniumHubWaiter.wait- projects_page.click_menu_item_of('Archive', parent_project)- projects_page.accept_alert_dialog!+ accept_alert do+ projects_page.click_menu_item_of('Archive', parent_project)+ end+ wait_for_reloadexpect(page).not_to have_text(parent_project.name)# The child project gets archived automatically@@ -372,7 +373,6 @@ RSpec.describe 'Projects index page',load_and_open_filters admin- SeleniumHubWaiter.waitprojects_page.filter_by_active('no')expect(page).to have_text("ARCHIVED #{parent_project.name}")@@ -387,7 +387,6 @@ RSpec.describe 'Projects index page',expect(menu).not_to have_text('Settings')expect(menu).not_to have_text('New subproject')- SeleniumHubWaiter.waitclick_link('Unarchive')end@@ -400,7 +399,6 @@ RSpec.describe 'Projects index page',load_and_open_filters admin- SeleniumHubWaiter.waitprojects_page.filter_by_active('yes')expect(page).to have_text(parent_project.name)@@ -425,23 +423,20 @@ RSpec.describe 'Projects index page',name: 'Green project')end- it 'sort and filter on project status' do+ it 'sorts and filters on project status' dologin_as(admin)projects_page.visit!- SeleniumHubWaiter.waitclick_link('Sort by "Status"')expect_project_at_place(green_project, 1)expect(page).to have_text('(1 - 5/5)')- SeleniumHubWaiter.waitclick_link('Ascending sorted by "Status"')expect_project_at_place(green_project, 5)expect(page).to have_text('(1 - 5/5)')- SeleniumHubWaiter.waitprojects_page.open_filtersprojects_page.set_filter('project_status_code',@@ -450,28 +445,29 @@ RSpec.describe 'Projects index page',['On track'])click_on 'Apply'+ wait_for_reloadexpect(page).to have_text(green_project.name)expect(page).not_to have_text(no_status_project.name)- SeleniumHubWaiter.waitprojects_page.set_filter('project_status_code','Project status','is not empty',[])click_on 'Apply'+ wait_for_reloadexpect(page).to have_text(green_project.name)expect(page).not_to have_text(no_status_project.name)- SeleniumHubWaiter.waitprojects_page.set_filter('project_status_code','Project status','is empty',[])click_on 'Apply'+ wait_for_reloadexpect(page).not_to have_text(green_project.name)expect(page).to have_text(no_status_project.name)@@ -482,6 +478,7 @@ RSpec.describe 'Projects index page',['On track'])click_on 'Apply'+ wait_for_reloadexpect(page).not_to have_text(green_project.name)expect(page).to have_text(no_status_project.name)@@ -543,23 +540,22 @@ RSpec.describe 'Projects index page',before doproject_created_on_todayload_and_open_filters admin- SeleniumHubWaiter.waitend- it 'selecting operator' do+ specify 'selecting operator' do# created on 'today' shows projects that were created todayprojects_page.set_filter('created_at','Created on','today')click_on 'Apply'+ wait_for_reloadexpect(page).to have_text(project_created_on_today.name)expect(page).not_to have_text(project_created_on_this_week.name)expect(page).not_to have_text(project_created_on_fixed_date.name)# created on 'this week' shows projects that were created within the last seven days- SeleniumHubWaiter.waitremove_filter('created_at')projects_page.set_filter('created_at',@@ -567,13 +563,13 @@ RSpec.describe 'Projects index page','this week')click_on 'Apply'+ wait_for_reloadexpect(page).to have_text(project_created_on_today.name)expect(page).to have_text(project_created_on_this_week.name)expect(page).not_to have_text(project_created_on_fixed_date.name)# created on 'on' shows projects that were created within the last seven days- SeleniumHubWaiter.waitremove_filter('created_at')projects_page.set_filter('created_at',@@ -582,13 +578,13 @@ RSpec.describe 'Projects index page',['2017-11-11'])click_on 'Apply'+ wait_for_reloadexpect(page).to have_text(project_created_on_fixed_date.name)expect(page).not_to have_text(project_created_on_today.name)expect(page).not_to have_text(project_created_on_this_week.name)# created on 'less than days ago'- SeleniumHubWaiter.waitremove_filter('created_at')projects_page.set_filter('created_at',@@ -597,12 +593,12 @@ RSpec.describe 'Projects index page',['1'])click_on 'Apply'+ wait_for_reloadexpect(page).to have_text(project_created_on_today.name)expect(page).not_to have_text(project_created_on_fixed_date.name)# created on 'more than days ago'- SeleniumHubWaiter.waitremove_filter('created_at')projects_page.set_filter('created_at',@@ -611,12 +607,12 @@ RSpec.describe 'Projects index page',['1'])click_on 'Apply'+ wait_for_reloadexpect(page).to have_text(project_created_on_fixed_date.name)expect(page).not_to have_text(project_created_on_today.name)# created on 'between'- SeleniumHubWaiter.waitremove_filter('created_at')projects_page.set_filter('created_at',@@ -625,12 +621,12 @@ RSpec.describe 'Projects index page',['2017-11-10', '2017-11-12'])click_on 'Apply'+ wait_for_reloadexpect(page).to have_text(project_created_on_fixed_date.name)expect(page).not_to have_text(project_created_on_today.name)# Latest activity at 'today'. This spot check would fail if the data does not get collected from multiple tables- SeleniumHubWaiter.waitremove_filter('created_at')projects_page.set_filter('latest_activity_at',@@ -638,12 +634,12 @@ RSpec.describe 'Projects index page','today')click_on 'Apply'+ wait_for_reloadexpect(page).to have_text(project_created_on_today.name)expect(page).not_to have_text(project_created_on_fixed_date.name)# CF List- SeleniumHubWaiter.waitremove_filter('latest_activity_at')projects_page.set_filter(list_custom_field.column_name,@@ -652,6 +648,7 @@ RSpec.describe 'Projects index page',[list_custom_field.possible_values[2].value])click_on 'Apply'+ wait_for_reloadexpect(page).to have_text(project_created_on_today.name)expect(page).not_to have_text(project_created_on_fixed_date.name)@@ -661,17 +658,16 @@ RSpec.describe 'Projects index page',within(cf_filter) do# Initial filter is a 'single select'expect(cf_filter.find(:select, 'value')).not_to be_multiple- SeleniumHubWaiter.waitclick_on 'Toggle multiselect'# switching to multiselect keeps the current selectionexpect(cf_filter.find(:select, 'value')).to be_multipleexpect(cf_filter).to have_select('value', selected: list_custom_field.possible_values[2].value)- SeleniumHubWaiter.waitselect list_custom_field.possible_values[3].value, from: 'value'endclick_on 'Apply'+ wait_for_reloadcf_filter = page.find("li[filter-name='#{list_custom_field.column_name}']")within(cf_filter) do@@ -683,7 +679,6 @@ RSpec.describe 'Projects index page',list_custom_field.possible_values[3].value])# switching to single select keeps the first selection- SeleniumHubWaiter.waitselect list_custom_field.possible_values[1].value, from: 'value'unselect list_custom_field.possible_values[2].value, from: 'value'@@ -694,6 +689,7 @@ RSpec.describe 'Projects index page',endclick_on 'Apply'+ wait_for_reloadcf_filter = page.find("li[filter-name='#{list_custom_field.column_name}']")within(cf_filter) do@@ -702,7 +698,6 @@ RSpec.describe 'Projects index page',end# CF date filter work (at least for one operator)- SeleniumHubWaiter.waitremove_filter(list_custom_field.column_name)projects_page.set_filter(date_custom_field.column_name,@@ -710,8 +705,8 @@ RSpec.describe 'Projects index page','on',['2011-11-11'])- SeleniumHubWaiter.waitclick_on 'Apply'+ wait_for_reloadexpect(page).to have_text(project_created_on_today.name)expect(page).not_to have_text(project_created_on_fixed_date.name)@@ -721,22 +716,22 @@ RSpec.describe 'Projects index page',enddescribe 'public filter' do- it 'filter on "public" status' do+ it 'filters on "public" status' doload_and_open_filters adminexpect(page).to have_text(project.name)expect(page).to have_text(public_project.name)- SeleniumHubWaiter.waitprojects_page.filter_by_public('no')+ wait_for_reloadexpect(page).to have_text(project.name)expect(page).not_to have_text(public_project.name)load_and_open_filters admin- SeleniumHubWaiter.waitprojects_page.filter_by_public('yes')+ wait_for_reloadexpect(page).to have_text(public_project.name)expect(page).not_to have_text(project.name)@@ -744,7 +739,7 @@ RSpec.describe 'Projects index page',endend- describe 'Non-admins with role with permission' do+ context 'for non-admins with role with permission' doshared_let(:can_copy_projects_role) docreate(:role, name: 'Can Copy Projects Role', permissions: [:copy_projects])end@@ -901,8 +896,8 @@ RSpec.describe 'Projects index page',child_project_z,public_project)- SeleniumHubWaiter.waitclick_link('Name')+ wait_for_reload# Projects ordered by name ascexpect_projects_in_order(child_project_a,@@ -912,8 +907,8 @@ RSpec.describe 'Projects index page',public_project,child_project_z)- SeleniumHubWaiter.waitclick_link('Name')+ wait_for_reload# Projects ordered by name descexpect_projects_in_order(child_project_z,@@ -923,8 +918,8 @@ RSpec.describe 'Projects index page',development_project,child_project_a)- SeleniumHubWaiter.waitclick_link(integer_custom_field.name)+ wait_for_reload# Projects ordered by cf asc first then project name descexpect_projects_in_order(project,@@ -934,8 +929,8 @@ RSpec.describe 'Projects index page',child_project_m,child_project_a)- SeleniumHubWaiter.waitclick_link('Sort by "Project hierarchy"')+ wait_for_reload# again ordered by name asc on each hierarchical levelexpect_projects_in_order(development_project,@@ -947,8 +942,8 @@ RSpec.describe 'Projects index page',endend- describe 'blacklisted filters' do- it 'are not visible' do+ describe 'blacklisted filter' do+ it 'is not visible' doload_and_open_filters adminexpect(page).not_to have_select('add_filter_select', with_options: ["Principal"])diff --git a/spec/support/pages/projects/index.rb b/spec/support/pages/projects/index.rbindex c10f9a283a7..fec81d56363 100644--- a/spec/support/pages/projects/index.rb+++ b/spec/support/pages/projects/index.rb@@ -148,6 +148,7 @@ module Pagesrow.hovermenu = find('ul.project-actions')menu.click+ expect(page).to have_selector('.menu-drop-down-container')yield menuendenddiff --git a/spec/support/shared/wait_for_reload.rb b/spec/support/shared/wait_for_reload.rbnew file mode 100644index 00000000000..faafb892df7--- /dev/null+++ b/spec/support/shared/wait_for_reload.rb@@ -0,0 +1,39 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2023 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.+# +++#++# Wrapper for Cuprite's `page.driver.wait_for_reload`+# Used to wait for both:+# 1. Network traffic to become idle.+# 2. Waiting for DOM to be loaded and ready avoiding+# AJAX timing issues.+def wait_for_reload+ page.driver.wait_for_reload+end