2021-09-30 23:02:18 +05:30
|
|
|
import '~/commons';
|
2022-07-16 23:28:13 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import { GlEmptyState } from '@gitlab/ui';
|
|
|
|
import { stubExperiments } from 'helpers/experimentation_helper';
|
2021-02-22 17:27:13 +05:30
|
|
|
import EmptyState from '~/pipelines/components/pipelines_list/empty_state.vue';
|
2022-07-16 23:28:13 +05:30
|
|
|
import GitlabExperiment from '~/experimentation/components/gitlab_experiment.vue';
|
2022-06-21 17:19:12 +05:30
|
|
|
import PipelinesCiTemplates from '~/pipelines/components/pipelines_list/empty_state/pipelines_ci_templates.vue';
|
2022-07-16 23:28:13 +05:30
|
|
|
import IosTemplates from '~/pipelines/components/pipelines_list/empty_state/ios_templates.vue';
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
describe('Pipelines Empty State', () => {
|
2021-02-22 17:27:13 +05:30
|
|
|
let wrapper;
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
const findIllustration = () => wrapper.find('img');
|
|
|
|
const findButton = () => wrapper.find('a');
|
2021-09-30 23:02:18 +05:30
|
|
|
const pipelinesCiTemplates = () => wrapper.findComponent(PipelinesCiTemplates);
|
2022-07-16 23:28:13 +05:30
|
|
|
const iosTemplates = () => wrapper.findComponent(IosTemplates);
|
2021-04-17 20:07:23 +05:30
|
|
|
|
|
|
|
const createWrapper = (props = {}) => {
|
2022-07-16 23:28:13 +05:30
|
|
|
wrapper = shallowMount(EmptyState, {
|
2021-09-30 23:02:18 +05:30
|
|
|
provide: {
|
|
|
|
pipelineEditorPath: '',
|
|
|
|
suggestedCiTemplates: [],
|
2022-07-16 23:28:13 +05:30
|
|
|
anyRunnersAvailable: true,
|
|
|
|
ciRunnerSettingsPath: '',
|
2021-09-30 23:02:18 +05:30
|
|
|
},
|
2021-02-22 17:27:13 +05:30
|
|
|
propsData: {
|
2021-04-17 20:07:23 +05:30
|
|
|
emptyStateSvgPath: 'foo.svg',
|
2021-02-22 17:27:13 +05:30
|
|
|
canSetCi: true,
|
2021-04-17 20:07:23 +05:30
|
|
|
...props,
|
2021-02-22 17:27:13 +05:30
|
|
|
},
|
2022-07-16 23:28:13 +05:30
|
|
|
stubs: {
|
|
|
|
GlEmptyState,
|
|
|
|
GitlabExperiment,
|
|
|
|
},
|
2021-02-22 17:27:13 +05:30
|
|
|
});
|
|
|
|
};
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
|
|
|
});
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
describe('when user can configure CI', () => {
|
2022-07-16 23:28:13 +05:30
|
|
|
describe('when the ios_specific_templates experiment is active', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
stubExperiments({ ios_specific_templates: 'candidate' });
|
|
|
|
createWrapper();
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
it('should render the iOS templates', () => {
|
|
|
|
expect(iosTemplates().exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not render the CI/CD templates', () => {
|
|
|
|
expect(pipelinesCiTemplates().exists()).toBe(false);
|
|
|
|
});
|
2018-03-27 19:54:05 +05:30
|
|
|
});
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
describe('when the ios_specific_templates experiment is inactive', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
stubExperiments({ ios_specific_templates: 'control' });
|
|
|
|
createWrapper();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render the CI/CD templates', () => {
|
|
|
|
expect(pipelinesCiTemplates().exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not render the iOS templates', () => {
|
|
|
|
expect(iosTemplates().exists()).toBe(false);
|
|
|
|
});
|
2021-04-17 20:07:23 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when user cannot configure CI', () => {
|
|
|
|
beforeEach(() => {
|
2022-07-16 23:28:13 +05:30
|
|
|
createWrapper({ canSetCi: false });
|
2021-04-17 20:07:23 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should render empty state SVG', () => {
|
|
|
|
expect(findIllustration().attributes('src')).toBe('foo.svg');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render empty state header', () => {
|
|
|
|
expect(wrapper.text()).toBe('This project is not currently set up to run pipelines.');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not render a link', () => {
|
|
|
|
expect(findButton().exists()).toBe(false);
|
2021-02-22 17:27:13 +05:30
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|