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
Fix OP#51135: selecting "Group by" should group
Christophe Bliard26edb2f4e1b4
diff --git a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/display-settings-tab.component.ts b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/display-settings-tab.component.tsindex 947654a0c23..b50edd182df 100644--- a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/display-settings-tab.component.ts+++ b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/display-settings-tab.component.ts@@ -76,7 +76,7 @@ export class WpTableConfigurationDisplaySettingsTabComponent implements TabCompo.onReady().then(() => {this.availableGroups = _.sortBy(this.wpTableGroupBy.available, 'name');- this.currentGroup = this.wpTableGroupBy.current;+ this.currentGroup = this.wpTableGroupBy.current || this.availableGroups[0];});}}diff --git a/spec/features/work_packages/table/group_by/group_by_spec.rb b/spec/features/work_packages/table/group_by/group_by_spec.rbnew file mode 100644index 00000000000..79d08d35386--- /dev/null+++ b/spec/features/work_packages/table/group_by/group_by_spec.rb@@ -0,0 +1,54 @@+# frozen_string_literal: true++#-- 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 'spec_helper'++RSpec.describe 'Work Package group by progress', :js do+ let(:user) { create(:admin) }+ let(:project) { create(:project) }+ let(:group_by) { Components::WorkPackages::GroupBy.new }++ current_user { user }++ before do+ create_list(:work_package, 3, project:, author: user)+ end++ it 'switches to grouped view when selecting "group by" option' do+ visit work_packages_path(project:)++ # Activate group by option+ group_by.enable++ # Expect table to be grouped into 1 group+ group_by.expect_number_of_groups 1+ group_by.expect_grouped_by_value '-', 3+ end+enddiff --git a/spec/support/components/work_packages/group_by.rb b/spec/support/components/work_packages/group_by.rbindex baddad4cd73..9bc5cb33e61 100644--- a/spec/support/components/work_packages/group_by.rb+++ b/spec/support/components/work_packages/group_by.rb@@ -41,30 +41,30 @@ module Componentsendend- def enable_via_menu(name)- modal = TableConfigurationModal.new+ def enable+ set_display_mode('grouped')+ end- modal.open_and_set_display_mode 'grouped'- select name, from: 'selected_grouping'- modal.save+ def enable_via_menu(name)+ set_display_mode('grouped') do+ select name, from: 'selected_grouping'+ endenddef disable_via_menu- modal = TableConfigurationModal.new- modal.open_and_set_display_mode 'default'- modal.save+ set_display_mode('default')enddef expect_number_of_groups(count)- expect(page).to have_selector('[data-test-selector="op-group--value"] .count', count:)+ expect(page).to have_css('[data-test-selector="op-group--value"] .count', count:)enddef expect_grouped_by_value(value_name, count)- expect(page).to have_selector('[data-test-selector="op-group--value"]', text: "#{value_name} (#{count})")+ expect(page).to have_css('[data-test-selector="op-group--value"]', text: "#{value_name} (#{count})")enddef expect_no_groups- expect(page).not_to have_selector('[data-test-selector="op-group--value"]')+ expect(page).not_to have_css('[data-test-selector="op-group--value"]')enddef expect_not_grouped_by(name)@@ -77,6 +77,14 @@ module Componentsprivate+ def set_display_mode(mode)+ modal = TableConfigurationModal.new++ modal.open_and_set_display_mode mode+ yield if block_given?+ modal.save+ end+def open_table_column_context_menu(name)page.find(".generic-table--sort-header ##{name.downcase}").clickend