Commit 0106f74b authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'add-feature-specs-for-admin-reindexing-ui' into 'master'

Add specs to detect reindexing UI issues

See merge request gitlab-org/gitlab!39578
parents 3efc769f bf8d2ea9
......@@ -11,6 +11,26 @@ RSpec.describe Admin::ApplicationSettingsController do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
end
describe 'GET #general' do
before do
sign_in(admin)
end
context 'zero-downtime elasticsearch reindexing' do
render_views
let!(:task) { create(:elastic_reindexing_task) }
it 'assigns elasticsearch reindexing task' do
get :general
expect(assigns(:elasticsearch_reindexing_task)).to eq(task)
expect(response.body).to include('Reindexing status')
expect(response.body).to include("State: #{task.state}")
end
end
end
describe 'PUT #update' do
before do
sign_in(admin)
......
......@@ -75,6 +75,56 @@ RSpec.describe 'admin/application_settings/_elasticsearch_form' do
end
end
context 'zero-downtime elasticsearch reindexing' do
let(:application_setting) { build(:application_setting) }
before do
assign(:elasticsearch_reindexing_task, task)
end
context 'without extended details' do
let(:task) { build(:elastic_reindexing_task) }
it 'renders the task' do
render
expect(rendered).to include("State: #{task.state}")
expect(rendered).not_to include("Task ID:")
expect(rendered).not_to include("Error:")
expect(rendered).not_to include("Expected documents:")
expect(rendered).not_to include("Documents reindexed:")
end
end
context 'with extended details' do
let(:task) { build(:elastic_reindexing_task, state: :reindexing, elastic_task: 'elastic-task-id', error_message: 'error-message', documents_count_target: 5, documents_count: 10) }
it 'renders the task' do
render
expect(rendered).to include("State: #{task.state}")
expect(rendered).to include("Task ID: #{task.elastic_task}")
expect(rendered).to include("Error: #{task.error_message}")
expect(rendered).to include("Expected documents: #{task.documents_count}")
expect(rendered).to include("Documents reindexed: #{task.documents_count_target} (50.0%)")
end
end
context 'with extended details, but without documents_count_target' do
let(:task) { build(:elastic_reindexing_task, state: :reindexing, elastic_task: 'elastic-task-id', documents_count: 10) }
it 'renders the task' do
render
expect(rendered).to include("State: #{task.state}")
expect(rendered).to include("Task ID: #{task.elastic_task}")
expect(rendered).to include("Expected documents: #{task.documents_count}")
expect(rendered).not_to include("Error:")
expect(rendered).not_to include("Documents reindexed:")
end
end
end
context 'when there are elasticsearch indexed namespaces' do
let(:application_setting) { build(:application_setting, elasticsearch_limit_indexing: true) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment