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

[51372] Fixed admin_storages_spec

Andreas Pfohl8ce5516e558f
diff --git a/modules/storages/app/components/storages/admin/forms/redirect_uri_form_component.html.erb b/modules/storages/app/components/storages/admin/forms/redirect_uri_form_component.html.erb
index 4c98e07c6f0..822897bc124 100644
--- a/modules/storages/app/components/storages/admin/forms/redirect_uri_form_component.html.erb
+++ b/modules/storages/app/components/storages/admin/forms/redirect_uri_form_component.html.erb
@@ -12,8 +12,6 @@
) do |form|
flex_layout do |oauth_client_row|
oauth_client_row.with_row(mb: 3) do
- # concat(render(Storages::Admin::StorageIsCompleteHiddenInputForm.new(form)))
-
concat(render(Primer::OpenProject::InputGroup.new(input_width: :large)) do |input_group|
input_group.with_text_input(
name: :oauth_client_redirect_uri,
@@ -33,7 +31,8 @@
},
data: {
'storages--oauth-client-form-target': 'redirectUri'
- }
+ },
+ test_selector: 'storage-oauth-client-redirect-uri'
)
end)
diff --git a/modules/storages/app/components/storages/admin/redirect_uri_component.html.erb b/modules/storages/app/components/storages/admin/redirect_uri_component.html.erb
index 75fb18cc722..5e6030aa75b 100644
--- a/modules/storages/app/components/storages/admin/redirect_uri_component.html.erb
+++ b/modules/storages/app/components/storages/admin/redirect_uri_component.html.erb
@@ -21,7 +21,7 @@
grid.with_area(:"icon-button", tag: :div, color: :muted) do
flex_layout(justify_content: :flex_end) do |icons_container|
icons_container.with_column do
- render(Primer::Beta::IconButton.new(**edit_icon_button_options))
+ render(Primer::Beta::IconButton.new(**show_icon_button_options))
end
end
end
diff --git a/modules/storages/app/components/storages/admin/redirect_uri_component.rb b/modules/storages/app/components/storages/admin/redirect_uri_component.rb
index 23e942f0ea2..1fd9c5f8af2 100644
--- a/modules/storages/app/components/storages/admin/redirect_uri_component.rb
+++ b/modules/storages/app/components/storages/admin/redirect_uri_component.rb
@@ -41,21 +41,15 @@ module Storages::Admin
@storage = storage
end
- def edit_icon_button_options
+ def show_icon_button_options
{
- icon: oauth_client_configured? ? :eye : :pencil,
+ icon: :eye,
tag: :a,
href: Rails.application.routes.url_helpers.show_redirect_uri_admin_settings_storage_oauth_client_path(storage),
scheme: :invisible,
aria: { label: I18n.t("storages.label_show_storage_redirect_uri") },
- test_selector: 'storage-edit-oauth-client-button'
+ test_selector: 'storage-show-redirect-uri-button'
}
end
-
- private
-
- def oauth_client_configured?
- storage.configuration_checks[:storage_oauth_client_configured]
- end
end
end
diff --git a/modules/storages/spec/features/admin_storages_spec.rb b/modules/storages/spec/features/admin_storages_spec.rb
index f88c3ca5f6b..6af980fcda5 100644
--- a/modules/storages/spec/features/admin_storages_spec.rb
+++ b/modules/storages/spec/features/admin_storages_spec.rb
@@ -134,13 +134,13 @@ RSpec.describe 'Admin storages',
expect(page).to have_test_selector('storage-new-page-header--title', text: 'New Nextcloud storage')
expect(page).to have_test_selector('storage-new-page-header--description',
text: "Read our documentation on setting up a Nextcloud file storage " \
- "integration for more information.")
+ "integration for more information.")
# General information
expect(page).to have_test_selector('storage-provider-configuration-instructions',
text: "Please make sure you have administration privileges in your " \
- "Nextcloud instance and the application “Integration OpenProject” " \
- "is installed before doing the setup.")
+ "Nextcloud instance and the application “Integration OpenProject” " \
+ "is installed before doing the setup.")
# OAuth application
expect(page).to have_test_selector('storage-openproject-oauth-label', text: 'OpenProject OAuth')
@@ -181,8 +181,8 @@ RSpec.describe 'Admin storages',
within_test_selector('storage-openproject-oauth-application-form') do
warning_section = find_test_selector('storage-openproject_oauth_application_warning')
expect(warning_section).to have_text('The client secret value will not be accessible again after you close ' \
- 'this window. Please copy these values into the Nextcloud ' \
- 'OpenProject Integration settings.')
+ 'this window. Please copy these values into the Nextcloud ' \
+ 'OpenProject Integration settings.')
expect(warning_section).to have_link('Nextcloud OpenProject Integration settings',
href: "https://example.com/settings/admin/openproject")
@@ -231,7 +231,7 @@ RSpec.describe 'Admin storages',
# Test the error path for an invalid storage password.
# Mock a valid response (=401) for example.com, so the password validation should fail
mock_nextcloud_application_credentials_validation('https://example.com', password: "1234567890",
- response_code: 401)
+ response_code: 401)
automatically_managed_switch = page.find('[name="storages_nextcloud_storage[automatically_managed]"]')
expect(automatically_managed_switch).to be_checked
fill_in 'storages_nextcloud_storage_password', with: "1234567890"
@@ -251,10 +251,10 @@ RSpec.describe 'Admin storages',
expect(page).to have_current_path(admin_settings_storages_path)
expect(page).to have_test_selector(
- "primer-banner-message-component",
- text: "Storage connected successfully! Remember to activate the module and the specific " \
- "storage in the project settings of each desired project to use it."
- )
+ "primer-banner-message-component",
+ text: "Storage connected successfully! Remember to activate the module and the specific " \
+ "storage in the project settings of each desired project to use it."
+ )
end
end
end
@@ -288,21 +288,23 @@ RSpec.describe 'Admin storages',
expect(page).to have_test_selector('storage-new-page-header--title', text: 'New OneDrive/SharePoint storage')
expect(page).to have_test_selector('storage-new-page-header--description',
text: "Read our documentation on setting up a OneDrive/SharePoint " \
- "file storage integration for more information.")
+ "file storage integration for more information.")
# General information
expect(page).to have_test_selector('storage-provider-configuration-instructions',
text: "Please make sure you have administration privileges in the " \
- "Azure portal or contact your Microsoft administrator before " \
- "doing the setup. In the portal, you also need to register an " \
- "Azure application or use an existing one for authentication.")
+ "Azure portal or contact your Microsoft administrator before " \
+ "doing the setup. In the portal, you also need to register an " \
+ "Azure application or use an existing one for authentication.")
# OAuth client
wait_for(page).to have_test_selector('storage-oauth-client-label', text: 'Azure OAuth')
expect(page).not_to have_test_selector('label-storage_oauth_client_configured-status')
expect(page).to have_test_selector('storage-oauth-client-id-description',
text: "Allow OpenProject to access Azure data using OAuth " \
- "to connect OneDrive/Sharepoint.")
+ "to connect OneDrive/Sharepoint.")
+ expect(page).to have_test_selector('storage-redirect-uri-description',
+ text: "Complete the setup with the correct URI redirection.")
end
aggregate_failures 'General information' do
@@ -326,7 +328,7 @@ RSpec.describe 'Admin storages',
within_test_selector('storage-oauth-client-form') do
expect(page).to have_test_selector('storage-provider-credentials-instructions',
text: 'Copy these values from the desired application in the ' \
- 'Azure portal.')
+ 'Azure portal.')
# With null values, submit button should be disabled
expect(page).to have_css('#oauth_client_client_id', value: '')
@@ -338,14 +340,18 @@ RSpec.describe 'Admin storages',
fill_in 'oauth_client_client_secret', with: '0987654321'
expect(find_test_selector('storage-oauth-client-submit-button')).not_to be_disabled
click_button 'Save and continue'
+
+ expect(page).to have_test_selector('storage-oauth-client-redirect-uri')
+
+ click_button 'Done, complete setup'
end
expect(page).to have_current_path(admin_settings_storages_path)
wait_for(page).to have_test_selector(
- "primer-banner-message-component",
- text: "Storage connected successfully! Remember to activate the module and the specific " \
- "storage in the project settings of each desired project to use it."
- )
+ "primer-banner-message-component",
+ text: "Storage connected successfully! Remember to activate the module and the specific " \
+ "storage in the project settings of each desired project to use it."
+ )
end
end
end
@@ -472,8 +478,8 @@ RSpec.describe 'Admin storages',
within_test_selector('storage-openproject-oauth-application-form') do
warning_section = find_test_selector('storage-openproject_oauth_application_warning')
expect(warning_section).to have_text('The client secret value will not be accessible again after you close ' \
- 'this window. Please copy these values into the Nextcloud ' \
- 'OpenProject Integration settings.')
+ 'this window. Please copy these values into the Nextcloud ' \
+ 'OpenProject Integration settings.')
expect(warning_section).to have_link('Nextcloud OpenProject Integration settings',
href: "#{storage.host}/settings/admin/openproject")
@@ -524,7 +530,7 @@ RSpec.describe 'Admin storages',
# Test the error path for an invalid storage password.
# Mock a valid response (=401) for example.com, so the password validation should fail
mock_nextcloud_application_credentials_validation(storage.host, password: "1234567890",
- response_code: 401)
+ response_code: 401)
automatically_managed_switch = page.find('[name="storages_nextcloud_storage[automatically_managed]"]')
expect(automatically_managed_switch).to be_checked
fill_in 'storages_nextcloud_storage_password', with: "1234567890"
@@ -615,6 +621,17 @@ RSpec.describe 'Admin storages',
click_button 'Save and continue'
end
+ aggregate_failures 'Redirect URI' do
+ expect(page).to have_test_selector('storage-redirect-uri-label')
+ expect(page).to have_test_selector('storage-show-redirect-uri-button')
+ expect(page).not_to have_test_selector('storage-oauth-client-redirect-uri')
+
+ find('a[data-test-selector="storage-show-redirect-uri-button"]').click
+
+ expect(page).to have_test_selector('storage-oauth-client-redirect-uri')
+ expect(find_test_selector('storage-oauth-client-submit-button')).to be_disabled
+ end
+
expect(page).to have_test_selector('label-storage_oauth_client_configured-status', text: 'Completed')
expect(page).to have_test_selector('storage-oauth-client-id-description', text: "OAuth Client ID: 1234567890")
end