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#50212]: Expand Storage "Nextcloud OAuth" spec

Kabiru Mwenja3d79a79e795b
diff --git a/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.html.erb b/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.html.erb
index ea23fbcc386..190820e5413 100644
--- a/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.html.erb
+++ b/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.html.erb
@@ -1,23 +1,25 @@
<%=
- primer_form_with(
- model: oauth_client,
- url: admin_settings_storage_oauth_client_path(storage)
- ) do |form|
- flex_layout do |oauth_client_row|
- oauth_client_row.with_row(mb: 3) do
- render(Primer::Beta::Text.new(font_weight: :semibold)) { I18n.t("storages.file_storage_view.#{storage.short_provider_type}_oauth") }
- end
+ render(Primer::Beta::Text.new(tag: :div, test_selector: 'storage-oauth-client-form')) do
+ primer_form_with(
+ model: oauth_client,
+ url: admin_settings_storage_oauth_client_path(storage)
+ ) do |form|
+ flex_layout do |oauth_client_row|
+ oauth_client_row.with_row(mb: 3) do
+ render(Primer::Beta::Text.new(font_weight: :semibold)) { I18n.t("storages.file_storage_view.#{storage.short_provider_type}_oauth") }
+ end
- oauth_client_row.with_row(mb: 3) do
- render(Primer::Beta::Text.new(font_weight: :light)) { storage_provider_credentials_copy_instructions }
- end
+ oauth_client_row.with_row(mb: 3) do
+ render(Primer::Beta::Text.new(font_weight: :light)) { storage_provider_credentials_copy_instructions }
+ end
- oauth_client_row.with_row(mb: 3) do
- render(Storages::Admin::OAuthClientForm.new(form, storage:))
- end
+ oauth_client_row.with_row(mb: 3) do
+ render(Storages::Admin::OAuthClientForm.new(form, storage:))
+ end
- oauth_client_row.with_row do
- render(Storages::Admin::SaveOrCancelForm.new(form, storage:))
+ oauth_client_row.with_row do
+ render(Storages::Admin::SaveOrCancelForm.new(form, storage:))
+ end
end
end
end
diff --git a/modules/storages/spec/features/admin_storages_spec.rb b/modules/storages/spec/features/admin_storages_spec.rb
index 56e70a9785d..88c3108fc10 100644
--- a/modules/storages/spec/features/admin_storages_spec.rb
+++ b/modules/storages/spec/features/admin_storages_spec.rb
@@ -166,6 +166,30 @@ RSpec.describe 'Admin storages',
expect(page).to have_test_selector('label-storage_oauth_client_configured-status', text: 'Incomplete')
expect(page).to have_test_selector('storage-oauth-client-id-description',
text: "Allow OpenProject to access Nextcloud data using an OAuth.")
+
+ accept_confirm do
+ find_test_selector('storage-edit-oauth-client-button').click
+ end
+
+ within_test_selector('storage-oauth-client-form') do
+ expect(page).to have_css('#oauth_client_client_id', value: '')
+ expect(page).to have_css('#oauth_client_client_secret', value: '')
+
+ # Unhappy path - Attempt to submit null values
+ click_button 'Save and continue'
+ # TODO: This should be "Client ID can't be blank." but primer assumes the label is "Client"
+ expect(page).to have_text("Client can't be blank.")
+ expect(page).to have_text("Client secret can't be blank.")
+
+ # Happy path - Submit valid values
+ fill_in 'oauth_client_client_id', with: '1234567890'
+ fill_in 'oauth_client_client_secret', with: '0987654321'
+ click_button 'Save and continue'
+ end
+
+ expect(page).to have_test_selector('label-storage_oauth_client_configured-status', text: 'Connected')
+ expect(page).to have_test_selector('storage-oauth-client-id-description',
+ text: "OAuth Client ID: 1234567890")
end
aggregate_failures 'Automatically managed project folders' do