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-51021] extract new storage button unit tests from feature

Kabiru Mwenja5b5d3d84e47b
diff --git a/modules/storages/app/components/storages/admin/new_storage_button_component.html.erb b/modules/storages/app/components/storages/admin/new_storage_button_component.html.erb
index fd290f9dad0..cf0ccf551ee 100644
--- a/modules/storages/app/components/storages/admin/new_storage_button_component.html.erb
+++ b/modules/storages/app/components/storages/admin/new_storage_button_component.html.erb
@@ -8,9 +8,10 @@
::Storages::Storage::PROVIDER_TYPES.each do |provider_type|
short_provider_type = ::Storages::Storage.shorten_provider_type(provider_type)
+
menu.with_item(
label: I18n.t("storages.provider_types.#{short_provider_type}.name"),
- href: select_provider_admin_settings_storages_path(provider: short_provider_type)
+ href: url_helpers.select_provider_admin_settings_storages_path(provider: short_provider_type)
) do |item|
item.with_trailing_visual_icon(icon: "op-enterprise-addons", classes: "upsale-colored") if show_ee_icon?(provider_type:)
end
diff --git a/modules/storages/spec/components/storages/admin/new_storage_button_component_spec.rb b/modules/storages/spec/components/storages/admin/new_storage_button_component_spec.rb
new file mode 100644
index 00000000000..4315447df97
--- /dev/null
+++ b/modules/storages/spec/components/storages/admin/new_storage_button_component_spec.rb
@@ -0,0 +1,43 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 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'
+require_module_spec_helper
+
+RSpec.describe Storages::Admin::NewStorageButtonComponent, type: :component do
+ include Rails.application.routes.url_helpers
+
+ it 'renders a "New Storage" Action Menu' do
+ with_rendered_component_path(render_inline(described_class.new)) do |_rendered_fragement_path|
+ expect(page).to have_button 'Storage', aria: { label: 'Add new storage' }
+
+ expect(page).to have_link 'Nextcloud', href: select_provider_admin_settings_storages_path(provider: 'nextcloud')
+ expect(page).to have_link 'OneDrive/SharePoint', href: select_provider_admin_settings_storages_path(provider: 'one_drive')
+ end
+ end
+end
diff --git a/modules/storages/spec/features/admin_storages_spec.rb b/modules/storages/spec/features/admin_storages_spec.rb
index d13a828a4de..a8ecf3a521b 100644
--- a/modules/storages/spec/features/admin_storages_spec.rb
+++ b/modules/storages/spec/features/admin_storages_spec.rb
@@ -66,10 +66,6 @@ RSpec.describe 'Admin storages',
end
it 'renders a blank slate' do
- # Show Add storage button
- expect(page).to have_button 'Storage', aria: { label: 'Add new storage' }
-
- # Show empty storages list
expect(page).to have_title('File storages')
expect(page.find('.PageHeader-title')).to have_text('File storages')
expect(page).to have_text("You don't have any storages yet.")