2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
RSpec.describe 'Gcp Cluster', :js, feature_category: :deployment_management do
|
2018-03-17 18:26:18 +05:30
|
|
|
include GoogleApi::CloudPlatformHelpers
|
|
|
|
|
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
2018-11-18 11:00:15 +05:30
|
|
|
project.add_maintainer(user)
|
2018-03-17 18:26:18 +05:30
|
|
|
gitlab_sign_in(user)
|
|
|
|
allow(Projects::ClustersController).to receive(:STATUS_POLLING_INTERVAL) { 100 }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user has signed with Google' do
|
|
|
|
let(:project_id) { 'test-project-1234' }
|
|
|
|
|
|
|
|
before do
|
2018-11-08 19:23:39 +05:30
|
|
|
allow_any_instance_of(Projects::ClustersController)
|
2018-03-17 18:26:18 +05:30
|
|
|
.to receive(:token_in_session).and_return('token')
|
2018-11-08 19:23:39 +05:30
|
|
|
allow_any_instance_of(Projects::ClustersController)
|
2018-03-17 18:26:18 +05:30
|
|
|
.to receive(:expires_at_in_session).and_return(1.hour.since.to_i.to_s)
|
|
|
|
end
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
context 'when user have a cluster and visits cluster page' do
|
2018-11-08 19:23:39 +05:30
|
|
|
let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
before do
|
|
|
|
visit project_cluster_path(project, cluster)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
it 'user sees a cluster details page' do
|
|
|
|
expect(page).to have_button('Save changes')
|
|
|
|
expect(page.find(:css, '.cluster-name').value).to eq(cluster.name)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
include_examples "user disables a cluster"
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
context 'when user changes cluster parameters' do
|
|
|
|
before do
|
|
|
|
fill_in 'cluster_platform_kubernetes_attributes_namespace', with: 'my-namespace'
|
2020-04-08 14:13:33 +05:30
|
|
|
page.within('.js-provider-details') { click_button 'Save changes' }
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
it 'user sees the successful message' do
|
|
|
|
expect(page).to have_content('Kubernetes cluster was successfully updated.')
|
|
|
|
expect(cluster.reload.platform_kubernetes.namespace).to eq('my-namespace')
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
context 'when a user adds an existing cluster' do
|
|
|
|
before do
|
|
|
|
visit project_clusters_path(project)
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
click_button(class: 'dropdown-toggle-split')
|
2022-06-21 17:19:12 +05:30
|
|
|
click_link 'Connect a cluster (certificate - deprecated)'
|
2020-07-28 23:09:34 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'user sees the "Environment scope" field' do
|
|
|
|
expect(page).to have_css('#cluster_environment_scope')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
context 'when user destroys the cluster' do
|
2018-11-08 19:23:39 +05:30
|
|
|
before do
|
2020-04-08 14:13:33 +05:30
|
|
|
click_link 'Advanced Settings'
|
2022-07-23 23:45:48 +05:30
|
|
|
find('[data-testid="remove-integration-button"]').click
|
2020-01-01 13:55:28 +05:30
|
|
|
fill_in 'confirm_cluster_name_input', with: cluster.name
|
2022-07-23 23:45:48 +05:30
|
|
|
find('[data-testid="remove-integration-modal-button"]').click
|
2022-01-26 12:08:38 +05:30
|
|
|
click_link 'Certificate'
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'user sees creation form with the successful message' do
|
|
|
|
expect(page).to have_content('Kubernetes cluster integration was successfully removed.')
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
context 'when user has not dismissed GCP signup offer' do
|
|
|
|
before do
|
|
|
|
visit project_clusters_path(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'user sees offer on cluster index page' do
|
|
|
|
expect(page).to have_css('.gcp-signup-offer')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user has dismissed GCP signup offer' do
|
|
|
|
before do
|
|
|
|
visit project_clusters_path(project)
|
2022-01-26 12:08:38 +05:30
|
|
|
click_link 'Certificate'
|
2018-10-15 14:42:47 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'user does not see offer after dismissing' do
|
|
|
|
expect(page).to have_css('.gcp-signup-offer')
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
find('.gcp-signup-offer .js-close').click
|
2018-10-15 14:42:47 +05:30
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).not_to have_css('.gcp-signup-offer')
|
|
|
|
end
|
|
|
|
end
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
context 'when third party offers are disabled', :clean_gitlab_redis_shared_state do
|
2021-12-11 22:18:48 +05:30
|
|
|
let(:user) { create(:admin) }
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
|
2021-12-11 22:18:48 +05:30
|
|
|
gitlab_enable_admin_mode_sign_in(user)
|
2020-10-24 23:57:45 +05:30
|
|
|
visit general_admin_application_settings_path
|
2020-01-01 13:55:28 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'user does not see the offer' do
|
|
|
|
page.within('.as-third-party-offers') do
|
|
|
|
click_button 'Expand'
|
2022-03-02 08:16:31 +05:30
|
|
|
check 'Do not display content for customer experience improvement and offers from third parties'
|
2020-01-01 13:55:28 +05:30
|
|
|
click_button 'Save changes'
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_content "Application settings saved successfully"
|
|
|
|
|
|
|
|
visit project_clusters_path(project)
|
|
|
|
|
|
|
|
expect(page).not_to have_css('.gcp-signup-offer')
|
|
|
|
end
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|