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

77 lines
2 KiB
JavaScript
Raw Normal View History

2021-04-17 20:07:23 +05:30
import { mount } from '@vue/test-utils';
2021-02-22 17:27:13 +05:30
import EmptyState from '~/pipelines/components/pipelines_list/empty_state.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');
const createWrapper = (props = {}) => {
wrapper = mount(EmptyState, {
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
},
});
};
2017-08-17 22:00:37 +05:30
2021-04-17 20:07:23 +05:30
describe('when user can configure CI', () => {
2021-02-22 17:27:13 +05:30
beforeEach(() => {
2021-04-17 20:07:23 +05:30
createWrapper({}, mount);
2021-02-22 17:27:13 +05:30
});
2017-08-17 22:00:37 +05:30
2021-02-22 17:27:13 +05:30
afterEach(() => {
wrapper.destroy();
wrapper = null;
2018-03-27 19:54:05 +05:30
});
2021-02-22 17:27:13 +05:30
it('should render empty state SVG', () => {
2021-04-17 20:07:23 +05:30
expect(findIllustration().attributes('src')).toBe('foo.svg');
2021-02-22 17:27:13 +05:30
});
2017-08-17 22:00:37 +05:30
2021-02-22 17:27:13 +05:30
it('should render empty state header', () => {
2021-04-17 20:07:23 +05:30
expect(wrapper.text()).toContain('Build with confidence');
2021-02-22 17:27:13 +05:30
});
2017-08-17 22:00:37 +05:30
2021-03-11 19:13:27 +05:30
it('should render empty state information', () => {
2021-04-17 20:07:23 +05:30
expect(wrapper.text()).toContain(
2021-03-11 19:13:27 +05:30
'GitLab CI/CD can automatically build, test, and deploy your code. Let GitLab take care of time',
'consuming tasks, so you can spend more time creating',
);
2021-02-22 17:27:13 +05:30
});
2018-12-13 13:39:08 +05:30
2021-04-17 20:07:23 +05:30
it('should render button with help path', () => {
expect(findButton().attributes('href')).toBe('/help/ci/quick_start/index.md');
});
2021-03-11 19:13:27 +05:30
it('should render button text', () => {
2021-04-17 20:07:23 +05:30
expect(findButton().text()).toBe('Get started with CI/CD');
});
});
describe('when user cannot configure CI', () => {
beforeEach(() => {
createWrapper({ canSetCi: false }, mount);
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
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
});
});