summaryrefslogtreecommitdiff
path: root/spec/frontend/clusters/services
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/clusters/services')
-rw-r--r--spec/frontend/clusters/services/application_state_machine_spec.js206
-rw-r--r--spec/frontend/clusters/services/crossplane_provider_stack_spec.js85
-rw-r--r--spec/frontend/clusters/services/mock_data.js155
3 files changed, 2 insertions, 444 deletions
diff --git a/spec/frontend/clusters/services/application_state_machine_spec.js b/spec/frontend/clusters/services/application_state_machine_spec.js
deleted file mode 100644
index 4e731e331c2..00000000000
--- a/spec/frontend/clusters/services/application_state_machine_spec.js
+++ /dev/null
@@ -1,206 +0,0 @@
-import {
- APPLICATION_STATUS,
- UNINSTALL_EVENT,
- UPDATE_EVENT,
- INSTALL_EVENT,
-} from '~/clusters/constants';
-import transitionApplicationState from '~/clusters/services/application_state_machine';
-
-const {
- NO_STATUS,
- SCHEDULED,
- NOT_INSTALLABLE,
- INSTALLABLE,
- INSTALLING,
- INSTALLED,
- ERROR,
- UPDATING,
- UPDATED,
- UPDATE_ERRORED,
- UNINSTALLING,
- UNINSTALL_ERRORED,
- UNINSTALLED,
- PRE_INSTALLED,
- EXTERNALLY_INSTALLED,
-} = APPLICATION_STATUS;
-
-const NO_EFFECTS = 'no effects';
-
-describe('applicationStateMachine', () => {
- const noEffectsToEmptyObject = (effects) => (typeof effects === 'string' ? {} : effects);
-
- describe(`current state is ${NO_STATUS}`, () => {
- it.each`
- expectedState | event | effects
- ${INSTALLING} | ${SCHEDULED} | ${NO_EFFECTS}
- ${NOT_INSTALLABLE} | ${NOT_INSTALLABLE} | ${NO_EFFECTS}
- ${INSTALLABLE} | ${INSTALLABLE} | ${NO_EFFECTS}
- ${INSTALLING} | ${INSTALLING} | ${NO_EFFECTS}
- ${INSTALLED} | ${INSTALLED} | ${NO_EFFECTS}
- ${INSTALLABLE} | ${ERROR} | ${{ installFailed: true }}
- ${UPDATING} | ${UPDATING} | ${NO_EFFECTS}
- ${INSTALLED} | ${UPDATED} | ${NO_EFFECTS}
- ${INSTALLED} | ${UPDATE_ERRORED} | ${{ updateFailed: true }}
- ${UNINSTALLING} | ${UNINSTALLING} | ${NO_EFFECTS}
- ${INSTALLED} | ${UNINSTALL_ERRORED} | ${{ uninstallFailed: true }}
- ${UNINSTALLED} | ${UNINSTALLED} | ${NO_EFFECTS}
- ${PRE_INSTALLED} | ${PRE_INSTALLED} | ${NO_EFFECTS}
- ${EXTERNALLY_INSTALLED} | ${EXTERNALLY_INSTALLED} | ${NO_EFFECTS}
- `(`transitions to $expectedState on $event event and applies $effects`, (data) => {
- const { expectedState, event, effects } = data;
- const currentAppState = {
- status: NO_STATUS,
- };
-
- expect(transitionApplicationState(currentAppState, event)).toEqual({
- status: expectedState,
- ...noEffectsToEmptyObject(effects),
- });
- });
- });
-
- describe(`current state is ${NOT_INSTALLABLE}`, () => {
- it.each`
- expectedState | event | effects
- ${INSTALLABLE} | ${INSTALLABLE} | ${NO_EFFECTS}
- `(`transitions to $expectedState on $event event and applies $effects`, (data) => {
- const { expectedState, event, effects } = data;
- const currentAppState = {
- status: NOT_INSTALLABLE,
- };
-
- expect(transitionApplicationState(currentAppState, event)).toEqual({
- status: expectedState,
- ...noEffectsToEmptyObject(effects),
- });
- });
- });
-
- describe(`current state is ${INSTALLABLE}`, () => {
- it.each`
- expectedState | event | effects
- ${INSTALLING} | ${INSTALL_EVENT} | ${{ installFailed: false }}
- ${INSTALLED} | ${INSTALLED} | ${{ installFailed: false }}
- ${NOT_INSTALLABLE} | ${NOT_INSTALLABLE} | ${NO_EFFECTS}
- ${UNINSTALLED} | ${UNINSTALLED} | ${{ installFailed: false }}
- `(`transitions to $expectedState on $event event and applies $effects`, (data) => {
- const { expectedState, event, effects } = data;
- const currentAppState = {
- status: INSTALLABLE,
- };
-
- expect(transitionApplicationState(currentAppState, event)).toEqual({
- status: expectedState,
- ...noEffectsToEmptyObject(effects),
- });
- });
- });
-
- describe(`current state is ${INSTALLING}`, () => {
- it.each`
- expectedState | event | effects
- ${INSTALLED} | ${INSTALLED} | ${NO_EFFECTS}
- ${INSTALLABLE} | ${ERROR} | ${{ installFailed: true }}
- `(`transitions to $expectedState on $event event and applies $effects`, (data) => {
- const { expectedState, event, effects } = data;
- const currentAppState = {
- status: INSTALLING,
- };
-
- expect(transitionApplicationState(currentAppState, event)).toEqual({
- status: expectedState,
- ...noEffectsToEmptyObject(effects),
- });
- });
- });
-
- describe(`current state is ${INSTALLED}`, () => {
- it.each`
- expectedState | event | effects
- ${UPDATING} | ${UPDATE_EVENT} | ${{ updateFailed: false, updateSuccessful: false }}
- ${UNINSTALLING} | ${UNINSTALL_EVENT} | ${{ uninstallFailed: false, uninstallSuccessful: false }}
- ${NOT_INSTALLABLE} | ${NOT_INSTALLABLE} | ${NO_EFFECTS}
- ${UNINSTALLED} | ${UNINSTALLED} | ${NO_EFFECTS}
- ${INSTALLABLE} | ${ERROR} | ${{ installFailed: true }}
- `(`transitions to $expectedState on $event event and applies $effects`, (data) => {
- const { expectedState, event, effects } = data;
- const currentAppState = {
- status: INSTALLED,
- };
-
- expect(transitionApplicationState(currentAppState, event)).toEqual({
- status: expectedState,
- ...noEffectsToEmptyObject(effects),
- });
- });
- });
-
- describe(`current state is ${UPDATING}`, () => {
- it.each`
- expectedState | event | effects
- ${INSTALLED} | ${UPDATED} | ${{ updateSuccessful: true }}
- ${INSTALLED} | ${UPDATE_ERRORED} | ${{ updateFailed: true }}
- `(`transitions to $expectedState on $event event and applies $effects`, (data) => {
- const { expectedState, event, effects } = data;
- const currentAppState = {
- status: UPDATING,
- };
-
- expect(transitionApplicationState(currentAppState, event)).toEqual({
- status: expectedState,
- ...effects,
- });
- });
- });
-
- describe(`current state is ${UNINSTALLING}`, () => {
- it.each`
- expectedState | event | effects
- ${INSTALLABLE} | ${INSTALLABLE} | ${{ uninstallSuccessful: true }}
- ${INSTALLED} | ${UNINSTALL_ERRORED} | ${{ uninstallFailed: true }}
- `(`transitions to $expectedState on $event event and applies $effects`, (data) => {
- const { expectedState, event, effects } = data;
- const currentAppState = {
- status: UNINSTALLING,
- };
-
- expect(transitionApplicationState(currentAppState, event)).toEqual({
- status: expectedState,
- ...effects,
- });
- });
- });
-
- describe(`current state is ${UNINSTALLED}`, () => {
- it.each`
- expectedState | event | effects
- ${INSTALLED} | ${INSTALLED} | ${NO_EFFECTS}
- ${INSTALLABLE} | ${ERROR} | ${{ installFailed: true }}
- `(`transitions to $expectedState on $event event and applies $effects`, (data) => {
- const { expectedState, event, effects } = data;
- const currentAppState = {
- status: UNINSTALLED,
- };
-
- expect(transitionApplicationState(currentAppState, event)).toEqual({
- status: expectedState,
- ...noEffectsToEmptyObject(effects),
- });
- });
- });
- describe('current state is undefined', () => {
- it('returns the current state without having any effects', () => {
- const currentAppState = {};
- expect(transitionApplicationState(currentAppState, INSTALLABLE)).toEqual(currentAppState);
- });
- });
-
- describe('with event is undefined', () => {
- it('returns the current state without having any effects', () => {
- const currentAppState = {
- status: NO_STATUS,
- };
- expect(transitionApplicationState(currentAppState, undefined)).toEqual(currentAppState);
- });
- });
-});
diff --git a/spec/frontend/clusters/services/crossplane_provider_stack_spec.js b/spec/frontend/clusters/services/crossplane_provider_stack_spec.js
deleted file mode 100644
index f95b175ca64..00000000000
--- a/spec/frontend/clusters/services/crossplane_provider_stack_spec.js
+++ /dev/null
@@ -1,85 +0,0 @@
-import { GlDropdownItem, GlIcon } from '@gitlab/ui';
-import { shallowMount } from '@vue/test-utils';
-import CrossplaneProviderStack from '~/clusters/components/crossplane_provider_stack.vue';
-
-describe('CrossplaneProviderStack component', () => {
- let wrapper;
-
- const defaultProps = {
- stacks: [
- {
- name: 'Google Cloud Platform',
- code: 'gcp',
- },
- {
- name: 'Amazon Web Services',
- code: 'aws',
- },
- ],
- };
-
- function createComponent(props = {}) {
- const propsData = {
- ...defaultProps,
- ...props,
- };
-
- wrapper = shallowMount(CrossplaneProviderStack, {
- propsData,
- });
- }
-
- beforeEach(() => {
- const crossplane = {
- title: 'crossplane',
- stack: '',
- };
- createComponent({ crossplane });
- });
-
- const findDropdownElements = () => wrapper.findAll(GlDropdownItem);
- const findFirstDropdownElement = () => findDropdownElements().at(0);
-
- afterEach(() => {
- wrapper.destroy();
- });
-
- it('renders all of the available stacks in the dropdown', () => {
- const dropdownElements = findDropdownElements();
-
- expect(dropdownElements.length).toBe(defaultProps.stacks.length);
-
- defaultProps.stacks.forEach((stack, index) =>
- expect(dropdownElements.at(index).text()).toEqual(stack.name),
- );
- });
-
- it('displays the correct label for the first dropdown item if a stack is selected', () => {
- const crossplane = {
- title: 'crossplane',
- stack: 'gcp',
- };
- createComponent({ crossplane });
- expect(wrapper.vm.dropdownText).toBe('Google Cloud Platform');
- });
-
- it('emits the "set" event with the selected stack value', () => {
- const crossplane = {
- title: 'crossplane',
- stack: 'gcp',
- };
- createComponent({ crossplane });
- findFirstDropdownElement().vm.$emit('click');
- return wrapper.vm.$nextTick().then(() => {
- expect(wrapper.emitted().set[0][0].code).toEqual('gcp');
- });
- });
-
- it('renders the correct dropdown text when no stack is selected', () => {
- expect(wrapper.vm.dropdownText).toBe('Select Stack');
- });
-
- it('renders an external link', () => {
- expect(wrapper.find(GlIcon).props('name')).toBe('external-link');
- });
-});
diff --git a/spec/frontend/clusters/services/mock_data.js b/spec/frontend/clusters/services/mock_data.js
index a75fcb0cb06..cf63d5452ac 100644
--- a/spec/frontend/clusters/services/mock_data.js
+++ b/spec/frontend/clusters/services/mock_data.js
@@ -1,170 +1,19 @@
-import { APPLICATION_STATUS } from '~/clusters/constants';
-
const CLUSTERS_MOCK_DATA = {
GET: {
'/gitlab-org/gitlab-shell/clusters/1/status.json': {
data: {
status: 'errored',
status_reason: 'Failed to request to CloudPlatform.',
- applications: [
- {
- name: 'helm',
- status: APPLICATION_STATUS.INSTALLABLE,
- status_reason: null,
- can_uninstall: false,
- },
- {
- name: 'ingress',
- status: APPLICATION_STATUS.ERROR,
- status_reason: 'Cannot connect',
- external_ip: null,
- external_hostname: null,
- can_uninstall: false,
- },
- {
- name: 'runner',
- status: APPLICATION_STATUS.INSTALLING,
- status_reason: null,
- can_uninstall: false,
- },
- {
- name: 'prometheus',
- status: APPLICATION_STATUS.ERROR,
- status_reason: 'Cannot connect',
- can_uninstall: false,
- },
- {
- name: 'jupyter',
- status: APPLICATION_STATUS.INSTALLING,
- status_reason: 'Cannot connect',
- can_uninstall: false,
- },
- {
- name: 'knative',
- status: APPLICATION_STATUS.INSTALLING,
- status_reason: 'Cannot connect',
- can_uninstall: false,
- },
- {
- name: 'cert_manager',
- status: APPLICATION_STATUS.ERROR,
- status_reason: 'Cannot connect',
- email: 'test@example.com',
- can_uninstall: false,
- },
- {
- name: 'crossplane',
- status: APPLICATION_STATUS.ERROR,
- status_reason: 'Cannot connect',
- can_uninstall: false,
- },
- {
- name: 'elastic_stack',
- status: APPLICATION_STATUS.ERROR,
- status_reason: 'Cannot connect',
- can_uninstall: false,
- },
- ],
},
},
'/gitlab-org/gitlab-shell/clusters/2/status.json': {
data: {
status: 'errored',
status_reason: 'Failed to request to CloudPlatform.',
- applications: [
- {
- name: 'helm',
- status: APPLICATION_STATUS.INSTALLED,
- status_reason: null,
- },
- {
- name: 'ingress',
- status: APPLICATION_STATUS.INSTALLED,
- status_reason: 'Cannot connect',
- external_ip: '1.1.1.1',
- external_hostname: null,
- },
- {
- name: 'runner',
- status: APPLICATION_STATUS.INSTALLING,
- status_reason: null,
- },
- {
- name: 'prometheus',
- status: APPLICATION_STATUS.ERROR,
- status_reason: 'Cannot connect',
- },
- {
- name: 'jupyter',
- status: APPLICATION_STATUS.INSTALLABLE,
- status_reason: 'Cannot connect',
- },
- {
- name: 'knative',
- status: APPLICATION_STATUS.INSTALLABLE,
- status_reason: 'Cannot connect',
- },
- {
- name: 'cert_manager',
- status: APPLICATION_STATUS.ERROR,
- status_reason: 'Cannot connect',
- email: 'test@example.com',
- },
- {
- name: 'crossplane',
- status: APPLICATION_STATUS.ERROR,
- status_reason: 'Cannot connect',
- stack: 'gcp',
- },
- {
- name: 'elastic_stack',
- status: APPLICATION_STATUS.ERROR,
- status_reason: 'Cannot connect',
- },
- ],
},
},
},
- POST: {
- '/gitlab-org/gitlab-shell/clusters/1/applications/helm': {},
- '/gitlab-org/gitlab-shell/clusters/1/applications/ingress': {},
- '/gitlab-org/gitlab-shell/clusters/1/applications/crossplane': {},
- '/gitlab-org/gitlab-shell/clusters/1/applications/cert_manager': {},
- '/gitlab-org/gitlab-shell/clusters/1/applications/runner': {},
- '/gitlab-org/gitlab-shell/clusters/1/applications/prometheus': {},
- '/gitlab-org/gitlab-shell/clusters/1/applications/jupyter': {},
- '/gitlab-org/gitlab-shell/clusters/1/applications/knative': {},
- '/gitlab-org/gitlab-shell/clusters/1/applications/elastic_stack': {},
- },
-};
-
-const DEFAULT_APPLICATION_STATE = {
- id: 'some-app',
- title: 'My App',
- titleLink: 'https://about.gitlab.com/',
- description: 'Some description about this interesting application!',
- status: null,
- statusReason: null,
- requestReason: null,
-};
-
-const APPLICATIONS_MOCK_STATE = {
- helm: { title: 'Helm Tiller', status: 'installable' },
- ingress: {
- title: 'Ingress',
- status: 'installable',
- },
- crossplane: { title: 'Crossplane', status: 'installable', stack: '' },
- cert_manager: { title: 'Cert-Manager', status: 'installable' },
- runner: { title: 'GitLab Runner' },
- prometheus: { title: 'Prometheus' },
- jupyter: { title: 'JupyterHub', status: 'installable', hostname: '' },
- knative: { title: 'Knative ', status: 'installable', hostname: '' },
- elastic_stack: { title: 'Elastic Stack', status: 'installable' },
- cilium: {
- title: 'GitLab Container Network Policies',
- status: 'not_installable',
- },
+ POST: {},
};
-export { CLUSTERS_MOCK_DATA, DEFAULT_APPLICATION_STATE, APPLICATIONS_MOCK_STATE };
+export { CLUSTERS_MOCK_DATA };