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 "General information" spec

Kabiru Mwenja47c8f17b5ed4
diff --git a/modules/storages/app/components/storages/admin/forms/general_info_form_component.html.erb b/modules/storages/app/components/storages/admin/forms/general_info_form_component.html.erb
index 30f403e74ab..870354dc4d6 100644
--- a/modules/storages/app/components/storages/admin/forms/general_info_form_component.html.erb
+++ b/modules/storages/app/components/storages/admin/forms/general_info_form_component.html.erb
@@ -1,16 +1,18 @@
<%=
- primer_form_with(
- model: storage,
- url: admin_settings_storage_path(storage),
- method: :patch
- ) do |form|
- flex_layout do |general_info_row|
- general_info_row.with_row(mb: 3) do
- render(Storages::Admin::StorageProviderForm.new(form))
- end
+ render(Primer::Beta::Text.new(tag: :div, test_selector: 'storage-general-info-form')) do
+ primer_form_with(
+ model: storage,
+ url: admin_settings_storage_path(storage),
+ method: :patch
+ ) do |form|
+ flex_layout do |general_info_row|
+ general_info_row.with_row(mb: 3) do
+ render(Storages::Admin::StorageProviderForm.new(form))
+ end
- general_info_row.with_row do
- render(Storages::Admin::SaveOrCancelForm.new(form, storage:))
+ general_info_row.with_row do
+ render(Storages::Admin::SaveOrCancelForm.new(form, storage:))
+ end
end
end
end
diff --git a/modules/storages/spec/contracts/storages/storages/nextcloud_contract_spec.rb b/modules/storages/spec/contracts/storages/storages/nextcloud_contract_spec.rb
index 217506f04b7..026054f9df5 100644
--- a/modules/storages/spec/contracts/storages/storages/nextcloud_contract_spec.rb
+++ b/modules/storages/spec/contracts/storages/storages/nextcloud_contract_spec.rb
@@ -31,7 +31,7 @@
require 'spec_helper'
require_module_spec_helper
-RSpec.describe Storages::Storages::NextcloudContract, :storage_server_helpers, webmock: true do
+RSpec.describe Storages::Storages::NextcloudContract, :storage_server_helpers, :webmock do
let(:current_user) { create(:admin) }
let(:storage_host) { 'https://host1.example.com' }
let(:storage) { build(:nextcloud_storage, host: storage_host) }
@@ -55,14 +55,14 @@ RSpec.describe Storages::Storages::NextcloudContract, :storage_server_helpers, w
end
describe 'Nextcloud application credentials validation' do
- before do
- mock_server_capabilities_response(storage.host)
- mock_server_config_check_response(storage.host)
- end
-
context 'with valid credentials' do
let(:storage) { build(:nextcloud_storage, :as_automatically_managed) }
+ before do
+ mock_server_capabilities_response(storage.host)
+ mock_server_config_check_response(storage.host)
+ end
+
it 'passes validation' do
credentials_request = mock_nextcloud_application_credentials_validation(storage.host)
diff --git a/modules/storages/spec/features/admin_storages_spec.rb b/modules/storages/spec/features/admin_storages_spec.rb
index aca420bdb63..8fd511fec9b 100644
--- a/modules/storages/spec/features/admin_storages_spec.rb
+++ b/modules/storages/spec/features/admin_storages_spec.rb
@@ -91,8 +91,9 @@ RSpec.describe 'Admin storages',
describe 'File storage edit view', with_flag: { storage_primer_design: true } do
let(:storage) { create(:nextcloud_storage) }
+ let(:oauth_application) { create(:oauth_application, integration: storage) }
- before { storage }
+ before { oauth_application }
it 'renders the edit view' do
visit edit_admin_settings_storage_path(storage)
@@ -105,11 +106,38 @@ RSpec.describe 'Admin storages',
expect(page).to have_test_selector('storage-description', text: [storage.short_provider_type.capitalize,
storage.name,
storage.host].join(' - '))
+
+ # Update a storage - happy path
+ find_test_selector('storage-edit-host-button').click
+ within_test_selector('storage-general-info-form') do
+ select 'Nextcloud', from: 'storages_nextcloud_storage_provider_type'
+ fill_in 'storages_nextcloud_storage_name', with: 'My Nextcloud'
+ click_button 'Save and continue'
+ end
+
+ expect(page).to have_test_selector('storage-description', text: [storage.short_provider_type.capitalize,
+ 'My Nextcloud',
+ storage.host].join(' - '))
+
+ # Update a storage - unhappy path
+ find_test_selector('storage-edit-host-button').click
+ within_test_selector('storage-general-info-form') do
+ fill_in 'storages_nextcloud_storage_name', with: nil
+ fill_in 'storages_nextcloud_storage_host', with: nil
+ click_button 'Save and continue'
+
+ expect(page).to have_text("Name can't be blank.")
+ expect(page).to have_text("Host is not a valid URL.")
+
+ click_link 'Cancel'
+ end
end
aggregate_failures 'OAuth application' do
expect(page).to have_test_selector('storage-openproject-oauth-label', text: 'OpenProject OAuth')
- expect(page).to have_test_selector('label-openproject_oauth_application_configured-status', text: 'Incomplete')
+ expect(page).to have_test_selector('label-openproject_oauth_application_configured-status', text: 'Connected')
+ expect(page).to have_test_selector('storage-openproject-oauth-client-description',
+ text: "OAuth Client ID: #{oauth_application.uid}")
end
aggregate_failures 'Nextcloud OAuth' do