diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/frontend/design_management/pages/design/index_spec.js | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/frontend/design_management/pages/design/index_spec.js')
-rw-r--r-- | spec/frontend/design_management/pages/design/index_spec.js | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/spec/frontend/design_management/pages/design/index_spec.js b/spec/frontend/design_management/pages/design/index_spec.js index 430cf8722fe..82b607eb77d 100644 --- a/spec/frontend/design_management/pages/design/index_spec.js +++ b/spec/frontend/design_management/pages/design/index_spec.js @@ -5,8 +5,8 @@ import { ApolloMutation } from 'vue-apollo'; import createFlash from '~/flash'; import DesignIndex from '~/design_management/pages/design/index.vue'; import DesignSidebar from '~/design_management/components/design_sidebar.vue'; -import DesignReplyForm from '~/design_management/components/design_notes/design_reply_form.vue'; -import createImageDiffNoteMutation from '~/design_management/graphql/mutations/createImageDiffNote.mutation.graphql'; +import DesignPresentation from '~/design_management/components/design_presentation.vue'; +import createImageDiffNoteMutation from '~/design_management/graphql/mutations/create_image_diff_note.mutation.graphql'; import design from '../../mock_data/design'; import mockResponseWithDesigns from '../../mock_data/designs'; import mockResponseNoDesigns from '../../mock_data/no_designs'; @@ -26,6 +26,15 @@ jest.mock('mousetrap', () => ({ unbind: jest.fn(), })); +const focusInput = jest.fn(); + +const DesignReplyForm = { + template: '<div><textarea ref="textarea"></textarea></div>', + methods: { + focusInput, + }, +}; + const localVue = createLocalVue(); localVue.use(VueRouter); @@ -64,6 +73,7 @@ describe('Design management design index page', () => { const findDiscussionForm = () => wrapper.find(DesignReplyForm); const findSidebar = () => wrapper.find(DesignSidebar); + const findDesignPresentation = () => wrapper.find(DesignPresentation); function createComponent(loading = false, data = {}) { const $apollo = { @@ -83,6 +93,7 @@ describe('Design management design index page', () => { stubs: { ApolloMutation, DesignSidebar, + DesignReplyForm, }, data() { return { @@ -153,13 +164,29 @@ describe('Design management design index page', () => { }, }); - wrapper.vm.openCommentForm({ x: 0, y: 0 }); + findDesignPresentation().vm.$emit('openCommentForm', { x: 0, y: 0 }); return wrapper.vm.$nextTick().then(() => { expect(findDiscussionForm().exists()).toBe(true); }); }); + it('keeps new discussion form focused', () => { + createComponent(false, { + design: { + ...design, + discussions: { + nodes: [], + }, + }, + annotationCoordinates, + }); + + findDesignPresentation().vm.$emit('openCommentForm', { x: 10, y: 10 }); + + expect(focusInput).toHaveBeenCalled(); + }); + it('sends a mutation on submitting form and closes form', () => { createComponent(false, { design: { |