diff options
author | Nathan Friend <nathan@gitlab.com> | 2019-09-10 21:18:39 +0300 |
---|---|---|
committer | Nathan Friend <nathan@gitlab.com> | 2019-09-11 13:27:58 +0300 |
commit | 11f1305ec7b71721a24352ab2346d3ed865883c4 (patch) | |
tree | e714bad8becb45bc2249179c0d48a52027ef2ce4 /spec/javascripts/vue_mr_widget | |
parent | 1ba9f029e89e99a245a201c21a98f4f79dc7b302 (diff) |
Make MR pipeline widget text more descriptive (CE)
This change updates the text of the pipeline widget that appears on the
merge request page. The text has been made more consistent between
different types of pipelines; this makes the front-end implementation
simpler and more maintainable. In addition, the type of pipeline is
(i.e. regular pipeline, merge request pipeline, detached pipeline)
included in the text, making this type more obvious to the end user.
Some information has been removed from the widget as part of this
change; however, any information that was removed already appears
elsewhere on the merge request page.
Diffstat (limited to 'spec/javascripts/vue_mr_widget')
-rw-r--r-- | spec/javascripts/vue_mr_widget/components/mr_widget_pipeline_spec.js | 86 | ||||
-rw-r--r-- | spec/javascripts/vue_mr_widget/mock_data.js | 4 |
2 files changed, 44 insertions, 46 deletions
diff --git a/spec/javascripts/vue_mr_widget/components/mr_widget_pipeline_spec.js b/spec/javascripts/vue_mr_widget/components/mr_widget_pipeline_spec.js index fe831094ecf..67e85763fae 100644 --- a/spec/javascripts/vue_mr_widget/components/mr_widget_pipeline_spec.js +++ b/spec/javascripts/vue_mr_widget/components/mr_widget_pipeline_spec.js @@ -69,7 +69,6 @@ describe('MRWidgetPipeline', () => { vm = mountComponent(Component, { pipeline: mockData.pipeline, hasCi: true, - ciStatus: null, troubleshootingDocsPath: 'help', }); @@ -208,71 +207,66 @@ describe('MRWidgetPipeline', () => { }); }); - describe('without pipeline.merge_request', () => { - it('should render info that includes the commit and branch details', () => { - const mockCopy = JSON.parse(JSON.stringify(mockData)); - delete mockCopy.pipeline.merge_request; - const { pipeline } = mockCopy; - - vm = mountComponent(Component, { - pipeline, - hasCi: true, - ciStatus: 'success', - troubleshootingDocsPath: 'help', - sourceBranchLink: mockCopy.source_branch_link, - }); - - const expected = `Pipeline #${pipeline.id} ${pipeline.details.status.label} for ${pipeline.commit.short_id} on ${mockCopy.source_branch_link}`; + describe('for each type of pipeline', () => { + let pipeline; - const actual = trimText(vm.$el.querySelector('.js-pipeline-info-container').innerText); + beforeEach(() => { + ({ pipeline } = JSON.parse(JSON.stringify(mockData))); - expect(actual).toBe(expected); + pipeline.details.name = 'Pipeline'; + pipeline.merge_request_event_type = undefined; + pipeline.ref.tag = false; + pipeline.ref.branch = false; }); - }); - - describe('with pipeline.merge_request and flags.merge_request_pipeline', () => { - it('should render info that includes the commit, MR, source branch, and target branch details', () => { - const mockCopy = JSON.parse(JSON.stringify(mockData)); - const { pipeline } = mockCopy; - pipeline.flags.merge_request_pipeline = true; - pipeline.flags.detached_merge_request_pipeline = false; + const factory = () => { vm = mountComponent(Component, { pipeline, hasCi: true, ciStatus: 'success', troubleshootingDocsPath: 'help', - sourceBranchLink: mockCopy.source_branch_link, + sourceBranchLink: mockData.source_branch_link, }); + }; + + describe('for a branch pipeline', () => { + it('renders a pipeline widget that reads "Pipeline <ID> <status> for <SHA> on <branch>"', () => { + pipeline.ref.branch = true; - const expected = `Pipeline #${pipeline.id} ${pipeline.details.status.label} for ${pipeline.commit.short_id} on !${pipeline.merge_request.iid} with ${pipeline.merge_request.source_branch} into ${pipeline.merge_request.target_branch}`; + factory(); - const actual = trimText(vm.$el.querySelector('.js-pipeline-info-container').innerText); + const expected = `Pipeline #${pipeline.id} ${pipeline.details.status.label} for ${pipeline.commit.short_id} on ${mockData.source_branch_link}`; + const actual = trimText(vm.$el.querySelector('.js-pipeline-info-container').innerText); - expect(actual).toBe(expected); + expect(actual).toBe(expected); + }); }); - }); - describe('with pipeline.merge_request and flags.detached_merge_request_pipeline', () => { - it('should render info that includes the commit, MR, and source branch details', () => { - const mockCopy = JSON.parse(JSON.stringify(mockData)); - const { pipeline } = mockCopy; - pipeline.flags.merge_request_pipeline = false; - pipeline.flags.detached_merge_request_pipeline = true; + describe('for a tag pipeline', () => { + it('renders a pipeline widget that reads "Pipeline <ID> <status> for <SHA> on <branch>"', () => { + pipeline.ref.tag = true; - vm = mountComponent(Component, { - pipeline, - hasCi: true, - ciStatus: 'success', - troubleshootingDocsPath: 'help', - sourceBranchLink: mockCopy.source_branch_link, + factory(); + + const expected = `Pipeline #${pipeline.id} ${pipeline.details.status.label} for ${pipeline.commit.short_id}`; + const actual = trimText(vm.$el.querySelector('.js-pipeline-info-container').innerText); + + expect(actual).toBe(expected); }); + }); + + describe('for a detached merge request pipeline', () => { + it('renders a pipeline widget that reads "Detached merge request pipeline <ID> <status> for <SHA>"', () => { + pipeline.details.name = 'Detached merge request pipeline'; + pipeline.merge_request_event_type = 'detached'; - const expected = `Pipeline #${pipeline.id} ${pipeline.details.status.label} for ${pipeline.commit.short_id} on !${pipeline.merge_request.iid} with ${pipeline.merge_request.source_branch}`; + factory(); - const actual = trimText(vm.$el.querySelector('.js-pipeline-info-container').innerText); + const expected = `Detached merge request pipeline #${pipeline.id} ${pipeline.details.status.label} for ${pipeline.commit.short_id}`; + const actual = trimText(vm.$el.querySelector('.js-pipeline-info-container').innerText); - expect(actual).toBe(expected); + expect(actual).toBe(expected); + }); }); }); }); diff --git a/spec/javascripts/vue_mr_widget/mock_data.js b/spec/javascripts/vue_mr_widget/mock_data.js index a55d5537df7..2f79806652b 100644 --- a/spec/javascripts/vue_mr_widget/mock_data.js +++ b/spec/javascripts/vue_mr_widget/mock_data.js @@ -259,6 +259,8 @@ export const mockStore = { tooltip: 'passed', }, }, + flags: {}, + ref: {}, }, mergePipeline: { id: 1, @@ -276,6 +278,8 @@ export const mockStore = { tooltip: 'passed', }, }, + flags: {}, + ref: {}, }, targetBranch: 'target-branch', sourceBranch: 'source-branch', |