Commit 3e5b2e5b authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'nfriend-update-pipeline-list-view' into 'master'

Update pipeline list view to accommodate post-merge request pipelines

See merge request gitlab-org/gitlab-ce!25690
parents d141b874 a24cb6de
...@@ -110,12 +110,12 @@ export default { ...@@ -110,12 +110,12 @@ export default {
{{ __('stuck') }} {{ __('stuck') }}
</span> </span>
<span <span
v-if="pipeline.flags.merge_request" v-if="pipeline.flags.detached_merge_request_pipeline"
v-gl-tooltip v-gl-tooltip
:title="__('This pipeline is run in a merge request context')" :title="__('This pipeline is run on the source branch')"
class="js-pipeline-url-mergerequest badge badge-info" class="js-pipeline-url-detached badge badge-info"
> >
{{ __('merge request') }} {{ __('detached') }}
</span> </span>
</div> </div>
</div> </div>
......
...@@ -272,10 +272,11 @@ export default { ...@@ -272,10 +272,11 @@ export default {
:tag="commitTag" :tag="commitTag"
:commit-ref="commitRef" :commit-ref="commitRef"
:commit-url="commitUrl" :commit-url="commitUrl"
:merge-request-ref="pipeline.merge_request"
:short-sha="commitShortSha" :short-sha="commitShortSha"
:title="commitTitle" :title="commitTitle"
:author="commitAuthor" :author="commitAuthor"
:show-branch="!isChildView" :show-ref-info="!isChildView"
/> />
</div> </div>
</div> </div>
......
<script> <script>
import { GlTooltipDirective } from '@gitlab/ui'; import _ from 'underscore';
import { GlTooltipDirective, GlLink } from '@gitlab/ui';
import UserAvatarLink from './user_avatar/user_avatar_link.vue'; import UserAvatarLink from './user_avatar/user_avatar_link.vue';
import Icon from '../../vue_shared/components/icon.vue'; import Icon from '../../vue_shared/components/icon.vue';
...@@ -10,6 +11,7 @@ export default { ...@@ -10,6 +11,7 @@ export default {
components: { components: {
UserAvatarLink, UserAvatarLink,
Icon, Icon,
GlLink,
}, },
props: { props: {
/** /**
...@@ -33,6 +35,27 @@ export default { ...@@ -33,6 +35,27 @@ export default {
required: false, required: false,
default: () => ({}), default: () => ({}),
}, },
/**
* If provided, is used the render the MR IID and link
* in place of the branch name. Must contains the
* following properties:
* - iid (number)
* - path (non-empty string)
*
* May optionally contain the following properties:
* - title (string): used in a tooltip if provided
*
* Any additional properties are ignored.
*/
mergeRequestRef: {
type: Object,
required: false,
default: undefined,
validator: ref =>
_.isUndefined(ref) || (_.isFinite(ref.iid) && _.isString(ref.path) && !_.isEmpty(ref.path)),
},
/** /**
* Used to link to the commit sha. * Used to link to the commit sha.
*/ */
...@@ -70,7 +93,11 @@ export default { ...@@ -70,7 +93,11 @@ export default {
required: false, required: false,
default: () => ({}), default: () => ({}),
}, },
showBranch: {
/**
* Indicates whether or not to show the branch/MR ref info
*/
showRefInfo: {
type: Boolean, type: Boolean,
required: false, required: false,
default: true, default: true,
...@@ -78,14 +105,12 @@ export default { ...@@ -78,14 +105,12 @@ export default {
}, },
computed: { computed: {
/** /**
* Used to verify if all the properties needed to render the commit * Determines if we shoud render the ref info section based
* ref section were provided.
*
* @returns {Boolean}
*/ */
hasCommitRef() { shouldShowRefInfo() {
return this.commitRef && this.commitRef.name && this.commitRef.ref_url; return this.showRefInfo && (this.commitRef || this.mergeRequestRef);
}, },
/** /**
* Used to verify if all the properties needed to render the commit * Used to verify if all the properties needed to render the commit
* author section were provided. * author section were provided.
...@@ -109,18 +134,35 @@ export default { ...@@ -109,18 +134,35 @@ export default {
</script> </script>
<template> <template>
<div class="branch-commit"> <div class="branch-commit">
<template v-if="hasCommitRef && showBranch"> <template v-if="shouldShowRefInfo">
<div class="icon-container"> <div class="icon-container">
<i v-if="tag" class="fa fa-tag" aria-hidden="true"> </i> <icon v-if="!tag" name="fork" /> <icon v-if="tag" name="tag" />
<icon v-else-if="mergeRequestRef" name="git-merge" />
<icon v-else name="branch" />
</div> </div>
<a v-gl-tooltip :href="commitRef.ref_url" :title="commitRef.name" class="ref-name"> <gl-link
v-if="mergeRequestRef"
v-gl-tooltip
:href="mergeRequestRef.path"
:title="mergeRequestRef.title"
class="ref-name"
>
{{ mergeRequestRef.iid }}
</gl-link>
<gl-link
v-else
v-gl-tooltip
:href="commitRef.ref_url"
:title="commitRef.name"
class="ref-name"
>
{{ commitRef.name }} {{ commitRef.name }}
</a> </gl-link>
</template> </template>
<icon name="commit" class="commit-icon js-commit-icon" /> <icon name="commit" class="commit-icon js-commit-icon" />
<a :href="commitUrl" class="commit-sha"> {{ shortSha }} </a> <gl-link :href="commitUrl" class="commit-sha"> {{ shortSha }} </gl-link>
<div class="commit-title flex-truncate-parent"> <div class="commit-title flex-truncate-parent">
<span v-if="title" class="flex-truncate-child"> <span v-if="title" class="flex-truncate-child">
...@@ -132,7 +174,7 @@ export default { ...@@ -132,7 +174,7 @@ export default {
:tooltip-text="author.username" :tooltip-text="author.username"
class="avatar-image-container" class="avatar-image-container"
/> />
<a :href="commitUrl" class="commit-row-message"> {{ title }} </a> <gl-link :href="commitUrl" class="commit-row-message"> {{ title }} </gl-link>
</span> </span>
<span v-else> Can't find HEAD commit for this branch </span> <span v-else> Can't find HEAD commit for this branch </span>
</div> </div>
......
---
title: Update pipeline list view to accommodate post-merge pipeline information
merge_request: 25690
author:
type: added
...@@ -7924,7 +7924,7 @@ msgstr "" ...@@ -7924,7 +7924,7 @@ msgstr ""
msgid "This page will be removed in a future release." msgid "This page will be removed in a future release."
msgstr "" msgstr ""
msgid "This pipeline is run in a merge request context" msgid "This pipeline is run on the source branch"
msgstr "" msgstr ""
msgid "This pipeline makes use of a predefined CI/CD configuration enabled by %{strongStart}Auto DevOps.%{strongEnd}" msgid "This pipeline makes use of a predefined CI/CD configuration enabled by %{strongStart}Auto DevOps.%{strongEnd}"
...@@ -9136,6 +9136,9 @@ msgstr "" ...@@ -9136,6 +9136,9 @@ msgstr ""
msgid "deploy token" msgid "deploy token"
msgstr "" msgstr ""
msgid "detached"
msgstr ""
msgid "disabled" msgid "disabled"
msgstr "" msgstr ""
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
describe 'Merge request > User sees merge request pipelines', :js do describe 'Merge request > User sees pipelines triggered by merge request', :js do
include ProjectForksHelper include ProjectForksHelper
include TestReportsHelper include TestReportsHelper
...@@ -47,7 +47,7 @@ describe 'Merge request > User sees merge request pipelines', :js do ...@@ -47,7 +47,7 @@ describe 'Merge request > User sees merge request pipelines', :js do
.execute(:push) .execute(:push)
end end
let!(:merge_request_pipeline) do let!(:detached_merge_request_pipeline) do
Ci::CreatePipelineService.new(project, user, ref: 'feature') Ci::CreatePipelineService.new(project, user, ref: 'feature')
.execute(:merge_request_event, merge_request: merge_request) .execute(:merge_request_event, merge_request: merge_request)
end end
...@@ -60,16 +60,16 @@ describe 'Merge request > User sees merge request pipelines', :js do ...@@ -60,16 +60,16 @@ describe 'Merge request > User sees merge request pipelines', :js do
end end
end end
it 'sees branch pipelines and merge request pipelines in correct order' do it 'sees branch pipelines and detached merge request pipelines in correct order' do
page.within('.ci-table') do page.within('.ci-table') do
expect(page).to have_selector('.ci-pending', count: 2) expect(page).to have_selector('.ci-pending', count: 2)
expect(first('.js-pipeline-url-link')).to have_content("##{merge_request_pipeline.id}") expect(first('.js-pipeline-url-link')).to have_content("##{detached_merge_request_pipeline.id}")
end end
end end
it 'sees the latest merge request pipeline as the head pipeline' do it 'sees the latest detached merge request pipeline as the head pipeline' do
page.within('.ci-widget-content') do page.within('.ci-widget-content') do
expect(page).to have_content("##{merge_request_pipeline.id}") expect(page).to have_content("##{detached_merge_request_pipeline.id}")
end end
end end
...@@ -79,7 +79,7 @@ describe 'Merge request > User sees merge request pipelines', :js do ...@@ -79,7 +79,7 @@ describe 'Merge request > User sees merge request pipelines', :js do
.execute(:push) .execute(:push)
end end
let!(:merge_request_pipeline_2) do let!(:detached_merge_request_pipeline_2) do
Ci::CreatePipelineService.new(project, user, ref: 'feature') Ci::CreatePipelineService.new(project, user, ref: 'feature')
.execute(:merge_request_event, merge_request: merge_request) .execute(:merge_request_event, merge_request: merge_request)
end end
...@@ -92,15 +92,15 @@ describe 'Merge request > User sees merge request pipelines', :js do ...@@ -92,15 +92,15 @@ describe 'Merge request > User sees merge request pipelines', :js do
end end
end end
it 'sees branch pipelines and merge request pipelines in correct order' do it 'sees branch pipelines and detached merge request pipelines in correct order' do
page.within('.ci-table') do page.within('.ci-table') do
expect(page).to have_selector('.ci-pending', count: 4) expect(page).to have_selector('.ci-pending', count: 4)
expect(all('.js-pipeline-url-link')[0]) expect(all('.js-pipeline-url-link')[0])
.to have_content("##{merge_request_pipeline_2.id}") .to have_content("##{detached_merge_request_pipeline_2.id}")
expect(all('.js-pipeline-url-link')[1]) expect(all('.js-pipeline-url-link')[1])
.to have_content("##{merge_request_pipeline.id}") .to have_content("##{detached_merge_request_pipeline.id}")
expect(all('.js-pipeline-url-link')[2]) expect(all('.js-pipeline-url-link')[2])
.to have_content("##{push_pipeline_2.id}") .to have_content("##{push_pipeline_2.id}")
...@@ -110,25 +110,25 @@ describe 'Merge request > User sees merge request pipelines', :js do ...@@ -110,25 +110,25 @@ describe 'Merge request > User sees merge request pipelines', :js do
end end
end end
it 'sees merge request tag for merge request pipelines' do it 'sees detached tag for detached merge request pipelines' do
page.within('.ci-table') do page.within('.ci-table') do
expect(all('.pipeline-tags')[0]) expect(all('.pipeline-tags')[0])
.to have_content("merge request") .to have_content("detached")
expect(all('.pipeline-tags')[1]) expect(all('.pipeline-tags')[1])
.to have_content("merge request") .to have_content("detached")
expect(all('.pipeline-tags')[2]) expect(all('.pipeline-tags')[2])
.not_to have_content("merge request") .not_to have_content("detached")
expect(all('.pipeline-tags')[3]) expect(all('.pipeline-tags')[3])
.not_to have_content("merge request") .not_to have_content("detached")
end end
end end
it 'sees the latest merge request pipeline as the head pipeline' do it 'sees the latest detached merge request pipeline as the head pipeline' do
page.within('.ci-widget-content') do page.within('.ci-widget-content') do
expect(page).to have_content("##{merge_request_pipeline_2.id}") expect(page).to have_content("##{detached_merge_request_pipeline_2.id}")
end end
end end
end end
...@@ -140,16 +140,16 @@ describe 'Merge request > User sees merge request pipelines', :js do ...@@ -140,16 +140,16 @@ describe 'Merge request > User sees merge request pipelines', :js do
wait_for_requests wait_for_requests
end end
context 'when merge request pipeline is pending' do context 'when detached merge request pipeline is pending' do
it 'waits the head pipeline' do it 'waits the head pipeline' do
expect(page).to have_content('to be merged automatically when the pipeline succeeds') expect(page).to have_content('to be merged automatically when the pipeline succeeds')
expect(page).to have_link('Cancel automatic merge') expect(page).to have_link('Cancel automatic merge')
end end
end end
context 'when merge request pipeline succeeds' do context 'when detached merge request pipeline succeeds' do
before do before do
merge_request_pipeline.succeed! detached_merge_request_pipeline.succeed!
wait_for_requests wait_for_requests
end end
...@@ -218,7 +218,7 @@ describe 'Merge request > User sees merge request pipelines', :js do ...@@ -218,7 +218,7 @@ describe 'Merge request > User sees merge request pipelines', :js do
.execute(:push) .execute(:push)
end end
let!(:merge_request_pipeline) do let!(:detached_merge_request_pipeline) do
Ci::CreatePipelineService.new(forked_project, user2, ref: 'feature') Ci::CreatePipelineService.new(forked_project, user2, ref: 'feature')
.execute(:merge_request_event, merge_request: merge_request) .execute(:merge_request_event, merge_request: merge_request)
end end
...@@ -236,16 +236,16 @@ describe 'Merge request > User sees merge request pipelines', :js do ...@@ -236,16 +236,16 @@ describe 'Merge request > User sees merge request pipelines', :js do
end end
end end
it 'sees branch pipelines and merge request pipelines in correct order' do it 'sees branch pipelines and detached merge request pipelines in correct order' do
page.within('.ci-table') do page.within('.ci-table') do
expect(page).to have_selector('.ci-pending', count: 2) expect(page).to have_selector('.ci-pending', count: 2)
expect(first('.js-pipeline-url-link')).to have_content("##{merge_request_pipeline.id}") expect(first('.js-pipeline-url-link')).to have_content("##{detached_merge_request_pipeline.id}")
end end
end end
it 'sees the latest merge request pipeline as the head pipeline' do it 'sees the latest detached merge request pipeline as the head pipeline' do
page.within('.ci-widget-content') do page.within('.ci-widget-content') do
expect(page).to have_content("##{merge_request_pipeline.id}") expect(page).to have_content("##{detached_merge_request_pipeline.id}")
end end
end end
...@@ -261,7 +261,7 @@ describe 'Merge request > User sees merge request pipelines', :js do ...@@ -261,7 +261,7 @@ describe 'Merge request > User sees merge request pipelines', :js do
.execute(:push) .execute(:push)
end end
let!(:merge_request_pipeline_2) do let!(:detached_merge_request_pipeline_2) do
Ci::CreatePipelineService.new(forked_project, user2, ref: 'feature') Ci::CreatePipelineService.new(forked_project, user2, ref: 'feature')
.execute(:merge_request_event, merge_request: merge_request) .execute(:merge_request_event, merge_request: merge_request)
end end
...@@ -274,15 +274,15 @@ describe 'Merge request > User sees merge request pipelines', :js do ...@@ -274,15 +274,15 @@ describe 'Merge request > User sees merge request pipelines', :js do
end end
end end
it 'sees branch pipelines and merge request pipelines in correct order' do it 'sees branch pipelines and detached merge request pipelines in correct order' do
page.within('.ci-table') do page.within('.ci-table') do
expect(page).to have_selector('.ci-pending', count: 4) expect(page).to have_selector('.ci-pending', count: 4)
expect(all('.js-pipeline-url-link')[0]) expect(all('.js-pipeline-url-link')[0])
.to have_content("##{merge_request_pipeline_2.id}") .to have_content("##{detached_merge_request_pipeline_2.id}")
expect(all('.js-pipeline-url-link')[1]) expect(all('.js-pipeline-url-link')[1])
.to have_content("##{merge_request_pipeline.id}") .to have_content("##{detached_merge_request_pipeline.id}")
expect(all('.js-pipeline-url-link')[2]) expect(all('.js-pipeline-url-link')[2])
.to have_content("##{push_pipeline_2.id}") .to have_content("##{push_pipeline_2.id}")
...@@ -292,25 +292,25 @@ describe 'Merge request > User sees merge request pipelines', :js do ...@@ -292,25 +292,25 @@ describe 'Merge request > User sees merge request pipelines', :js do
end end
end end
it 'sees merge request tag for merge request pipelines' do it 'sees detached tag for detached merge request pipelines' do
page.within('.ci-table') do page.within('.ci-table') do
expect(all('.pipeline-tags')[0]) expect(all('.pipeline-tags')[0])
.to have_content("merge request") .to have_content("detached")
expect(all('.pipeline-tags')[1]) expect(all('.pipeline-tags')[1])
.to have_content("merge request") .to have_content("detached")
expect(all('.pipeline-tags')[2]) expect(all('.pipeline-tags')[2])
.not_to have_content("merge request") .not_to have_content("detached")
expect(all('.pipeline-tags')[3]) expect(all('.pipeline-tags')[3])
.not_to have_content("merge request") .not_to have_content("detached")
end end
end end
it 'sees the latest merge request pipeline as the head pipeline' do it 'sees the latest detached merge request pipeline as the head pipeline' do
page.within('.ci-widget-content') do page.within('.ci-widget-content') do
expect(page).to have_content("##{merge_request_pipeline_2.id}") expect(page).to have_content("##{detached_merge_request_pipeline_2.id}")
end end
end end
...@@ -328,16 +328,16 @@ describe 'Merge request > User sees merge request pipelines', :js do ...@@ -328,16 +328,16 @@ describe 'Merge request > User sees merge request pipelines', :js do
wait_for_requests wait_for_requests
end end
context 'when merge request pipeline is pending' do context 'when detached merge request pipeline is pending' do
it 'waits the head pipeline' do it 'waits the head pipeline' do
expect(page).to have_content('to be merged automatically when the pipeline succeeds') expect(page).to have_content('to be merged automatically when the pipeline succeeds')
expect(page).to have_link('Cancel automatic merge') expect(page).to have_link('Cancel automatic merge')
end end
end end
context 'when merge request pipeline succeeds' do context 'when detached merge request pipeline succeeds' do
before do before do
merge_request_pipeline.succeed! detached_merge_request_pipeline.succeed!
wait_for_requests wait_for_requests
end end
......
require 'spec_helper' require 'spec_helper'
describe 'Pipelines', :js do describe 'Pipelines', :js do
include ProjectForksHelper
let(:project) { create(:project) } let(:project) { create(:project) }
context 'when user is logged in' do context 'when user is logged in' do
...@@ -165,6 +167,99 @@ describe 'Pipelines', :js do ...@@ -165,6 +167,99 @@ describe 'Pipelines', :js do
end end
end end
context 'when pipeline is detached merge request pipeline' do
let(:merge_request) do
create(:merge_request,
:with_detached_merge_request_pipeline,
source_project: source_project,
target_project: target_project)
end
let!(:pipeline) { merge_request.all_pipelines.first }
let(:source_project) { project }
let(:target_project) { project }
before do
visit project_pipelines_path(source_project)
end
shared_examples_for 'showing detached merge request pipeline information' do
it 'shows detached tag for the pipeline' do
within '.pipeline-tags' do
expect(page).to have_content('detached')
end
end
it 'shows the link of the merge request' do
within '.branch-commit' do
expect(page).to have_link(merge_request.iid,
href: project_merge_request_path(project, merge_request))
end
end
it 'does not show the ref of the pipeline' do
within '.branch-commit' do
expect(page).not_to have_link(pipeline.ref)
end
end
end
it_behaves_like 'showing detached merge request pipeline information'
context 'when source project is a forked project' do
let(:source_project) { fork_project(project, user, repository: true) }
it_behaves_like 'showing detached merge request pipeline information'
end
end
context 'when pipeline is merge request pipeline' do
let(:merge_request) do
create(:merge_request,
:with_merge_request_pipeline,
source_project: source_project,
target_project: target_project,
merge_sha: target_project.commit.sha)
end
let!(:pipeline) { merge_request.all_pipelines.first }
let(:source_project) { project }
let(:target_project) { project }
before do
visit project_pipelines_path(source_project)
end
shared_examples_for 'Correct merge request pipeline information' do
it 'does not show detached tag for the pipeline' do
within '.pipeline-tags' do
expect(page).not_to have_content('detached')
end
end
it 'shows the link of the merge request' do
within '.branch-commit' do
expect(page).to have_link(merge_request.iid,
href: project_merge_request_path(project, merge_request))
end
end
it 'does not show the ref of the pipeline' do
within '.branch-commit' do
expect(page).not_to have_link(pipeline.ref)
end
end
end
it_behaves_like 'Correct merge request pipeline information'
context 'when source project is a forked project' do
let(:source_project) { fork_project(project, user, repository: true) }
it_behaves_like 'Correct merge request pipeline information'
end
end
context 'when pipeline has configuration errors' do context 'when pipeline has configuration errors' do
let(:pipeline) do let(:pipeline) do
create(:ci_pipeline, :invalid, project: project) create(:ci_pipeline, :invalid, project: project)
......
...@@ -60,7 +60,7 @@ describe('Environment item', () => { ...@@ -60,7 +60,7 @@ describe('Environment item', () => {
sha: '500aabcb17c97bdcf2d0c410b70cb8556f0362dd', sha: '500aabcb17c97bdcf2d0c410b70cb8556f0362dd',
ref: { ref: {
name: 'master', name: 'master',
ref_path: 'root/ci-folders/tree/master', ref_url: 'root/ci-folders/tree/master',
}, },
tag: true, tag: true,
'last?': true, 'last?': true,
......
...@@ -100,7 +100,8 @@ describe('Pipeline Url Component', () => { ...@@ -100,7 +100,8 @@ describe('Pipeline Url Component', () => {
latest: true, latest: true,
yaml_errors: true, yaml_errors: true,
stuck: true, stuck: true,
merge_request: true, merge_request_pipeline: true,
detached_merge_request_pipeline: true,
}, },
}, },
autoDevopsHelpPath: 'foo', autoDevopsHelpPath: 'foo',
...@@ -108,15 +109,16 @@ describe('Pipeline Url Component', () => { ...@@ -108,15 +109,16 @@ describe('Pipeline Url Component', () => {
}).$mount(); }).$mount();
expect(component.$el.querySelector('.js-pipeline-url-latest').textContent).toContain('latest'); expect(component.$el.querySelector('.js-pipeline-url-latest').textContent).toContain('latest');
expect(component.$el.querySelector('.js-pipeline-url-yaml').textContent).toContain( expect(component.$el.querySelector('.js-pipeline-url-yaml').textContent).toContain(
'yaml invalid', 'yaml invalid',
); );
expect(component.$el.querySelector('.js-pipeline-url-mergerequest').textContent).toContain(
'merge request',
);
expect(component.$el.querySelector('.js-pipeline-url-stuck').textContent).toContain('stuck'); expect(component.$el.querySelector('.js-pipeline-url-stuck').textContent).toContain('stuck');
expect(component.$el.querySelector('.js-pipeline-url-detached').textContent).toContain(
'detached',
);
}); });
it('should render a badge for autodevops', () => { it('should render a badge for autodevops', () => {
......
...@@ -61,7 +61,7 @@ describe('Commit component', () => { ...@@ -61,7 +61,7 @@ describe('Commit component', () => {
}); });
it('should render a tag icon if it represents a tag', () => { it('should render a tag icon if it represents a tag', () => {
expect(component.$el.querySelector('.icon-container i').classList).toContain('fa-tag'); expect(component.$el.querySelector('.icon-container svg.ic-tag')).not.toBeNull();
}); });
it('should render a link to the ref url', () => { it('should render a link to the ref url', () => {
...@@ -143,4 +143,92 @@ describe('Commit component', () => { ...@@ -143,4 +143,92 @@ describe('Commit component', () => {
); );
}); });
}); });
describe('When commit ref is provided, but merge ref is not', () => {
it('should render the commit ref', () => {
props = {
tag: false,
commitRef: {
name: 'master',
ref_url: 'http://localhost/namespace2/gitlabhq/tree/master',
},
commitUrl:
'https://gitlab.com/gitlab-org/gitlab-ce/commit/b7836eddf62d663c665769e1b0960197fd215067',
shortSha: 'b7836edd',
title: null,
author: {},
};
component = mountComponent(CommitComponent, props);
const refEl = component.$el.querySelector('.ref-name');
expect(refEl.textContent).toContain('master');
expect(refEl.href).toBe(props.commitRef.ref_url);
expect(refEl.getAttribute('data-original-title')).toBe(props.commitRef.name);
expect(component.$el.querySelector('.icon-container .ic-branch')).not.toBeNull();
});
});
describe('When both commit and merge ref are provided', () => {
it('should render the merge ref', () => {
props = {
tag: false,
commitRef: {
name: 'master',
ref_url: 'http://localhost/namespace2/gitlabhq/tree/master',
},
commitUrl:
'https://gitlab.com/gitlab-org/gitlab-ce/commit/b7836eddf62d663c665769e1b0960197fd215067',
mergeRequestRef: {
iid: 1234,
path: 'https://example.com/path/to/mr',
title: 'Test MR',
},
shortSha: 'b7836edd',
title: null,
author: {},
};
component = mountComponent(CommitComponent, props);
const refEl = component.$el.querySelector('.ref-name');
expect(refEl.textContent).toContain('1234');
expect(refEl.href).toBe(props.mergeRequestRef.path);
expect(refEl.getAttribute('data-original-title')).toBe(props.mergeRequestRef.title);
expect(component.$el.querySelector('.icon-container .ic-git-merge')).not.toBeNull();
});
});
describe('When showRefInfo === false', () => {
it('should not render any ref info', () => {
props = {
tag: false,
commitRef: {
name: 'master',
ref_url: 'http://localhost/namespace2/gitlabhq/tree/master',
},
commitUrl:
'https://gitlab.com/gitlab-org/gitlab-ce/commit/b7836eddf62d663c665769e1b0960197fd215067',
mergeRequestRef: {
iid: 1234,
path: '/path/to/mr',
title: 'Test MR',
},
shortSha: 'b7836edd',
title: null,
author: {},
showRefInfo: false,
};
component = mountComponent(CommitComponent, props);
expect(component.$el.querySelector('.ref-name')).toBeNull();
});
});
}); });
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