diff options
Diffstat (limited to 'spec/frontend/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js')
-rw-r--r-- | spec/frontend/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/spec/frontend/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js b/spec/frontend/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js index da3a323e8ea..46d90ddc83c 100644 --- a/spec/frontend/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js +++ b/spec/frontend/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js @@ -87,7 +87,11 @@ const createReadyToMergeResponse = (customMr) => { }); }; -const createComponent = (customConfig = {}, mergeRequestWidgetGraphql = false) => { +const createComponent = ( + customConfig = {}, + mergeRequestWidgetGraphql = false, + restructuredMrWidget = false, +) => { wrapper = shallowMount(ReadyToMerge, { localVue, propsData: { @@ -97,6 +101,7 @@ const createComponent = (customConfig = {}, mergeRequestWidgetGraphql = false) = provide: { glFeatures: { mergeRequestWidgetGraphql, + restructuredMrWidget, }, }, stubs: { @@ -307,6 +312,20 @@ describe('ReadyToMerge', () => { }, }); + beforeEach(() => { + readyToMergeResponseSpy = jest + .fn() + .mockResolvedValueOnce(createReadyToMergeResponse({ squash: true, squashOnMerge: true })) + .mockResolvedValue( + createReadyToMergeResponse({ + squash: true, + squashOnMerge: true, + defaultMergeCommitMessage: '', + defaultSquashCommitMessage: '', + }), + ); + }); + it('should handle merge when pipeline succeeds', async () => { createComponent(); @@ -379,6 +398,27 @@ describe('ReadyToMerge', () => { expect(params.should_remove_source_branch).toBeTruthy(); expect(params.auto_merge_strategy).toBeUndefined(); }); + + it('hides edit commit message', async () => { + createComponent({}, true, true); + + await waitForPromises(); + + jest.spyOn(eventHub, '$emit').mockImplementation(() => {}); + jest.spyOn(wrapper.vm.service, 'merge').mockResolvedValue(response('success')); + + await wrapper + .findComponent('[data-testid="widget_edit_commit_message"]') + .vm.$emit('input', true); + + expect(wrapper.findComponent('[data-testid="edit_commit_message"]').exists()).toBe(true); + + wrapper.vm.handleMergeButtonClick(); + + await waitForPromises(); + + expect(wrapper.findComponent('[data-testid="edit_commit_message"]').exists()).toBe(false); + }); }); describe('initiateRemoveSourceBranchPolling', () => { |