diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/admin/clusters/eks_spec.rb | 29 | ||||
-rw-r--r-- | spec/features/groups/clusters/eks_spec.rb | 35 | ||||
-rw-r--r-- | spec/features/projects/clusters/eks_spec.rb | 2 | ||||
-rw-r--r-- | spec/frontend/create_cluster/gke_cluster_namespace/gke_cluster_namespace_spec.js (renamed from spec/frontend/projects/gke_cluster_namespace/gke_cluster_namespace_spec.js) | 4 | ||||
-rw-r--r-- | spec/frontend/create_cluster/init_create_cluster_spec.js | 73 |
5 files changed, 140 insertions, 3 deletions
diff --git a/spec/features/admin/clusters/eks_spec.rb b/spec/features/admin/clusters/eks_spec.rb new file mode 100644 index 00000000000..b262db1ad7c --- /dev/null +++ b/spec/features/admin/clusters/eks_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'Instance-level AWS EKS Cluster', :js do + let(:user) { create(:admin) } + + before do + sign_in(user) + end + + context 'when user does not have a cluster and visits group clusters page' do + before do + visit admin_clusters_path + + click_link 'Add Kubernetes cluster' + end + + context 'when user creates a cluster on AWS EKS' do + before do + click_link 'Amazon EKS' + end + + it 'user sees a form to create an EKS cluster' do + expect(page).to have_content('Create new Cluster on EKS') + end + end + end +end diff --git a/spec/features/groups/clusters/eks_spec.rb b/spec/features/groups/clusters/eks_spec.rb new file mode 100644 index 00000000000..b6942304c22 --- /dev/null +++ b/spec/features/groups/clusters/eks_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'Group AWS EKS Cluster', :js do + let(:group) { create(:group) } + let(:user) { create(:user) } + + before do + group.add_maintainer(user) + gitlab_sign_in(user) + + allow(Groups::ClustersController).to receive(:STATUS_POLLING_INTERVAL) { 100 } + allow_any_instance_of(Clusters::Kubernetes::CreateOrUpdateNamespaceService).to receive(:execute) + allow_any_instance_of(Clusters::Cluster).to receive(:retrieve_connection_status).and_return(:connected) + end + + context 'when user does not have a cluster and visits group clusters page' do + before do + visit group_clusters_path(group) + + click_link 'Add Kubernetes cluster' + end + + context 'when user creates a cluster on AWS EKS' do + before do + click_link 'Amazon EKS' + end + + it 'user sees a form to create an EKS cluster' do + expect(page).to have_content('Create new Cluster on EKS') + end + end + end +end diff --git a/spec/features/projects/clusters/eks_spec.rb b/spec/features/projects/clusters/eks_spec.rb index 758dccd6e49..9cb989b8004 100644 --- a/spec/features/projects/clusters/eks_spec.rb +++ b/spec/features/projects/clusters/eks_spec.rb @@ -27,7 +27,7 @@ describe 'AWS EKS Cluster', :js do end it 'user sees a form to create an EKS cluster' do - expect(page).to have_selector(:css, '.js-create-eks-cluster') + expect(page).to have_content('Create new Cluster on EKS') end end end diff --git a/spec/frontend/projects/gke_cluster_namespace/gke_cluster_namespace_spec.js b/spec/frontend/create_cluster/gke_cluster_namespace/gke_cluster_namespace_spec.js index 7b8df03d3c3..b1c25d8fff7 100644 --- a/spec/frontend/projects/gke_cluster_namespace/gke_cluster_namespace_spec.js +++ b/spec/frontend/create_cluster/gke_cluster_namespace/gke_cluster_namespace_spec.js @@ -1,4 +1,4 @@ -import initGkeNamespace from '~/projects/gke_cluster_namespace'; +import initGkeNamespace from '~/create_cluster/gke_cluster_namespace'; describe('GKE cluster namespace', () => { const changeEvent = new Event('change'); @@ -14,7 +14,7 @@ describe('GKE cluster namespace', () => { <input class="js-gl-managed" type="checkbox" value="1" checked /> <div class="js-namespace"> <input type="text" /> - </div> + </div> <div class="js-namespace-prefixed"> <input type="text" /> </div> diff --git a/spec/frontend/create_cluster/init_create_cluster_spec.js b/spec/frontend/create_cluster/init_create_cluster_spec.js new file mode 100644 index 00000000000..e7b9a7adde4 --- /dev/null +++ b/spec/frontend/create_cluster/init_create_cluster_spec.js @@ -0,0 +1,73 @@ +import initCreateCluster from '~/create_cluster/init_create_cluster'; +import initGkeDropdowns from '~/create_cluster/gke_cluster'; +import initGkeNamespace from '~/create_cluster/gke_cluster_namespace'; +import PersistentUserCallout from '~/persistent_user_callout'; + +jest.mock('~/create_cluster/gke_cluster', () => jest.fn()); +jest.mock('~/create_cluster/gke_cluster_namespace', () => jest.fn()); +jest.mock('~/persistent_user_callout', () => ({ + factory: jest.fn(), +})); + +describe('initCreateCluster', () => { + let document; + let gon; + + beforeEach(() => { + document = { + body: { dataset: {} }, + querySelector: jest.fn(), + }; + gon = { features: {} }; + }); + afterEach(() => { + initGkeDropdowns.mockReset(); + initGkeNamespace.mockReset(); + PersistentUserCallout.factory.mockReset(); + }); + + describe.each` + pageSuffix | page + ${':clusters:new'} | ${'project:clusters:new'} + ${':clusters:create_gcp'} | ${'groups:clusters:create_gcp'} + ${':clusters:create_user'} | ${'admin:clusters:create_user'} + `('when cluster page ends in $pageSuffix', ({ page }) => { + beforeEach(() => { + document.body.dataset = { page }; + + initCreateCluster(document, gon); + }); + + it('initializes create GKE cluster app', () => { + expect(initGkeDropdowns).toHaveBeenCalled(); + }); + + it('initializes gcp signup offer banner', () => { + expect(PersistentUserCallout.factory).toHaveBeenCalled(); + }); + }); + + describe('when creating a project level cluster', () => { + it('initializes gke namespace app', () => { + document.body.dataset.page = 'project:clusters:new'; + + initCreateCluster(document, gon); + + expect(initGkeNamespace).toHaveBeenCalled(); + }); + }); + + describe.each` + clusterLevel | page + ${'group level'} | ${'groups:clusters:new'} + ${'instance level'} | ${'admin:clusters:create_gcp'} + `('when creating a $clusterLevel cluster', ({ page }) => { + it('does not initialize gke namespace app', () => { + document.body.dataset = { page }; + + initCreateCluster(document, gon); + + expect(initGkeNamespace).not.toHaveBeenCalled(); + }); + }); +}); |