diff options
Diffstat (limited to 'spec/features/admin/admin_sees_background_migrations_spec.rb')
-rw-r--r-- | spec/features/admin/admin_sees_background_migrations_spec.rb | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/spec/features/admin/admin_sees_background_migrations_spec.rb b/spec/features/admin/admin_sees_background_migrations_spec.rb index 432721d63ad..8edddcf9a9b 100644 --- a/spec/features/admin/admin_sees_background_migrations_spec.rb +++ b/spec/features/admin/admin_sees_background_migrations_spec.rb @@ -31,6 +31,52 @@ RSpec.describe "Admin > Admin sees background migrations" do end end + it 'can click on a specific migration' do + visit admin_background_migrations_path + + within '#content-body' do + tab = find_link active_migration.job_class_name + tab.click + + expect(page).to have_current_path admin_background_migration_path(active_migration) + end + end + + it 'can view failed jobs' do + visit admin_background_migration_path(failed_migration) + + within '#content-body' do + expect(page).to have_content('Failed jobs') + expect(page).to have_content('Id') + expect(page).to have_content('Started at') + expect(page).to have_content('Finished at') + expect(page).to have_content('Batch size') + end + end + + it 'can click on a specific job' do + job = create(:batched_background_migration_job, :failed, batched_migration: failed_migration) + + visit admin_background_migration_path(failed_migration) + + within '#content-body' do + tab = find_link job.id + tab.click + + expect(page).to have_current_path admin_background_migration_batched_job_path(id: job.id, background_migration_id: failed_migration.id) + end + end + + context 'when there are no failed jobs' do + it 'dos not display failed jobs' do + visit admin_background_migration_path(active_migration) + + within '#content-body' do + expect(page).not_to have_content('Failed jobs') + end + end + end + it 'can view queued migrations and pause and resume them' do visit admin_background_migrations_path @@ -66,6 +112,17 @@ RSpec.describe "Admin > Admin sees background migrations" do end end + it 'can fire an action with a database param' do + visit admin_background_migrations_path(database: 'main') + + within '#content-body' do + tab = find_link 'Failed' + tab.click + + expect(page).to have_selector("[method='post'][action='/admin/background_migrations/#{failed_migration.id}/retry?database=main']") + end + end + it 'can view and retry them' do visit admin_background_migrations_path @@ -109,4 +166,89 @@ RSpec.describe "Admin > Admin sees background migrations" do expect(page).to have_content(finished_migration.status_name.to_s) end end + + it 'can change tabs and retain database param' do + skip_if_multiple_databases_not_setup + + visit admin_background_migrations_path(database: 'ci') + + within '#content-body' do + tab = find_link 'Finished' + expect(tab[:class]).not_to include('gl-tab-nav-item-active') + + tab.click + + expect(page).to have_current_path(admin_background_migrations_path(tab: 'finished', database: 'ci')) + expect(tab[:class]).to include('gl-tab-nav-item-active') + end + end + + it 'can view documentation from Learn more link' do + visit admin_background_migrations_path + + within '#content-body' do + expect(page).to have_link('Learn more', href: help_page_path('development/database/batched_background_migrations')) + end + end + + describe 'selected database toggle', :js do + context 'when multi database is not enabled' do + before do + skip_if_multiple_databases_are_setup + + allow(Gitlab::Database).to receive(:db_config_names).and_return(['main']) + end + + it 'does not render the database listbox' do + visit admin_background_migrations_path + + expect(page).not_to have_selector('[data-testid="database-listbox"]') + end + end + + context 'when multi database is enabled' do + before do + skip_if_multiple_databases_not_setup + + allow(Gitlab::Database).to receive(:db_config_names).and_return(%w[main ci]) + end + + it 'does render the database listbox' do + visit admin_background_migrations_path + + expect(page).to have_selector('[data-testid="database-listbox"]') + end + + it 'defaults to main when no parameter is passed' do + visit admin_background_migrations_path + + listbox = page.find('[data-testid="database-listbox"]') + + expect(listbox).to have_text('main') + end + + it 'shows correct database when a parameter is passed' do + visit admin_background_migrations_path(database: 'ci') + + listbox = page.find('[data-testid="database-listbox"]') + + expect(listbox).to have_text('ci') + end + + it 'updates the path to correct database when clicking on listbox option' do + visit admin_background_migrations_path + + listbox = page.find('[data-testid="database-listbox"]') + expect(listbox).to have_text('main') + + listbox.find('button').click + listbox.find('li', text: 'ci').click + wait_for_requests + + expect(page).to have_current_path(admin_background_migrations_path(database: 'ci')) + listbox = page.find('[data-testid="database-listbox"]') + expect(listbox).to have_text('ci') + end + end + end end |