Commit e6ae8dd6 authored by Denys Mishunov's avatar Denys Mishunov

Merge branch 'ph/33586/confirmCancelReply' into 'master'

Fixes confirm box not showing when users cancelling reply form

Closes #33586

See merge request gitlab-org/gitlab!30617
parents cd5f3d3e 34d378a1
...@@ -328,7 +328,8 @@ export default { ...@@ -328,7 +328,8 @@ export default {
<button <button
class="btn note-edit-cancel js-close-discussion-note-form" class="btn note-edit-cancel js-close-discussion-note-form"
type="button" type="button"
@click="cancelHandler()" data-testid="cancelBatchCommentsEnabled"
@click="cancelHandler(true)"
> >
{{ __('Cancel') }} {{ __('Cancel') }}
</button> </button>
...@@ -353,7 +354,8 @@ export default { ...@@ -353,7 +354,8 @@ export default {
<button <button
class="btn btn-cancel note-edit-cancel js-close-discussion-note-form" class="btn btn-cancel note-edit-cancel js-close-discussion-note-form"
type="button" type="button"
@click="cancelHandler()" data-testid="cancel"
@click="cancelHandler(true)"
> >
{{ __('Cancel') }} {{ __('Cancel') }}
</button> </button>
......
---
title: Fixed cancel reply button not alerting the user
merge_request:
author:
type: fixed
...@@ -67,6 +67,17 @@ describe('issue_note_form component', () => { ...@@ -67,6 +67,17 @@ describe('issue_note_form component', () => {
return store.dispatch('batchComments/enableBatchComments').then(vm.$nextTick); return store.dispatch('batchComments/enableBatchComments').then(vm.$nextTick);
}); });
it('should be possible to cancel', () => {
jest.spyOn(vm, 'cancelHandler');
return vm.$nextTick().then(() => {
const cancelButton = vm.$el.querySelector('[data-testid="cancelBatchCommentsEnabled"]');
cancelButton.click();
expect(vm.cancelHandler).toHaveBeenCalledWith(true);
});
});
it('shows resolve checkbox', () => { it('shows resolve checkbox', () => {
expect( expect(
vm.$el.querySelector('[data-qa-selector="resolve_review_discussion_checkbox"]'), vm.$el.querySelector('[data-qa-selector="resolve_review_discussion_checkbox"]'),
......
...@@ -235,7 +235,9 @@ describe 'Merge request > User posts diff notes', :js do ...@@ -235,7 +235,9 @@ describe 'Merge request > User posts diff notes', :js do
def should_allow_dismissing_a_comment(line_holder, diff_side = nil) def should_allow_dismissing_a_comment(line_holder, diff_side = nil)
write_comment_on_line(line_holder, diff_side) write_comment_on_line(line_holder, diff_side)
find('.js-close-discussion-note-form').click accept_confirm do
find('.js-close-discussion-note-form').click
end
assert_comment_dismissal(line_holder) assert_comment_dismissal(line_holder)
end end
......
...@@ -147,7 +147,10 @@ describe 'Merge request > User posts notes', :js do ...@@ -147,7 +147,10 @@ describe 'Merge request > User posts notes', :js do
it 'resets the edit note form textarea with the original content of the note if cancelled' do it 'resets the edit note form textarea with the original content of the note if cancelled' do
within('.current-note-edit-form') do within('.current-note-edit-form') do
fill_in 'note[note]', with: 'Some new content' fill_in 'note[note]', with: 'Some new content'
find('.btn-cancel').click
accept_confirm do
find('.btn-cancel').click
end
end end
expect(find('.js-note-text').text).to eq '' expect(find('.js-note-text').text).to eq ''
end end
......
...@@ -161,18 +161,18 @@ describe('issue_note_form component', () => { ...@@ -161,18 +161,18 @@ describe('issue_note_form component', () => {
describe('actions', () => { describe('actions', () => {
it('should be possible to cancel', () => { it('should be possible to cancel', () => {
// TODO: do not spy on vm const cancelHandler = jest.fn();
jest.spyOn(wrapper.vm, 'cancelHandler');
wrapper.setProps({ wrapper.setProps({
...props, ...props,
isEditing: true, isEditing: true,
}); });
wrapper.setMethods({ cancelHandler });
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
const cancelButton = wrapper.find('.note-edit-cancel'); const cancelButton = wrapper.find('[data-testid="cancel"]');
cancelButton.trigger('click'); cancelButton.trigger('click');
expect(wrapper.vm.cancelHandler).toHaveBeenCalled(); expect(cancelHandler).toHaveBeenCalledWith(true);
}); });
}); });
......
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