2020-06-23 00:09:42 +05:30
|
|
|
import { GlSprintf } from '@gitlab/ui';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2020-06-23 00:09:42 +05:30
|
|
|
import ApplicationRow from '~/clusters/components/application_row.vue';
|
2019-07-31 22:56:46 +05:30
|
|
|
import UninstallApplicationConfirmationModal from '~/clusters/components/uninstall_application_confirmation_modal.vue';
|
2020-06-23 00:09:42 +05:30
|
|
|
import UpdateApplicationConfirmationModal from '~/clusters/components/update_application_confirmation_modal.vue';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { APPLICATION_STATUS, ELASTIC_STACK } from '~/clusters/constants';
|
|
|
|
import eventHub from '~/clusters/event_hub';
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
import { DEFAULT_APPLICATION_STATE } from '../services/mock_data';
|
|
|
|
|
|
|
|
describe('Application Row', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
let wrapper;
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
afterEach(() => {
|
2020-06-23 00:09:42 +05:30
|
|
|
wrapper.destroy();
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
const mountComponent = (data) => {
|
2020-06-23 00:09:42 +05:30
|
|
|
wrapper = shallowMount(ApplicationRow, {
|
|
|
|
stubs: { GlSprintf },
|
|
|
|
propsData: {
|
|
|
|
...DEFAULT_APPLICATION_STATE,
|
|
|
|
...data,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe('Title', () => {
|
|
|
|
it('shows title', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({ titleLink: null });
|
|
|
|
|
|
|
|
const title = wrapper.find('.js-cluster-application-title');
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(title.element).toBeInstanceOf(HTMLSpanElement);
|
|
|
|
expect(title.text()).toEqual(DEFAULT_APPLICATION_STATE.title);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('shows title link', () => {
|
|
|
|
expect(DEFAULT_APPLICATION_STATE.titleLink).toBeDefined();
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent();
|
|
|
|
const title = wrapper.find('.js-cluster-application-title');
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(title.element).toBeInstanceOf(HTMLAnchorElement);
|
|
|
|
expect(title.text()).toEqual(DEFAULT_APPLICATION_STATE.title);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Install button', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
const button = () => wrapper.find('.js-cluster-application-install-button');
|
|
|
|
const checkButtonState = (label, loading, disabled) => {
|
2020-11-24 15:15:51 +05:30
|
|
|
expect(button().text()).toEqual(label);
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(button().props('loading')).toEqual(loading);
|
|
|
|
expect(button().props('disabled')).toEqual(disabled);
|
|
|
|
};
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it('has indeterminate state on page load', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({ status: null });
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
expect(button().text()).toBe('');
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
it('has install button', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent();
|
2019-03-02 22:35:43 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(button().exists()).toBe(true);
|
2019-03-02 22:35:43 +05:30
|
|
|
});
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
it('has disabled "Install" when APPLICATION_STATUS.NOT_INSTALLABLE', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({ status: APPLICATION_STATUS.NOT_INSTALLABLE });
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
checkButtonState('Install', false, true);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
it('has enabled "Install" when APPLICATION_STATUS.INSTALLABLE', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({ status: APPLICATION_STATUS.INSTALLABLE });
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
checkButtonState('Install', false, false);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
it('has loading "Installing" when APPLICATION_STATUS.INSTALLING', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({ status: APPLICATION_STATUS.INSTALLING });
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
checkButtonState('Installing', true, true);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it('has disabled "Install" when APPLICATION_STATUS.UNINSTALLED', () => {
|
|
|
|
mountComponent({ status: APPLICATION_STATUS.UNINSTALLED });
|
|
|
|
|
|
|
|
checkButtonState('Install', false, true);
|
|
|
|
});
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
it('has disabled "Externally installed" when APPLICATION_STATUS.EXTERNALLY_INSTALLED', () => {
|
|
|
|
mountComponent({ status: APPLICATION_STATUS.EXTERNALLY_INSTALLED });
|
|
|
|
|
|
|
|
checkButtonState('Externally installed', false, true);
|
|
|
|
});
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
it('has disabled "Installed" when application is installed and not uninstallable', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({
|
2018-11-18 11:00:15 +05:30
|
|
|
status: APPLICATION_STATUS.INSTALLED,
|
2019-07-31 22:56:46 +05:30
|
|
|
installed: true,
|
|
|
|
uninstallable: false,
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
checkButtonState('Installed', false, true);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
it('hides when application is installed and uninstallable', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({
|
2019-07-31 22:56:46 +05:30
|
|
|
status: APPLICATION_STATUS.INSTALLED,
|
|
|
|
installed: true,
|
|
|
|
uninstallable: true,
|
2018-12-13 13:39:08 +05:30
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(button().exists()).toBe(false);
|
2018-12-13 13:39:08 +05:30
|
|
|
});
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
it('has enabled "Install" when install fails', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({
|
2019-07-31 22:56:46 +05:30
|
|
|
status: APPLICATION_STATUS.INSTALLABLE,
|
|
|
|
installFailed: true,
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
checkButtonState('Install', false, false);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it('has disabled "Install" when installation disabled', () => {
|
|
|
|
mountComponent({
|
|
|
|
status: APPLICATION_STATUS.INSTALLABLE,
|
|
|
|
installable: false,
|
|
|
|
});
|
|
|
|
|
|
|
|
checkButtonState('Install', false, true);
|
|
|
|
});
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it('has enabled "Install" when REQUEST_FAILURE (so you can try installing again)', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({ status: APPLICATION_STATUS.INSTALLABLE });
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
checkButtonState('Install', false, false);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('clicking install button emits event', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
const spy = jest.spyOn(eventHub, '$emit');
|
|
|
|
mountComponent({ status: APPLICATION_STATUS.INSTALLABLE });
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
button().vm.$emit('click');
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(spy).toHaveBeenCalledWith('installApplication', {
|
2018-11-08 19:23:39 +05:30
|
|
|
id: DEFAULT_APPLICATION_STATE.id,
|
|
|
|
params: {},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('clicking install button when installApplicationRequestParams are provided emits event', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
const spy = jest.spyOn(eventHub, '$emit');
|
|
|
|
mountComponent({
|
2018-11-18 11:00:15 +05:30
|
|
|
status: APPLICATION_STATUS.INSTALLABLE,
|
2018-11-08 19:23:39 +05:30
|
|
|
installApplicationRequestParams: { hostname: 'jupyter' },
|
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
button().vm.$emit('click');
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(spy).toHaveBeenCalledWith('installApplication', {
|
2018-11-08 19:23:39 +05:30
|
|
|
id: DEFAULT_APPLICATION_STATE.id,
|
|
|
|
params: { hostname: 'jupyter' },
|
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('clicking disabled install button emits nothing', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
const spy = jest.spyOn(eventHub, '$emit');
|
|
|
|
mountComponent({ status: APPLICATION_STATUS.INSTALLING });
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(button().props('disabled')).toEqual(true);
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
button().vm.$emit('click');
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(spy).not.toHaveBeenCalled();
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
describe('Uninstall button', () => {
|
|
|
|
it('displays button when app is installed and uninstallable', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({
|
2019-07-31 22:56:46 +05:30
|
|
|
installed: true,
|
|
|
|
uninstallable: true,
|
|
|
|
status: APPLICATION_STATUS.NOT_INSTALLABLE,
|
|
|
|
});
|
2020-06-23 00:09:42 +05:30
|
|
|
const uninstallButton = wrapper.find('.js-cluster-application-uninstall-button');
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(uninstallButton.exists()).toBe(true);
|
2019-07-31 22:56:46 +05:30
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it('displays a success toast message if application uninstall was successful', async () => {
|
|
|
|
mountComponent({
|
2019-07-31 22:56:46 +05:30
|
|
|
title: 'GitLab Runner',
|
|
|
|
uninstallSuccessful: false,
|
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
wrapper.vm.$toast = { show: jest.fn() };
|
|
|
|
wrapper.setProps({ uninstallSuccessful: true });
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
await wrapper.vm.$nextTick();
|
|
|
|
expect(wrapper.vm.$toast.show).toHaveBeenCalledWith(
|
|
|
|
'GitLab Runner uninstalled successfully.',
|
|
|
|
);
|
2019-07-31 22:56:46 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when confirmation modal triggers confirm event', () => {
|
|
|
|
it('triggers uninstallApplication event', () => {
|
|
|
|
jest.spyOn(eventHub, '$emit');
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent();
|
2019-07-31 22:56:46 +05:30
|
|
|
wrapper.find(UninstallApplicationConfirmationModal).vm.$emit('confirm');
|
|
|
|
|
|
|
|
expect(eventHub.$emit).toHaveBeenCalledWith('uninstallApplication', {
|
|
|
|
id: DEFAULT_APPLICATION_STATE.id,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
describe('Update button', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
const button = () => wrapper.find('.js-cluster-application-update-button');
|
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
it('has indeterminate state on page load', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent();
|
2019-03-02 22:35:43 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(button().exists()).toBe(false);
|
2019-03-02 22:35:43 +05:30
|
|
|
});
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
it('has enabled "Update" when "updateAvailable" is true', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({ updateAvailable: true });
|
2019-03-02 22:35:43 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(button().exists()).toBe(true);
|
2020-11-24 15:15:51 +05:30
|
|
|
expect(button().text()).toContain('Update');
|
2019-03-02 22:35:43 +05:30
|
|
|
});
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
it('has enabled "Retry update" when update process fails', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({
|
2019-07-31 22:56:46 +05:30
|
|
|
status: APPLICATION_STATUS.INSTALLED,
|
|
|
|
updateFailed: true,
|
2019-03-02 22:35:43 +05:30
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(button().exists()).toBe(true);
|
2020-11-24 15:15:51 +05:30
|
|
|
expect(button().text()).toContain('Retry update');
|
2019-03-02 22:35:43 +05:30
|
|
|
});
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
it('has disabled "Updating" when APPLICATION_STATUS.UPDATING', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({ status: APPLICATION_STATUS.UPDATING });
|
2019-03-02 22:35:43 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(button().exists()).toBe(true);
|
2020-11-24 15:15:51 +05:30
|
|
|
expect(button().text()).toContain('Updating');
|
2019-03-02 22:35:43 +05:30
|
|
|
});
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
it('clicking update button emits event', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
const spy = jest.spyOn(eventHub, '$emit');
|
|
|
|
mountComponent({
|
2019-07-31 22:56:46 +05:30
|
|
|
status: APPLICATION_STATUS.INSTALLED,
|
2019-09-04 21:01:54 +05:30
|
|
|
updateAvailable: true,
|
2019-03-02 22:35:43 +05:30
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
button().vm.$emit('click');
|
2019-03-02 22:35:43 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(spy).toHaveBeenCalledWith('updateApplication', {
|
2019-03-02 22:35:43 +05:30
|
|
|
id: DEFAULT_APPLICATION_STATE.id,
|
|
|
|
params: {},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
it('clicking disabled update button emits nothing', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
const spy = jest.spyOn(eventHub, '$emit');
|
|
|
|
mountComponent({ status: APPLICATION_STATUS.UPDATING });
|
2019-03-02 22:35:43 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
button().vm.$emit('click');
|
2019-03-02 22:35:43 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(spy).not.toHaveBeenCalled();
|
2019-03-02 22:35:43 +05:30
|
|
|
});
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
it('displays an error message if application update failed', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({
|
2019-03-02 22:35:43 +05:30
|
|
|
title: 'GitLab Runner',
|
2019-07-31 22:56:46 +05:30
|
|
|
status: APPLICATION_STATUS.INSTALLED,
|
|
|
|
updateFailed: true,
|
2019-03-02 22:35:43 +05:30
|
|
|
});
|
2020-06-23 00:09:42 +05:30
|
|
|
const failureMessage = wrapper.find('.js-cluster-application-update-details');
|
2019-03-02 22:35:43 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(failureMessage.exists()).toBe(true);
|
|
|
|
expect(failureMessage.text()).toContain(
|
2019-07-07 11:18:12 +05:30
|
|
|
'Update failed. Please check the logs and try again.',
|
2019-03-02 22:35:43 +05:30
|
|
|
);
|
|
|
|
});
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it('displays a success toast message if application update was successful', async () => {
|
|
|
|
mountComponent({
|
2019-07-31 22:56:46 +05:30
|
|
|
title: 'GitLab Runner',
|
|
|
|
updateSuccessful: false,
|
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
wrapper.vm.$toast = { show: jest.fn() };
|
|
|
|
wrapper.setProps({ updateSuccessful: true });
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
await wrapper.vm.$nextTick();
|
|
|
|
expect(wrapper.vm.$toast.show).toHaveBeenCalledWith('GitLab Runner updated successfully.');
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when updating does not require confirmation', () => {
|
|
|
|
beforeEach(() => mountComponent({ updateAvailable: true }));
|
|
|
|
|
|
|
|
it('the modal is not rendered', () => {
|
2020-11-24 15:15:51 +05:30
|
|
|
expect(wrapper.find(UpdateApplicationConfirmationModal).exists()).toBe(false);
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('the correct button is rendered', () => {
|
2020-11-24 15:15:51 +05:30
|
|
|
expect(wrapper.find("[data-qa-selector='update_button']").exists()).toBe(true);
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when updating requires confirmation', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
mountComponent({
|
|
|
|
updateAvailable: true,
|
|
|
|
id: ELASTIC_STACK,
|
|
|
|
version: '1.1.2',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('displays a modal', () => {
|
2020-11-24 15:15:51 +05:30
|
|
|
expect(wrapper.find(UpdateApplicationConfirmationModal).exists()).toBe(true);
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('the correct button is rendered', () => {
|
2020-11-24 15:15:51 +05:30
|
|
|
expect(wrapper.find("[data-qa-selector='update_button_with_confirmation']").exists()).toBe(
|
|
|
|
true,
|
|
|
|
);
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('triggers updateApplication event', () => {
|
|
|
|
jest.spyOn(eventHub, '$emit');
|
|
|
|
wrapper.find(UpdateApplicationConfirmationModal).vm.$emit('confirm');
|
|
|
|
|
|
|
|
expect(eventHub.$emit).toHaveBeenCalledWith('updateApplication', {
|
|
|
|
id: ELASTIC_STACK,
|
|
|
|
params: {},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('updating Elastic Stack special case', () => {
|
|
|
|
it('needs confirmation if version is lower than 3.0.0', () => {
|
|
|
|
mountComponent({
|
|
|
|
updateAvailable: true,
|
|
|
|
id: ELASTIC_STACK,
|
|
|
|
version: '1.1.2',
|
|
|
|
});
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
expect(wrapper.find("[data-qa-selector='update_button_with_confirmation']").exists()).toBe(
|
|
|
|
true,
|
|
|
|
);
|
|
|
|
expect(wrapper.find(UpdateApplicationConfirmationModal).exists()).toBe(true);
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('does not need confirmation is version is 3.0.0', () => {
|
|
|
|
mountComponent({
|
|
|
|
updateAvailable: true,
|
|
|
|
id: ELASTIC_STACK,
|
|
|
|
version: '3.0.0',
|
|
|
|
});
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
expect(wrapper.find("[data-qa-selector='update_button']").exists()).toBe(true);
|
|
|
|
expect(wrapper.find(UpdateApplicationConfirmationModal).exists()).toBe(false);
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('does not need confirmation if version is higher than 3.0.0', () => {
|
|
|
|
mountComponent({
|
|
|
|
updateAvailable: true,
|
|
|
|
id: ELASTIC_STACK,
|
|
|
|
version: '5.2.1',
|
|
|
|
});
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
expect(wrapper.find("[data-qa-selector='update_button']").exists()).toBe(true);
|
|
|
|
expect(wrapper.find(UpdateApplicationConfirmationModal).exists()).toBe(false);
|
2019-07-31 22:56:46 +05:30
|
|
|
});
|
|
|
|
});
|
2019-03-02 22:35:43 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
describe('Version', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
const updateDetails = () => wrapper.find('.js-cluster-application-update-details');
|
|
|
|
const versionEl = () => wrapper.find('.js-cluster-application-update-version');
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
it('displays a version number if application has been updated', () => {
|
2019-03-02 22:35:43 +05:30
|
|
|
const version = '0.1.45';
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({
|
2019-07-31 22:56:46 +05:30
|
|
|
status: APPLICATION_STATUS.INSTALLED,
|
|
|
|
updateSuccessful: true,
|
2019-03-02 22:35:43 +05:30
|
|
|
version,
|
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(updateDetails().text()).toBe(`Updated to chart v${version}`);
|
2019-03-02 22:35:43 +05:30
|
|
|
});
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
it('contains a link to the chart repo if application has been updated', () => {
|
2019-03-02 22:35:43 +05:30
|
|
|
const version = '0.1.45';
|
2019-12-04 20:38:33 +05:30
|
|
|
const chartRepo = 'https://gitlab.com/gitlab-org/charts/gitlab-runner';
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({
|
2019-07-31 22:56:46 +05:30
|
|
|
status: APPLICATION_STATUS.INSTALLED,
|
|
|
|
updateSuccessful: true,
|
2019-03-02 22:35:43 +05:30
|
|
|
chartRepo,
|
|
|
|
version,
|
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(versionEl().attributes('href')).toEqual(chartRepo);
|
|
|
|
expect(versionEl().props('target')).toEqual('_blank');
|
2019-03-02 22:35:43 +05:30
|
|
|
});
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
it('does not display a version number if application update failed', () => {
|
2019-03-02 22:35:43 +05:30
|
|
|
const version = '0.1.45';
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({
|
2019-07-31 22:56:46 +05:30
|
|
|
status: APPLICATION_STATUS.INSTALLED,
|
|
|
|
updateFailed: true,
|
2019-03-02 22:35:43 +05:30
|
|
|
version,
|
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(updateDetails().text()).toBe('Update failed');
|
|
|
|
expect(versionEl().exists()).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('displays updating when the application update is currently updating', () => {
|
|
|
|
mountComponent({
|
|
|
|
status: APPLICATION_STATUS.UPDATING,
|
|
|
|
updateSuccessful: true,
|
|
|
|
version: '1.2.3',
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(updateDetails().text()).toBe('Updating');
|
|
|
|
expect(versionEl().exists()).toBe(false);
|
2019-03-02 22:35:43 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe('Error block', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
const generalErrorMessage = () => wrapper.find('.js-cluster-application-general-error-message');
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
describe('when nothing fails', () => {
|
|
|
|
it('does not show error block', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent();
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(generalErrorMessage().exists()).toBe(false);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
describe('when install or uninstall fails', () => {
|
2018-03-17 18:26:18 +05:30
|
|
|
const statusReason = 'We broke it 0.0';
|
2019-07-31 22:56:46 +05:30
|
|
|
const requestReason = 'We broke the request 0.0';
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({
|
2019-07-31 22:56:46 +05:30
|
|
|
status: APPLICATION_STATUS.ERROR,
|
|
|
|
statusReason,
|
|
|
|
requestReason,
|
|
|
|
installFailed: true,
|
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
it('shows status reason if it is available', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
const statusErrorMessage = wrapper.find('.js-cluster-application-status-error-message');
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(statusErrorMessage.text()).toEqual(statusReason);
|
2019-07-31 22:56:46 +05:30
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
it('shows request reason if it is available', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
const requestErrorMessage = wrapper.find('.js-cluster-application-request-error-message');
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(requestErrorMessage.text()).toEqual(requestReason);
|
2019-07-31 22:56:46 +05:30
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
describe('when install fails', () => {
|
|
|
|
beforeEach(() => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({
|
2019-07-31 22:56:46 +05:30
|
|
|
status: APPLICATION_STATUS.ERROR,
|
|
|
|
installFailed: true,
|
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
it('shows a general message indicating the installation failed', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(generalErrorMessage().text()).toEqual(
|
2019-07-31 22:56:46 +05:30
|
|
|
`Something went wrong while installing ${DEFAULT_APPLICATION_STATE.title}`,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when uninstall fails', () => {
|
|
|
|
beforeEach(() => {
|
2020-06-23 00:09:42 +05:30
|
|
|
mountComponent({
|
2019-07-31 22:56:46 +05:30
|
|
|
status: APPLICATION_STATUS.ERROR,
|
|
|
|
uninstallFailed: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows a general message indicating the uninstalling failed', () => {
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(generalErrorMessage().text()).toEqual(
|
2019-07-31 22:56:46 +05:30
|
|
|
`Something went wrong while uninstalling ${DEFAULT_APPLICATION_STATE.title}`,
|
|
|
|
);
|
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|