Skip to content

Commit

Permalink
chore[#50921] Cleanup tests for health status
Browse files Browse the repository at this point in the history
  • Loading branch information
dominic-braeunlein committed Nov 28, 2023
1 parent 1fd4d48 commit 2221117
Showing 1 changed file with 47 additions and 47 deletions.
94 changes: 47 additions & 47 deletions modules/storages/spec/features/admin_storages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
RSpec.describe 'Admin storages',
:js,
:storage_server_helpers do
include Redmine::I18n

let(:admin) { create(:admin) }

Expand All @@ -60,24 +59,24 @@
it 'renders a list of storages' do
visit admin_settings_storages_path

expect(page).to have_css('[data-test-selector="storage-name"]', text: complete_storage.name)
expect(page).to have_css('[data-test-selector="storage-name"]', text: incomplete_storage.name)
expect(page).to have_test_selector('storage-name', text: complete_storage.name)
expect(page).to have_test_selector('storage-name', text: incomplete_storage.name)
expect(page).to have_css("a[role='button'][aria-label='Add new storage'][href='#{new_admin_settings_storage_path}']",
text: 'Storage')

within "li#storages_nextcloud_storage_#{complete_storage.id}" do
expect(page).not_to have_css('[data-test-selector="label-incomplete"]')
expect(page).not_to have_test_selector('label-incomplete')
expect(page).to have_link(complete_storage.name, href: edit_admin_settings_storage_path(complete_storage))
expect(page).to have_css('[data-test-selector="storage-creator"]', text: complete_storage.creator.name)
expect(page).to have_css('[data-test-selector="storage-provider"]', text: 'Nextcloud')
expect(page).to have_css('[data-test-selector="storage-host"]', text: complete_storage.host)
expect(page).to have_test_selector('storage-creator', text: complete_storage.creator.name)
expect(page).to have_test_selector('storage-provider', text: 'Nextcloud')
expect(page).to have_test_selector('storage-host', text: complete_storage.host)
end

within "li#storages_nextcloud_storage_#{incomplete_storage.id}" do
expect(page).to have_css('[data-test-selector="label-incomplete"]')
expect(page).to have_css('[data-test-selector="storage-name"]', text: incomplete_storage.name)
expect(page).to have_css('[data-test-selector="storage-provider"]', text: 'Nextcloud')
expect(page).to have_css('[data-test-selector="storage-host"]', text: incomplete_storage.host)
expect(page).to have_test_selector('label-incomplete')
expect(page).to have_test_selector('storage-name', text: incomplete_storage.name)
expect(page).to have_test_selector('storage-provider', text: 'Nextcloud')
expect(page).to have_test_selector('storage-host', text: incomplete_storage.host)
expect(page).to have_css('.op-principal--name', text: incomplete_storage.creator.name)
end

Expand Down Expand Up @@ -571,48 +570,49 @@
end
end

describe 'health status information in edit page' do
frozen_date_time = Time.current
describe 'Health status information in edit page' do
frozen_date_time = Time.zone.local(2023, 11, 28, 1, 2, 3)

Timecop.freeze(frozen_date_time) do
let(:complete_nextcloud_storage_health_pending) { create(:nextcloud_storage_with_complete_configuration) }
let(:complete_nextcloud_storage_health_healthy) { create(:nextcloud_storage_with_complete_configuration, :as_healthy) }
let(:complete_nextcloud_storage_health_unhealthy) { create(:nextcloud_storage_with_complete_configuration, :as_unhealthy) }
let(:complete_nextcloud_storage_health_unhealthy_long_reason) do
create(:nextcloud_storage_with_complete_configuration, :as_unhealthy_long_reason)
end
let(:complete_nextcloud_storage_health_pending) { create(:nextcloud_storage_with_complete_configuration) }
let(:complete_nextcloud_storage_health_healthy) { create(:nextcloud_storage_with_complete_configuration, :as_healthy) }
let(:complete_nextcloud_storage_health_unhealthy) { create(:nextcloud_storage_with_complete_configuration, :as_unhealthy) }
let(:complete_nextcloud_storage_health_unhealthy_long_reason) do
create(:nextcloud_storage_with_complete_configuration, :as_unhealthy_long_reason)
end

before do
complete_nextcloud_storage_health_pending
complete_nextcloud_storage_health_healthy
complete_nextcloud_storage_health_unhealthy
complete_nextcloud_storage_health_unhealthy_long_reason
end
before do
Timecop.freeze(frozen_date_time)
complete_nextcloud_storage_health_pending
complete_nextcloud_storage_health_healthy
complete_nextcloud_storage_health_unhealthy
complete_nextcloud_storage_health_unhealthy_long_reason
end

it 'shows healthy status for storages that are healthy' do
visit edit_admin_settings_storage_path(complete_nextcloud_storage_health_healthy)
expect(page).to have_css('[data-test-selector="storage-health-label-healthy"]', text: 'Healthy')
expect(page).to have_css('[data-test-selector="storage-health-changed-at"]',
text: "Checked #{format_time(frozen_date_time)}")
end
after do
Timecop.return
end

it 'shows pending label for a storage that is pending' do
visit edit_admin_settings_storage_path(complete_nextcloud_storage_health_pending)
expect(page).to have_css('[data-test-selector="storage-health-label-pending"]', text: 'Pending')
end
it 'shows healthy status for storages that are healthy' do
visit edit_admin_settings_storage_path(complete_nextcloud_storage_health_healthy)
expect(page).to have_test_selector('storage-health-label-healthy', text: 'Healthy')
expect(page).to have_test_selector('storage-health-changed-at', text: "Checked 11/28/2023 01:02 AM")
end

it 'shows error status for storages that are unhealthy' do
visit edit_admin_settings_storage_path(complete_nextcloud_storage_health_unhealthy)
expect(page).to have_css('[data-test-selector="storage-health-label-error"]', text: 'Error')
expect(page).to have_css('[data-test-selector="storage-health-reason"]', text: 'error reason')
end
it 'shows pending label for a storage that is pending' do
visit edit_admin_settings_storage_path(complete_nextcloud_storage_health_pending)
expect(page).to have_test_selector('storage-health-label-pending', text: 'Pending')
end

it 'shows formatted error reason for storages that are unhealthy' do
visit edit_admin_settings_storage_path(complete_nextcloud_storage_health_unhealthy_long_reason)
expect(page).to have_css('[data-test-selector="storage-health-label-error"]', text: 'Error')
expect(page).to have_css('[data-test-selector="storage-health-reason"]',
text: 'Unauthorized: Outbound request not authorized')
end
it 'shows error status for storages that are unhealthy' do
visit edit_admin_settings_storage_path(complete_nextcloud_storage_health_unhealthy)
expect(page).to have_test_selector('storage-health-label-error', text: 'Error')
expect(page).to have_test_selector('storage-health-reason', text: 'error reason')
end

it 'shows formatted error reason for storages that are unhealthy' do
visit edit_admin_settings_storage_path(complete_nextcloud_storage_health_unhealthy_long_reason)
expect(page).to have_test_selector('storage-health-label-error', text: 'Error')
expect(page).to have_test_selector('storage-health-reason', text: 'Unauthorized: Outbound request not authorized')
end
end
end

0 comments on commit 2221117

Please sign in to comment.