Commit 3b968515 authored by Sarah Groff Hennigh-Palermo's avatar Sarah Groff Hennigh-Palermo Committed by Mark Florian

Updates feature specs for Pipelines

* Removed stubbed false flags
* Updates selectors for feature specs
* Add tests for both flag states in ee
parent 14d6ca06
...@@ -61,6 +61,9 @@ export default { ...@@ -61,6 +61,9 @@ export default {
isUpstream() { isUpstream() {
return this.type === UPSTREAM; return this.type === UPSTREAM;
}, },
minWidth() {
return this.isUpstream ? 0 : this.$options.minWidth;
},
}, },
methods: { methods: {
getPipelineData(pipeline) { getPipelineData(pipeline) {
...@@ -132,8 +135,8 @@ export default { ...@@ -132,8 +135,8 @@ export default {
this.$emit('pipelineExpandToggle', jobName, expanded); this.$emit('pipelineExpandToggle', jobName, expanded);
}, },
showDownstreamContainer(id) { showContainer(id) {
return !this.isUpstream && (this.isExpanded(id) || this.isLoadingPipeline(id)); return this.isExpanded(id) || this.isLoadingPipeline(id);
}, },
}, },
}; };
...@@ -164,8 +167,8 @@ export default { ...@@ -164,8 +167,8 @@ export default {
@pipelineExpandToggle="onPipelineExpandToggle" @pipelineExpandToggle="onPipelineExpandToggle"
/> />
<div <div
v-if="showDownstreamContainer(pipeline.id)" v-if="showContainer(pipeline.id)"
:style="{ minWidth: $options.minWidth }" :style="{ minWidth }"
class="gl-display-inline-block" class="gl-display-inline-block"
> >
<pipeline-graph <pipeline-graph
......
...@@ -84,7 +84,7 @@ export default { ...@@ -84,7 +84,7 @@ export default {
}; };
</script> </script>
<template> <template>
<main-graph-wrapper class="gl-px-6"> <main-graph-wrapper class="gl-px-6" data-testid="stage-column">
<template #stages> <template #stages>
<div <div
data-testid="stage-column-title" data-testid="stage-column-title"
......
...@@ -7,7 +7,6 @@ RSpec.describe 'Pipeline', :js do ...@@ -7,7 +7,6 @@ RSpec.describe 'Pipeline', :js do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
before do before do
stub_feature_flags(graphql_pipeline_details: false)
stub_feature_flags(graphql_pipeline_details_users: false) stub_feature_flags(graphql_pipeline_details_users: false)
sign_in(user) sign_in(user)
...@@ -31,6 +30,8 @@ RSpec.describe 'Pipeline', :js do ...@@ -31,6 +30,8 @@ RSpec.describe 'Pipeline', :js do
create_link(pipeline, downstream_pipeline) create_link(pipeline, downstream_pipeline)
end end
context 'when :graphql_pipeline_details flag is on' do
context 'expands the upstream pipeline on click' do
it 'renders upstream pipeline' do it 'renders upstream pipeline' do
subject subject
...@@ -38,13 +39,12 @@ RSpec.describe 'Pipeline', :js do ...@@ -38,13 +39,12 @@ RSpec.describe 'Pipeline', :js do
expect(page).to have_content(upstream_pipeline.project.name) expect(page).to have_content(upstream_pipeline.project.name)
end end
context 'expands the upstream pipeline on click' do
it 'expands the upstream on click' do it 'expands the upstream on click' do
subject subject
page.find(".js-pipeline-expand-#{upstream_pipeline.id}").click page.find(".js-pipeline-expand-#{upstream_pipeline.id}").click
wait_for_requests wait_for_requests
expect(page).to have_selector(".js-upstream-pipeline-#{upstream_pipeline.id}") expect(page).to have_selector("#pipeline-links-container-#{upstream_pipeline.id}")
end end
it 'closes the expanded upstream on click' do it 'closes the expanded upstream on click' do
...@@ -57,7 +57,7 @@ RSpec.describe 'Pipeline', :js do ...@@ -57,7 +57,7 @@ RSpec.describe 'Pipeline', :js do
# close # close
page.find(".js-pipeline-expand-#{upstream_pipeline.id}").click page.find(".js-pipeline-expand-#{upstream_pipeline.id}").click
expect(page).not_to have_selector(".js-upstream-pipeline-#{upstream_pipeline.id}") expect(page).not_to have_selector("#pipeline-links-container-#{upstream_pipeline.id}")
end end
end end
...@@ -68,6 +68,60 @@ RSpec.describe 'Pipeline', :js do ...@@ -68,6 +68,60 @@ RSpec.describe 'Pipeline', :js do
expect(page).to have_content(downstream_pipeline.project.name) expect(page).to have_content(downstream_pipeline.project.name)
end end
context 'expands the downstream pipeline on click' do
it 'expands the downstream on click' do
subject
page.find(".js-pipeline-expand-#{downstream_pipeline.id}").click
wait_for_requests
expect(page).to have_selector("#pipeline-links-container-#{downstream_pipeline.id}")
end
it 'closes the expanded downstream on click' do
subject
# open
page.find(".js-pipeline-expand-#{downstream_pipeline.id}").click
wait_for_requests
# close
page.find(".js-pipeline-expand-#{downstream_pipeline.id}").click
expect(page).not_to have_selector("#pipeline-links-container-#{downstream_pipeline.id}")
end
end
end
# remove when :graphql_pipeline_details flag is removed
# https://gitlab.com/gitlab-org/gitlab/-/issues/299112
context 'when :graphql_pipeline_details flag is off' do
before do
stub_feature_flags(graphql_pipeline_details: false)
stub_feature_flags(graphql_pipeline_details_users: false)
end
context 'expands the upstream pipeline on click' do
it 'expands the upstream on click' do
subject
page.find(".js-pipeline-expand-#{upstream_pipeline.id}").click
wait_for_requests
expect(page).to have_selector(".js-upstream-pipeline-#{upstream_pipeline.id}")
end
it 'closes the expanded upstream on click' do
subject
# open
page.find(".js-pipeline-expand-#{upstream_pipeline.id}").click
wait_for_requests
# close
page.find(".js-pipeline-expand-#{upstream_pipeline.id}").click
expect(page).not_to have_selector(".js-upstream-pipeline-#{upstream_pipeline.id}")
end
end
context 'expands the downstream pipeline on click' do context 'expands the downstream pipeline on click' do
it 'expands the downstream on click' do it 'expands the downstream on click' do
subject subject
...@@ -92,6 +146,7 @@ RSpec.describe 'Pipeline', :js do ...@@ -92,6 +146,7 @@ RSpec.describe 'Pipeline', :js do
end end
end end
end end
end
describe 'GET /:project/-/pipelines/:id/security' do describe 'GET /:project/-/pipelines/:id/security' do
let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) } let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) }
...@@ -124,7 +179,7 @@ RSpec.describe 'Pipeline', :js do ...@@ -124,7 +179,7 @@ RSpec.describe 'Pipeline', :js do
it 'displays the pipeline graph' do it 'displays the pipeline graph' do
expect(current_path).to eq(pipeline_path(pipeline)) expect(current_path).to eq(pipeline_path(pipeline))
expect(page).not_to have_css('#js-tab-security') expect(page).not_to have_css('#js-tab-security')
expect(page).to have_selector('.pipeline-visualization') expect(page).to have_selector('.js-pipeline-graph')
end end
end end
end end
...@@ -162,7 +217,7 @@ RSpec.describe 'Pipeline', :js do ...@@ -162,7 +217,7 @@ RSpec.describe 'Pipeline', :js do
it 'displays the pipeline graph' do it 'displays the pipeline graph' do
expect(current_path).to eq(pipeline_path(pipeline)) expect(current_path).to eq(pipeline_path(pipeline))
expect(page).not_to have_content('Licenses') expect(page).not_to have_content('Licenses')
expect(page).to have_selector('.pipeline-visualization') expect(page).to have_selector('.js-pipeline-graph')
end end
end end
end end
......
...@@ -14,8 +14,6 @@ RSpec.describe 'Pipeline', :js do ...@@ -14,8 +14,6 @@ RSpec.describe 'Pipeline', :js do
before do before do
sign_in(user) sign_in(user)
project.add_role(user, role) project.add_role(user, role)
stub_feature_flags(graphql_pipeline_details: false)
stub_feature_flags(graphql_pipeline_details_users: false)
end end
shared_context 'pipeline builds' do shared_context 'pipeline builds' do
...@@ -70,7 +68,7 @@ RSpec.describe 'Pipeline', :js do ...@@ -70,7 +68,7 @@ RSpec.describe 'Pipeline', :js do
it 'shows the pipeline graph' do it 'shows the pipeline graph' do
visit_pipeline visit_pipeline
expect(page).to have_selector('.pipeline-visualization') expect(page).to have_selector('.js-pipeline-graph')
expect(page).to have_content('Build') expect(page).to have_content('Build')
expect(page).to have_content('Test') expect(page).to have_content('Test')
expect(page).to have_content('Deploy') expect(page).to have_content('Deploy')
...@@ -644,7 +642,7 @@ RSpec.describe 'Pipeline', :js do ...@@ -644,7 +642,7 @@ RSpec.describe 'Pipeline', :js do
end end
it 'shows the pipeline graph' do it 'shows the pipeline graph' do
expect(page).to have_selector('.pipeline-visualization') expect(page).to have_selector('.js-pipeline-graph')
expect(page).to have_content('Build') expect(page).to have_content('Build')
expect(page).to have_content('Test') expect(page).to have_content('Test')
expect(page).to have_content('Deploy') expect(page).to have_content('Deploy')
...@@ -684,7 +682,7 @@ RSpec.describe 'Pipeline', :js do ...@@ -684,7 +682,7 @@ RSpec.describe 'Pipeline', :js do
end end
it 'shows the pipeline with a bridge job' do it 'shows the pipeline with a bridge job' do
expect(page).to have_selector('.pipeline-visualization') expect(page).to have_selector('.js-pipeline-graph')
expect(page).to have_content('cross-build') expect(page).to have_content('cross-build')
end end
...@@ -757,6 +755,14 @@ RSpec.describe 'Pipeline', :js do ...@@ -757,6 +755,14 @@ RSpec.describe 'Pipeline', :js do
describe 'GET /:project/-/pipelines/:id' do describe 'GET /:project/-/pipelines/:id' do
subject { visit project_pipeline_path(project, pipeline) } subject { visit project_pipeline_path(project, pipeline) }
# remove when :graphql_pipeline_details flag is removed
# https://gitlab.com/gitlab-org/gitlab/-/issues/299112
context 'when :graphql_pipeline_details flag is off' do
before do
stub_feature_flags(graphql_pipeline_details: false)
stub_feature_flags(graphql_pipeline_details_users: false)
end
it 'shows deploy job as created' do it 'shows deploy job as created' do
subject subject
...@@ -764,7 +770,7 @@ RSpec.describe 'Pipeline', :js do ...@@ -764,7 +770,7 @@ RSpec.describe 'Pipeline', :js do
expect(page).to have_content('pending') expect(page).to have_content('pending')
end end
within('.pipeline-graph') do within('.js-pipeline-graph') do
within '.stage-column:nth-child(1)' do within '.stage-column:nth-child(1)' do
expect(page).to have_content('test') expect(page).to have_content('test')
expect(page).to have_css('.ci-status-icon-pending') expect(page).to have_css('.ci-status-icon-pending')
...@@ -802,6 +808,53 @@ RSpec.describe 'Pipeline', :js do ...@@ -802,6 +808,53 @@ RSpec.describe 'Pipeline', :js do
end end
end end
end end
end
it 'shows deploy job as created' do
subject
within('.pipeline-header-container') do
expect(page).to have_content('pending')
end
within('.js-pipeline-graph') do
within(all('[data-testid="stage-column"]')[0]) do
expect(page).to have_content('test')
expect(page).to have_css('.ci-status-icon-pending')
end
within(all('[data-testid="stage-column"]')[1]) do
expect(page).to have_content('deploy')
expect(page).to have_css('.ci-status-icon-created')
end
end
end
context 'when test job succeeded' do
before do
test_job.success!
end
it 'shows deploy job as pending' do
subject
within('.pipeline-header-container') do
expect(page).to have_content('running')
end
within('.js-pipeline-graph') do
within(all('[data-testid="stage-column"]')[0]) do
expect(page).to have_content('test')
expect(page).to have_css('.ci-status-icon-success')
end
within(all('[data-testid="stage-column"]')[1]) do
expect(page).to have_content('deploy')
expect(page).to have_css('.ci-status-icon-pending')
end
end
end
end
context 'when test job succeeded but there are no available resources' do context 'when test job succeeded but there are no available resources' do
let(:another_job) { create(:ci_build, :running, project: project, resource_group: resource_group) } let(:another_job) { create(:ci_build, :running, project: project, resource_group: resource_group) }
...@@ -811,6 +864,28 @@ RSpec.describe 'Pipeline', :js do ...@@ -811,6 +864,28 @@ RSpec.describe 'Pipeline', :js do
test_job.success! test_job.success!
end end
it 'shows deploy job as waiting for resource' do
subject
within('.pipeline-header-container') do
expect(page).to have_content('waiting')
end
within('.js-pipeline-graph') do
within(all('[data-testid="stage-column"]')[1]) do
expect(page).to have_content('deploy')
expect(page).to have_css('.ci-status-icon-waiting-for-resource')
end
end
end
# remove when :graphql_pipeline_details flag is removed
# https://gitlab.com/gitlab-org/gitlab/-/issues/299112
context 'when :graphql_pipeline_details flag is off' do
before do
stub_feature_flags(graphql_pipeline_details: false)
stub_feature_flags(graphql_pipeline_details_users: false)
end
it 'shows deploy job as waiting for resource' do it 'shows deploy job as waiting for resource' do
subject subject
...@@ -825,12 +900,35 @@ RSpec.describe 'Pipeline', :js do ...@@ -825,12 +900,35 @@ RSpec.describe 'Pipeline', :js do
end end
end end
end end
end
context 'when resource is released from another job' do context 'when resource is released from another job' do
before do before do
another_job.success! another_job.success!
end end
it 'shows deploy job as pending' do
subject
within('.pipeline-header-container') do
expect(page).to have_content('running')
end
within('.js-pipeline-graph') do
within(all('[data-testid="stage-column"]')[1]) do
expect(page).to have_content('deploy')
expect(page).to have_css('.ci-status-icon-pending')
end
end
end
# remove when :graphql_pipeline_details flag is removed
# https://gitlab.com/gitlab-org/gitlab/-/issues/299112
context 'when :graphql_pipeline_details flag is off' do
before do
stub_feature_flags(graphql_pipeline_details: false)
stub_feature_flags(graphql_pipeline_details_users: false)
end
it 'shows deploy job as pending' do it 'shows deploy job as pending' do
subject subject
...@@ -846,6 +944,7 @@ RSpec.describe 'Pipeline', :js do ...@@ -846,6 +944,7 @@ RSpec.describe 'Pipeline', :js do
end end
end end
end end
end
context 'when deploy job is a bridge to trigger a downstream pipeline' do context 'when deploy job is a bridge to trigger a downstream pipeline' do
let!(:deploy_job) do let!(:deploy_job) do
...@@ -860,8 +959,30 @@ RSpec.describe 'Pipeline', :js do ...@@ -860,8 +959,30 @@ RSpec.describe 'Pipeline', :js do
expect(page).to have_content('waiting') expect(page).to have_content('waiting')
end end
within('.pipeline-graph') do within('.js-pipeline-graph') do
within '.stage-column:nth-child(2)' do within(all('[data-testid="stage-column"]')[1]) do
expect(page).to have_content('deploy')
expect(page).to have_css('.ci-status-icon-waiting-for-resource')
end
end
end
end
context 'when deploy job is a bridge to trigger a downstream pipeline' do
let!(:deploy_job) do
create(:ci_bridge, :created, stage: 'deploy', name: 'deploy',
stage_idx: 2, pipeline: pipeline, project: project, resource_group: resource_group)
end
it 'shows deploy job as waiting for resource' do
subject
within('.pipeline-header-container') do
expect(page).to have_content('waiting')
end
within('.js-pipeline-graph') do
within(all('[data-testid="stage-column"]')[1]) do
expect(page).to have_content('deploy') expect(page).to have_content('deploy')
expect(page).to have_css('.ci-status-icon-waiting-for-resource') expect(page).to have_css('.ci-status-icon-waiting-for-resource')
end end
...@@ -1082,6 +1203,22 @@ RSpec.describe 'Pipeline', :js do ...@@ -1082,6 +1203,22 @@ RSpec.describe 'Pipeline', :js do
failed_build.update!(status: :success) failed_build.update!(status: :success)
end end
it 'displays the pipeline graph' do
subject
expect(current_path).to eq(pipeline_path(pipeline))
expect(page).not_to have_content('Failed Jobs')
expect(page).to have_selector('.js-pipeline-graph')
end
# remove when :graphql_pipeline_details flag is removed
# https://gitlab.com/gitlab-org/gitlab/-/issues/299112
context 'when :graphql_pipeline_details flag is off' do
before do
stub_feature_flags(graphql_pipeline_details: false)
stub_feature_flags(graphql_pipeline_details_users: false)
end
it 'displays the pipeline graph' do it 'displays the pipeline graph' do
subject subject
...@@ -1091,6 +1228,7 @@ RSpec.describe 'Pipeline', :js do ...@@ -1091,6 +1228,7 @@ RSpec.describe 'Pipeline', :js do
end end
end end
end end
end
describe 'GET /:project/-/pipelines/:id/dag' do describe 'GET /:project/-/pipelines/:id/dag' do
include_context 'pipeline builds' include_context 'pipeline builds'
......
...@@ -14,6 +14,7 @@ RSpec.describe 'Pipelines', :js do ...@@ -14,6 +14,7 @@ RSpec.describe 'Pipelines', :js do
sign_in(user) sign_in(user)
stub_feature_flags(graphql_pipeline_details: false) stub_feature_flags(graphql_pipeline_details: false)
stub_feature_flags(graphql_pipeline_details_users: false) stub_feature_flags(graphql_pipeline_details_users: false)
project.add_developer(user) project.add_developer(user)
project.update!(auto_devops_attributes: { enabled: false }) project.update!(auto_devops_attributes: { enabled: false })
end end
......
...@@ -2,7 +2,7 @@ import { mount, shallowMount, createLocalVue } from '@vue/test-utils'; ...@@ -2,7 +2,7 @@ import { mount, shallowMount, createLocalVue } from '@vue/test-utils';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import getPipelineDetails from 'shared_queries/pipelines/get_pipeline_details.query.graphql'; import getPipelineDetails from 'shared_queries/pipelines/get_pipeline_details.query.graphql';
import { DOWNSTREAM, GRAPHQL } from '~/pipelines/components/graph/constants'; import { DOWNSTREAM, GRAPHQL, UPSTREAM } from '~/pipelines/components/graph/constants';
import PipelineGraph from '~/pipelines/components/graph/graph_component.vue'; import PipelineGraph from '~/pipelines/components/graph/graph_component.vue';
import LinkedPipeline from '~/pipelines/components/graph/linked_pipeline.vue'; import LinkedPipeline from '~/pipelines/components/graph/linked_pipeline.vue';
import LinkedPipelinesColumn from '~/pipelines/components/graph/linked_pipelines_column.vue'; import LinkedPipelinesColumn from '~/pipelines/components/graph/linked_pipelines_column.vue';
...@@ -17,7 +17,7 @@ const processedPipeline = pipelineWithUpstreamDownstream(mockPipelineResponse); ...@@ -17,7 +17,7 @@ const processedPipeline = pipelineWithUpstreamDownstream(mockPipelineResponse);
describe('Linked Pipelines Column', () => { describe('Linked Pipelines Column', () => {
const defaultProps = { const defaultProps = {
columnTitle: 'Upstream', columnTitle: 'Downstream',
linkedPipelines: processedPipeline.downstream, linkedPipelines: processedPipeline.downstream,
type: DOWNSTREAM, type: DOWNSTREAM,
}; };
...@@ -45,14 +45,15 @@ describe('Linked Pipelines Column', () => { ...@@ -45,14 +45,15 @@ describe('Linked Pipelines Column', () => {
}); });
}; };
const createComponentWithApollo = ( const createComponentWithApollo = ({
mountFn = shallowMount, mountFn = shallowMount,
getPipelineDetailsHandler = jest.fn().mockResolvedValue(wrappedPipelineReturn), getPipelineDetailsHandler = jest.fn().mockResolvedValue(wrappedPipelineReturn),
) => { props = {},
} = {}) => {
const requestHandlers = [[getPipelineDetails, getPipelineDetailsHandler]]; const requestHandlers = [[getPipelineDetails, getPipelineDetailsHandler]];
const apolloProvider = createMockApollo(requestHandlers); const apolloProvider = createMockApollo(requestHandlers);
createComponent({ apolloProvider, mountFn }); createComponent({ apolloProvider, mountFn, props });
}; };
afterEach(() => { afterEach(() => {
...@@ -86,9 +87,10 @@ describe('Linked Pipelines Column', () => { ...@@ -86,9 +87,10 @@ describe('Linked Pipelines Column', () => {
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
}; };
describe('downstream', () => {
describe('when successful', () => { describe('when successful', () => {
beforeEach(() => { beforeEach(() => {
createComponentWithApollo(mount); createComponentWithApollo({ mountFn: mount });
}); });
it('toggles the pipeline visibility', async () => { it('toggles the pipeline visibility', async () => {
...@@ -102,7 +104,10 @@ describe('Linked Pipelines Column', () => { ...@@ -102,7 +104,10 @@ describe('Linked Pipelines Column', () => {
describe('on error', () => { describe('on error', () => {
beforeEach(() => { beforeEach(() => {
createComponentWithApollo(mount, jest.fn().mockRejectedValue(new Error('GraphQL error'))); createComponentWithApollo({
mountFn: mount,
getPipelineDetailsHandler: jest.fn().mockRejectedValue(new Error('GraphQL error')),
});
}); });
it('emits the error', async () => { it('emits the error', async () => {
...@@ -117,4 +122,56 @@ describe('Linked Pipelines Column', () => { ...@@ -117,4 +122,56 @@ describe('Linked Pipelines Column', () => {
}); });
}); });
}); });
describe('upstream', () => {
const upstreamProps = {
columnTitle: 'Upstream',
/*
Because the IDs need to match to work, rather
than make new mock data, we are representing
the upstream pipeline with the downstream data.
*/
linkedPipelines: processedPipeline.downstream,
type: UPSTREAM,
};
describe('when successful', () => {
beforeEach(() => {
createComponentWithApollo({
mountFn: mount,
props: upstreamProps,
});
});
it('toggles the pipeline visibility', async () => {
expect(findPipelineGraph().exists()).toBe(false);
await clickExpandButtonAndAwaitTimers();
expect(findPipelineGraph().exists()).toBe(true);
await clickExpandButton();
expect(findPipelineGraph().exists()).toBe(false);
});
});
describe('on error', () => {
beforeEach(() => {
createComponentWithApollo({
mountFn: mount,
getPipelineDetailsHandler: jest.fn().mockRejectedValue(new Error('GraphQL error')),
props: upstreamProps,
});
});
it('emits the error', async () => {
await clickExpandButton();
expect(wrapper.emitted().error).toEqual([[LOAD_FAILURE]]);
});
it('does not show the pipeline', async () => {
expect(findPipelineGraph().exists()).toBe(false);
await clickExpandButtonAndAwaitTimers();
expect(findPipelineGraph().exists()).toBe(false);
});
});
});
});
}); });
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