diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-15 21:09:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-15 21:09:05 +0300 |
commit | a0213db466c75403a5a79f95af8a0a5cff13014c (patch) | |
tree | 6118144407f99f1121c34e934cf0d96c991d578e /spec/frontend/pipelines/empty_state_spec.js | |
parent | f5c3f32975addd56fe8659f1c346d0e56f0b23d9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/pipelines/empty_state_spec.js')
-rw-r--r-- | spec/frontend/pipelines/empty_state_spec.js | 57 |
1 files changed, 41 insertions, 16 deletions
diff --git a/spec/frontend/pipelines/empty_state_spec.js b/spec/frontend/pipelines/empty_state_spec.js index fdbb98dfd55..912bc7a104a 100644 --- a/spec/frontend/pipelines/empty_state_spec.js +++ b/spec/frontend/pipelines/empty_state_spec.js @@ -1,23 +1,25 @@ -import { shallowMount } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; import EmptyState from '~/pipelines/components/pipelines_list/empty_state.vue'; describe('Pipelines Empty State', () => { let wrapper; - const findGetStartedButton = () => wrapper.find('[data-testid="get-started-pipelines"]'); - const findInfoText = () => wrapper.find('[data-testid="info-text"]').text(); - const createWrapper = () => { - wrapper = shallowMount(EmptyState, { + const findIllustration = () => wrapper.find('img'); + const findButton = () => wrapper.find('a'); + + const createWrapper = (props = {}) => { + wrapper = mount(EmptyState, { propsData: { - emptyStateSvgPath: 'foo', + emptyStateSvgPath: 'foo.svg', canSetCi: true, + ...props, }, }); }; - describe('renders', () => { + describe('when user can configure CI', () => { beforeEach(() => { - createWrapper(); + createWrapper({}, mount); }); afterEach(() => { @@ -26,26 +28,49 @@ describe('Pipelines Empty State', () => { }); 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', () => { - expect(wrapper.find('[data-testid="header-text"]').text()).toBe('Build with confidence'); - }); - - it('should render a link with provided help path', () => { - expect(findGetStartedButton().attributes('href')).toBe('/help/ci/quick_start/index.md'); + expect(wrapper.text()).toContain('Build with confidence'); }); 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', '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', () => { - 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); }); }); }); |