Commit b21dc414 authored by pburdette's avatar pburdette Committed by Jose Ivan Vargas

Fixed post merge ci status bug

Fixed bug where users see error message
on post merge pipeline due to incorrect
handling of ciStatus.

Changelog: fixed
parent 7928d956
...@@ -88,6 +88,9 @@ export default { ...@@ -88,6 +88,9 @@ export default {
return this.mr.preferredAutoMergeStrategy; return this.mr.preferredAutoMergeStrategy;
}, },
ciStatus() {
return this.isPostMerge ? this.mr?.mergePipeline?.details?.status?.text : this.mr.ciStatus;
},
}, },
}; };
</script> </script>
...@@ -97,7 +100,7 @@ export default { ...@@ -97,7 +100,7 @@ export default {
:pipeline="pipeline" :pipeline="pipeline"
:pipeline-coverage-delta="mr.pipelineCoverageDelta" :pipeline-coverage-delta="mr.pipelineCoverageDelta"
:builds-with-coverage="mr.buildsWithCoverage" :builds-with-coverage="mr.buildsWithCoverage"
:ci-status="mr.ciStatus" :ci-status="ciStatus"
:has-ci="mr.hasCI" :has-ci="mr.hasCI"
:pipeline-must-succeed="mr.onlyAllowMergeIfPipelineSucceeds" :pipeline-must-succeed="mr.onlyAllowMergeIfPipelineSucceeds"
:source-branch="branch" :source-branch="branch"
......
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import ArtifactsApp from '~/vue_merge_request_widget/components/artifacts_list_app.vue'; import ArtifactsApp from '~/vue_merge_request_widget/components/artifacts_list_app.vue';
import DeploymentList from '~/vue_merge_request_widget/components/deployment/deployment_list.vue'; import DeploymentList from '~/vue_merge_request_widget/components/deployment/deployment_list.vue';
...@@ -12,12 +13,14 @@ describe('MrWidgetPipelineContainer', () => { ...@@ -12,12 +13,14 @@ describe('MrWidgetPipelineContainer', () => {
let mock; let mock;
const factory = (props = {}) => { const factory = (props = {}) => {
wrapper = mount(MrWidgetPipelineContainer, { wrapper = extendedWrapper(
propsData: { mount(MrWidgetPipelineContainer, {
mr: { ...mockStore }, propsData: {
...props, mr: { ...mockStore },
}, ...props,
}); },
}),
);
}; };
beforeEach(() => { beforeEach(() => {
...@@ -30,6 +33,7 @@ describe('MrWidgetPipelineContainer', () => { ...@@ -30,6 +33,7 @@ describe('MrWidgetPipelineContainer', () => {
}); });
const findDeploymentList = () => wrapper.findComponent(DeploymentList); const findDeploymentList = () => wrapper.findComponent(DeploymentList);
const findCIErrorMessage = () => wrapper.findByTestId('ci-error-message');
describe('when pre merge', () => { describe('when pre merge', () => {
beforeEach(() => { beforeEach(() => {
...@@ -69,15 +73,21 @@ describe('MrWidgetPipelineContainer', () => { ...@@ -69,15 +73,21 @@ describe('MrWidgetPipelineContainer', () => {
beforeEach(() => { beforeEach(() => {
factory({ factory({
isPostMerge: true, isPostMerge: true,
mr: {
...mockStore,
pipeline: {},
ciStatus: undefined,
},
}); });
}); });
it('renders pipeline', () => { it('renders pipeline', () => {
expect(wrapper.find(MrWidgetPipeline).exists()).toBe(true); expect(wrapper.find(MrWidgetPipeline).exists()).toBe(true);
expect(findCIErrorMessage().exists()).toBe(false);
expect(wrapper.find(MrWidgetPipeline).props()).toMatchObject({ expect(wrapper.find(MrWidgetPipeline).props()).toMatchObject({
pipeline: mockStore.mergePipeline, pipeline: mockStore.mergePipeline,
pipelineCoverageDelta: mockStore.pipelineCoverageDelta, pipelineCoverageDelta: mockStore.pipelineCoverageDelta,
ciStatus: mockStore.ciStatus, ciStatus: mockStore.mergePipeline.details.status.text,
hasCi: mockStore.hasCI, hasCi: mockStore.hasCI,
sourceBranch: mockStore.targetBranch, sourceBranch: mockStore.targetBranch,
sourceBranchLink: mockStore.targetBranch, sourceBranchLink: mockStore.targetBranch,
...@@ -92,7 +102,6 @@ describe('MrWidgetPipelineContainer', () => { ...@@ -92,7 +102,6 @@ describe('MrWidgetPipelineContainer', () => {
targetBranch: 'Foo<script>alert("XSS")</script>', targetBranch: 'Foo<script>alert("XSS")</script>',
}, },
}); });
expect(wrapper.find(MrWidgetPipeline).props().sourceBranchLink).toBe('Foo'); expect(wrapper.find(MrWidgetPipeline).props().sourceBranchLink).toBe('Foo');
}); });
......
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