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
Refactor: Extract common page assertion methods into base class
Aaron Contrerasaf4627fcc745
diff --git a/modules/boards/spec/features/support/board_index_page.rb b/modules/boards/spec/features/support/board_index_page.rbindex 700118f5e85..5742ca48e04 100644--- a/modules/boards/spec/features/support/board_index_page.rb+++ b/modules/boards/spec/features/support/board_index_page.rb@@ -27,10 +27,10 @@#++require 'support/pages/page'-require_relative './board_page'+require_relative 'board_list_page'module Pages- class BoardIndex < Page+ class BoardIndex < BoardListPageattr_reader :projectdef initialize(project = nil)@@ -45,18 +45,6 @@ module Pagesendend- def expect_create_button- within '.toolbar-items' do- expect(page).to have_link 'Board'- end- end-- def expect_no_create_button- within '.toolbar-items' do- expect(page).not_to have_link 'Board'- end- end-def expect_editable(editable)# Editable / draggable checkexpect(page).to have_conditional_selector(editable, '.buttons a.icon-delete')@@ -68,38 +56,6 @@ module Pagesexpect(page).to have_conditional_selector(present, 'td.name', text: name)end- def expect_boards_listed(*boards)- within '#content-wrapper' do- boards.each do |board|- expect(page).to have_selector("td.name", text: board.name)- end- end- end-- def expect_boards_not_listed(*boards)- within '#content-wrapper' do- boards.each do |board|- expect(page).not_to have_selector("td.title", text: board.name)- end- end- end-- def expect_no_boards_listed- within '#content-wrapper' do- expect(page).to have_content I18n.t(:no_results_title_text)- end- end-- def expect_to_be_on_page(number)- expect(page).to have_selector('.op-pagination--item_current', text: number)- end-- def to_page(number)- within '.op-pagination--pages' do- click_link number.to_s- end- end-def create_board(action: nil, expect_empty: false, via_toolbar: false)if via_toolbarpage.find('[data-qa-selector="sidebar--create-board-button"]').clickdiff --git a/modules/boards/spec/features/support/board_list_page.rb b/modules/boards/spec/features/support/board_list_page.rbnew file mode 100644index 00000000000..4d4986360f5--- /dev/null+++ b/modules/boards/spec/features/support/board_list_page.rb@@ -0,0 +1,81 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-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.+#++++require 'support/pages/page'++module Pages+ class BoardListPage < Page+ def visit!+ raise 'Define how to visit me'+ end++ def expect_create_button+ within '.toolbar-items' do+ expect(page).to have_link 'Board'+ end+ end++ def expect_no_create_button+ within '.toolbar-items' do+ expect(page).not_to have_link 'Board'+ end+ end++ def expect_boards_listed(*boards)+ within '#content-wrapper' do+ boards.each do |board|+ expect(page).to have_selector("td.name", text: board.name)+ end+ end+ end++ def expect_boards_not_listed(*boards)+ within '#content-wrapper' do+ boards.each do |board|+ expect(page).not_to have_selector("td.title", text: board.name)+ end+ end+ end++ def expect_no_boards_listed+ within '#content-wrapper' do+ expect(page).to have_content I18n.t(:no_results_title_text)+ end+ end++ def expect_to_be_on_page(number)+ expect(page).to have_selector('.op-pagination--item_current', text: number)+ end++ def to_page(number)+ within '.op-pagination--pages' do+ click_link number.to_s+ end+ end+ end+enddiff --git a/modules/boards/spec/features/support/board_overview_page.rb b/modules/boards/spec/features/support/board_overview_page.rbindex dfaac149ac0..cac8cfa9c0a 100644--- a/modules/boards/spec/features/support/board_overview_page.rb+++ b/modules/boards/spec/features/support/board_overview_page.rb@@ -27,10 +27,10 @@#++require 'support/pages/page'-require_relative './board_page'+require_relative 'board_list_page'module Pages- class BoardOverview < Page+ class BoardOverview < BoardListPagedef visit!navigate_to_modules_menu_item("Boards")end@@ -40,49 +40,5 @@ module Pagesexpect(page).to have_selector('.selected', text: 'Boards')endend-- def expect_create_button- within '.toolbar-items' do- expect(page).to have_link 'Board'- end- end-- def expect_no_create_button- within '.toolbar-items' do- expect(page).not_to have_link 'Board'- end- end-- def expect_no_boards_listed- within '#content-wrapper' do- expect(page).to have_content I18n.t(:no_results_title_text)- end- end-- def expect_boards_listed(*boards)- within '#content-wrapper' do- boards.each do |board|- expect(page).to have_selector("td.name", text: board.name)- end- end- end-- def expect_to_be_on_page(number)- expect(page).to have_selector('.op-pagination--item_current', text: number)- end-- def to_page(number)- within '.op-pagination--pages' do- click_link number.to_s- end- end-- def expect_boards_not_listed(*boards)- within '#content-wrapper' do- boards.each do |board|- expect(page).not_to have_selector("td.title", text: board.name)- end- end- endendend