Commit 466c5ea1 authored by Fatih Acet's avatar Fatih Acet

Merge branch 'winh-clear-batch-comment-draft-ee' into 'master'

Clear local drafts after submitting merge request review

Closes #11176

See merge request gitlab-org/gitlab-ee!11063
parents 65e7821f 482678d6
...@@ -3,6 +3,7 @@ import { TEXT_DIFF_POSITION_TYPE, IMAGE_DIFF_POSITION_TYPE } from '~/diffs/const ...@@ -3,6 +3,7 @@ import { TEXT_DIFF_POSITION_TYPE, IMAGE_DIFF_POSITION_TYPE } from '~/diffs/const
import { getDraftReplyFormData, getDraftFormData } from 'ee/batch_comments/utils'; import { getDraftReplyFormData, getDraftFormData } from 'ee/batch_comments/utils';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { clearDraft } from '~/lib/utils/autosave';
export default { export default {
computed: { computed: {
...@@ -78,7 +79,13 @@ export default { ...@@ -78,7 +79,13 @@ export default {
fileHash: this.diffFileHash, fileHash: this.diffFileHash,
}); });
this.$nextTick(() => { this.$nextTick(() => {
this.resetAutoSave(); if (this.autosaveKey) {
clearDraft(this.autosaveKey);
} else {
// TODO: remove the following after replacing the autosave mixin
// https://gitlab.com/gitlab-org/gitlab-ce/issues/60587
this.resetAutoSave();
}
}); });
}, },
showDraft(replyId) { showDraft(replyId) {
......
...@@ -167,6 +167,8 @@ describe 'Merge request > Batch comments', :js do ...@@ -167,6 +167,8 @@ describe 'Merge request > Batch comments', :js do
expect(page).to have_content('1/1 discussion resolved') expect(page).to have_content('1/1 discussion resolved')
expect(page).to have_selector('.line-resolve-btn.is-active') expect(page).to have_selector('.line-resolve-btn.is-active')
end end
expect_empty_local_draft
end end
end end
...@@ -210,6 +212,8 @@ describe 'Merge request > Batch comments', :js do ...@@ -210,6 +212,8 @@ describe 'Merge request > Batch comments', :js do
expect(page).to have_content('0/1 discussion resolved') expect(page).to have_content('0/1 discussion resolved')
expect(page).to have_selector('.line-resolve-btn.is-disabled') expect(page).to have_selector('.line-resolve-btn.is-disabled')
end end
expect_empty_local_draft
end end
end end
end end
...@@ -263,3 +267,10 @@ def write_reply_to_discussion(button_text: 'Start a review', text: 'Line is wron ...@@ -263,3 +267,10 @@ def write_reply_to_discussion(button_text: 'Start a review', text: 'Line is wron
wait_for_requests wait_for_requests
end end
def expect_empty_local_draft
page.within('.discussion-reply-holder') do
click_button('Reply...')
expect(find('#note_note').value).to eq('')
end
end
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