Skip to content

Commit

Permalink
Merge pull request #15079 from opf/bug/53202-backport
Browse files Browse the repository at this point in the history
Backport into 13.4 [#53202]: Health status is not showing for OneDrive storages
  • Loading branch information
ulferts authored Mar 22, 2024
2 parents 2a7e8fb + f6be1eb commit ba49d84
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ See COPYRIGHT and LICENSE files for more details.
<% end %>
<% end %>

<% if @storage.provider_type_nextcloud? && @storage.automatic_management_enabled? %>
<% if @storage.automatic_management_enabled? %>
<%= render(Primer::Alpha::Layout.new(stacking_breakpoint: :lg)) do |component| %>
<% component.with_main() do %>
<%= render(::Storages::Admin::StorageViewComponent.new(@storage)) %>
Expand Down
30 changes: 17 additions & 13 deletions modules/storages/spec/factories/storage_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,6 @@
trait :as_generic do
provider_type { 'Storages::Storage' }
end
end

factory :nextcloud_storage,
parent: :storage,
class: '::Storages::NextcloudStorage' do
provider_type { Storages::Storage::PROVIDER_TYPE_NEXTCLOUD }
sequence(:host) { |n| "https://host#{n}.example.com" }

trait :as_automatically_managed do
automatically_managed { true }
username { 'OpenProject' }
password { 'Password123' }
end

trait :as_not_automatically_managed do
automatically_managed { false }
Expand Down Expand Up @@ -91,6 +78,19 @@
end
end

factory :nextcloud_storage,
parent: :storage,
class: '::Storages::NextcloudStorage' do
provider_type { Storages::Storage::PROVIDER_TYPE_NEXTCLOUD }
sequence(:host) { |n| "https://host#{n}.example.com" }

trait :as_automatically_managed do
automatically_managed { true }
username { 'OpenProject' }
password { 'Password123' }
end
end

factory :nextcloud_storage_configured, parent: :nextcloud_storage do
after(:create) do |storage, _evaluator|
create(:oauth_client, integration: storage)
Expand Down Expand Up @@ -155,6 +155,10 @@
host { nil }
tenant_id { SecureRandom.uuid }
drive_id { SecureRandom.uuid }

trait :as_automatically_managed do
automatically_managed { true }
end
end

factory :sharepoint_dev_drive_storage,
Expand Down
34 changes: 31 additions & 3 deletions modules/storages/spec/features/storages/admin/edit_storage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,28 @@
end
end

context 'with OneDrive Storage' do
let(:storage) { create(:one_drive_storage, name: 'Test Drive') }
context 'with Nextcloud Storage and not automatically managed' do
let(:storage) { create(:nextcloud_storage, :as_not_automatically_managed, name: 'Cloud Storage') }

it 'does not render health status information' do
visit edit_admin_settings_storage_path(storage)

expect(page).not_to have_test_selector('storage-health-label-pending', text: 'Pending')
end
end

context 'with OneDrive/SharePoint Storage' do
let(:storage) { create(:one_drive_storage, :as_automatically_managed, name: 'Test Drive') }
let(:oauth_client) { create(:oauth_client, integration: storage) }

before { oauth_client }

it 'renders an edit view', :webmock do
visit edit_admin_settings_storage_path(storage)

expect(page).to be_axe_clean.within '#content'
expect(page).to be_axe_clean
.within('#content')
.skipping('heading-order')

expect(page).to have_test_selector('storage-new-page-header--title', text: 'Test Drive (OneDrive/SharePoint)')

Expand Down Expand Up @@ -314,5 +326,21 @@
expect(page).to have_test_selector('storage-oauth-client-id-description', text: "OAuth Client ID: 1234567890")
end
end

it 'renders health status information' do
visit edit_admin_settings_storage_path(storage)

expect(page).to have_test_selector('storage-health-label-pending', text: 'Pending')
end
end

context 'with OneDrive/SharePoint Storage and not automatically managed' do
let(:storage) { create(:one_drive_storage, :as_not_automatically_managed, name: 'Cloud Storage') }

it 'does not render health status information' do
visit edit_admin_settings_storage_path(storage)

expect(page).not_to have_test_selector('storage-health-label-pending', text: 'Pending')
end
end
end

0 comments on commit ba49d84

Please sign in to comment.