debian-mirror-gitlab/spec/frontend/clusters/components/remove_cluster_confirmation_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

82 lines
2.6 KiB
JavaScript
Raw Normal View History

2021-12-11 22:18:48 +05:30
import { GlModal, GlSprintf } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { mount } from '@vue/test-utils';
2022-04-04 11:22:00 +05:30
import { nextTick } from 'vue';
2021-12-11 22:18:48 +05:30
import { stubComponent } from 'helpers/stub_component';
2020-01-01 13:55:28 +05:30
import RemoveClusterConfirmation from '~/clusters/components/remove_cluster_confirmation.vue';
describe('Remove cluster confirmation modal', () => {
let wrapper;
2021-12-11 22:18:48 +05:30
const createComponent = ({ props = {}, stubs = {} } = {}) => {
2020-01-01 13:55:28 +05:30
wrapper = mount(RemoveClusterConfirmation, {
propsData: {
clusterPath: 'clusterPath',
clusterName: 'clusterName',
...props,
},
2021-12-11 22:18:48 +05:30
stubs,
2020-01-01 13:55:28 +05:30
});
};
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
2022-07-23 23:45:48 +05:30
it('renders buttons with modal included', () => {
2020-01-01 13:55:28 +05:30
createComponent();
expect(wrapper.element).toMatchSnapshot();
});
2022-07-23 23:45:48 +05:30
describe('two buttons', () => {
2021-12-11 22:18:48 +05:30
const findModal = () => wrapper.findComponent(GlModal);
2022-07-23 23:45:48 +05:30
const findRemoveIntegrationButton = () =>
wrapper.find('[data-testid="remove-integration-button"]');
const findRemoveIntegrationAndResourcesButton = () =>
wrapper.find('[data-testid="remove-integration-and-resources-button"]');
2020-01-01 13:55:28 +05:30
beforeEach(() => {
2021-12-11 22:18:48 +05:30
createComponent({
props: { clusterName: 'my-test-cluster' },
stubs: { GlSprintf, GlModal: stubComponent(GlModal) },
});
jest.spyOn(findModal().vm, 'show').mockReturnValue();
2020-01-01 13:55:28 +05:30
});
2022-07-23 23:45:48 +05:30
it('open modal with "cleanup" option', async () => {
findRemoveIntegrationAndResourcesButton().trigger('click');
2020-01-01 13:55:28 +05:30
2022-04-04 11:22:00 +05:30
await nextTick();
2021-12-11 22:18:48 +05:30
expect(findModal().vm.show).toHaveBeenCalled();
expect(wrapper.vm.confirmCleanup).toEqual(true);
expect(findModal().html()).toContain(
'<strong>To remove your integration and resources, type <code>my-test-cluster</code> to confirm:</strong>',
);
2020-01-01 13:55:28 +05:30
});
2022-07-23 23:45:48 +05:30
it('open modal without "cleanup" option', async () => {
findRemoveIntegrationButton().trigger('click');
2020-01-01 13:55:28 +05:30
2022-04-04 11:22:00 +05:30
await nextTick();
2021-12-11 22:18:48 +05:30
expect(findModal().vm.show).toHaveBeenCalled();
expect(wrapper.vm.confirmCleanup).toEqual(false);
expect(findModal().html()).toContain(
'<strong>To remove your integration, type <code>my-test-cluster</code> to confirm:</strong>',
);
2020-01-01 13:55:28 +05:30
});
2020-07-28 23:09:34 +05:30
describe('with cluster management project', () => {
beforeEach(() => {
2021-12-11 22:18:48 +05:30
createComponent({ props: { hasManagementProject: true } });
2020-07-28 23:09:34 +05:30
});
it('renders regular button instead', () => {
2022-07-23 23:45:48 +05:30
expect(findRemoveIntegrationAndResourcesButton().exists()).toBe(false);
expect(findRemoveIntegrationButton().exists()).toBe(true);
2020-07-28 23:09:34 +05:30
});
});
2020-01-01 13:55:28 +05:30
});
});