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

chore[Op#49396]: add oauth access grant nudge modal component spec

Kabiru Mwenja5efcd20d8531
diff --git a/modules/storages/app/components/storages/admin/oauth_access_grant_nudge_modal_component.rb b/modules/storages/app/components/storages/admin/oauth_access_grant_nudge_modal_component.rb
index 68ed128ab0d..cbfb360e4e7 100644
--- a/modules/storages/app/components/storages/admin/oauth_access_grant_nudge_modal_component.rb
+++ b/modules/storages/app/components/storages/admin/oauth_access_grant_nudge_modal_component.rb
@@ -60,7 +60,9 @@ module Storages::Admin
def body_text
if authorized?
- concat(render(Storages::OpenProjectStorageModalComponent::Body.new(:success, success_subtitle_notice: :ready)))
+ success_title = I18n.t('storages.oauth_grant_nudge_modal.access_granted')
+ success_subtitle = I18n.t('storages.oauth_grant_nudge_modal.storage_ready', storage: project_storage.storage.name)
+ concat(render(Storages::OpenProjectStorageModalComponent::Body.new(:success, success_subtitle:, success_title:)))
else
I18n.t('storages.oauth_grant_nudge_modal.body')
end
diff --git a/modules/storages/app/components/storages/open_project_storage_modal_component/body.html.erb b/modules/storages/app/components/storages/open_project_storage_modal_component/body.html.erb
index 8ca6fafbb6d..b52a662c5eb 100644
--- a/modules/storages/app/components/storages/open_project_storage_modal_component/body.html.erb
+++ b/modules/storages/app/components/storages/open_project_storage_modal_component/body.html.erb
@@ -17,7 +17,7 @@
<%= render(Primer::Beta::Octicon.new(:"check-circle", size: :medium, color: :success)) %>
<% end %>
<% flex.with_row do %>
- <%= render(Primer::Beta::Heading.new(tag: :h2, text_align: :center)) { I18n.t('storages.open_project_storage_modal.success.title') } %>
+ <%= render(Primer::Beta::Heading.new(tag: :h2, text_align: :center)) { success_title } %>
<% end %>
<% flex.with_row do %>
<%= render(Primer::Beta::Text.new(text_align: :center, color: :muted)) { success_subtitle } %>
diff --git a/modules/storages/app/components/storages/open_project_storage_modal_component/body.rb b/modules/storages/app/components/storages/open_project_storage_modal_component/body.rb
index a7eb4b3ca21..ae3c010ebbe 100644
--- a/modules/storages/app/components/storages/open_project_storage_modal_component/body.rb
+++ b/modules/storages/app/components/storages/open_project_storage_modal_component/body.rb
@@ -25,16 +25,11 @@
#++
class Storages::OpenProjectStorageModalComponent::Body < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
- options success_subtitle_notice: :redirect
+ options success_title: I18n.t('storages.open_project_storage_modal.success.title'),
+ success_subtitle: I18n.t('storages.open_project_storage_modal.success.subtitle')
def initialize(state, **options)
@state = state
super(nil, **options)
end
-
- private
-
- def success_subtitle
- I18n.t("storages.open_project_storage_modal.success.subtitle_#{success_subtitle_notice}")
- end
end
diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.yml
index a0e878f5b62..076d0d09c5a 100644
--- a/modules/storages/config/locales/en.yml
+++ b/modules/storages/config/locales/en.yml
@@ -176,14 +176,15 @@ en:
no_results: No storages set up yet.
notice_successful_storage_connection: Storage connected successfully! Remember to activate the module and the specific storage in the project settings of each desired project to use it.
oauth_grant_nudge_modal:
+ access_granted: Access granted
body: You have successfully added a storage to this project. Would you like to login in the storage and authenticate your user to start using the storage?
cancel_button_label: I will do it later
confirm_button_label: 'Yes'
+ storage_ready: You are now ready to use %{storage}
title: Storage added
open_project_storage_modal:
success:
- subtitle_ready: You are now ready to use the integration
- subtitle_redirect: You are being redirected
+ subtitle: You are being redirected
title: Integration setup completed
waiting:
subtitle: One moment please, this might take some time...
diff --git a/modules/storages/spec/components/storages/admin/oauth_access_grant_nudge_modal_component_spec.rb b/modules/storages/spec/components/storages/admin/oauth_access_grant_nudge_modal_component_spec.rb
new file mode 100644
index 00000000000..f5c69e170cd
--- /dev/null
+++ b/modules/storages/spec/components/storages/admin/oauth_access_grant_nudge_modal_component_spec.rb
@@ -0,0 +1,70 @@
+#-- 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::OAuthAccessGrantNudgeModalComponent, type: :component do # rubocop:disable RSpec/SpecFilePathFormat
+ include Rails.application.routes.url_helpers
+
+ shared_let(:project_storage) { create(:project_storage) }
+
+ before do
+ render_inline(oauth_access_grant_nudge_modal_component)
+ end
+
+ context 'with access pending authorization' do
+ let(:oauth_access_grant_nudge_modal_component) { described_class.new(project_storage_id: project_storage.id) }
+
+ it 'renders the nudge modal' do
+ expect(page).to have_text('Storage added')
+ expect(page).to have_text('You have successfully added a storage to this project. ' \
+ 'Would you like to login in the storage and authenticate ' \
+ 'your user to start using the storage?')
+
+ expect(page).to have_button('I will do it later')
+ expect(page).to have_link('Yes',
+ href: oauth_access_grant_project_settings_project_storage_path(
+ project_id: project_storage.project_id, id: project_storage
+ ))
+ end
+ end
+
+ context 'with access authorized' do
+ let(:oauth_access_grant_nudge_modal_component) do
+ described_class.new(project_storage_id: project_storage.id, authorized: true)
+ end
+
+ it 'renders a success modal' do
+ expect(page).to have_text('Access granted')
+ expect(page).to have_text("You are now ready to use #{project_storage.storage.name}")
+
+ expect(page).to have_button('Close')
+ end
+ end
+end