diff --git a/app/assets/javascripts/notes/components/comment_form.vue b/app/assets/javascripts/notes/components/comment_form.vue index 33d6a60ba84c8acbcb6d71e47a185a2f0fc225ff..68206f0bc0b00c8673b30f09a3792e1f39aab38f 100644 --- a/app/assets/javascripts/notes/components/comment_form.vue +++ b/app/assets/javascripts/notes/components/comment_form.vue @@ -172,6 +172,11 @@ export default { isEpic() { return constants.NOTEABLE_TYPE_MAPPING[this.noteableType] === constants.EPIC_NOTEABLE_TYPE; }, + isMergeRequest() { + return ( + constants.NOTEABLE_TYPE_MAPPING[this.noteableType] === constants.MERGE_REQUEST_NOTEABLE_TYPE + ); + }, trackingLabel() { return slugifyWithUnderscore(`${this.commentButtonTitle} button`); }, @@ -186,11 +191,6 @@ export default { return null; }, - commentNowButtonTitle() { - return this.noteType === constants.COMMENT - ? this.$options.i18n.addCommentNow - : this.$options.i18n.addThreadNow; - }, }, watch: { noteIsInternal(val) { @@ -237,7 +237,7 @@ export default { isDraft, }; - if (this.noteType === constants.DISCUSSION) { + if (this.noteType === constants.DISCUSSION || isDraft) { noteData.data.note.type = constants.DISCUSSION_NOTE; } @@ -407,24 +407,23 @@ export default { /> { const findCloseReopenButton = () => wrapper.findByTestId('close-reopen-button'); const findMarkdownEditor = () => wrapper.findComponent(MarkdownEditor); const findMarkdownEditorTextarea = () => findMarkdownEditor().find('textarea'); - const findAddToReviewDropdown = () => wrapper.findByTestId('add-to-review-dropdown'); - const findAddToReviewButton = () => findAddToReviewDropdown().find('button'); + const findStartReviewButton = () => wrapper.findByTestId('start-review-button'); + const findAddToReviewButton = () => wrapper.findByTestId('add-to-review-button'); const findAddCommentNowButton = () => wrapper.findByTestId('add-comment-now-button'); const findConfidentialNoteCheckbox = () => wrapper.findByTestId('internal-note-checkbox'); const findInternalNoteTooltipIcon = () => wrapper.findByTestId('question-o-icon'); @@ -466,6 +466,7 @@ describe('issue_comment_form component', () => { note: 'a', noteable_id: noteableDataMock.id, noteable_type: 'Issue', + type: 'DiscussionNote', }, }, endpoint: notesDataMock.draftsPath, @@ -485,6 +486,7 @@ describe('issue_comment_form component', () => { note: 'a', noteable_id: noteableDataMock.id, noteable_type: 'Issue', + type: 'DiscussionNote', }, }, endpoint: notesDataMock.draftsPath, @@ -865,7 +867,7 @@ describe('issue_comment_form component', () => { }); describe('with batchComments in store', () => { - describe('add to review and comment now buttons', () => { + describe('start review, add to review and comment now buttons', () => { let store; beforeEach(() => { @@ -873,10 +875,19 @@ describe('issue_comment_form component', () => { store.registerModule('batchComments', batchComments()); }); - it('when no drafts exist, should not render', () => { + it('when no drafts exist on non-merge request, should not render', () => { mountComponent({ store }); expect(findCommentTypeDropdown().exists()).toBe(true); - expect(findAddToReviewDropdown().exists()).toBe(false); + expect(findStartReviewButton().exists()).toBe(false); + expect(findAddToReviewButton().exists()).toBe(false); + expect(findAddCommentNowButton().exists()).toBe(false); + }); + + it('when no drafts exist in a merge request, should render', () => { + mountComponent({ noteableType: constants.MERGE_REQUEST_NOTEABLE_TYPE, store }); + expect(findCommentTypeDropdown().exists()).toBe(true); + expect(findStartReviewButton().exists()).toBe(true); + expect(findAddToReviewButton().exists()).toBe(false); expect(findAddCommentNowButton().exists()).toBe(false); }); @@ -885,11 +896,12 @@ describe('issue_comment_form component', () => { store.state.batchComments.drafts = [{ note: 'A' }]; }); - it('should render', async () => { + it('should render proper action elements', async () => { await mountComponent({ store }); expect(findCommentTypeDropdown().exists()).toBe(false); - expect(findAddToReviewDropdown().exists()).toBe(true); + expect(findAddToReviewButton().exists()).toBe(true); expect(findAddCommentNowButton().exists()).toBe(true); + expect(findStartReviewButton().exists()).toBe(false); }); it('clicking `add to review`, should call draft endpoint, set `isDraft` true', async () => {