Commit 507260f3 authored by Tiffany Rea's avatar Tiffany Rea

Merge branch '352169-refactor-admin-runners-tests-cover-admin-and-groups' into 'master'

Refactor runner registration specs

See merge request gitlab-org/gitlab!84280
parents 62ebc291 cf4e53c8
...@@ -4,7 +4,6 @@ require 'spec_helper' ...@@ -4,7 +4,6 @@ require 'spec_helper'
RSpec.describe "Admin Runners" do RSpec.describe "Admin Runners" do
include StubENV include StubENV
include Spec::Support::Helpers::ModalHelpers
before do before do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
...@@ -15,7 +14,7 @@ RSpec.describe "Admin Runners" do ...@@ -15,7 +14,7 @@ RSpec.describe "Admin Runners" do
wait_for_requests wait_for_requests
end end
describe "Runners page", :js do describe "Admin Runners page", :js do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:namespace) { create(:namespace) } let_it_be(:namespace) { create(:namespace) }
...@@ -486,63 +485,14 @@ RSpec.describe "Admin Runners" do ...@@ -486,63 +485,14 @@ RSpec.describe "Admin Runners" do
end end
end end
describe 'runners registration' do describe "runners registration" do
let!(:token) { Gitlab::CurrentSettings.runners_registration_token }
before do before do
visit admin_runners_path visit admin_runners_path
click_on 'Register an instance runner'
end end
describe 'show registration instructions' do it_behaves_like "shows and resets runner registration token" do
before do let(:dropdown_text) { 'Register an instance runner' }
click_on 'Show runner installation and registration instructions' let(:registration_token) { Gitlab::CurrentSettings.runners_registration_token }
wait_for_requests
end
it 'opens runner installation modal' do
expect(page).to have_text "Install a runner"
expect(page).to have_text "Environment"
expect(page).to have_text "Architecture"
expect(page).to have_text "Download and install binary"
end
it 'dismisses runner installation modal' do
within_modal do
click_button('Close', match: :first)
end
expect(page).not_to have_text "Install a runner"
end
end
it 'has a registration token' do
click_on 'Click to reveal'
expect(page.find('[data-testid="token-value"]')).to have_content(token)
end
describe 'reset registration token' do
let(:page_token) { find('[data-testid="token-value"]').text }
before do
click_on 'Reset registration token'
within_modal do
click_button('Reset token', match: :first)
end
wait_for_requests
end
it 'changes registration token' do
click_on 'Register an instance runner'
click_on 'Click to reveal'
expect(page_token).not_to eq token
end
end end
end end
end end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe "Group Runners" do
let_it_be(:group_owner) { create(:user) }
let_it_be(:group) { create(:group) }
let!(:group_registration_token) { group.runners_token }
before do
group.add_owner(group_owner)
sign_in(group_owner)
end
describe "Group runners page", :js do
describe "runners registration" do
before do
visit group_runners_path(group)
end
it_behaves_like "shows and resets runner registration token" do
let(:dropdown_text) { 'Register a group runner' }
let(:registration_token) { group_registration_token }
end
end
end
end
# frozen_string_literal: true
RSpec.shared_examples 'shows and resets runner registration token' do
include Spec::Support::Helpers::ModalHelpers
before do
click_on dropdown_text
end
describe 'shows registration instructions' do
before do
click_on 'Show runner installation and registration instructions'
wait_for_requests
end
it 'opens runner installation modal', :aggregate_failures do
within_modal do
expect(page).to have_text "Install a runner"
expect(page).to have_text "Environment"
expect(page).to have_text "Architecture"
expect(page).to have_text "Download and install binary"
end
end
it 'dismisses runner installation modal' do
within_modal do
click_button('Close', match: :first)
end
expect(page).not_to have_text "Install a runner"
end
end
it 'has a registration token' do
click_on 'Click to reveal'
expect(page.find('[data-testid="token-value"]')).to have_content(registration_token)
end
describe 'reset registration token' do
let!(:old_registration_token) { find('[data-testid="token-value"]').text }
before do
click_on 'Reset registration token'
within_modal do
click_button('Reset token', match: :first)
end
wait_for_requests
end
it 'changes registration token' do
expect(find('.gl-toast')).to have_content('New registration token generated!')
click_on dropdown_text
click_on 'Click to reveal'
expect(old_registration_token).not_to eq registration_token
end
end
end
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