Commit 816c5749 authored by Vitaly Slobodin's avatar Vitaly Slobodin

Merge branch '215845-uncheck-delete-source-branch-does-nothing-2' into 'master'

Resolve "Uncheck `delete source branch` does nothing."

See merge request gitlab-org/gitlab!58605
parents 4a9f4d44 102c5dd5
......@@ -71,11 +71,11 @@ export default {
return (this.glFeatures.mergeRequestWidgetGraphql ? this.state : this.mr).targetBranch;
},
shouldRemoveSourceBranch() {
if (this.glFeatures.mergeRequestWidgetGraphql) {
return this.state.shouldRemoveSourceBranch || this.state.forceRemoveSourceBranch;
}
if (!this.glFeatures.mergeRequestWidgetGraphql) return this.mr.shouldRemoveSourceBranch;
return this.mr.shouldRemoveSourceBranch;
if (!this.state.shouldRemoveSourceBranch) return false;
return this.state.shouldRemoveSourceBranch || this.state.forceRemoveSourceBranch;
},
autoMergeStrategy() {
return (this.glFeatures.mergeRequestWidgetGraphql ? this.state : this.mr).autoMergeStrategy;
......
---
title: Fix delete source branch status message
merge_request: 58605
author:
type: fixed
......@@ -28,11 +28,11 @@ function convertPropsToGraphqlState(props) {
};
}
function factory(propsData) {
function factory(propsData, stateOverride = {}) {
let state = {};
if (mergeRequestWidgetGraphqlEnabled) {
state = convertPropsToGraphqlState(propsData);
state = { ...convertPropsToGraphqlState(propsData), ...stateOverride };
}
wrapper = extendedWrapper(
......@@ -125,7 +125,7 @@ describe('MRWidgetAutoMergeEnabled', () => {
},
);
it('should return false when shouldRemoveSourceBranch set to false', () => {
it('should not find "Delete" button when shouldRemoveSourceBranch set to true', () => {
factory({
...defaultMrProps(),
shouldRemoveSourceBranch: true,
......@@ -134,6 +134,29 @@ describe('MRWidgetAutoMergeEnabled', () => {
expect(wrapper.findByTestId('removeSourceBranchButton').exists()).toBe(false);
});
it('should find "Delete" button when shouldRemoveSourceBranch overrides state.forceRemoveSourceBranch', () => {
factory(
{
...defaultMrProps(),
shouldRemoveSourceBranch: false,
},
{
forceRemoveSourceBranch: true,
},
);
expect(wrapper.findByTestId('removeSourceBranchButton').exists()).toBe(true);
});
it('should find "Delete" button when shouldRemoveSourceBranch set to false', () => {
factory({
...defaultMrProps(),
shouldRemoveSourceBranch: false,
});
expect(wrapper.findByTestId('removeSourceBranchButton').exists()).toBe(true);
});
it('should return false if user is not able to remove the source branch', () => {
factory({
...defaultMrProps(),
......
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