Commit 365ebd02 authored by Mark Florian's avatar Mark Florian

Merge branch 'vs-migrate-notes-to-jest' into 'master'

Migrate ee/notes to Jest

Closes #194297

See merge request gitlab-org/gitlab!27317
parents 0ae6cb7e 23eafed2
...@@ -3,7 +3,7 @@ import Vuex from 'vuex'; ...@@ -3,7 +3,7 @@ import Vuex from 'vuex';
import DiffLineNoteForm from '~/diffs/components/diff_line_note_form.vue'; import DiffLineNoteForm from '~/diffs/components/diff_line_note_form.vue';
import NoteForm from '~/notes/components/note_form.vue'; import NoteForm from '~/notes/components/note_form.vue';
import diffFileMockData from 'jest/diffs/mock_data/diff_file'; import diffFileMockData from 'jest/diffs/mock_data/diff_file';
import note from '../../notes/mock_data'; import note from 'jest/notes/mock_data';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
......
...@@ -2,7 +2,7 @@ import { shallowMount } from '@vue/test-utils'; ...@@ -2,7 +2,7 @@ import { shallowMount } from '@vue/test-utils';
import { TEST_HOST } from 'spec/test_constants'; import { TEST_HOST } from 'spec/test_constants';
import createStore from '~/notes/stores'; import createStore from '~/notes/stores';
import noteActions from '~/notes/components/note_actions.vue'; import noteActions from '~/notes/components/note_actions.vue';
import { userDataMock } from '../../../../spec/frontend/notes/mock_data'; import { userDataMock } from 'jest/notes/mock_data';
describe('noteActions', () => { describe('noteActions', () => {
let wrapper; let wrapper;
...@@ -48,7 +48,7 @@ describe('noteActions', () => { ...@@ -48,7 +48,7 @@ describe('noteActions', () => {
const resolveButton = wrapper.find({ ref: 'resolveButton' }); const resolveButton = wrapper.find({ ref: 'resolveButton' });
expect(resolveButton.exists()).toBe(true); expect(resolveButton.exists()).toBe(true);
expect(resolveButton.attributes('title')).toEqual('Thread stays unresolved'); expect(resolveButton.attributes('title')).toBe('Thread stays unresolved');
}); });
}); });
}); });
import Vue from 'vue'; import Vue from 'vue';
import { createStore } from 'ee/batch_comments/stores'; import { createStore } from 'ee/batch_comments/stores';
import { keyboardDownEvent } from 'spec/issue_show/helpers'; import { keyboardDownEvent } from 'jest/issue_show/helpers';
import { noteableDataMock, discussionMock, notesDataMock } from 'spec/notes/mock_data'; import { noteableDataMock, discussionMock, notesDataMock } from 'jest/notes/mock_data';
import diffsModule from '~/diffs/store/modules'; import diffsModule from '~/diffs/store/modules';
import notesModule from '~/notes/stores/modules'; import notesModule from '~/notes/stores/modules';
import issueNoteForm from '~/notes/components/note_form.vue'; import issueNoteForm from '~/notes/components/note_form.vue';
...@@ -45,7 +45,7 @@ describe('issue_note_form component', () => { ...@@ -45,7 +45,7 @@ describe('issue_note_form component', () => {
describe('on enter', () => { describe('on enter', () => {
it('should add comment when cmd+enter is pressed', () => { it('should add comment when cmd+enter is pressed', () => {
spyOn(vm, 'handleUpdate').and.callThrough(); jest.spyOn(vm, 'handleUpdate');
vm.$el.querySelector('textarea').value = 'Foo'; vm.$el.querySelector('textarea').value = 'Foo';
vm.$el.querySelector('textarea').dispatchEvent(keyboardDownEvent(13, true)); vm.$el.querySelector('textarea').dispatchEvent(keyboardDownEvent(13, true));
...@@ -53,7 +53,7 @@ describe('issue_note_form component', () => { ...@@ -53,7 +53,7 @@ describe('issue_note_form component', () => {
}); });
it('should add comment when ctrl+enter is pressed', () => { it('should add comment when ctrl+enter is pressed', () => {
spyOn(vm, 'handleUpdate').and.callThrough(); jest.spyOn(vm, 'handleUpdate');
vm.$el.querySelector('textarea').value = 'Foo'; vm.$el.querySelector('textarea').value = 'Foo';
vm.$el.querySelector('textarea').dispatchEvent(keyboardDownEvent(13, false, true)); vm.$el.querySelector('textarea').dispatchEvent(keyboardDownEvent(13, false, true));
...@@ -63,12 +63,8 @@ describe('issue_note_form component', () => { ...@@ -63,12 +63,8 @@ describe('issue_note_form component', () => {
}); });
describe('with batch comments', () => { describe('with batch comments', () => {
beforeEach(done => { beforeEach(() => {
store return store.dispatch('batchComments/enableBatchComments').then(vm.$nextTick);
.dispatch('batchComments/enableBatchComments')
.then(vm.$nextTick)
.then(done)
.catch(done.fail);
}); });
it('shows resolve checkbox', () => { it('shows resolve checkbox', () => {
...@@ -77,21 +73,19 @@ describe('issue_note_form component', () => { ...@@ -77,21 +73,19 @@ describe('issue_note_form component', () => {
).not.toBe(null); ).not.toBe(null);
}); });
it('hides actions for commits', done => { it('hides actions for commits', () => {
vm.discussion.for_commit = true; vm.discussion.for_commit = true;
vm.$nextTick(() => { return vm.$nextTick(() => {
expect(vm.$el.querySelector('.note-form-actions').textContent).not.toContain( expect(vm.$el.querySelector('.note-form-actions').textContent).not.toContain(
'Start a review', 'Start a review',
); );
done();
}); });
}); });
describe('on enter', () => { describe('on enter', () => {
it('should start review or add to review when cmd+enter is pressed', () => { it('should start review or add to review when cmd+enter is pressed', () => {
spyOn(vm, 'handleAddToReview').and.callThrough(); jest.spyOn(vm, 'handleAddToReview');
vm.$el.querySelector('textarea').value = 'Foo'; vm.$el.querySelector('textarea').value = 'Foo';
vm.$el.querySelector('textarea').dispatchEvent(keyboardDownEvent(13, true)); vm.$el.querySelector('textarea').dispatchEvent(keyboardDownEvent(13, true));
...@@ -99,7 +93,7 @@ describe('issue_note_form component', () => { ...@@ -99,7 +93,7 @@ describe('issue_note_form component', () => {
}); });
it('should start review or add to review when ctrl+enter is pressed', () => { it('should start review or add to review when ctrl+enter is pressed', () => {
spyOn(vm, 'handleAddToReview').and.callThrough(); jest.spyOn(vm, 'handleAddToReview');
vm.$el.querySelector('textarea').value = 'Foo'; vm.$el.querySelector('textarea').value = 'Foo';
vm.$el.querySelector('textarea').dispatchEvent(keyboardDownEvent(13, false, true)); vm.$el.querySelector('textarea').dispatchEvent(keyboardDownEvent(13, false, true));
......
This diff is collapsed.
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