debian-mirror-gitlab/spec/features/clusters/create_agent_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
1.8 KiB
Ruby
Raw Normal View History

2021-12-11 22:18:48 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Cluster agent registration', :js, feature_category: :kubernetes_management do
2021-12-11 22:18:48 +05:30
let_it_be(:project) { create(:project, :custom_repo, files: { '.gitlab/agents/example-agent-1/config.yaml' => '' }) }
let_it_be(:current_user) { create(:user, maintainer_projects: [project]) }
2022-08-27 11:52:29 +05:30
let_it_be(:token) { Devise.friendly_token }
2021-12-11 22:18:48 +05:30
before do
allow(Gitlab::Kas).to receive(:enabled?).and_return(true)
allow(Gitlab::Kas).to receive(:internal_url).and_return('kas.example.internal')
allow_next_instance_of(Gitlab::Kas::Client) do |client|
2022-10-11 01:57:18 +05:30
allow(client).to receive(:list_agent_config_files).and_return(
[
double(agent_name: 'example-agent-1', path: '.gitlab/agents/example-agent-1/config.yaml'),
double(agent_name: 'example-agent-2', path: '.gitlab/agents/example-agent-2/config.yaml')
])
2022-04-04 11:22:00 +05:30
allow(client).to receive(:get_connected_agents).and_return([])
2021-12-11 22:18:48 +05:30
end
2022-08-27 11:52:29 +05:30
allow(Devise).to receive(:friendly_token).and_return(token)
2021-12-11 22:18:48 +05:30
sign_in(current_user)
visit project_clusters_path(project)
end
it 'allows the user to select an agent to install, and displays the resulting agent token' do
2022-06-21 17:19:12 +05:30
click_button('Connect a cluster')
2022-01-26 12:08:38 +05:30
expect(page).to have_content('Register')
2021-12-11 22:18:48 +05:30
2023-03-04 22:38:38 +05:30
click_button('Select an agent or enter a name to create new')
page.find('li', text: 'example-agent-2').click
2022-01-26 12:08:38 +05:30
click_button('Register')
2021-12-11 22:18:48 +05:30
2022-01-26 12:08:38 +05:30
expect(page).to have_content('You cannot see this token again after you close this window.')
2022-08-27 11:52:29 +05:30
expect(page).to have_content(token)
2022-06-21 17:19:12 +05:30
expect(page).to have_content('helm upgrade --install')
2022-07-23 23:45:48 +05:30
expect(page).to have_content('example-agent-2')
2021-12-11 22:18:48 +05:30
within find('.modal-footer') do
click_button('Close')
end
expect(page).to have_link('example-agent-2')
end
end