diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/frontend/pipelines/pipeline_url_spec.js | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) | |
download | gitlab-ce-a09983ae35713f5a2bbb100981116d31ce99826e.tar.gz |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/frontend/pipelines/pipeline_url_spec.js')
-rw-r--r-- | spec/frontend/pipelines/pipeline_url_spec.js | 116 |
1 files changed, 74 insertions, 42 deletions
diff --git a/spec/frontend/pipelines/pipeline_url_spec.js b/spec/frontend/pipelines/pipeline_url_spec.js index 70b94f2c8e1..0bcc3f96f7c 100644 --- a/spec/frontend/pipelines/pipeline_url_spec.js +++ b/spec/frontend/pipelines/pipeline_url_spec.js @@ -1,108 +1,140 @@ import $ from 'jquery'; import { trimText } from 'helpers/text_helper'; import { shallowMount } from '@vue/test-utils'; -import PipelineUrlComponent from '~/pipelines/components/pipeline_url.vue'; +import PipelineUrlComponent from '~/pipelines/components/pipelines_list/pipeline_url.vue'; $.fn.popover = () => {}; describe('Pipeline Url Component', () => { let wrapper; + const findPipelineUrlLink = () => wrapper.find('[data-testid="pipeline-url-link"]'); + const findScheduledTag = () => wrapper.find('[data-testid="pipeline-url-scheduled"]'); + const findLatestTag = () => wrapper.find('[data-testid="pipeline-url-latest"]'); + const findYamlTag = () => wrapper.find('[data-testid="pipeline-url-yaml"]'); + const findFailureTag = () => wrapper.find('[data-testid="pipeline-url-failure"]'); + const findAutoDevopsTag = () => wrapper.find('[data-testid="pipeline-url-autodevops"]'); + const findStuckTag = () => wrapper.find('[data-testid="pipeline-url-stuck"]'); + const findDetachedTag = () => wrapper.find('[data-testid="pipeline-url-detached"]'); + + const defaultProps = { + pipeline: { + id: 1, + path: 'foo', + flags: {}, + }, + autoDevopsHelpPath: 'foo', + pipelineScheduleUrl: 'foo', + }; + const createComponent = props => { wrapper = shallowMount(PipelineUrlComponent, { - propsData: props, + propsData: { ...defaultProps, ...props }, }); }; afterEach(() => { wrapper.destroy(); + wrapper = null; }); it('should render a table cell', () => { + createComponent(); + + expect(wrapper.attributes('class')).toContain('table-section'); + }); + + it('should render a link the provided path and id', () => { + createComponent(); + + expect(findPipelineUrlLink().attributes('href')).toBe('foo'); + + expect(findPipelineUrlLink().text()).toBe('#1'); + }); + + it('should render the stuck tag when flag is provided', () => { createComponent({ pipeline: { - id: 1, - path: 'foo', - flags: {}, + flags: { + stuck: true, + }, }, - autoDevopsHelpPath: 'foo', }); - expect(wrapper.attributes('class')).toContain('table-section'); + expect(findStuckTag().text()).toContain('stuck'); }); - it('should render a link the provided path and id', () => { + it('should render latest tag when flag is provided', () => { createComponent({ pipeline: { - id: 1, - path: 'foo', - flags: {}, + flags: { + latest: true, + }, }, - autoDevopsHelpPath: 'foo', }); - expect(wrapper.find('.js-pipeline-url-link').attributes('href')).toBe('foo'); - - expect(wrapper.find('.js-pipeline-url-link span').text()).toBe('#1'); + expect(findLatestTag().text()).toContain('latest'); }); - it('should render latest, yaml invalid, merge request, and stuck flags when provided', () => { + it('should render a yaml badge when it is invalid', () => { createComponent({ pipeline: { - id: 1, - path: 'foo', flags: { - latest: true, yaml_errors: true, - stuck: true, - merge_request_pipeline: true, - detached_merge_request_pipeline: true, }, }, - autoDevopsHelpPath: 'foo', }); - expect(wrapper.find('.js-pipeline-url-latest').text()).toContain('latest'); - - expect(wrapper.find('.js-pipeline-url-yaml').text()).toContain('yaml invalid'); + expect(findYamlTag().text()).toContain('yaml invalid'); + }); - expect(wrapper.find('.js-pipeline-url-stuck').text()).toContain('stuck'); + it('should render an autodevops badge when flag is provided', () => { + createComponent({ + pipeline: { + flags: { + auto_devops: true, + }, + }, + }); - expect(wrapper.find('.js-pipeline-url-detached').text()).toContain('detached'); + expect(trimText(findAutoDevopsTag().text())).toBe('Auto DevOps'); }); - it('should render a badge for autodevops', () => { + it('should render a detached badge when flag is provided', () => { createComponent({ pipeline: { - id: 1, - path: 'foo', flags: { - latest: true, - yaml_errors: true, - stuck: true, - auto_devops: true, + detached_merge_request_pipeline: true, }, }, - autoDevopsHelpPath: 'foo', }); - expect(trimText(wrapper.find('.js-pipeline-url-autodevops').text())).toEqual('Auto DevOps'); + expect(findDetachedTag().text()).toContain('detached'); }); it('should render error badge when pipeline has a failure reason set', () => { createComponent({ pipeline: { - id: 1, - path: 'foo', flags: { failure_reason: true, }, failure_reason: 'some reason', }, - autoDevopsHelpPath: 'foo', }); - expect(wrapper.find('.js-pipeline-url-failure').text()).toContain('error'); - expect(wrapper.find('.js-pipeline-url-failure').attributes('title')).toContain('some reason'); + expect(findFailureTag().text()).toContain('error'); + expect(findFailureTag().attributes('title')).toContain('some reason'); + }); + + it('should render scheduled badge when pipeline was triggered by a schedule', () => { + createComponent({ + pipeline: { + flags: {}, + source: 'schedule', + }, + }); + + expect(findScheduledTag().exists()).toBe(true); + expect(findScheduledTag().text()).toContain('Scheduled'); }); }); |