Commit ca55063b authored by charlie ablett's avatar charlie ablett

Merge branch 'enable-agent-creation-in-core' into 'master'

Enable Agent creation in Core

See merge request gitlab-org/gitlab!71882
parents 2049fa9b fc6adf3d
......@@ -12,8 +12,8 @@ module ClustersHelper
end
end
def display_cluster_agents?(_clusterable)
false
def display_cluster_agents?(clusterable)
clusterable.is_a?(Project)
end
def js_cluster_agents_list_data(clusterable_project)
......
......@@ -583,6 +583,7 @@ module ProjectsHelper
%w[
environments
clusters
cluster_agents
functions
error_tracking
alert_management
......
# frozen_string_literal: true
module EE
module ClustersHelper
extend ::Gitlab::Utils::Override
override :display_cluster_agents?
def display_cluster_agents?(clusterable)
clusterable.is_a?(Project) && clusterable.feature_available?(:cluster_agents)
end
end
end
......@@ -7,7 +7,6 @@ module EE
override :sidebar_operations_paths
def sidebar_operations_paths
super + %w[
cluster_agents
oncall_schedules
]
end
......
......@@ -67,7 +67,6 @@ class License < ApplicationRecord
board_milestone_lists
ci_cd_projects
ci_secrets_management
cluster_agents
cluster_agents_gitops
cluster_deployments
code_owner_approval_required
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'ClusterAgents', :js do
let_it_be(:token) { create(:cluster_agent_token, description: 'feature test token')}
let(:agent) { token.agent }
let(:project) { agent.project }
let(:user) { project.creator }
before do
gitlab_sign_in(user)
end
context 'premium user' do
before do
stub_licensed_features(cluster_agents: true)
end
context 'when user does not have any agents and visits the index page' do
let(:empty_project) { create(:project) }
before do
empty_project.add_maintainer(user)
visit project_clusters_path(empty_project)
end
it 'displays empty state', :aggregate_failures do
click_link 'GitLab Agent managed clusters'
expect(page).to have_content('Integrate with the GitLab Agent')
expect(page).to have_selector('.empty-state')
end
end
context 'when user has an agent' do
context 'when visiting the index page' do
before do
visit project_clusters_path(project)
end
it 'displays a table with agent', :aggregate_failures do
click_link 'GitLab Agent managed clusters'
expect(page).to have_content(agent.name)
expect(page).to have_selector('[data-testid="cluster-agent-list-table"] tbody tr', count: 1)
end
end
context 'when visiting the show page' do
before do
visit project_cluster_agent_path(project, agent.name)
end
it 'displays agent and token information', :aggregate_failures do
expect(page).to have_content(agent.name)
expect(page).to have_content(token.description)
end
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ClustersHelper do
describe '#display_cluster_agents?' do
let(:clusterable) { build(:project) }
subject { helper.display_cluster_agents?(clusterable) }
context 'without premium license' do
it 'does not allows agents to display' do
expect(subject).to be_falsey
end
end
context 'with premium license' do
before do
allow(Gitlab).to receive(:com?).and_return(false)
stub_licensed_features(cluster_agents: true)
end
context 'when clusterable is a project' do
it 'allows agents to display' do
expect(subject).to be_truthy
end
end
context 'when clusterable is a group' do
let(:clusterable) { build(:group) }
it 'does not allows agents to display' do
expect(subject).to be_falsey
end
end
end
end
end
......@@ -7,8 +7,6 @@ RSpec.describe 'Cluster agent registration', :js do
let_it_be(:current_user) { create(:user, maintainer_projects: [project]) }
before do
stub_licensed_features(cluster_agents: true)
allow(Gitlab::Kas).to receive(:enabled?).and_return(true)
allow(Gitlab::Kas).to receive(:internal_url).and_return('kas.example.internal')
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'ClusterAgents', :js do
let_it_be(:token) { create(:cluster_agent_token, description: 'feature test token')}
let(:agent) { token.agent }
let(:project) { agent.project }
let(:user) { project.creator }
before do
gitlab_sign_in(user)
end
context 'when user does not have any agents and visits the index page' do
let(:empty_project) { create(:project) }
before do
empty_project.add_maintainer(user)
visit project_clusters_path(empty_project)
end
it 'displays empty state', :aggregate_failures do
click_link 'GitLab Agent managed clusters'
expect(page).to have_content('Integrate with the GitLab Agent')
expect(page).to have_selector('.empty-state')
end
end
context 'when user has an agent' do
context 'when visiting the index page' do
before do
visit project_clusters_path(project)
end
it 'displays a table with agent', :aggregate_failures do
click_link 'GitLab Agent managed clusters'
expect(page).to have_content(agent.name)
expect(page).to have_selector('[data-testid="cluster-agent-list-table"] tbody tr', count: 1)
end
end
context 'when visiting the show page' do
before do
visit project_cluster_agent_path(project, agent.name)
end
it 'displays agent and token information', :aggregate_failures do
expect(page).to have_content(agent.name)
expect(page).to have_content(token.description)
end
end
end
end
......@@ -152,4 +152,24 @@ RSpec.describe ClustersHelper do
end
end
end
describe '#display_cluster_agents?' do
subject { helper.display_cluster_agents?(clusterable) }
context 'when clusterable is a project' do
let(:clusterable) { build(:project) }
it 'allows agents to display' do
expect(subject).to be_truthy
end
end
context 'when clusterable is a group' do
let(:clusterable) { build(:group) }
it 'does not allow agents to display' do
expect(subject).to be_falsey
end
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