summaryrefslogtreecommitdiff
path: root/spec/frontend/notes/components/note_form_spec.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 11:18:50 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 11:18:50 +0000
commit8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch)
treea77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/frontend/notes/components/note_form_spec.js
parent00b35af3db1abfe813a778f643dad221aad51fca (diff)
downloadgitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/frontend/notes/components/note_form_spec.js')
-rw-r--r--spec/frontend/notes/components/note_form_spec.js54
1 files changed, 53 insertions, 1 deletions
diff --git a/spec/frontend/notes/components/note_form_spec.js b/spec/frontend/notes/components/note_form_spec.js
index 8270c148fb5..15802841c57 100644
--- a/spec/frontend/notes/components/note_form_spec.js
+++ b/spec/frontend/notes/components/note_form_spec.js
@@ -1,8 +1,9 @@
import { shallowMount, createLocalVue } from '@vue/test-utils';
import createStore from '~/notes/stores';
import NoteForm from '~/notes/components/note_form.vue';
+import batchComments from '~/batch_comments/stores/modules/batch_comments';
import MarkdownField from '~/vue_shared/components/markdown/field.vue';
-import { noteableDataMock, notesDataMock } from '../mock_data';
+import { noteableDataMock, notesDataMock, discussionMock } from '../mock_data';
import { getDraft, updateDraft } from '~/lib/utils/autosave';
@@ -245,4 +246,55 @@ describe('issue_note_form component', () => {
expect(updateDraft).toHaveBeenCalledWith(dummyAutosaveKey, dummyContent);
});
});
+
+ describe('with batch comments', () => {
+ beforeEach(() => {
+ store.registerModule('batchComments', batchComments());
+
+ wrapper = createComponentWrapper();
+ wrapper.setProps({
+ ...props,
+ noteId: '',
+ discussion: { ...discussionMock, for_commit: false },
+ });
+ });
+
+ it('should be possible to cancel', () => {
+ jest.spyOn(wrapper.vm, 'cancelHandler');
+
+ return wrapper.vm.$nextTick().then(() => {
+ const cancelButton = wrapper.find('[data-testid="cancelBatchCommentsEnabled"]');
+ cancelButton.trigger('click');
+
+ expect(wrapper.vm.cancelHandler).toHaveBeenCalledWith(true);
+ });
+ });
+
+ it('shows resolve checkbox', () => {
+ expect(wrapper.find('.js-resolve-checkbox').exists()).toBe(true);
+ });
+
+ it('hides actions for commits', () => {
+ wrapper.setProps({ discussion: { for_commit: true } });
+
+ return wrapper.vm.$nextTick(() => {
+ expect(wrapper.find('.note-form-actions').text()).not.toContain('Start a review');
+ });
+ });
+
+ describe('on enter', () => {
+ it('should start review or add to review when cmd+enter is pressed', () => {
+ const textarea = wrapper.find('textarea');
+
+ jest.spyOn(wrapper.vm, 'handleAddToReview');
+
+ textarea.setValue('Foo');
+ textarea.trigger('keydown.enter', { metaKey: true });
+
+ return wrapper.vm.$nextTick(() => {
+ expect(wrapper.vm.handleAddToReview).toHaveBeenCalled();
+ });
+ });
+ });
+ });
});