summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-15 06:08:54 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-15 06:08:54 +0000
commita552864a355f31c496e476ad4e57585aeab95a12 (patch)
tree4f64140ae93033e7b8e7ee683666d506eca41b68 /spec
parent4998f4e2d82409aaebb4a0fb6f85ad130819da57 (diff)
downloadgitlab-ce-a552864a355f31c496e476ad4e57585aeab95a12.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/pipelines/graph/linked_pipeline_spec.js63
-rw-r--r--spec/frontend/pipelines/graph/linked_pipelines_mock_data.js4
-rw-r--r--spec/javascripts/pipelines/graph/graph_component_spec.js1
-rw-r--r--spec/javascripts/pipelines/graph/linked_pipelines_column_spec.js1
-rw-r--r--spec/javascripts/pipelines/linked_pipelines_mock.json3
5 files changed, 59 insertions, 13 deletions
diff --git a/spec/frontend/pipelines/graph/linked_pipeline_spec.js b/spec/frontend/pipelines/graph/linked_pipeline_spec.js
index 8cd9cb7e95d..de1f9142001 100644
--- a/spec/frontend/pipelines/graph/linked_pipeline_spec.js
+++ b/spec/frontend/pipelines/graph/linked_pipeline_spec.js
@@ -8,6 +8,13 @@ const mockPipeline = mockData.triggered[0];
describe('Linked pipeline', () => {
let wrapper;
+ const createWrapper = propsData => {
+ wrapper = mount(LinkedPipelineComponent, {
+ attachToDocument: true,
+ propsData,
+ });
+ };
+
afterEach(() => {
wrapper.destroy();
});
@@ -15,13 +22,12 @@ describe('Linked pipeline', () => {
describe('rendered output', () => {
const props = {
pipeline: mockPipeline,
+ projectId: 20,
+ columnTitle: 'Downstream',
};
beforeEach(() => {
- wrapper = mount(LinkedPipelineComponent, {
- attachToDocument: true,
- propsData: props,
- });
+ createWrapper(props);
});
it('should render a list item as the containing element', () => {
@@ -73,18 +79,50 @@ describe('Linked pipeline', () => {
it('does not render the loading icon when isLoading is false', () => {
expect(wrapper.find('.js-linked-pipeline-loading').exists()).toBe(false);
});
+
+ it('should not display child label when pipeline project id is not the same as triggered pipeline project id', () => {
+ const labelContainer = wrapper.find('.parent-child-label-container');
+ expect(labelContainer.exists()).toBe(false);
+ });
+ });
+
+ describe('parent/child', () => {
+ const downstreamProps = {
+ pipeline: mockPipeline,
+ projectId: 19,
+ columnTitle: 'Downstream',
+ };
+
+ const upstreamProps = {
+ ...downstreamProps,
+ columnTitle: 'Upstream',
+ };
+
+ it('parent/child label container should exist', () => {
+ createWrapper(downstreamProps);
+ expect(wrapper.find('.parent-child-label-container').exists()).toBe(true);
+ });
+
+ it('should display child label when pipeline project id is the same as triggered pipeline project id', () => {
+ createWrapper(downstreamProps);
+ expect(wrapper.find('.parent-child-label-container').text()).toContain('Child');
+ });
+
+ it('should display parent label when pipeline project id is the same as triggered_by pipeline project id', () => {
+ createWrapper(upstreamProps);
+ expect(wrapper.find('.parent-child-label-container').text()).toContain('Parent');
+ });
});
describe('when isLoading is true', () => {
const props = {
pipeline: { ...mockPipeline, isLoading: true },
+ projectId: 19,
+ columnTitle: 'Downstream',
};
beforeEach(() => {
- wrapper = mount(LinkedPipelineComponent, {
- attachToDocument: true,
- propsData: props,
- });
+ createWrapper(props);
});
it('renders a loading icon', () => {
@@ -95,20 +133,19 @@ describe('Linked pipeline', () => {
describe('on click', () => {
const props = {
pipeline: mockPipeline,
+ projectId: 19,
+ columnTitle: 'Downstream',
};
beforeEach(() => {
- wrapper = mount(LinkedPipelineComponent, {
- attachToDocument: true,
- propsData: props,
- });
+ createWrapper(props);
});
it('emits `pipelineClicked` event', () => {
jest.spyOn(wrapper.vm, '$emit');
wrapper.find('button').trigger('click');
- expect(wrapper.vm.$emit).toHaveBeenCalledWith('pipelineClicked');
+ expect(wrapper.emitted().pipelineClicked).toBeTruthy();
});
it('should emit `bv::hide::tooltip` to close the tooltip', () => {
diff --git a/spec/frontend/pipelines/graph/linked_pipelines_mock_data.js b/spec/frontend/pipelines/graph/linked_pipelines_mock_data.js
index f794b8484a7..c9a94b3101f 100644
--- a/spec/frontend/pipelines/graph/linked_pipelines_mock_data.js
+++ b/spec/frontend/pipelines/graph/linked_pipelines_mock_data.js
@@ -1,4 +1,7 @@
export default {
+ project: {
+ id: 19,
+ },
triggered_by: {
id: 129,
active: true,
@@ -63,6 +66,7 @@ export default {
path: '/gitlab-org/gitlab-foss/pipelines/132',
project: {
name: 'GitLabCE',
+ id: 19,
},
details: {
status: {
diff --git a/spec/javascripts/pipelines/graph/graph_component_spec.js b/spec/javascripts/pipelines/graph/graph_component_spec.js
index 5effbaabcd1..fa6a5f57410 100644
--- a/spec/javascripts/pipelines/graph/graph_component_spec.js
+++ b/spec/javascripts/pipelines/graph/graph_component_spec.js
@@ -190,6 +190,7 @@ describe('graph component', () => {
describe('on click', () => {
it('should emit `onClickTriggered`', () => {
spyOn(component, '$emit');
+ spyOn(component, 'calculateMarginTop').and.callFake(() => '16px');
component.$el.querySelector('#js-linked-pipeline-34993051').click();
diff --git a/spec/javascripts/pipelines/graph/linked_pipelines_column_spec.js b/spec/javascripts/pipelines/graph/linked_pipelines_column_spec.js
index fe7039da9e4..613ab2a906f 100644
--- a/spec/javascripts/pipelines/graph/linked_pipelines_column_spec.js
+++ b/spec/javascripts/pipelines/graph/linked_pipelines_column_spec.js
@@ -9,6 +9,7 @@ describe('Linked Pipelines Column', () => {
columnTitle: 'Upstream',
linkedPipelines: mockData.triggered,
graphPosition: 'right',
+ projectId: 19,
};
let vm;
diff --git a/spec/javascripts/pipelines/linked_pipelines_mock.json b/spec/javascripts/pipelines/linked_pipelines_mock.json
index b498903f804..60e214ddc32 100644
--- a/spec/javascripts/pipelines/linked_pipelines_mock.json
+++ b/spec/javascripts/pipelines/linked_pipelines_mock.json
@@ -341,6 +341,9 @@
"commit_url": "https://gitlab.com/gitlab-org/gitlab-runner/commit/8083eb0a920572214d0dccedd7981f05d535ad46",
"commit_path": "/gitlab-org/gitlab-runner/commit/8083eb0a920572214d0dccedd7981f05d535ad46"
},
+ "project": {
+ "id": 1794617
+ },
"triggered_by": {
"id": 12,
"user": {