summaryrefslogtreecommitdiff
path: root/spec/frontend/create_cluster
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-14 21:06:30 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-14 21:06:30 +0000
commit565fa11a26c6824b1c6072d2dc5459979345ee57 (patch)
tree2668b631d925341e121c06b7b77cfe12954a015a /spec/frontend/create_cluster
parent8c30d396c5a789080345303330069981aa06e4af (diff)
downloadgitlab-ce-565fa11a26c6824b1c6072d2dc5459979345ee57.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/create_cluster')
-rw-r--r--spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js131
-rw-r--r--spec/frontend/create_cluster/eks_cluster/store/actions_spec.js32
-rw-r--r--spec/frontend/create_cluster/eks_cluster/store/mutations_spec.js32
3 files changed, 182 insertions, 13 deletions
diff --git a/spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js b/spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js
index df214442369..321dc5bd6ba 100644
--- a/spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js
+++ b/spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js
@@ -1,9 +1,10 @@
import { shallowMount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex';
import Vue from 'vue';
+import { GlFormCheckbox } from '@gitlab/ui';
+
import EksClusterConfigurationForm from '~/create_cluster/eks_cluster/components/eks_cluster_configuration_form.vue';
import RegionDropdown from '~/create_cluster/eks_cluster/components/region_dropdown.vue';
-
import eksClusterFormState from '~/create_cluster/eks_cluster/store/state';
import clusterDropdownStoreState from '~/create_cluster/eks_cluster/store/cluster_dropdown/state';
@@ -19,21 +20,28 @@ describe('EksClusterConfigurationForm', () => {
let vpcsState;
let subnetsState;
let keyPairsState;
+ let securityGroupsState;
let vpcsActions;
let rolesActions;
let regionsActions;
let subnetsActions;
let keyPairsActions;
+ let securityGroupsActions;
let vm;
beforeEach(() => {
state = eksClusterFormState();
actions = {
+ setClusterName: jest.fn(),
+ setEnvironmentScope: jest.fn(),
+ setKubernetesVersion: jest.fn(),
setRegion: jest.fn(),
setVpc: jest.fn(),
setSubnet: jest.fn(),
setRole: jest.fn(),
setKeyPair: jest.fn(),
+ setSecurityGroup: jest.fn(),
+ setGitlabManagedCluster: jest.fn(),
};
regionsActions = {
fetchItems: jest.fn(),
@@ -50,6 +58,9 @@ describe('EksClusterConfigurationForm', () => {
rolesActions = {
fetchItems: jest.fn(),
};
+ securityGroupsActions = {
+ fetchItems: jest.fn(),
+ };
rolesState = {
...clusterDropdownStoreState(),
};
@@ -65,6 +76,9 @@ describe('EksClusterConfigurationForm', () => {
keyPairsState = {
...clusterDropdownStoreState(),
};
+ securityGroupsState = {
+ ...clusterDropdownStoreState(),
+ };
store = new Vuex.Store({
state,
actions,
@@ -94,6 +108,11 @@ describe('EksClusterConfigurationForm', () => {
state: keyPairsState,
actions: keyPairsActions,
},
+ securityGroups: {
+ namespaced: true,
+ state: securityGroupsState,
+ actions: securityGroupsActions,
+ },
},
});
});
@@ -102,6 +121,9 @@ describe('EksClusterConfigurationForm', () => {
vm = shallowMount(EksClusterConfigurationForm, {
localVue,
store,
+ propsData: {
+ gitlabManagedClusterHelpPath: '',
+ },
});
});
@@ -109,11 +131,16 @@ describe('EksClusterConfigurationForm', () => {
vm.destroy();
});
+ const findClusterNameInput = () => vm.find('[id=eks-cluster-name]');
+ const findEnvironmentScopeInput = () => vm.find('[id=eks-environment-scope]');
+ const findKubernetesVersionDropdown = () => vm.find('[field-id="eks-kubernetes-version"]');
const findRegionDropdown = () => vm.find(RegionDropdown);
const findKeyPairDropdown = () => vm.find('[field-id="eks-key-pair"]');
const findVpcDropdown = () => vm.find('[field-id="eks-vpc"]');
const findSubnetDropdown = () => vm.find('[field-id="eks-subnet"]');
const findRoleDropdown = () => vm.find('[field-id="eks-role"]');
+ const findSecurityGroupDropdown = () => vm.find('[field-id="eks-security-group"]');
+ const findGitlabManagedClusterCheckbox = () => vm.find(GlFormCheckbox);
describe('when mounted', () => {
it('fetches available regions', () => {
@@ -249,6 +276,36 @@ describe('EksClusterConfigurationForm', () => {
expect(findSubnetDropdown().props('hasErrors')).toEqual(true);
});
+ it('disables SecurityGroupDropdown when no vpc is selected', () => {
+ expect(findSecurityGroupDropdown().props('disabled')).toBe(true);
+ });
+
+ it('enables SecurityGroupDropdown when a vpc is selected', () => {
+ state.selectedVpc = { name: 'vpc-1 ' };
+
+ return Vue.nextTick().then(() => {
+ expect(findSecurityGroupDropdown().props('disabled')).toBe(false);
+ });
+ });
+
+ it('sets isLoadingSecurityGroups to SecurityGroupDropdown loading property', () => {
+ securityGroupsState.isLoadingItems = true;
+
+ return Vue.nextTick().then(() => {
+ expect(findSecurityGroupDropdown().props('loading')).toBe(securityGroupsState.isLoadingItems);
+ });
+ });
+
+ it('sets securityGroups to SecurityGroupDropdown items property', () => {
+ expect(findSecurityGroupDropdown().props('items')).toBe(securityGroupsState.items);
+ });
+
+ it('sets SecurityGroupDropdown hasErrors to true when loading security groups fails', () => {
+ securityGroupsState.loadingItemsError = new Error();
+
+ expect(findSecurityGroupDropdown().props('hasErrors')).toEqual(true);
+ });
+
describe('when region is selected', () => {
const region = { name: 'us-west-2' };
@@ -273,6 +330,54 @@ describe('EksClusterConfigurationForm', () => {
});
});
+ it('dispatches setClusterName when cluster name input changes', () => {
+ const clusterName = 'name';
+
+ findClusterNameInput().vm.$emit('input', clusterName);
+
+ expect(actions.setClusterName).toHaveBeenCalledWith(
+ expect.anything(),
+ { clusterName },
+ undefined,
+ );
+ });
+
+ it('dispatches setEnvironmentScope when environment scope input changes', () => {
+ const environmentScope = 'production';
+
+ findEnvironmentScopeInput().vm.$emit('input', environmentScope);
+
+ expect(actions.setEnvironmentScope).toHaveBeenCalledWith(
+ expect.anything(),
+ { environmentScope },
+ undefined,
+ );
+ });
+
+ it('dispatches setKubernetesVersion when kubernetes version dropdown changes', () => {
+ const kubernetesVersion = { name: '1.11' };
+
+ findKubernetesVersionDropdown().vm.$emit('input', kubernetesVersion);
+
+ expect(actions.setKubernetesVersion).toHaveBeenCalledWith(
+ expect.anything(),
+ { kubernetesVersion },
+ undefined,
+ );
+ });
+
+ it('dispatches setGitlabManagedCluster when gitlab managed cluster input changes', () => {
+ const gitlabManagedCluster = false;
+
+ findGitlabManagedClusterCheckbox().vm.$emit('input', gitlabManagedCluster);
+
+ expect(actions.setGitlabManagedCluster).toHaveBeenCalledWith(
+ expect.anything(),
+ { gitlabManagedCluster },
+ undefined,
+ );
+ });
+
describe('when vpc is selected', () => {
const vpc = { name: 'vpc-1' };
@@ -287,6 +392,14 @@ describe('EksClusterConfigurationForm', () => {
it('dispatches fetchSubnets action', () => {
expect(subnetsActions.fetchItems).toHaveBeenCalledWith(expect.anything(), { vpc }, undefined);
});
+
+ it('dispatches fetchSecurityGroups action', () => {
+ expect(securityGroupsActions.fetchItems).toHaveBeenCalledWith(
+ expect.anything(),
+ { vpc },
+ undefined,
+ );
+ });
});
describe('when a subnet is selected', () => {
@@ -324,4 +437,20 @@ describe('EksClusterConfigurationForm', () => {
expect(actions.setKeyPair).toHaveBeenCalledWith(expect.anything(), { keyPair }, undefined);
});
});
+
+ describe('when security group is selected', () => {
+ const securityGroup = { name: 'default group' };
+
+ beforeEach(() => {
+ findSecurityGroupDropdown().vm.$emit('input', securityGroup);
+ });
+
+ it('dispatches setSecurityGroup action', () => {
+ expect(actions.setSecurityGroup).toHaveBeenCalledWith(
+ expect.anything(),
+ { securityGroup },
+ undefined,
+ );
+ });
+ });
});
diff --git a/spec/frontend/create_cluster/eks_cluster/store/actions_spec.js b/spec/frontend/create_cluster/eks_cluster/store/actions_spec.js
index aa7ced81e0d..1ed7f806804 100644
--- a/spec/frontend/create_cluster/eks_cluster/store/actions_spec.js
+++ b/spec/frontend/create_cluster/eks_cluster/store/actions_spec.js
@@ -3,35 +3,55 @@ import testAction from 'helpers/vuex_action_helper';
import createState from '~/create_cluster/eks_cluster/store/state';
import * as actions from '~/create_cluster/eks_cluster/store/actions';
import {
+ SET_CLUSTER_NAME,
+ SET_ENVIRONMENT_SCOPE,
+ SET_KUBERNETES_VERSION,
SET_REGION,
SET_VPC,
SET_KEY_PAIR,
SET_SUBNET,
SET_ROLE,
+ SET_SECURITY_GROUP,
+ SET_GITLAB_MANAGED_CLUSTER,
} from '~/create_cluster/eks_cluster/store/mutation_types';
describe('EKS Cluster Store Actions', () => {
+ let clusterName;
+ let environmentScope;
+ let kubernetesVersion;
let region;
let vpc;
let subnet;
let role;
let keyPair;
+ let securityGroup;
+ let gitlabManagedCluster;
beforeEach(() => {
+ clusterName = 'my cluster';
+ environmentScope = 'production';
+ kubernetesVersion = '11.1';
region = { name: 'regions-1' };
vpc = { name: 'vpc-1' };
subnet = { name: 'subnet-1' };
role = { name: 'role-1' };
keyPair = { name: 'key-pair-1' };
+ securityGroup = { name: 'default group' };
+ gitlabManagedCluster = true;
});
it.each`
- action | mutation | payload | payloadDescription
- ${'setRole'} | ${SET_ROLE} | ${{ role }} | ${'role'}
- ${'setRegion'} | ${SET_REGION} | ${{ region }} | ${'region'}
- ${'setKeyPair'} | ${SET_KEY_PAIR} | ${{ keyPair }} | ${'key pair'}
- ${'setVpc'} | ${SET_VPC} | ${{ vpc }} | ${'vpc'}
- ${'setSubnet'} | ${SET_SUBNET} | ${{ subnet }} | ${'subnet'}
+ action | mutation | payload | payloadDescription
+ ${'setClusterName'} | ${SET_CLUSTER_NAME} | ${{ clusterName }} | ${'cluster name'}
+ ${'setEnvironmentScope'} | ${SET_ENVIRONMENT_SCOPE} | ${{ environmentScope }} | ${'environment scope'}
+ ${'setKubernetesVersion'} | ${SET_KUBERNETES_VERSION} | ${{ kubernetesVersion }} | ${'kubernetes version'}
+ ${'setRole'} | ${SET_ROLE} | ${{ role }} | ${'role'}
+ ${'setRegion'} | ${SET_REGION} | ${{ region }} | ${'region'}
+ ${'setKeyPair'} | ${SET_KEY_PAIR} | ${{ keyPair }} | ${'key pair'}
+ ${'setVpc'} | ${SET_VPC} | ${{ vpc }} | ${'vpc'}
+ ${'setSubnet'} | ${SET_SUBNET} | ${{ subnet }} | ${'subnet'}
+ ${'setSecurityGroup'} | ${SET_SECURITY_GROUP} | ${{ securityGroup }} | ${'securityGroup'}
+ ${'setGitlabManagedCluster'} | ${SET_GITLAB_MANAGED_CLUSTER} | ${gitlabManagedCluster} | ${'gitlab managed cluster'}
`(`$action commits $mutation with $payloadDescription payload`, data => {
const { action, mutation, payload } = data;
diff --git a/spec/frontend/create_cluster/eks_cluster/store/mutations_spec.js b/spec/frontend/create_cluster/eks_cluster/store/mutations_spec.js
index 966406386ac..81b65180fb5 100644
--- a/spec/frontend/create_cluster/eks_cluster/store/mutations_spec.js
+++ b/spec/frontend/create_cluster/eks_cluster/store/mutations_spec.js
@@ -1,38 +1,58 @@
import {
+ SET_CLUSTER_NAME,
+ SET_ENVIRONMENT_SCOPE,
+ SET_KUBERNETES_VERSION,
SET_REGION,
SET_VPC,
SET_KEY_PAIR,
SET_SUBNET,
SET_ROLE,
+ SET_SECURITY_GROUP,
+ SET_GITLAB_MANAGED_CLUSTER,
} from '~/create_cluster/eks_cluster/store/mutation_types';
import createState from '~/create_cluster/eks_cluster/store/state';
import mutations from '~/create_cluster/eks_cluster/store/mutations';
describe('Create EKS cluster store mutations', () => {
+ let clusterName;
+ let environmentScope;
+ let kubernetesVersion;
let state;
let region;
let vpc;
let subnet;
let role;
let keyPair;
+ let securityGroup;
+ let gitlabManagedCluster;
beforeEach(() => {
+ clusterName = 'my cluster';
+ environmentScope = 'production';
+ kubernetesVersion = '11.1';
region = { name: 'regions-1' };
vpc = { name: 'vpc-1' };
subnet = { name: 'subnet-1' };
role = { name: 'role-1' };
keyPair = { name: 'key pair' };
+ securityGroup = { name: 'default group' };
+ gitlabManagedCluster = false;
state = createState();
});
it.each`
- mutation | mutatedProperty | payload | expectedValue | expectedValueDescription
- ${SET_ROLE} | ${'selectedRole'} | ${{ role }} | ${role} | ${'selected role payload'}
- ${SET_REGION} | ${'selectedRegion'} | ${{ region }} | ${region} | ${'selected region payload'}
- ${SET_KEY_PAIR} | ${'selectedKeyPair'} | ${{ keyPair }} | ${keyPair} | ${'selected key pair payload'}
- ${SET_VPC} | ${'selectedVpc'} | ${{ vpc }} | ${vpc} | ${'selected vpc payload'}
- ${SET_SUBNET} | ${'selectedSubnet'} | ${{ subnet }} | ${subnet} | ${'selected sybnet payload'}
+ mutation | mutatedProperty | payload | expectedValue | expectedValueDescription
+ ${SET_CLUSTER_NAME} | ${'clusterName'} | ${{ clusterName }} | ${clusterName} | ${'cluster name'}
+ ${SET_ENVIRONMENT_SCOPE} | ${'environmentScope'} | ${{ environmentScope }} | ${environmentScope} | ${'environment scope'}
+ ${SET_KUBERNETES_VERSION} | ${'kubernetesVersion'} | ${{ kubernetesVersion }} | ${kubernetesVersion} | ${'kubernetes version'}
+ ${SET_ROLE} | ${'selectedRole'} | ${{ role }} | ${role} | ${'selected role payload'}
+ ${SET_REGION} | ${'selectedRegion'} | ${{ region }} | ${region} | ${'selected region payload'}
+ ${SET_KEY_PAIR} | ${'selectedKeyPair'} | ${{ keyPair }} | ${keyPair} | ${'selected key pair payload'}
+ ${SET_VPC} | ${'selectedVpc'} | ${{ vpc }} | ${vpc} | ${'selected vpc payload'}
+ ${SET_SUBNET} | ${'selectedSubnet'} | ${{ subnet }} | ${subnet} | ${'selected sybnet payload'}
+ ${SET_SECURITY_GROUP} | ${'selectedSecurityGroup'} | ${{ securityGroup }} | ${securityGroup} | ${'selected security group payload'}
+ ${SET_GITLAB_MANAGED_CLUSTER} | ${'gitlabManagedCluster'} | ${{ gitlabManagedCluster }} | ${gitlabManagedCluster} | ${'gitlab managed cluster'}
`(`$mutation sets $mutatedProperty to $expectedValueDescription`, data => {
const { mutation, mutatedProperty, payload, expectedValue } = data;