Commit 00d053e8 authored by Scott Hampton's avatar Scott Hampton

Merge branch '301010-refactor-empty-state-pipelines' into 'master'

Use GitLab UI empty state in pipelines list

See merge request gitlab-org/gitlab!56499
parents c152931c b91cd321
<script> <script>
import { GlButton } from '@gitlab/ui'; import { GlEmptyState } from '@gitlab/ui';
import { helpPagePath } from '~/helpers/help_page_helper'; import { helpPagePath } from '~/helpers/help_page_helper';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
export default { export default {
i18n: { i18n: {
infoMessage: s__(`Pipelines|GitLab CI/CD can automatically build, title: s__('Pipelines|Build with confidence'),
description: s__(`Pipelines|GitLab CI/CD can automatically build,
test, and deploy your code. Let GitLab take care of time test, and deploy your code. Let GitLab take care of time
consuming tasks, so you can spend more time creating.`), consuming tasks, so you can spend more time creating.`),
buttonMessage: s__('Pipelines|Get started with CI/CD'), btnText: s__('Pipelines|Get started with CI/CD'),
noCiDescription: s__('Pipelines|This project is not currently set up to run pipelines.'),
}, },
name: 'PipelinesEmptyState', name: 'PipelinesEmptyState',
components: { components: {
GlButton, GlEmptyState,
}, },
props: { props: {
emptyStateSvgPath: { emptyStateSvgPath: {
...@@ -32,37 +34,20 @@ export default { ...@@ -32,37 +34,20 @@ export default {
}; };
</script> </script>
<template> <template>
<div class="row empty-state js-empty-state"> <div>
<div class="col-12"> <gl-empty-state
<div class="svg-content svg-250"><img :src="emptyStateSvgPath" /></div> v-if="canSetCi"
</div> :title="$options.i18n.title"
:svg-path="emptyStateSvgPath"
<div class="col-12"> :description="$options.i18n.description"
<div class="text-content"> :primary-button-text="$options.i18n.btnText"
<template v-if="canSetCi"> :primary-button-link="ciHelpPagePath"
<h4 data-testid="header-text" class="gl-text-center"> />
{{ s__('Pipelines|Build with confidence') }} <gl-empty-state
</h4> v-else
<p data-testid="info-text"> title=""
{{ $options.i18n.infoMessage }} :svg-path="emptyStateSvgPath"
</p> :description="$options.i18n.noCiDescription"
/>
<div class="gl-text-center">
<gl-button
:href="ciHelpPagePath"
variant="info"
category="primary"
data-testid="get-started-pipelines"
>
{{ $options.i18n.buttonMessage }}
</gl-button>
</div>
</template>
<p v-else class="gl-text-center">
{{ s__('Pipelines|This project is not currently set up to run pipelines.') }}
</p>
</div>
</div>
</div> </div>
</template> </template>
...@@ -271,7 +271,6 @@ describe('Pipelines table in Commits and Merge requests', () => { ...@@ -271,7 +271,6 @@ describe('Pipelines table in Commits and Merge requests', () => {
setImmediate(() => { setImmediate(() => {
expect(vm.$el.querySelector('.js-pipelines-error-state')).toBeDefined(); expect(vm.$el.querySelector('.js-pipelines-error-state')).toBeDefined();
expect(vm.$el.querySelector('.realtime-loading')).toBe(null); expect(vm.$el.querySelector('.realtime-loading')).toBe(null);
expect(vm.$el.querySelector('.js-empty-state')).toBe(null);
expect(vm.$el.querySelector('.ci-table')).toBe(null); expect(vm.$el.querySelector('.ci-table')).toBe(null);
done(); done();
}); });
......
import { shallowMount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import EmptyState from '~/pipelines/components/pipelines_list/empty_state.vue'; import EmptyState from '~/pipelines/components/pipelines_list/empty_state.vue';
describe('Pipelines Empty State', () => { describe('Pipelines Empty State', () => {
let wrapper; let wrapper;
const findGetStartedButton = () => wrapper.find('[data-testid="get-started-pipelines"]'); const findIllustration = () => wrapper.find('img');
const findInfoText = () => wrapper.find('[data-testid="info-text"]').text(); const findButton = () => wrapper.find('a');
const createWrapper = () => {
wrapper = shallowMount(EmptyState, { const createWrapper = (props = {}) => {
wrapper = mount(EmptyState, {
propsData: { propsData: {
emptyStateSvgPath: 'foo', emptyStateSvgPath: 'foo.svg',
canSetCi: true, canSetCi: true,
...props,
}, },
}); });
}; };
describe('renders', () => { describe('when user can configure CI', () => {
beforeEach(() => { beforeEach(() => {
createWrapper(); createWrapper({}, mount);
}); });
afterEach(() => { afterEach(() => {
...@@ -26,26 +28,49 @@ describe('Pipelines Empty State', () => { ...@@ -26,26 +28,49 @@ describe('Pipelines Empty State', () => {
}); });
it('should render empty state SVG', () => { it('should render empty state SVG', () => {
expect(wrapper.find('img').attributes('src')).toBe('foo'); expect(findIllustration().attributes('src')).toBe('foo.svg');
}); });
it('should render empty state header', () => { it('should render empty state header', () => {
expect(wrapper.find('[data-testid="header-text"]').text()).toBe('Build with confidence'); expect(wrapper.text()).toContain('Build with confidence');
});
it('should render a link with provided help path', () => {
expect(findGetStartedButton().attributes('href')).toBe('/help/ci/quick_start/index.md');
}); });
it('should render empty state information', () => { it('should render empty state information', () => {
expect(findInfoText()).toContain( expect(wrapper.text()).toContain(
'GitLab CI/CD can automatically build, test, and deploy your code. Let GitLab take care of time', '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', 'consuming tasks, so you can spend more time creating',
); );
}); });
it('should render button with help path', () => {
expect(findButton().attributes('href')).toBe('/help/ci/quick_start/index.md');
});
it('should render button text', () => { it('should render button text', () => {
expect(findGetStartedButton().text()).toBe('Get started with CI/CD'); 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);
}); });
}); });
}); });
...@@ -539,12 +539,11 @@ describe('Pipelines', () => { ...@@ -539,12 +539,11 @@ describe('Pipelines', () => {
}); });
it('renders empty state', () => { it('renders empty state', () => {
expect(findEmptyState().find('[data-testid="header-text"]').text()).toBe( expect(findEmptyState().text()).toContain('Build with confidence');
'Build with confidence', expect(findEmptyState().text()).toContain(
);
expect(findEmptyState().find('[data-testid="info-text"]').text()).toContain(
'GitLab CI/CD can automatically build, test, and deploy your code.', 'GitLab CI/CD can automatically build, test, and deploy your code.',
); );
expect(findEmptyState().find(GlButton).text()).toBe('Get started with CI/CD'); expect(findEmptyState().find(GlButton).text()).toBe('Get started with CI/CD');
expect(findEmptyState().find(GlButton).attributes('href')).toBe( expect(findEmptyState().find(GlButton).attributes('href')).toBe(
'/help/ci/quick_start/index.md', '/help/ci/quick_start/index.md',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment