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

create_eks_cluster_spec.js « components « eks_cluster « create_cluster « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 95810e882a1157ee929b8cab0025e024175816b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import { shallowMount, createLocalVue } from '@vue/test-utils';
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';

const localVue = createLocalVue();
localVue.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,
      },
      localVue,
      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,
        );
      });
    });
  });
});