debian-mirror-gitlab/spec/frontend/pipelines/nav_controls_spec.js

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

81 lines
2.3 KiB
JavaScript
Raw Normal View History

2023-05-27 22:25:52 +05:30
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
2021-04-29 21:17:54 +05:30
import NavControls from '~/pipelines/components/pipelines_list/nav_controls.vue';
2017-08-17 22:00:37 +05:30
describe('Pipelines Nav Controls', () => {
2021-04-29 21:17:54 +05:30
let wrapper;
2017-08-17 22:00:37 +05:30
2021-04-29 21:17:54 +05:30
const createComponent = (props) => {
2023-05-27 22:25:52 +05:30
wrapper = shallowMountExtended(NavControls, {
2021-04-29 21:17:54 +05:30
propsData: {
...props,
},
});
};
2023-05-27 22:25:52 +05:30
const findRunPipelineButton = () => wrapper.findByTestId('run-pipeline-button');
const findCiLintButton = () => wrapper.findByTestId('ci-lint-button');
const findClearCacheButton = () => wrapper.findByTestId('clear-cache-button');
2018-03-27 19:54:05 +05:30
2017-08-17 22:00:37 +05:30
it('should render link to create a new pipeline', () => {
const mockData = {
newPipelinePath: 'foo',
ciLintPath: 'foo',
2018-03-17 18:26:18 +05:30
resetCachePath: 'foo',
2017-08-17 22:00:37 +05:30
};
2021-04-29 21:17:54 +05:30
createComponent(mockData);
2017-08-17 22:00:37 +05:30
2023-05-27 22:25:52 +05:30
const runPipelineButton = findRunPipelineButton();
expect(runPipelineButton.text()).toContain('Run pipeline');
expect(runPipelineButton.attributes('href')).toBe(mockData.newPipelinePath);
2017-08-17 22:00:37 +05:30
});
2018-03-27 19:54:05 +05:30
it('should not render link to create pipeline if no path is provided', () => {
2017-08-17 22:00:37 +05:30
const mockData = {
helpPagePath: 'foo',
ciLintPath: 'foo',
2018-03-17 18:26:18 +05:30
resetCachePath: 'foo',
2017-08-17 22:00:37 +05:30
};
2021-04-29 21:17:54 +05:30
createComponent(mockData);
2017-08-17 22:00:37 +05:30
2023-05-27 22:25:52 +05:30
expect(findRunPipelineButton().exists()).toBe(false);
2017-08-17 22:00:37 +05:30
});
it('should render link for CI lint', () => {
const mockData = {
newPipelinePath: 'foo',
helpPagePath: 'foo',
ciLintPath: 'foo',
2018-03-17 18:26:18 +05:30
resetCachePath: 'foo',
2017-08-17 22:00:37 +05:30
};
2021-04-29 21:17:54 +05:30
createComponent(mockData);
2023-05-27 22:25:52 +05:30
const ciLintButton = findCiLintButton();
2017-08-17 22:00:37 +05:30
2023-05-27 22:25:52 +05:30
expect(ciLintButton.text()).toContain('CI lint');
expect(ciLintButton.attributes('href')).toBe(mockData.ciLintPath);
2017-08-17 22:00:37 +05:30
});
2018-05-09 12:01:36 +05:30
describe('Reset Runners Cache', () => {
beforeEach(() => {
const mockData = {
newPipelinePath: 'foo',
ciLintPath: 'foo',
resetCachePath: 'foo',
};
2021-04-29 21:17:54 +05:30
createComponent(mockData);
2018-05-09 12:01:36 +05:30
});
it('should render button for resetting runner caches', () => {
2023-05-27 22:25:52 +05:30
expect(findClearCacheButton().text()).toContain('Clear runner caches');
2018-05-09 12:01:36 +05:30
});
2023-05-27 22:25:52 +05:30
it('should emit postAction event when reset runner cache button is clicked', () => {
findClearCacheButton().vm.$emit('click');
2018-05-09 12:01:36 +05:30
2023-05-27 22:25:52 +05:30
expect(wrapper.emitted('resetRunnersCache')).toEqual([['foo']]);
2018-05-09 12:01:36 +05:30
});
});
2017-08-17 22:00:37 +05:30
});