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

Add spec for extensible tabs with Lambdas as paths

Henriette Dingerf1f81f919e16
diff --git a/frontend/src/app/components/wp-table/configuration-modal/wp-table-configuration.modal.html b/frontend/src/app/components/wp-table/configuration-modal/wp-table-configuration.modal.html
index 629068de437..98db611cb6b 100644
--- a/frontend/src/app/components/wp-table/configuration-modal/wp-table-configuration.modal.html
+++ b/frontend/src/app/components/wp-table/configuration-modal/wp-table-configuration.modal.html
@@ -23,8 +23,9 @@
<ul class="tabrow">
<li *ngFor="let tab of availableTabs"
[ngClass]="{ 'selected': currentTab && tab.name === currentTab.name }">
- <a role="button"
- [ngClass]="{ '-disabled': tab.disableBecause != null }"
+ <a class="tab-show"
+ role="button"
+ [ngClass]="{ '-disabled': tab.disableBecause != null, 'selected': currentTab && tab.name === currentTab.name }"
[attr.title]="tab.disableBecause || tab.title"
[textContent]="tab.title"
(click)="switchTo(tab.name)"
diff --git a/frontend/src/app/modules/boards/board/configuration-modal/board-configuration.modal.html b/frontend/src/app/modules/boards/board/configuration-modal/board-configuration.modal.html
index 02bc09e9223..ce649ee090e 100644
--- a/frontend/src/app/modules/boards/board/configuration-modal/board-configuration.modal.html
+++ b/frontend/src/app/modules/boards/board/configuration-modal/board-configuration.modal.html
@@ -19,8 +19,9 @@
<ul class="tabrow">
<li *ngFor="let tab of availableTabs"
[ngClass]="{ 'selected': currentTab && tab.name === currentTab.name }">
- <a role="button"
- [ngClass]="{ '-disabled': tab.disableBecause != null }"
+ <a class="tab-show"
+ role="button"
+ [ngClass]="{ '-disabled': tab.disableBecause != null, 'selected': currentTab && tab.name === currentTab.name }"
[attr.title]="tab.disableBecause || tab.title"
[textContent]="tab.title"
(click)="switchTo(tab.name)"
diff --git a/spec/features/work_packages/table/configuration_modal/table_configuration_modal_spec.rb b/spec/features/work_packages/table/configuration_modal/table_configuration_modal_spec.rb
index 68f236a82ca..fdb08173be0 100644
--- a/spec/features/work_packages/table/configuration_modal/table_configuration_modal_spec.rb
+++ b/spec/features/work_packages/table/configuration_modal/table_configuration_modal_spec.rb
@@ -40,6 +40,6 @@ describe 'Work Package table configuration modal', js: true do
expect(page).to have_focus_on('.columns-modal--content input.select2-input')
# Expect active tab is columns
- expect(page).to have_selector('.tab-show.selected', text: 'Columns')
+ expect(page).to have_selector('.tab-show.selected', text: 'COLUMNS')
end
end
diff --git a/spec/helpers/tabs_helper_spec.rb b/spec/helpers/tabs_helper_spec.rb
new file mode 100644
index 00000000000..633c6119177
--- /dev/null
+++ b/spec/helpers/tabs_helper_spec.rb
@@ -0,0 +1,69 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2020 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-2017 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 docs/COPYRIGHT.rdoc for more details.
+#++
+
+require 'spec_helper'
+
+describe TabsHelper, type: :helper do
+ include TabsHelper
+
+ let(:given_tab) {
+ { name: 'avatar',
+ partial: 'avatars/users/avatar_tab',
+ path: ->(params) { tab_edit_user_path(params[:user], tab: :avatar) },
+ label: :label_avatar }
+ }
+
+ let(:expected_tab) {
+ { name: 'avatar',
+ partial: 'avatars/users/avatar_tab',
+ path: '/users/2/edit/avatar',
+ label: :label_avatar }
+ }
+
+ describe 'render_extensible_tabs' do
+ before do
+ allow_any_instance_of(TabsHelper)
+ .to receive(:render_tabs)
+ .with([ expected_tab ])
+ .and_return [ expected_tab ]
+
+ allow(::OpenProject::Ui::ExtensibleTabs)
+ .to receive(:enabled_tabs)
+ .with(:user)
+ .and_return [ given_tab ]
+
+ user = FactoryBot.build(:user, id: 2)
+ @tabs = render_extensible_tabs(:user, user: user)
+ end
+
+ it "should return an evaluated path" do
+ expect(response.status).to eq 200
+ expect(@tabs).to eq([ expected_tab ])
+ end
+ end
+end
diff --git a/spec/support/components/work_packages/table_configuration/filters.rb b/spec/support/components/work_packages/table_configuration/filters.rb
index f873869ef81..55231f664c1 100644
--- a/spec/support/components/work_packages/table_configuration/filters.rb
+++ b/spec/support/components/work_packages/table_configuration/filters.rb
@@ -55,7 +55,7 @@ module Components
def expect_open
modal.expect_open
- expect(page).to have_selector('.tab-show.selected', text: 'Filters')
+ expect(page).to have_selector('.tab-show.selected', text: 'FILTERS')
end
def expect_closed
diff --git a/spec/support/components/work_packages/table_configuration/highlighting.rb b/spec/support/components/work_packages/table_configuration/highlighting.rb
index 847b82dc348..3e9626b05ff 100644
--- a/spec/support/components/work_packages/table_configuration/highlighting.rb
+++ b/spec/support/components/work_packages/table_configuration/highlighting.rb
@@ -83,7 +83,7 @@ module Components
::Components::WorkPackages::SettingsMenu.new.open_and_choose 'Configure view'
retry_block do
- find(".tab-show", text: 'Highlighting', wait: 10).click
+ find(".tab-show", text: 'HIGHLIGHTING', wait: 10).click
end
end
diff --git a/spec/support/components/work_packages/table_configuration_modal.rb b/spec/support/components/work_packages/table_configuration_modal.rb
index d75c3ce45cb..3aff039a0cd 100644
--- a/spec/support/components/work_packages/table_configuration_modal.rb
+++ b/spec/support/components/work_packages/table_configuration_modal.rb
@@ -88,11 +88,11 @@ module Components
end
def expect_disabled_tab(name)
- expect(page).to have_selector("#{selector} .tab-show.-disabled", text: name)
+ expect(page).to have_selector("#{selector} .tab-show.-disabled", text: name.upcase)
end
def selected_tab(name)
- page.find("#{selector} .tab-show.selected", text: name)
+ page.find("#{selector} .tab-show.selected", text: name.upcase)
page.find("#{selector} .tab-content[data-tab-name='#{name}']")
end
@@ -102,7 +102,7 @@ module Components
sleep 1
retry_block do
- find("#{selector} .tab-show", text: target, wait: 10).click
+ find("#{selector} .tab-show", text: target.upcase, wait: 10).click
selected_tab(target)
end
end