| ... | @@ -13,6 +13,7 @@ localVue.use(Vuex); |
... | @@ -13,6 +13,7 @@ localVue.use(Vuex); |
|
|
describe('EksClusterConfigurationForm', () => {
|
|
describe('EksClusterConfigurationForm', () => {
|
|
|
let store;
|
|
let store;
|
|
|
let actions;
|
|
let actions;
|
|
|
|
let getters;
|
|
|
let state;
|
|
let state;
|
|
|
let rolesState;
|
|
let rolesState;
|
|
|
let regionsState;
|
|
let regionsState;
|
| ... | @@ -29,8 +30,7 @@ describe('EksClusterConfigurationForm', () => { |
... | @@ -29,8 +30,7 @@ describe('EksClusterConfigurationForm', () => { |
|
|
let securityGroupsActions;
|
|
let securityGroupsActions;
|
|
|
let vm;
|
|
let vm;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
const createStore = (config = {}) => {
|
|
|
state = eksClusterFormState();
|
|
|
|
|
actions = {
|
|
actions = {
|
|
|
createCluster: jest.fn(),
|
|
createCluster: jest.fn(),
|
|
|
setClusterName: jest.fn(),
|
|
setClusterName: jest.fn(),
|
| ... | @@ -64,29 +64,44 @@ describe('EksClusterConfigurationForm', () => { |
... | @@ -64,29 +64,44 @@ describe('EksClusterConfigurationForm', () => { |
|
|
securityGroupsActions = {
|
|
securityGroupsActions = {
|
|
|
fetchItems: jest.fn(),
|
|
fetchItems: jest.fn(),
|
|
|
};
|
|
};
|
|
|
|
state = {
|
|
|
|
...eksClusterFormState(),
|
|
|
|
...config.initialState,
|
|
|
|
};
|
|
|
rolesState = {
|
|
rolesState = {
|
|
|
...clusterDropdownStoreState(),
|
|
...clusterDropdownStoreState(),
|
|
|
|
...config.rolesState,
|
|
|
};
|
|
};
|
|
|
regionsState = {
|
|
regionsState = {
|
|
|
...clusterDropdownStoreState(),
|
|
...clusterDropdownStoreState(),
|
|
|
|
...config.regionsState,
|
|
|
};
|
|
};
|
|
|
vpcsState = {
|
|
vpcsState = {
|
|
|
...clusterDropdownStoreState(),
|
|
...clusterDropdownStoreState(),
|
|
|
|
...config.vpcsState,
|
|
|
};
|
|
};
|
|
|
subnetsState = {
|
|
subnetsState = {
|
|
|
...clusterDropdownStoreState(),
|
|
...clusterDropdownStoreState(),
|
|
|
|
...config.subnetsState,
|
|
|
};
|
|
};
|
|
|
keyPairsState = {
|
|
keyPairsState = {
|
|
|
...clusterDropdownStoreState(),
|
|
...clusterDropdownStoreState(),
|
|
|
|
...config.keyPairsState,
|
|
|
};
|
|
};
|
|
|
securityGroupsState = {
|
|
securityGroupsState = {
|
|
|
...clusterDropdownStoreState(),
|
|
...clusterDropdownStoreState(),
|
|
|
|
...config.securityGroupsState,
|
|
|
};
|
|
};
|
|
|
instanceTypesState = {
|
|
instanceTypesState = {
|
|
|
...clusterDropdownStoreState(),
|
|
...clusterDropdownStoreState(),
|
|
|
|
...config.instanceTypesState,
|
|
|
|
};
|
|
|
|
getters = {
|
|
|
|
subnetValid: config?.getters?.subnetValid || (() => false),
|
|
|
};
|
|
};
|
|
|
store = new Vuex.Store({
|
|
store = new Vuex.Store({
|
|
|
state,
|
|
state,
|
|
|
|
getters,
|
|
|
actions,
|
|
actions,
|
|
|
modules: {
|
|
modules: {
|
|
|
vpcs: {
|
|
vpcs: {
|
| ... | @@ -125,9 +140,29 @@ describe('EksClusterConfigurationForm', () => { |
... | @@ -125,9 +140,29 @@ describe('EksClusterConfigurationForm', () => { |
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const createValidStateStore = initialState => {
|
|
|
|
createStore({
|
|
|
|
initialState: {
|
|
|
|
clusterName: 'cluster name',
|
|
|
|
environmentScope: '*',
|
|
|
|
selectedRegion: 'region',
|
|
|
|
selectedRole: 'role',
|
|
|
|
selectedKeyPair: 'key pair',
|
|
|
|
selectedVpc: 'vpc',
|
|
|
|
selectedSubnet: ['subnet 1', 'subnet 2'],
|
|
|
|
selectedSecurityGroup: 'group',
|
|
|
|
selectedInstanceType: 'small-1',
|
|
|
|
...initialState,
|
|
|
|
},
|
|
|
|
getters: {
|
|
|
|
subnetValid: () => true,
|
|
|
|
},
|
|
|
});
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
const buildWrapper = () => {
|
|
|
vm = shallowMount(EksClusterConfigurationForm, {
|
|
vm = shallowMount(EksClusterConfigurationForm, {
|
|
|
localVue,
|
|
localVue,
|
|
|
store,
|
|
store,
|
| ... | @@ -137,27 +172,17 @@ describe('EksClusterConfigurationForm', () => { |
... | @@ -137,27 +172,17 @@ describe('EksClusterConfigurationForm', () => { |
|
|
externalLinkIcon: '',
|
|
externalLinkIcon: '',
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
createStore();
|
|
|
|
buildWrapper();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
afterEach(() => {
|
|
|
vm.destroy();
|
|
vm.destroy();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const setAllConfigurationFields = () => {
|
|
|
|
|
store.replaceState({
|
|
|
|
|
...state,
|
|
|
|
|
clusterName: 'cluster name',
|
|
|
|
|
environmentScope: '*',
|
|
|
|
|
selectedRegion: 'region',
|
|
|
|
|
selectedRole: 'role',
|
|
|
|
|
selectedKeyPair: 'key pair',
|
|
|
|
|
selectedVpc: 'vpc',
|
|
|
|
|
selectedSubnet: 'subnet',
|
|
|
|
|
selectedSecurityGroup: 'group',
|
|
|
|
|
selectedInstanceType: 'small-1',
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const findCreateClusterButton = () => vm.find('.js-create-cluster');
|
|
const findCreateClusterButton = () => vm.find('.js-create-cluster');
|
|
|
const findClusterNameInput = () => vm.find('[id=eks-cluster-name]');
|
|
const findClusterNameInput = () => vm.find('[id=eks-cluster-name]');
|
|
|
const findEnvironmentScopeInput = () => vm.find('[id=eks-environment-scope]');
|
|
const findEnvironmentScopeInput = () => vm.find('[id=eks-environment-scope]');
|
| ... | @@ -310,12 +335,29 @@ describe('EksClusterConfigurationForm', () => { |
... | @@ -310,12 +335,29 @@ describe('EksClusterConfigurationForm', () => { |
|
|
expect(findSubnetDropdown().props('items')).toBe(subnetsState.items);
|
|
expect(findSubnetDropdown().props('items')).toBe(subnetsState.items);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('sets SubnetDropdown hasErrors to true when loading subnets fails', () => {
|
|
it('displays a validation error in the subnet dropdown when loading subnets fails', () => {
|
|
|
subnetsState.loadingItemsError = new Error();
|
|
createStore({
|
|
|
|
subnetsState: {
|
|
|
|
loadingItemsError: new Error(),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
buildWrapper();
|
|
|
|
|
|
|
|
return Vue.nextTick().then(() => {
|
|
|
|
|
expect(findSubnetDropdown().props('hasErrors')).toEqual(true);
|
|
expect(findSubnetDropdown().props('hasErrors')).toEqual(true);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('displays a validation error in the subnet dropdown when a single subnet is selected', () => {
|
|
|
|
createStore({
|
|
|
|
initialState: {
|
|
|
|
selectedSubnet: ['subnet 1'],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
buildWrapper();
|
|
|
|
|
|
|
|
expect(findSubnetDropdown().props('hasErrors')).toEqual(true);
|
|
|
|
expect(findSubnetDropdown().props('errorMessage')).toEqual(
|
|
|
|
'You should select at least two subnets',
|
|
|
|
);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('disables SecurityGroupDropdown when no vpc is selected', () => {
|
|
it('disables SecurityGroupDropdown when no vpc is selected', () => {
|
| ... | @@ -386,11 +428,7 @@ describe('EksClusterConfigurationForm', () => { |
... | @@ -386,11 +428,7 @@ describe('EksClusterConfigurationForm', () => { |
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('cleans selected subnet', () => {
|
|
it('cleans selected subnet', () => {
|
|
|
expect(actions.setSubnet).toHaveBeenCalledWith(
|
|
expect(actions.setSubnet).toHaveBeenCalledWith(expect.anything(), { subnet: [] }, undefined);
|
|
|
expect.anything(),
|
|
|
|
|
{ subnet: null },
|
|
|
|
|
undefined,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('cleans selected security group', () => {
|
|
it('cleans selected security group', () => {
|
| ... | @@ -464,11 +502,7 @@ describe('EksClusterConfigurationForm', () => { |
... | @@ -464,11 +502,7 @@ describe('EksClusterConfigurationForm', () => { |
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('cleans selected subnet', () => {
|
|
it('cleans selected subnet', () => {
|
|
|
expect(actions.setSubnet).toHaveBeenCalledWith(
|
|
expect(actions.setSubnet).toHaveBeenCalledWith(expect.anything(), { subnet: [] }, undefined);
|
|
|
expect.anything(),
|
|
|
|
|
{ subnet: null },
|
|
|
|
|
undefined,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('cleans selected security group', () => {
|
|
it('cleans selected security group', () => {
|
| ... | @@ -573,22 +607,19 @@ describe('EksClusterConfigurationForm', () => { |
... | @@ -573,22 +607,19 @@ describe('EksClusterConfigurationForm', () => { |
|
|
});
|
|
});
|
|
|
|
|
|
|
|
describe('when all cluster configuration fields are set', () => {
|
|
describe('when all cluster configuration fields are set', () => {
|
|
|
beforeEach(() => {
|
|
|
|
|
setAllConfigurationFields();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('enables create cluster button', () => {
|
|
it('enables create cluster button', () => {
|
|
|
|
createValidStateStore();
|
|
|
|
buildWrapper();
|
|
|
expect(findCreateClusterButton().props('disabled')).toBe(false);
|
|
expect(findCreateClusterButton().props('disabled')).toBe(false);
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
describe('when at least one cluster configuration field is not set', () => {
|
|
describe('when at least one cluster configuration field is not set', () => {
|
|
|
beforeEach(() => {
|
|
beforeEach(() => {
|
|
|
setAllConfigurationFields();
|
|
createValidStateStore({
|
|
|
store.replaceState({
|
|
clusterName: null,
|
|
|
...state,
|
|
|
|
|
clusterName: '',
|
|
|
|
|
});
|
|
});
|
|
|
|
buildWrapper();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('disables create cluster button', () => {
|
|
it('disables create cluster button', () => {
|
| ... | @@ -596,13 +627,12 @@ describe('EksClusterConfigurationForm', () => { |
... | @@ -596,13 +627,12 @@ describe('EksClusterConfigurationForm', () => { |
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
describe('when isCreatingCluster', () => {
|
|
describe('when is creating cluster', () => {
|
|
|
beforeEach(() => {
|
|
beforeEach(() => {
|
|
|
setAllConfigurationFields();
|
|
createValidStateStore({
|
|
|
store.replaceState({
|
|
|
|
|
...state,
|
|
|
|
|
isCreatingCluster: true,
|
|
isCreatingCluster: true,
|
|
|
});
|
|
});
|
|
|
|
buildWrapper();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('sets create cluster button as loading', () => {
|
|
it('sets create cluster button as loading', () => {
|
| ... | |
... | |
| ... | | ... | |