diff options
Diffstat (limited to 'spec/features/admin/admin_runners_spec.rb')
-rw-r--r-- | spec/features/admin/admin_runners_spec.rb | 146 |
1 files changed, 96 insertions, 50 deletions
diff --git a/spec/features/admin/admin_runners_spec.rb b/spec/features/admin/admin_runners_spec.rb index cc2d36221dc..ceb91b86876 100644 --- a/spec/features/admin/admin_runners_spec.rb +++ b/spec/features/admin/admin_runners_spec.rb @@ -21,12 +21,16 @@ RSpec.describe "Admin Runners" do context "when there are runners" do it 'has all necessary texts' do - create(:ci_runner, :instance, contacted_at: Time.now) + create(:ci_runner, :instance, created_at: 1.year.ago, contacted_at: Time.now) + create(:ci_runner, :instance, created_at: 1.year.ago, contacted_at: 1.week.ago) + create(:ci_runner, :instance, created_at: 1.year.ago, contacted_at: 1.year.ago) visit admin_runners_path expect(page).to have_text "Register an instance runner" - expect(page).to have_text "Online Runners 1" + expect(page).to have_text "Online runners 1" + expect(page).to have_text "Offline runners 2" + expect(page).to have_text "Stale runners 1" end it 'with an instance runner shows an instance badge' do @@ -131,6 +135,9 @@ RSpec.describe "Admin Runners" do it 'shows correct runner when description matches' do input_filtered_search_keys('runner-foo') + expect(page).to have_link('All 1') + expect(page).to have_link('Instance 1') + expect(page).to have_content("runner-foo") expect(page).not_to have_content("runner-bar") end @@ -138,71 +145,78 @@ RSpec.describe "Admin Runners" do it 'shows no runner when description does not match' do input_filtered_search_keys('runner-baz') + expect(page).to have_link('All 0') + expect(page).to have_link('Instance 0') + expect(page).to have_text 'No runners found' end end describe 'filter by status' do - it 'shows correct runner when status matches' do - create(:ci_runner, :instance, description: 'runner-active', active: true) - create(:ci_runner, :instance, description: 'runner-paused', active: false) + let!(:never_contacted) { create(:ci_runner, :instance, description: 'runner-never-contacted', contacted_at: nil) } + + before do + create(:ci_runner, :instance, description: 'runner-1', contacted_at: Time.now) + create(:ci_runner, :instance, description: 'runner-2', contacted_at: Time.now) + create(:ci_runner, :instance, description: 'runner-paused', active: false, contacted_at: Time.now) visit admin_runners_path + end - expect(page).to have_content 'runner-active' + it 'shows all runners' do + expect(page).to have_content 'runner-1' + expect(page).to have_content 'runner-2' expect(page).to have_content 'runner-paused' + expect(page).to have_content 'runner-never-contacted' + expect(page).to have_link('All 4') + end + + it 'shows correct runner when status matches' do input_filtered_search_filter_is_only('Status', 'Active') - expect(page).to have_content 'runner-active' + expect(page).to have_link('All 3') + + expect(page).to have_content 'runner-1' + expect(page).to have_content 'runner-2' + expect(page).to have_content 'runner-never-contacted' expect(page).not_to have_content 'runner-paused' end it 'shows no runner when status does not match' do - create(:ci_runner, :instance, description: 'runner-active', active: true) - create(:ci_runner, :instance, description: 'runner-paused', active: false) + input_filtered_search_filter_is_only('Status', 'Stale') - visit admin_runners_path - - input_filtered_search_filter_is_only('Status', 'Online') - - expect(page).not_to have_content 'runner-active' - expect(page).not_to have_content 'runner-paused' + expect(page).to have_link('All 0') expect(page).to have_text 'No runners found' end it 'shows correct runner when status is selected and search term is entered' do - create(:ci_runner, :instance, description: 'runner-a-1', active: true) - create(:ci_runner, :instance, description: 'runner-a-2', active: false) - create(:ci_runner, :instance, description: 'runner-b-1', active: true) - - visit admin_runners_path - input_filtered_search_filter_is_only('Status', 'Active') + input_filtered_search_keys('runner-1') - expect(page).to have_content 'runner-a-1' - expect(page).to have_content 'runner-b-1' - expect(page).not_to have_content 'runner-a-2' - - input_filtered_search_keys('runner-a') + expect(page).to have_link('All 1') - expect(page).to have_content 'runner-a-1' - expect(page).not_to have_content 'runner-b-1' - expect(page).not_to have_content 'runner-a-2' + expect(page).to have_content 'runner-1' + expect(page).not_to have_content 'runner-2' + expect(page).not_to have_content 'runner-never-contacted' + expect(page).not_to have_content 'runner-paused' end - it 'shows correct runner when type is selected and search term is entered' do - create(:ci_runner, :instance, description: 'runner-connected', contacted_at: Time.now) - create(:ci_runner, :instance, description: 'runner-not-connected', contacted_at: nil) + it 'shows correct runner when status filter is entered' do + # use the string "Never" to avoid using space and trigger an early selection + input_filtered_search_filter_is_only('Status', 'Never') - visit admin_runners_path + expect(page).to have_link('All 1') - # use the string "Not" to avoid using space and trigger an early selection - input_filtered_search_filter_is_only('Status', 'Not') + expect(page).not_to have_content 'runner-1' + expect(page).not_to have_content 'runner-2' + expect(page).not_to have_content 'runner-paused' + expect(page).to have_content 'runner-never-contacted' - expect(page).not_to have_content 'runner-connected' - expect(page).to have_content 'runner-not-connected' + within "[data-testid='runner-row-#{never_contacted.id}']" do + expect(page).to have_selector '.badge', text: 'never contacted' + end end end @@ -215,6 +229,10 @@ RSpec.describe "Admin Runners" do it '"All" tab is selected by default' do visit admin_runners_path + expect(page).to have_link('All 2') + expect(page).to have_link('Group 1') + expect(page).to have_link('Project 1') + page.within('[data-testid="runner-type-tabs"]') do expect(page).to have_link('All', class: 'active') end @@ -373,9 +391,28 @@ RSpec.describe "Admin Runners" do it 'has all necessary texts including no runner message' do expect(page).to have_text "Register an instance runner" - expect(page).to have_text "Online Runners 0" + + expect(page).to have_text "Online runners 0" + expect(page).to have_text "Offline runners 0" + expect(page).to have_text "Stale runners 0" + expect(page).to have_text 'No runners found' end + + it 'shows tabs with total counts equal to 0' do + expect(page).to have_link('All 0') + expect(page).to have_link('Instance 0') + expect(page).to have_link('Group 0') + expect(page).to have_link('Project 0') + end + end + + context "when visiting outdated URLs" do + it 'updates NOT_CONNECTED runner status to NEVER_CONNECTED' do + visit admin_runners_path('status[]': 'NOT_CONNECTED') + + expect(page).to have_current_path(admin_runners_path('status[]': 'NEVER_CONTACTED') ) + end end describe 'runners registration' do @@ -422,7 +459,9 @@ RSpec.describe "Admin Runners" do before do click_on 'Reset registration token' - page.accept_alert + within_modal do + click_button('OK', match: :first) + end wait_for_requests end @@ -437,26 +476,29 @@ RSpec.describe "Admin Runners" do end end - describe "Runner show page" do + describe "Runner edit page" do let(:runner) { create(:ci_runner) } before do @project1 = create(:project) @project2 = create(:project) - visit admin_runner_path(runner) + visit edit_admin_runner_path(runner) + + wait_for_requests end describe 'runner page breadcrumbs' do - it 'contains the current runner token' do + it 'contains the current runner id and token' do page.within '[data-testid="breadcrumb-links"]' do - expect(page.find('h2')).to have_content(runner.short_sha) + expect(page).to have_link("##{runner.id} (#{runner.short_sha})") + expect(page.find('h2')).to have_content("Edit") end end end - describe 'runner page title', :js do - it 'contains the runner id' do - expect(find('.page-title')).to have_content("Runner ##{runner.id}") + describe 'runner header', :js do + it 'contains the runner status, type and id' do + expect(page).to have_content("never contacted shared Runner ##{runner.id} created") end end @@ -498,7 +540,7 @@ RSpec.describe "Admin Runners" do let(:runner) { create(:ci_runner, :project, projects: [@project1]) } before do - visit admin_runner_path(runner) + visit edit_admin_runner_path(runner) end it_behaves_like 'assignable runner' @@ -508,7 +550,7 @@ RSpec.describe "Admin Runners" do let(:runner) { create(:ci_runner, :project, projects: [@project1], locked: true) } before do - visit admin_runner_path(runner) + visit edit_admin_runner_path(runner) end it_behaves_like 'assignable runner' @@ -519,7 +561,7 @@ RSpec.describe "Admin Runners" do before do @project1.destroy! - visit admin_runner_path(runner) + visit edit_admin_runner_path(runner) end it_behaves_like 'assignable runner' @@ -530,7 +572,7 @@ RSpec.describe "Admin Runners" do let(:runner) { create(:ci_runner, :project, projects: [@project1]) } before do - visit admin_runner_path(runner) + visit edit_admin_runner_path(runner) end it 'removed specific runner from project' do @@ -567,6 +609,8 @@ RSpec.describe "Admin Runners" do page.find('input').send_keys(search_term) click_on 'Search' end + + wait_for_requests end def input_filtered_search_filter_is_only(filter, value) @@ -583,5 +627,7 @@ RSpec.describe "Admin Runners" do click_on 'Search' end + + wait_for_requests end end |