Commit 67a175b2 authored by Lee Tickett's avatar Lee Tickett Committed by Paul Slaughter

Add spec for disabled merge text

- Default
- Unapproved
parent 600b863b
...@@ -88,7 +88,8 @@ export default { ...@@ -88,7 +88,8 @@ export default {
mergeButtonText() { mergeButtonText() {
if (this.isMergingImmediately) { if (this.isMergingImmediately) {
return __('Merge in progress'); return __('Merge in progress');
} else if (this.isAutoMergeAvailable) { }
if (this.isAutoMergeAvailable) {
return this.autoMergeText; return this.autoMergeText;
} }
...@@ -306,7 +307,7 @@ export default { ...@@ -306,7 +307,7 @@ export default {
</template> </template>
<template v-else> <template v-else>
<span class="bold js-resolve-mr-widget-items-message"> <span class="bold js-resolve-mr-widget-items-message">
{{ __('You can only merge once the items above are resolved') }} {{ mergeDisabledText }}
</span> </span>
</template> </template>
</div> </div>
......
import { __ } from '~/locale'; import { __ } from '~/locale';
export const MERGE_DISABLED_TEXT = __('You can only merge once the items above are resolved.');
export default { export default {
computed: { computed: {
isMergeButtonDisabled() { isMergeButtonDisabled() {
...@@ -11,6 +13,9 @@ export default { ...@@ -11,6 +13,9 @@ export default {
this.mr.preventMerge, this.mr.preventMerge,
); );
}, },
mergeDisabledText() {
return MERGE_DISABLED_TEXT;
},
autoMergeText() { autoMergeText() {
// MWPS is currently the only auto merge strategy available in CE // MWPS is currently the only auto merge strategy available in CE
return __('Merge when pipeline succeeds'); return __('Merge when pipeline succeeds');
......
import { MTWPS_MERGE_STRATEGY, MT_MERGE_STRATEGY } from '~/vue_merge_request_widget/constants'; import { MTWPS_MERGE_STRATEGY, MT_MERGE_STRATEGY } from '~/vue_merge_request_widget/constants';
import { __ } from '~/locale'; import { __ } from '~/locale';
import base from '~/vue_merge_request_widget/mixins/ready_to_merge';
export const MERGE_DISABLED_TEXT_UNAPPROVED = __(
'You can only merge once this merge request is approved.',
);
export default { export default {
computed: { computed: {
...@@ -16,6 +21,13 @@ export default { ...@@ -16,6 +21,13 @@ export default {
this.mr.preventMerge, this.mr.preventMerge,
); );
}, },
mergeDisabledText() {
if (this.isApprovalNeeded) {
return MERGE_DISABLED_TEXT_UNAPPROVED;
}
return base.computed.mergeDisabledText.call(this);
},
autoMergeText() { autoMergeText() {
if (this.mr.preferredAutoMergeStrategy === MTWPS_MERGE_STRATEGY) { if (this.mr.preferredAutoMergeStrategy === MTWPS_MERGE_STRATEGY) {
if (this.mr.mergeTrainsCount === 0) { if (this.mr.mergeTrainsCount === 0) {
......
---
title: Improve unapproved MR merge button text
merge_request: 15745
author: Lee Tickett
type: other
...@@ -5,6 +5,8 @@ import { ...@@ -5,6 +5,8 @@ import {
MT_MERGE_STRATEGY, MT_MERGE_STRATEGY,
MTWPS_MERGE_STRATEGY, MTWPS_MERGE_STRATEGY,
} from '~/vue_merge_request_widget/constants'; } from '~/vue_merge_request_widget/constants';
import { MERGE_DISABLED_TEXT } from '~/vue_merge_request_widget/mixins/ready_to_merge';
import { MERGE_DISABLED_TEXT_UNAPPROVED } from 'ee/vue_merge_request_widget/mixins/ready_to_merge';
describe('ReadyToMerge', () => { describe('ReadyToMerge', () => {
const localVue = createLocalVue(); const localVue = createLocalVue();
...@@ -51,6 +53,9 @@ describe('ReadyToMerge', () => { ...@@ -51,6 +53,9 @@ describe('ReadyToMerge', () => {
({ vm } = wrapper); ({ vm } = wrapper);
}; };
const findResolveItemsMessage = () => wrapper.find('.js-resolve-mr-widget-items-message');
const findMergeButton = () => wrapper.find('.qa-merge-button');
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
}); });
...@@ -180,4 +185,38 @@ describe('ReadyToMerge', () => { ...@@ -180,4 +185,38 @@ describe('ReadyToMerge', () => {
expect(vm.shouldShowMergeImmediatelyDropdown).toBe(true); expect(vm.shouldShowMergeImmediatelyDropdown).toBe(true);
}); });
}); });
describe('cannot merge', () => {
describe('when isMergeAllowed=false', () => {
beforeEach(() => {
factory({ isMergeAllowed: false, availableAutoMergeStrategies: [] });
});
it('should show cannot merge text', () => {
expect(findResolveItemsMessage().text()).toEqual(MERGE_DISABLED_TEXT);
});
it('should show disabled merge button', () => {
const button = findMergeButton();
expect(button.exists()).toBe(true);
expect(button.attributes('disabled')).toBe('disabled');
});
});
});
describe('when needs approval', () => {
beforeEach(() => {
factory({
isMergeAllowed: false,
availableAutoMergeStrategies: [],
hasApprovalsAvailable: true,
isApproved: false,
});
});
it('should show approvals needed text', () => {
expect(findResolveItemsMessage().text()).toEqual(MERGE_DISABLED_TEXT_UNAPPROVED);
});
});
}); });
...@@ -17818,7 +17818,10 @@ msgstr "" ...@@ -17818,7 +17818,10 @@ msgstr ""
msgid "You can only edit files when you are on a branch" msgid "You can only edit files when you are on a branch"
msgstr "" msgstr ""
msgid "You can only merge once the items above are resolved" msgid "You can only merge once the items above are resolved."
msgstr ""
msgid "You can only merge once this merge request is approved."
msgstr "" msgstr ""
msgid "You can only transfer the project to namespaces you manage." msgid "You can only transfer the project to namespaces you manage."
......
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