Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/create_cluster/eks_cluster')
-rw-r--r--spec/frontend/create_cluster/eks_cluster/components/create_eks_cluster_spec.js98
-rw-r--r--spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js562
-rw-r--r--spec/frontend/create_cluster/eks_cluster/components/service_credentials_form_spec.js124
-rw-r--r--spec/frontend/create_cluster/eks_cluster/services/aws_services_facade_spec.js178
-rw-r--r--spec/frontend/create_cluster/eks_cluster/store/actions_spec.js366
-rw-r--r--spec/frontend/create_cluster/eks_cluster/store/getters_spec.js13
-rw-r--r--spec/frontend/create_cluster/eks_cluster/store/mutations_spec.js161
7 files changed, 0 insertions, 1502 deletions
diff --git a/spec/frontend/create_cluster/eks_cluster/components/create_eks_cluster_spec.js b/spec/frontend/create_cluster/eks_cluster/components/create_eks_cluster_spec.js
deleted file mode 100644
index c8020cf8308..00000000000
--- a/spec/frontend/create_cluster/eks_cluster/components/create_eks_cluster_spec.js
+++ /dev/null
@@ -1,98 +0,0 @@
-import { shallowMount } from '@vue/test-utils';
-import Vue from 'vue';
-import Vuex from 'vuex';
-
-import CreateEksCluster from '~/create_cluster/eks_cluster/components/create_eks_cluster.vue';
-import EksClusterConfigurationForm from '~/create_cluster/eks_cluster/components/eks_cluster_configuration_form.vue';
-import ServiceCredentialsForm from '~/create_cluster/eks_cluster/components/service_credentials_form.vue';
-
-Vue.use(Vuex);
-
-describe('CreateEksCluster', () => {
- let vm;
- let state;
- const gitlabManagedClusterHelpPath = 'gitlab-managed-cluster-help-path';
- const namespacePerEnvironmentHelpPath = 'namespace-per-environment-help-path';
- const accountAndExternalIdsHelpPath = 'account-and-external-id-help-path';
- const createRoleArnHelpPath = 'role-arn-help-path';
- const kubernetesIntegrationHelpPath = 'kubernetes-integration';
- const externalLinkIcon = 'external-link';
-
- beforeEach(() => {
- state = { hasCredentials: false };
- const store = new Vuex.Store({
- state,
- });
-
- vm = shallowMount(CreateEksCluster, {
- propsData: {
- gitlabManagedClusterHelpPath,
- namespacePerEnvironmentHelpPath,
- accountAndExternalIdsHelpPath,
- createRoleArnHelpPath,
- externalLinkIcon,
- kubernetesIntegrationHelpPath,
- },
- store,
- });
- });
- afterEach(() => vm.destroy());
-
- describe('when credentials are provided', () => {
- beforeEach(() => {
- state.hasCredentials = true;
- });
-
- it('displays eks cluster configuration form when credentials are valid', () => {
- expect(vm.find(EksClusterConfigurationForm).exists()).toBe(true);
- });
-
- describe('passes to the cluster configuration form', () => {
- it('help url for kubernetes integration documentation', () => {
- expect(vm.find(EksClusterConfigurationForm).props('gitlabManagedClusterHelpPath')).toBe(
- gitlabManagedClusterHelpPath,
- );
- });
-
- it('help url for namespace per environment cluster documentation', () => {
- expect(vm.find(EksClusterConfigurationForm).props('namespacePerEnvironmentHelpPath')).toBe(
- namespacePerEnvironmentHelpPath,
- );
- });
-
- it('help url for gitlab managed cluster documentation', () => {
- expect(vm.find(EksClusterConfigurationForm).props('kubernetesIntegrationHelpPath')).toBe(
- kubernetesIntegrationHelpPath,
- );
- });
- });
- });
-
- describe('when credentials are invalid', () => {
- beforeEach(() => {
- state.hasCredentials = false;
- });
-
- it('displays service credentials form', () => {
- expect(vm.find(ServiceCredentialsForm).exists()).toBe(true);
- });
-
- describe('passes to the service credentials form', () => {
- it('help url for account and external ids', () => {
- expect(vm.find(ServiceCredentialsForm).props('accountAndExternalIdsHelpPath')).toBe(
- accountAndExternalIdsHelpPath,
- );
- });
-
- it('external link icon', () => {
- expect(vm.find(ServiceCredentialsForm).props('externalLinkIcon')).toBe(externalLinkIcon);
- });
-
- it('help url to create a role ARN', () => {
- expect(vm.find(ServiceCredentialsForm).props('createRoleArnHelpPath')).toBe(
- createRoleArnHelpPath,
- );
- });
- });
- });
-});
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
deleted file mode 100644
index 1509d26c99d..00000000000
--- a/spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js
+++ /dev/null
@@ -1,562 +0,0 @@
-import { GlFormCheckbox } from '@gitlab/ui';
-import { shallowMount } from '@vue/test-utils';
-import Vue, { nextTick } from 'vue';
-import Vuex from 'vuex';
-
-import EksClusterConfigurationForm from '~/create_cluster/eks_cluster/components/eks_cluster_configuration_form.vue';
-import eksClusterFormState from '~/create_cluster/eks_cluster/store/state';
-import clusterDropdownStoreState from '~/create_cluster/store/cluster_dropdown/state';
-
-Vue.use(Vuex);
-
-describe('EksClusterConfigurationForm', () => {
- let store;
- let actions;
- let getters;
- let state;
- let rolesState;
- let vpcsState;
- let subnetsState;
- let keyPairsState;
- let securityGroupsState;
- let instanceTypesState;
- let vpcsActions;
- let rolesActions;
- let subnetsActions;
- let keyPairsActions;
- let securityGroupsActions;
- let vm;
-
- const createStore = (config = {}) => {
- actions = {
- createCluster: jest.fn(),
- 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(),
- setInstanceType: jest.fn(),
- setNodeCount: jest.fn(),
- setGitlabManagedCluster: jest.fn(),
- };
- keyPairsActions = {
- fetchItems: jest.fn(),
- };
- vpcsActions = {
- fetchItems: jest.fn(),
- };
- subnetsActions = {
- fetchItems: jest.fn(),
- };
- rolesActions = {
- fetchItems: jest.fn(),
- };
- securityGroupsActions = {
- fetchItems: jest.fn(),
- };
- state = {
- ...eksClusterFormState(),
- ...config.initialState,
- };
- rolesState = {
- ...clusterDropdownStoreState(),
- ...config.rolesState,
- };
- vpcsState = {
- ...clusterDropdownStoreState(),
- ...config.vpcsState,
- };
- subnetsState = {
- ...clusterDropdownStoreState(),
- ...config.subnetsState,
- };
- keyPairsState = {
- ...clusterDropdownStoreState(),
- ...config.keyPairsState,
- };
- securityGroupsState = {
- ...clusterDropdownStoreState(),
- ...config.securityGroupsState,
- };
- instanceTypesState = {
- ...clusterDropdownStoreState(),
- ...config.instanceTypesState,
- };
- getters = {
- subnetValid: config?.getters?.subnetValid || (() => false),
- };
- store = new Vuex.Store({
- state,
- getters,
- actions,
- modules: {
- vpcs: {
- namespaced: true,
- state: vpcsState,
- actions: vpcsActions,
- },
- subnets: {
- namespaced: true,
- state: subnetsState,
- actions: subnetsActions,
- },
- roles: {
- namespaced: true,
- state: rolesState,
- actions: rolesActions,
- },
- keyPairs: {
- namespaced: true,
- state: keyPairsState,
- actions: keyPairsActions,
- },
- securityGroups: {
- namespaced: true,
- state: securityGroupsState,
- actions: securityGroupsActions,
- },
- instanceTypes: {
- namespaced: true,
- state: instanceTypesState,
- },
- },
- });
- };
-
- const createValidStateStore = (initialState) => {
- createStore({
- initialState: {
- clusterName: 'cluster name',
- environmentScope: '*',
- kubernetesVersion: '1.16',
- selectedRegion: 'region',
- selectedRole: 'role',
- selectedKeyPair: 'key pair',
- selectedVpc: 'vpc',
- selectedSubnet: ['subnet 1', 'subnet 2'],
- selectedSecurityGroup: 'group',
- selectedInstanceType: 'small-1',
- ...initialState,
- },
- getters: {
- subnetValid: () => true,
- },
- });
- };
-
- const buildWrapper = () => {
- vm = shallowMount(EksClusterConfigurationForm, {
- store,
- propsData: {
- gitlabManagedClusterHelpPath: '',
- namespacePerEnvironmentHelpPath: '',
- kubernetesIntegrationHelpPath: '',
- externalLinkIcon: '',
- },
- });
- };
-
- beforeEach(() => {
- createStore();
- buildWrapper();
- });
-
- afterEach(() => {
- vm.destroy();
- });
-
- const findCreateClusterButton = () => vm.find('.js-create-cluster');
- 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 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 findInstanceTypeDropdown = () => vm.find('[field-id="eks-instance-type"');
- const findNodeCountInput = () => vm.find('[id="eks-node-count"]');
- const findGitlabManagedClusterCheckbox = () => vm.find(GlFormCheckbox);
-
- describe('when mounted', () => {
- it('fetches available roles', () => {
- expect(rolesActions.fetchItems).toHaveBeenCalled();
- });
-
- describe('when fetching vpcs and key pairs', () => {
- const region = 'us-west-2';
-
- beforeEach(() => {
- createValidStateStore({ selectedRegion: region });
- buildWrapper();
- });
-
- it('fetches available vpcs', () => {
- expect(vpcsActions.fetchItems).toHaveBeenCalledWith(expect.anything(), { region });
- });
-
- it('fetches available key pairs', () => {
- expect(keyPairsActions.fetchItems).toHaveBeenCalledWith(expect.anything(), { region });
- });
-
- it('cleans selected vpc', () => {
- expect(actions.setVpc).toHaveBeenCalledWith(expect.anything(), { vpc: null });
- });
-
- it('cleans selected key pair', () => {
- expect(actions.setKeyPair).toHaveBeenCalledWith(expect.anything(), { keyPair: null });
- });
-
- it('cleans selected subnet', () => {
- expect(actions.setSubnet).toHaveBeenCalledWith(expect.anything(), { subnet: [] });
- });
-
- it('cleans selected security group', () => {
- expect(actions.setSecurityGroup).toHaveBeenCalledWith(expect.anything(), {
- securityGroup: null,
- });
- });
- });
- });
-
- it('sets isLoadingRoles to RoleDropdown loading property', async () => {
- rolesState.isLoadingItems = true;
-
- await nextTick();
- expect(findRoleDropdown().props('loading')).toBe(rolesState.isLoadingItems);
- });
-
- it('sets roles to RoleDropdown items property', () => {
- expect(findRoleDropdown().props('items')).toBe(rolesState.items);
- });
-
- it('sets RoleDropdown hasErrors to true when loading roles failed', async () => {
- rolesState.loadingItemsError = new Error();
-
- await nextTick();
- expect(findRoleDropdown().props('hasErrors')).toEqual(true);
- });
-
- it('disables KeyPairDropdown when no region is selected', () => {
- expect(findKeyPairDropdown().props('disabled')).toBe(true);
- });
-
- it('enables KeyPairDropdown when no region is selected', async () => {
- state.selectedRegion = { name: 'west-1 ' };
-
- await nextTick();
- expect(findKeyPairDropdown().props('disabled')).toBe(false);
- });
-
- it('sets isLoadingKeyPairs to KeyPairDropdown loading property', async () => {
- keyPairsState.isLoadingItems = true;
-
- await nextTick();
- expect(findKeyPairDropdown().props('loading')).toBe(keyPairsState.isLoadingItems);
- });
-
- it('sets keyPairs to KeyPairDropdown items property', () => {
- expect(findKeyPairDropdown().props('items')).toBe(keyPairsState.items);
- });
-
- it('sets KeyPairDropdown hasErrors to true when loading key pairs fails', async () => {
- keyPairsState.loadingItemsError = new Error();
-
- await nextTick();
- expect(findKeyPairDropdown().props('hasErrors')).toEqual(true);
- });
-
- it('disables VpcDropdown when no region is selected', () => {
- expect(findVpcDropdown().props('disabled')).toBe(true);
- });
-
- it('enables VpcDropdown when no region is selected', async () => {
- state.selectedRegion = { name: 'west-1 ' };
-
- await nextTick();
- expect(findVpcDropdown().props('disabled')).toBe(false);
- });
-
- it('sets isLoadingVpcs to VpcDropdown loading property', async () => {
- vpcsState.isLoadingItems = true;
-
- await nextTick();
- expect(findVpcDropdown().props('loading')).toBe(vpcsState.isLoadingItems);
- });
-
- it('sets vpcs to VpcDropdown items property', () => {
- expect(findVpcDropdown().props('items')).toBe(vpcsState.items);
- });
-
- it('sets VpcDropdown hasErrors to true when loading vpcs fails', async () => {
- vpcsState.loadingItemsError = new Error();
-
- await nextTick();
- expect(findVpcDropdown().props('hasErrors')).toEqual(true);
- });
-
- it('disables SubnetDropdown when no vpc is selected', () => {
- expect(findSubnetDropdown().props('disabled')).toBe(true);
- });
-
- it('enables SubnetDropdown when a vpc is selected', async () => {
- state.selectedVpc = { name: 'vpc-1 ' };
-
- await nextTick();
- expect(findSubnetDropdown().props('disabled')).toBe(false);
- });
-
- it('sets isLoadingSubnets to SubnetDropdown loading property', async () => {
- subnetsState.isLoadingItems = true;
-
- await nextTick();
- expect(findSubnetDropdown().props('loading')).toBe(subnetsState.isLoadingItems);
- });
-
- it('sets subnets to SubnetDropdown items property', () => {
- expect(findSubnetDropdown().props('items')).toBe(subnetsState.items);
- });
-
- it('displays a validation error in the subnet dropdown when loading subnets fails', () => {
- createStore({
- subnetsState: {
- loadingItemsError: new Error(),
- },
- });
- buildWrapper();
-
- 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', () => {
- expect(findSecurityGroupDropdown().props('disabled')).toBe(true);
- });
-
- it('enables SecurityGroupDropdown when a vpc is selected', async () => {
- state.selectedVpc = { name: 'vpc-1 ' };
-
- await nextTick();
- expect(findSecurityGroupDropdown().props('disabled')).toBe(false);
- });
-
- it('sets isLoadingSecurityGroups to SecurityGroupDropdown loading property', async () => {
- securityGroupsState.isLoadingItems = true;
-
- await nextTick();
- 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', async () => {
- securityGroupsState.loadingItemsError = new Error();
-
- await nextTick();
- expect(findSecurityGroupDropdown().props('hasErrors')).toEqual(true);
- });
-
- it('dispatches setClusterName when cluster name input changes', () => {
- const clusterName = 'name';
-
- findClusterNameInput().vm.$emit('input', clusterName);
-
- expect(actions.setClusterName).toHaveBeenCalledWith(expect.anything(), { clusterName });
- });
-
- it('dispatches setEnvironmentScope when environment scope input changes', () => {
- const environmentScope = 'production';
-
- findEnvironmentScopeInput().vm.$emit('input', environmentScope);
-
- expect(actions.setEnvironmentScope).toHaveBeenCalledWith(expect.anything(), {
- environmentScope,
- });
- });
-
- 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,
- });
- });
-
- it('dispatches setGitlabManagedCluster when gitlab managed cluster input changes', () => {
- const gitlabManagedCluster = false;
-
- findGitlabManagedClusterCheckbox().vm.$emit('input', gitlabManagedCluster);
-
- expect(actions.setGitlabManagedCluster).toHaveBeenCalledWith(expect.anything(), {
- gitlabManagedCluster,
- });
- });
-
- describe('when vpc is selected', () => {
- const vpc = { name: 'vpc-1' };
- const region = 'east-1';
-
- beforeEach(() => {
- state.selectedRegion = region;
- findVpcDropdown().vm.$emit('input', vpc);
- });
-
- it('dispatches setVpc action', () => {
- expect(actions.setVpc).toHaveBeenCalledWith(expect.anything(), { vpc });
- });
-
- it('cleans selected subnet', () => {
- expect(actions.setSubnet).toHaveBeenCalledWith(expect.anything(), { subnet: [] });
- });
-
- it('cleans selected security group', () => {
- expect(actions.setSecurityGroup).toHaveBeenCalledWith(expect.anything(), {
- securityGroup: null,
- });
- });
-
- it('dispatches fetchSubnets action', () => {
- expect(subnetsActions.fetchItems).toHaveBeenCalledWith(expect.anything(), { vpc, region });
- });
-
- it('dispatches fetchSecurityGroups action', () => {
- expect(securityGroupsActions.fetchItems).toHaveBeenCalledWith(expect.anything(), {
- vpc,
- region,
- });
- });
- });
-
- describe('when a subnet is selected', () => {
- const subnet = { name: 'subnet-1' };
-
- beforeEach(() => {
- findSubnetDropdown().vm.$emit('input', subnet);
- });
-
- it('dispatches setSubnet action', () => {
- expect(actions.setSubnet).toHaveBeenCalledWith(expect.anything(), { subnet });
- });
- });
-
- describe('when role is selected', () => {
- const role = { name: 'admin' };
-
- beforeEach(() => {
- findRoleDropdown().vm.$emit('input', role);
- });
-
- it('dispatches setRole action', () => {
- expect(actions.setRole).toHaveBeenCalledWith(expect.anything(), { role });
- });
- });
-
- describe('when key pair is selected', () => {
- const keyPair = { name: 'key pair' };
-
- beforeEach(() => {
- findKeyPairDropdown().vm.$emit('input', keyPair);
- });
-
- it('dispatches setKeyPair action', () => {
- expect(actions.setKeyPair).toHaveBeenCalledWith(expect.anything(), { keyPair });
- });
- });
-
- 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 });
- });
- });
-
- describe('when instance type is selected', () => {
- const instanceType = 'small-1';
-
- beforeEach(() => {
- findInstanceTypeDropdown().vm.$emit('input', instanceType);
- });
-
- it('dispatches setInstanceType action', () => {
- expect(actions.setInstanceType).toHaveBeenCalledWith(expect.anything(), { instanceType });
- });
- });
-
- it('dispatches setNodeCount when node count input changes', () => {
- const nodeCount = 5;
-
- findNodeCountInput().vm.$emit('input', nodeCount);
-
- expect(actions.setNodeCount).toHaveBeenCalledWith(expect.anything(), { nodeCount });
- });
-
- describe('when all cluster configuration fields are set', () => {
- it('enables create cluster button', () => {
- createValidStateStore();
- buildWrapper();
- expect(findCreateClusterButton().props('disabled')).toBe(false);
- });
- });
-
- describe('when at least one cluster configuration field is not set', () => {
- beforeEach(() => {
- createValidStateStore({
- clusterName: null,
- });
- buildWrapper();
- });
-
- it('disables create cluster button', () => {
- expect(findCreateClusterButton().props('disabled')).toBe(true);
- });
- });
-
- describe('when is creating cluster', () => {
- beforeEach(() => {
- createValidStateStore({
- isCreatingCluster: true,
- });
- buildWrapper();
- });
-
- it('sets create cluster button as loading', () => {
- expect(findCreateClusterButton().props('loading')).toBe(true);
- });
- });
-
- describe('clicking create cluster button', () => {
- beforeEach(() => {
- findCreateClusterButton().vm.$emit('click');
- });
-
- it('dispatches createCluster action', () => {
- expect(actions.createCluster).toHaveBeenCalled();
- });
- });
-});
diff --git a/spec/frontend/create_cluster/eks_cluster/components/service_credentials_form_spec.js b/spec/frontend/create_cluster/eks_cluster/components/service_credentials_form_spec.js
deleted file mode 100644
index 0d823a18012..00000000000
--- a/spec/frontend/create_cluster/eks_cluster/components/service_credentials_form_spec.js
+++ /dev/null
@@ -1,124 +0,0 @@
-import { GlButton } from '@gitlab/ui';
-import { shallowMount } from '@vue/test-utils';
-import Vue, { nextTick } from 'vue';
-import Vuex from 'vuex';
-import ServiceCredentialsForm from '~/create_cluster/eks_cluster/components/service_credentials_form.vue';
-import eksClusterState from '~/create_cluster/eks_cluster/store/state';
-
-Vue.use(Vuex);
-
-describe('ServiceCredentialsForm', () => {
- let vm;
- let state;
- let createRoleAction;
- const accountId = 'accountId';
- const externalId = 'externalId';
-
- beforeEach(() => {
- state = Object.assign(eksClusterState(), {
- accountId,
- externalId,
- });
- createRoleAction = jest.fn();
-
- const store = new Vuex.Store({
- state,
- actions: {
- createRole: createRoleAction,
- },
- });
- vm = shallowMount(ServiceCredentialsForm, {
- propsData: {
- accountAndExternalIdsHelpPath: '',
- createRoleArnHelpPath: '',
- externalLinkIcon: '',
- },
- store,
- });
- });
- afterEach(() => vm.destroy());
-
- const findAccountIdInput = () => vm.find('#gitlab-account-id');
- const findCopyAccountIdButton = () => vm.find('.js-copy-account-id-button');
- const findExternalIdInput = () => vm.find('#eks-external-id');
- const findCopyExternalIdButton = () => vm.find('.js-copy-external-id-button');
- const findInvalidCredentials = () => vm.find('.js-invalid-credentials');
- const findSubmitButton = () => vm.find(GlButton);
-
- it('displays provided account id', () => {
- expect(findAccountIdInput().attributes('value')).toBe(accountId);
- });
-
- it('allows to copy account id', () => {
- expect(findCopyAccountIdButton().props('text')).toBe(accountId);
- });
-
- it('displays provided external id', () => {
- expect(findExternalIdInput().attributes('value')).toBe(externalId);
- });
-
- it('allows to copy external id', () => {
- expect(findCopyExternalIdButton().props('text')).toBe(externalId);
- });
-
- it('disables submit button when role ARN is not provided', () => {
- expect(findSubmitButton().attributes('disabled')).toBeTruthy();
- });
-
- it('enables submit button when role ARN is not provided', async () => {
- // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
- // eslint-disable-next-line no-restricted-syntax
- vm.setData({ roleArn: '123' });
-
- await nextTick();
- expect(findSubmitButton().attributes('disabled')).toBeFalsy();
- });
-
- it('dispatches createRole action when submit button is clicked', () => {
- // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
- // eslint-disable-next-line no-restricted-syntax
- vm.setData({ roleArn: '123' }); // set role ARN to enable button
-
- findSubmitButton().vm.$emit('click', new Event('click'));
-
- expect(createRoleAction).toHaveBeenCalled();
- });
-
- describe('when is creating role', () => {
- beforeEach(async () => {
- // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
- // eslint-disable-next-line no-restricted-syntax
- vm.setData({ roleArn: '123' }); // set role ARN to enable button
-
- state.isCreatingRole = true;
-
- await nextTick();
- });
-
- it('disables submit button', () => {
- expect(findSubmitButton().props('disabled')).toBe(true);
- });
-
- it('sets submit button as loading', () => {
- expect(findSubmitButton().props('loading')).toBe(true);
- });
-
- it('displays Authenticating label on submit button', () => {
- expect(findSubmitButton().text()).toBe('Authenticating');
- });
- });
-
- describe('when role can’t be created', () => {
- beforeEach(() => {
- state.createRoleError = 'Invalid credentials';
- });
-
- it('displays invalid role warning banner', () => {
- expect(findInvalidCredentials().exists()).toBe(true);
- });
-
- it('displays invalid role error message', () => {
- expect(findInvalidCredentials().text()).toContain(state.createRoleError);
- });
- });
-});
diff --git a/spec/frontend/create_cluster/eks_cluster/services/aws_services_facade_spec.js b/spec/frontend/create_cluster/eks_cluster/services/aws_services_facade_spec.js
deleted file mode 100644
index 7b93b6d0a09..00000000000
--- a/spec/frontend/create_cluster/eks_cluster/services/aws_services_facade_spec.js
+++ /dev/null
@@ -1,178 +0,0 @@
-import EC2 from 'aws-sdk/clients/ec2';
-import AWS from 'aws-sdk/global';
-import {
- setAWSConfig,
- fetchRoles,
- fetchKeyPairs,
- fetchVpcs,
- fetchSubnets,
- fetchSecurityGroups,
-} from '~/create_cluster/eks_cluster/services/aws_services_facade';
-
-const mockListRolesPromise = jest.fn();
-const mockDescribeRegionsPromise = jest.fn();
-const mockDescribeKeyPairsPromise = jest.fn();
-const mockDescribeVpcsPromise = jest.fn();
-const mockDescribeSubnetsPromise = jest.fn();
-const mockDescribeSecurityGroupsPromise = jest.fn();
-
-jest.mock('aws-sdk/clients/iam', () =>
- jest.fn().mockImplementation(() => ({
- listRoles: jest.fn().mockReturnValue({ promise: mockListRolesPromise }),
- })),
-);
-
-jest.mock('aws-sdk/clients/ec2', () =>
- jest.fn().mockImplementation(() => ({
- describeRegions: jest.fn().mockReturnValue({ promise: mockDescribeRegionsPromise }),
- describeKeyPairs: jest.fn().mockReturnValue({ promise: mockDescribeKeyPairsPromise }),
- describeVpcs: jest.fn().mockReturnValue({ promise: mockDescribeVpcsPromise }),
- describeSubnets: jest.fn().mockReturnValue({ promise: mockDescribeSubnetsPromise }),
- describeSecurityGroups: jest
- .fn()
- .mockReturnValue({ promise: mockDescribeSecurityGroupsPromise }),
- })),
-);
-
-describe('awsServicesFacade', () => {
- let region;
- let vpc;
-
- beforeEach(() => {
- region = 'west-1';
- vpc = 'vpc-2';
- });
-
- it('setAWSConfig configures AWS SDK with provided credentials', () => {
- const awsCredentials = {
- accessKeyId: 'access-key',
- secretAccessKey: 'secret-key',
- sessionToken: 'session-token',
- region,
- };
-
- setAWSConfig({ awsCredentials });
-
- expect(AWS.config).toEqual(awsCredentials);
- });
-
- describe('when fetchRoles succeeds', () => {
- let roles;
- let rolesOutput;
-
- beforeEach(() => {
- roles = [
- { RoleName: 'admin', Arn: 'aws::admin' },
- { RoleName: 'read-only', Arn: 'aws::read-only' },
- ];
- rolesOutput = roles.map(({ RoleName: name, Arn: value }) => ({ name, value }));
-
- mockListRolesPromise.mockResolvedValueOnce({ Roles: roles });
- });
-
- it('return list of regions where each item has a name and value', () => {
- return expect(fetchRoles()).resolves.toEqual(rolesOutput);
- });
- });
-
- describe('when fetchKeyPairs succeeds', () => {
- let keyPairs;
- let keyPairsOutput;
-
- beforeEach(() => {
- keyPairs = [{ KeyName: 'key-pair' }, { KeyName: 'key-pair-2' }];
- keyPairsOutput = keyPairs.map(({ KeyName: name }) => ({ name, value: name }));
-
- mockDescribeKeyPairsPromise.mockResolvedValueOnce({ KeyPairs: keyPairs });
- });
-
- it('instantatiates ec2 service with provided region', () => {
- fetchKeyPairs({ region });
- expect(EC2).toHaveBeenCalledWith({ region });
- });
-
- it('return list of key pairs where each item has a name and value', () => {
- return expect(fetchKeyPairs({ region })).resolves.toEqual(keyPairsOutput);
- });
- });
-
- describe('when fetchVpcs succeeds', () => {
- let vpcs;
- let vpcsOutput;
-
- beforeEach(() => {
- vpcs = [
- { VpcId: 'vpc-1', Tags: [] },
- { VpcId: 'vpc-2', Tags: [] },
- ];
- vpcsOutput = vpcs.map(({ VpcId: vpcId }) => ({ name: vpcId, value: vpcId }));
-
- mockDescribeVpcsPromise.mockResolvedValueOnce({ Vpcs: vpcs });
- });
-
- it('instantatiates ec2 service with provided region', () => {
- fetchVpcs({ region });
- expect(EC2).toHaveBeenCalledWith({ region });
- });
-
- it('return list of vpcs where each item has a name and value', () => {
- return expect(fetchVpcs({ region })).resolves.toEqual(vpcsOutput);
- });
- });
-
- describe('when vpcs has a Name tag', () => {
- const vpcName = 'vpc name';
- const vpcId = 'vpc id';
- let vpcs;
- let vpcsOutput;
-
- beforeEach(() => {
- vpcs = [{ VpcId: vpcId, Tags: [{ Key: 'Name', Value: vpcName }] }];
- vpcsOutput = [{ name: vpcName, value: vpcId }];
-
- mockDescribeVpcsPromise.mockResolvedValueOnce({ Vpcs: vpcs });
- });
-
- it('uses name tag value as the vpc name', () => {
- return expect(fetchVpcs({ region })).resolves.toEqual(vpcsOutput);
- });
- });
-
- describe('when fetchSubnets succeeds', () => {
- let subnets;
- let subnetsOutput;
-
- beforeEach(() => {
- subnets = [{ SubnetId: 'subnet-1' }, { SubnetId: 'subnet-2' }];
- subnetsOutput = subnets.map(({ SubnetId }) => ({ name: SubnetId, value: SubnetId }));
-
- mockDescribeSubnetsPromise.mockResolvedValueOnce({ Subnets: subnets });
- });
-
- it('return list of subnets where each item has a name and value', () => {
- return expect(fetchSubnets({ region, vpc })).resolves.toEqual(subnetsOutput);
- });
- });
-
- describe('when fetchSecurityGroups succeeds', () => {
- let securityGroups;
- let securityGroupsOutput;
-
- beforeEach(() => {
- securityGroups = [
- { GroupName: 'admin group', GroupId: 'group-1' },
- { GroupName: 'basic group', GroupId: 'group-2' },
- ];
- securityGroupsOutput = securityGroups.map(({ GroupId: value, GroupName: name }) => ({
- name,
- value,
- }));
-
- mockDescribeSecurityGroupsPromise.mockResolvedValueOnce({ SecurityGroups: securityGroups });
- });
-
- it('return list of security groups where each item has a name and value', () => {
- return expect(fetchSecurityGroups({ region, vpc })).resolves.toEqual(securityGroupsOutput);
- });
- });
-});
diff --git a/spec/frontend/create_cluster/eks_cluster/store/actions_spec.js b/spec/frontend/create_cluster/eks_cluster/store/actions_spec.js
deleted file mode 100644
index 8d7b22fe4ff..00000000000
--- a/spec/frontend/create_cluster/eks_cluster/store/actions_spec.js
+++ /dev/null
@@ -1,366 +0,0 @@
-import MockAdapter from 'axios-mock-adapter';
-import { useMockLocationHelper } from 'helpers/mock_window_location_helper';
-import testAction from 'helpers/vuex_action_helper';
-import { DEFAULT_REGION } from '~/create_cluster/eks_cluster/constants';
-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,
- SET_NAMESPACE_PER_ENVIRONMENT,
- SET_INSTANCE_TYPE,
- SET_NODE_COUNT,
- REQUEST_CREATE_ROLE,
- CREATE_ROLE_SUCCESS,
- CREATE_ROLE_ERROR,
- REQUEST_CREATE_CLUSTER,
- CREATE_CLUSTER_ERROR,
-} from '~/create_cluster/eks_cluster/store/mutation_types';
-import createState from '~/create_cluster/eks_cluster/store/state';
-import createFlash from '~/flash';
-import axios from '~/lib/utils/axios_utils';
-
-jest.mock('~/flash');
-
-describe('EKS Cluster Store Actions', () => {
- let clusterName;
- let environmentScope;
- let kubernetesVersion;
- let region;
- let vpc;
- let subnet;
- let role;
- let keyPair;
- let securityGroup;
- let instanceType;
- let nodeCount;
- let gitlabManagedCluster;
- let namespacePerEnvironment;
- let mock;
- let state;
- let newClusterUrl;
-
- beforeEach(() => {
- clusterName = 'my cluster';
- environmentScope = 'production';
- kubernetesVersion = '1.16';
- region = 'regions-1';
- vpc = 'vpc-1';
- subnet = 'subnet-1';
- role = 'role-1';
- keyPair = 'key-pair-1';
- securityGroup = 'default group';
- instanceType = 'small-1';
- nodeCount = '5';
- gitlabManagedCluster = true;
- namespacePerEnvironment = true;
-
- newClusterUrl = '/clusters/1';
-
- state = {
- ...createState(),
- createRolePath: '/clusters/roles/',
- createClusterPath: '/clusters/',
- };
- });
-
- beforeEach(() => {
- mock = new MockAdapter(axios);
- });
-
- afterEach(() => {
- mock.restore();
- });
-
- it.each`
- 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'}
- ${'setInstanceType'} | ${SET_INSTANCE_TYPE} | ${{ instanceType }} | ${'instance type'}
- ${'setNodeCount'} | ${SET_NODE_COUNT} | ${{ nodeCount }} | ${'node count'}
- ${'setGitlabManagedCluster'} | ${SET_GITLAB_MANAGED_CLUSTER} | ${gitlabManagedCluster} | ${'gitlab managed cluster'}
- ${'setNamespacePerEnvironment'} | ${SET_NAMESPACE_PER_ENVIRONMENT} | ${namespacePerEnvironment} | ${'namespace per environment'}
- `(`$action commits $mutation with $payloadDescription payload`, (data) => {
- const { action, mutation, payload } = data;
-
- testAction(actions[action], payload, state, [{ type: mutation, payload }]);
- });
-
- describe('createRole', () => {
- const payload = {
- roleArn: 'role_arn',
- externalId: 'externalId',
- };
- const response = {
- accessKeyId: 'access-key-id',
- secretAccessKey: 'secret-key-id',
- };
-
- describe('when request succeeds with default region', () => {
- beforeEach(() => {
- mock
- .onPost(state.createRolePath, {
- role_arn: payload.roleArn,
- role_external_id: payload.externalId,
- region: DEFAULT_REGION,
- })
- .reply(201, response);
- });
-
- it('dispatches createRoleSuccess action', () =>
- testAction(
- actions.createRole,
- payload,
- state,
- [],
- [
- { type: 'requestCreateRole' },
- {
- type: 'createRoleSuccess',
- payload: {
- region: DEFAULT_REGION,
- ...response,
- },
- },
- ],
- ));
- });
-
- describe('when request succeeds with custom region', () => {
- const customRegion = 'custom-region';
-
- beforeEach(() => {
- mock
- .onPost(state.createRolePath, {
- role_arn: payload.roleArn,
- role_external_id: payload.externalId,
- region: customRegion,
- })
- .reply(201, response);
- });
-
- it('dispatches createRoleSuccess action', () =>
- testAction(
- actions.createRole,
- {
- selectedRegion: customRegion,
- ...payload,
- },
- state,
- [],
- [
- { type: 'requestCreateRole' },
- {
- type: 'createRoleSuccess',
- payload: {
- region: customRegion,
- ...response,
- },
- },
- ],
- ));
- });
-
- describe('when request fails', () => {
- let error;
-
- beforeEach(() => {
- error = new Error('Request failed with status code 400');
- mock
- .onPost(state.createRolePath, {
- role_arn: payload.roleArn,
- role_external_id: payload.externalId,
- region: DEFAULT_REGION,
- })
- .reply(400, null);
- });
-
- it('dispatches createRoleError action', () =>
- testAction(
- actions.createRole,
- payload,
- state,
- [],
- [{ type: 'requestCreateRole' }, { type: 'createRoleError', payload: { error } }],
- ));
- });
-
- describe('when request fails with a message', () => {
- beforeEach(() => {
- const errResp = { message: 'Something failed' };
-
- mock
- .onPost(state.createRolePath, {
- role_arn: payload.roleArn,
- role_external_id: payload.externalId,
- region: DEFAULT_REGION,
- })
- .reply(4, errResp);
- });
-
- it('dispatches createRoleError action', () =>
- testAction(
- actions.createRole,
- payload,
- state,
- [],
- [
- { type: 'requestCreateRole' },
- { type: 'createRoleError', payload: { error: 'Something failed' } },
- ],
- ));
- });
- });
-
- describe('requestCreateRole', () => {
- it('commits requestCreaterole mutation', () => {
- testAction(actions.requestCreateRole, null, state, [{ type: REQUEST_CREATE_ROLE }]);
- });
- });
-
- describe('createRoleSuccess', () => {
- it('sets region and commits createRoleSuccess mutation', () => {
- testAction(
- actions.createRoleSuccess,
- { region },
- state,
- [{ type: CREATE_ROLE_SUCCESS }],
- [{ type: 'setRegion', payload: { region } }],
- );
- });
- });
-
- describe('createRoleError', () => {
- it('commits createRoleError mutation', () => {
- const payload = {
- error: new Error(),
- };
-
- testAction(actions.createRoleError, payload, state, [{ type: CREATE_ROLE_ERROR, payload }]);
- });
- });
-
- describe('createCluster', () => {
- let requestPayload;
-
- beforeEach(() => {
- requestPayload = {
- name: clusterName,
- environment_scope: environmentScope,
- managed: gitlabManagedCluster,
- namespace_per_environment: namespacePerEnvironment,
- provider_aws_attributes: {
- kubernetes_version: kubernetesVersion,
- region,
- vpc_id: vpc,
- subnet_ids: subnet,
- role_arn: role,
- key_name: keyPair,
- security_group_id: securityGroup,
- instance_type: instanceType,
- num_nodes: nodeCount,
- },
- };
- state = Object.assign(createState(), {
- clusterName,
- environmentScope,
- kubernetesVersion,
- selectedRegion: region,
- selectedVpc: vpc,
- selectedSubnet: subnet,
- selectedRole: role,
- selectedKeyPair: keyPair,
- selectedSecurityGroup: securityGroup,
- selectedInstanceType: instanceType,
- nodeCount,
- gitlabManagedCluster,
- namespacePerEnvironment,
- });
- });
-
- describe('when request succeeds', () => {
- beforeEach(() => {
- mock.onPost(state.createClusterPath, requestPayload).reply(201, null, {
- location: '/clusters/1',
- });
- });
-
- it('dispatches createClusterSuccess action', () =>
- testAction(
- actions.createCluster,
- null,
- state,
- [],
- [
- { type: 'requestCreateCluster' },
- { type: 'createClusterSuccess', payload: newClusterUrl },
- ],
- ));
- });
-
- describe('when request fails', () => {
- let response;
-
- beforeEach(() => {
- response = 'Request failed with status code 400';
- mock.onPost(state.createClusterPath, requestPayload).reply(400, response);
- });
-
- it('dispatches createRoleError action', () =>
- testAction(
- actions.createCluster,
- null,
- state,
- [],
- [{ type: 'requestCreateCluster' }, { type: 'createClusterError', payload: response }],
- ));
- });
- });
-
- describe('requestCreateCluster', () => {
- it('commits requestCreateCluster mutation', () => {
- testAction(actions.requestCreateCluster, null, state, [{ type: REQUEST_CREATE_CLUSTER }]);
- });
- });
-
- describe('createClusterSuccess', () => {
- useMockLocationHelper();
-
- it('redirects to the new cluster URL', () => {
- actions.createClusterSuccess(null, newClusterUrl);
-
- expect(window.location.assign).toHaveBeenCalledWith(newClusterUrl);
- });
- });
-
- describe('createClusterError', () => {
- let payload;
-
- beforeEach(() => {
- payload = { name: ['Create cluster failed'] };
- });
-
- it('commits createClusterError mutation and displays flash message', () =>
- testAction(actions.createClusterError, payload, state, [
- { type: CREATE_CLUSTER_ERROR, payload },
- ]).then(() => {
- expect(createFlash).toHaveBeenCalledWith({
- message: payload.name[0],
- });
- }));
- });
-});
diff --git a/spec/frontend/create_cluster/eks_cluster/store/getters_spec.js b/spec/frontend/create_cluster/eks_cluster/store/getters_spec.js
deleted file mode 100644
index 46c37961dd3..00000000000
--- a/spec/frontend/create_cluster/eks_cluster/store/getters_spec.js
+++ /dev/null
@@ -1,13 +0,0 @@
-import { subnetValid } from '~/create_cluster/eks_cluster/store/getters';
-
-describe('EKS Cluster Store Getters', () => {
- describe('subnetValid', () => {
- it('returns true if there are 2 or more selected subnets', () => {
- expect(subnetValid({ selectedSubnet: [1, 2] })).toBe(true);
- });
-
- it.each([[[], [1]]])('returns false if there are 1 or less selected subnets', (subnets) => {
- expect(subnetValid({ selectedSubnet: subnets })).toBe(false);
- });
- });
-});
diff --git a/spec/frontend/create_cluster/eks_cluster/store/mutations_spec.js b/spec/frontend/create_cluster/eks_cluster/store/mutations_spec.js
deleted file mode 100644
index 54d66e79be7..00000000000
--- a/spec/frontend/create_cluster/eks_cluster/store/mutations_spec.js
+++ /dev/null
@@ -1,161 +0,0 @@
-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_INSTANCE_TYPE,
- SET_NODE_COUNT,
- SET_GITLAB_MANAGED_CLUSTER,
- REQUEST_CREATE_ROLE,
- CREATE_ROLE_SUCCESS,
- CREATE_ROLE_ERROR,
- REQUEST_CREATE_CLUSTER,
- CREATE_CLUSTER_ERROR,
-} from '~/create_cluster/eks_cluster/store/mutation_types';
-import mutations from '~/create_cluster/eks_cluster/store/mutations';
-import createState from '~/create_cluster/eks_cluster/store/state';
-
-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 instanceType;
- let nodeCount;
- 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' };
- instanceType = 'small-1';
- nodeCount = '5';
- gitlabManagedCluster = false;
-
- state = createState();
- });
-
- it.each`
- 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 subnet payload'}
- ${SET_SECURITY_GROUP} | ${'selectedSecurityGroup'} | ${{ securityGroup }} | ${securityGroup} | ${'selected security group payload'}
- ${SET_INSTANCE_TYPE} | ${'selectedInstanceType'} | ${{ instanceType }} | ${instanceType} | ${'selected instance type payload'}
- ${SET_NODE_COUNT} | ${'nodeCount'} | ${{ nodeCount }} | ${nodeCount} | ${'node count payload'}
- ${SET_GITLAB_MANAGED_CLUSTER} | ${'gitlabManagedCluster'} | ${{ gitlabManagedCluster }} | ${gitlabManagedCluster} | ${'gitlab managed cluster'}
- `(`$mutation sets $mutatedProperty to $expectedValueDescription`, (data) => {
- const { mutation, mutatedProperty, payload, expectedValue } = data;
-
- mutations[mutation](state, payload);
- expect(state[mutatedProperty]).toBe(expectedValue);
- });
-
- describe(`mutation ${REQUEST_CREATE_ROLE}`, () => {
- beforeEach(() => {
- mutations[REQUEST_CREATE_ROLE](state);
- });
-
- it('sets isCreatingRole to true', () => {
- expect(state.isCreatingRole).toBe(true);
- });
-
- it('sets createRoleError to null', () => {
- expect(state.createRoleError).toBe(null);
- });
-
- it('sets hasCredentials to false', () => {
- expect(state.hasCredentials).toBe(false);
- });
- });
-
- describe(`mutation ${CREATE_ROLE_SUCCESS}`, () => {
- beforeEach(() => {
- mutations[CREATE_ROLE_SUCCESS](state);
- });
-
- it('sets isCreatingRole to false', () => {
- expect(state.isCreatingRole).toBe(false);
- });
-
- it('sets createRoleError to null', () => {
- expect(state.createRoleError).toBe(null);
- });
-
- it('sets hasCredentials to false', () => {
- expect(state.hasCredentials).toBe(true);
- });
- });
-
- describe(`mutation ${CREATE_ROLE_ERROR}`, () => {
- const error = new Error();
-
- beforeEach(() => {
- mutations[CREATE_ROLE_ERROR](state, { error });
- });
-
- it('sets isCreatingRole to false', () => {
- expect(state.isCreatingRole).toBe(false);
- });
-
- it('sets createRoleError to the error object', () => {
- expect(state.createRoleError).toBe(error);
- });
-
- it('sets hasCredentials to false', () => {
- expect(state.hasCredentials).toBe(false);
- });
- });
-
- describe(`mutation ${REQUEST_CREATE_CLUSTER}`, () => {
- beforeEach(() => {
- mutations[REQUEST_CREATE_CLUSTER](state);
- });
-
- it('sets isCreatingCluster to true', () => {
- expect(state.isCreatingCluster).toBe(true);
- });
-
- it('sets createClusterError to null', () => {
- expect(state.createClusterError).toBe(null);
- });
- });
-
- describe(`mutation ${CREATE_CLUSTER_ERROR}`, () => {
- const error = new Error();
-
- beforeEach(() => {
- mutations[CREATE_CLUSTER_ERROR](state, { error });
- });
-
- it('sets isCreatingRole to false', () => {
- expect(state.isCreatingCluster).toBe(false);
- });
-
- it('sets createRoleError to the error object', () => {
- expect(state.createClusterError).toBe(error);
- });
- });
-});