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

tests[Op#57989]: pagination links should have page param

Kabiru Mwenja368ec4da83d7
diff --git a/spec/features/admin/custom_fields/custom_fields_project_spec.rb b/spec/features/admin/custom_fields/custom_fields_project_spec.rb
index 8081ae4c153..d77540491ba 100644
--- a/spec/features/admin/custom_fields/custom_fields_project_spec.rb
+++ b/spec/features/admin/custom_fields/custom_fields_project_spec.rb
@@ -115,15 +115,7 @@ RSpec.describe "Custom Fields Multi-Project Activation", :js do
expect(page).to have_text(subproject.name)
aggregate_failures "pagination links maintain the correct url" do
- within ".op-pagination" do
- pagination_links = page.all(".op-pagination--item-link")
- expect(pagination_links.size).to be_positive
-
- pagination_links.each do |pagination_link|
- uri = URI.parse(pagination_link["href"])
- expect(uri.path).to eq(custom_field_projects_path(custom_field))
- end
- end
+ custom_field_projects_page.expect_correct_pagination_links(model: custom_field)
end
end
@@ -138,15 +130,7 @@ RSpec.describe "Custom Fields Multi-Project Activation", :js do
expect(page).to have_no_text(project.name)
aggregate_failures "pagination links maintain the correct url after unlinking is done" do
- within ".op-pagination" do
- pagination_links = page.all(".op-pagination--item-link")
- expect(pagination_links.size).to be_positive
-
- pagination_links.each do |pagination_link|
- uri = URI.parse(pagination_link["href"])
- expect(uri.path).to eq(custom_field_projects_path(custom_field))
- end
- end
+ custom_field_projects_page.expect_correct_pagination_links(model: custom_field)
end
end
diff --git a/spec/features/admin/project_custom_fields/project_mappings_spec.rb b/spec/features/admin/project_custom_fields/project_mappings_spec.rb
index ea0eee6e21e..9742080eee5 100644
--- a/spec/features/admin/project_custom_fields/project_mappings_spec.rb
+++ b/spec/features/admin/project_custom_fields/project_mappings_spec.rb
@@ -119,15 +119,7 @@ RSpec.describe "Project Custom Field Mappings", :js do
expect(page).to have_text(subproject.name)
aggregate_failures "pagination links maintain the correct url" do
- within ".op-pagination" do
- pagination_links = page.all(".op-pagination--item-link")
- expect(pagination_links.size).to be_positive
-
- pagination_links.each do |pagination_link|
- uri = URI.parse(pagination_link["href"])
- expect(uri.path).to eq(project_mappings_admin_settings_project_custom_field_path(project_custom_field))
- end
- end
+ project_custom_field_mappings_page.expect_correct_pagination_links(model: project_custom_field)
end
end
@@ -142,15 +134,7 @@ RSpec.describe "Project Custom Field Mappings", :js do
expect(page).to have_no_text(project.name)
aggregate_failures "pagination links maintain the correct url after unlinking is done" do
- within ".op-pagination" do
- pagination_links = page.all(".op-pagination--item-link")
- expect(pagination_links.size).to be_positive
-
- pagination_links.each do |pagination_link|
- uri = URI.parse(pagination_link["href"])
- expect(uri.path).to eq(project_mappings_admin_settings_project_custom_field_path(project_custom_field))
- end
- end
+ project_custom_field_mappings_page.expect_correct_pagination_links(model: project_custom_field)
end
end
diff --git a/spec/support/pages/admin/custom_fields/custom_fields_projects/custom_field_projects_index.rb b/spec/support/pages/admin/custom_fields/custom_fields_projects/custom_field_projects_index.rb
index a170b17e58e..1b692f34369 100644
--- a/spec/support/pages/admin/custom_fields/custom_fields_projects/custom_field_projects_index.rb
+++ b/spec/support/pages/admin/custom_fields/custom_fields_projects/custom_field_projects_index.rb
@@ -33,17 +33,32 @@ module Pages
module CustomFields
module CustomFieldsProjects
class CustomFieldProjectsIndex < ::Pages::Projects::Index
- def path
+ def path(custom_field)
"/custom_fields/#{custom_field.id}/projects"
end
def within_row(project)
- row = page.find("#admin-custom-fields-custom-field-projects-row-component-project-#{project.id}")
+ row = page.find("#{row_id_prefix}-#{project.id}")
row.hover
within row do
yield row
end
end
+
+ def expect_correct_pagination_links(model:)
+ within ".op-pagination" do
+ pagination_links = page.all(".op-pagination--item-link")
+ expect(pagination_links.size).to be_positive
+
+ pagination_links.each.with_index(1) do |pagination_link, page_number|
+ uri = URI.parse(pagination_link["href"])
+ expect(uri.path).to eq(path(model))
+ expect(uri.query).to include("page=#{page_number}")
+ end
+ end
+ end
+
+ def row_id_prefix = "#admin-custom-fields-custom-field-projects-row-component-project"
end
end
end
diff --git a/spec/support/pages/admin/settings/project_custom_fields/project_custom_field_mappings_index.rb b/spec/support/pages/admin/settings/project_custom_fields/project_custom_field_mappings_index.rb
index ab41fabafb8..136762591a4 100644
--- a/spec/support/pages/admin/settings/project_custom_fields/project_custom_field_mappings_index.rb
+++ b/spec/support/pages/admin/settings/project_custom_fields/project_custom_field_mappings_index.rb
@@ -32,18 +32,12 @@ module Pages
module Admin
module Settings
module ProjectCustomFields
- class ProjectCustomFieldMappingsIndex < ::Pages::Projects::Index
- def path
+ class ProjectCustomFieldMappingsIndex < ::Pages::Admin::CustomFields::CustomFieldsProjects::CustomFieldProjectsIndex
+ def path(project_custom_field)
"/admin/settings/project_custom_fields/#{project_custom_field.id}/project_mappings"
end
- def within_row(project)
- row = page.find("#settings-project-custom-fields-project-custom-field-mapping-row-component-project-#{project.id}")
- row.hover
- within row do
- yield row
- end
- end
+ def row_id_prefix = "#settings-project-custom-fields-project-custom-field-mapping-row-component-project"
end
end
end