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
|
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import PipelinesManualActions from '~/pipelines/components/pipelines_list/pipelines_manual_actions.vue';
import PipelineMultiActions from '~/pipelines/components/pipelines_list/pipeline_multi_actions.vue';
import PipelineOperations from '~/pipelines/components/pipelines_list/pipeline_operations.vue';
import eventHub from '~/pipelines/event_hub';
describe('Pipeline operations', () => {
let wrapper;
const defaultProps = {
pipeline: {
id: 329,
iid: 234,
details: {
has_manual_actions: true,
has_scheduled_actions: false,
},
flags: {
retryable: true,
cancelable: true,
},
cancel_path: '/root/ci-project/-/pipelines/329/cancel',
retry_path: '/root/ci-project/-/pipelines/329/retry',
},
};
const createComponent = (props = defaultProps) => {
wrapper = shallowMountExtended(PipelineOperations, {
propsData: {
...props,
},
});
};
const findManualActions = () => wrapper.findComponent(PipelinesManualActions);
const findMultiActions = () => wrapper.findComponent(PipelineMultiActions);
const findRetryBtn = () => wrapper.findByTestId('pipelines-retry-button');
const findCancelBtn = () => wrapper.findByTestId('pipelines-cancel-button');
it('should display pipeline manual actions', () => {
createComponent();
expect(findManualActions().exists()).toBe(true);
});
it('should display pipeline multi actions', () => {
createComponent();
expect(findMultiActions().exists()).toBe(true);
});
describe('events', () => {
beforeEach(() => {
createComponent();
jest.spyOn(eventHub, '$emit').mockImplementation(() => {});
});
it('should emit retryPipeline event', () => {
findRetryBtn().vm.$emit('click');
expect(eventHub.$emit).toHaveBeenCalledWith(
'retryPipeline',
defaultProps.pipeline.retry_path,
);
});
it('should emit openConfirmationModal event', () => {
findCancelBtn().vm.$emit('click');
expect(eventHub.$emit).toHaveBeenCalledWith('openConfirmationModal', {
pipeline: defaultProps.pipeline,
endpoint: defaultProps.pipeline.cancel_path,
});
});
});
});
|