diff options
author | Phil Hughes <me@iamphill.com> | 2017-05-22 09:13:49 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-05-22 09:13:49 +0100 |
commit | 16243985c2e2a44af91f6082c4d0f3b506d30cc5 (patch) | |
tree | 3006892f50a0b4879e8d70a1f725d94f3e898d7c /spec/javascripts/issue_show | |
parent | 982ab8703e7f2979cb7ac01e08f31f429fe71f43 (diff) | |
parent | 3c3b17a5a4b4f85f3f81f918a7e0c3a57f469eb7 (diff) | |
download | gitlab-ce-16243985c2e2a44af91f6082c4d0f3b506d30cc5.tar.gz |
Merge branch 'issue-edit-inline' into issue-edit-inline-locked-warning
[ci skip]
Diffstat (limited to 'spec/javascripts/issue_show')
3 files changed, 124 insertions, 13 deletions
diff --git a/spec/javascripts/issue_show/components/app_spec.js b/spec/javascripts/issue_show/components/app_spec.js index 0a7416441fa..3247f83d551 100644 --- a/spec/javascripts/issue_show/components/app_spec.js +++ b/spec/javascripts/issue_show/components/app_spec.js @@ -23,20 +23,22 @@ describe('Issuable output', () => { const IssuableDescriptionComponent = Vue.extend(issuableApp); Vue.http.interceptors.push(issueShowInterceptor(issueShowData.initialRequest)); - spyOn(eventHub, '$emit').and.callThrough(); + spyOn(eventHub, '$emit'); vm = new IssuableDescriptionComponent({ propsData: { canUpdate: true, canDestroy: true, + canMove: true, endpoint: '/gitlab-org/gitlab-shell/issues/9/realtime_changes', issuableRef: '#1', initialTitle: '', initialDescriptionHtml: '', initialDescriptionText: '', - isConfidential: false, markdownPreviewUrl: '/', markdownDocs: '/', + projectsAutocompleteUrl: '/', + isConfidential: false, }, }).$mount(); }); @@ -107,6 +109,30 @@ describe('Issuable output', () => { }); describe('updateIssuable', () => { + it('reloads the page if the confidential status has changed', (done) => { + spyOn(gl.utils, 'visitUrl'); + spyOn(vm.service, 'updateIssuable').and.callFake(() => new Promise((resolve) => { + resolve({ + json() { + return { + confidential: true, + path: location.pathname, + }; + }, + }); + })); + + vm.updateIssuable(); + + setTimeout(() => { + expect( + gl.utils.visitUrl, + ).toHaveBeenCalledWith(location.pathname); + + done(); + }); + }); + it('correctly updates issuable data', (done) => { spyOn(vm.service, 'updateIssuable').and.callFake(() => new Promise((resolve) => { resolve(); @@ -126,13 +152,38 @@ describe('Issuable output', () => { }); }); - it('reloads the page if the confidential status has changed', (done) => { - spyOn(window.location, 'reload'); + it('does not redirect if issue has not moved', (done) => { + spyOn(gl.utils, 'visitUrl'); spyOn(vm.service, 'updateIssuable').and.callFake(() => new Promise((resolve) => { resolve({ json() { return { - confidential: true, + path: location.pathname, + confidential: vm.isConfidential, + }; + }, + }); + })); + + vm.updateIssuable(); + + setTimeout(() => { + expect( + gl.utils.visitUrl, + ).not.toHaveBeenCalled(); + + done(); + }); + }); + + it('redirects if issue is moved', (done) => { + spyOn(gl.utils, 'visitUrl'); + spyOn(vm.service, 'updateIssuable').and.callFake(() => new Promise((resolve) => { + resolve({ + json() { + return { + path: '/testing-issue-move', + confidential: vm.isConfidential, }; }, }); @@ -142,8 +193,8 @@ describe('Issuable output', () => { setTimeout(() => { expect( - window.location.reload, - ).toHaveBeenCalled(); + gl.utils.visitUrl, + ).toHaveBeenCalledWith('/testing-issue-move'); done(); }); diff --git a/spec/javascripts/issue_show/components/fields/description_spec.js b/spec/javascripts/issue_show/components/fields/description_spec.js index cdb5c9ab862..f5b35b1e8b0 100644 --- a/spec/javascripts/issue_show/components/fields/description_spec.js +++ b/spec/javascripts/issue_show/components/fields/description_spec.js @@ -1,31 +1,53 @@ import Vue from 'vue'; +import Store from '~/issue_show/stores'; import descriptionField from '~/issue_show/components/fields/description.vue'; describe('Description field component', () => { let vm; + let store; beforeEach((done) => { const Component = Vue.extend(descriptionField); - - // Needs an el in the DOM to be able to test the element is focused const el = document.createElement('div'); + store = new Store({ + titleHtml: '', + descriptionHtml: '', + issuableRef: '', + }); + store.formState.description = 'test'; document.body.appendChild(el); vm = new Component({ el, propsData: { - formState: { - description: '', - }, - markdownDocs: '/', markdownPreviewUrl: '/', + markdownDocs: '/', + formState: store.formState, }, }).$mount(); Vue.nextTick(done); }); + it('renders markdown field with description', () => { + expect( + vm.$el.querySelector('.md-area textarea').value, + ).toBe('test'); + }); + + it('renders markdown field with a markdown description', (done) => { + store.formState.description = '**test**'; + + Vue.nextTick(() => { + expect( + vm.$el.querySelector('.md-area textarea').value, + ).toBe('**test**'); + + done(); + }); + }); + it('focuses field when mounted', () => { expect( document.activeElement, diff --git a/spec/javascripts/issue_show/components/fields/project_move_spec.js b/spec/javascripts/issue_show/components/fields/project_move_spec.js new file mode 100644 index 00000000000..86d35c33ff4 --- /dev/null +++ b/spec/javascripts/issue_show/components/fields/project_move_spec.js @@ -0,0 +1,38 @@ +import Vue from 'vue'; +import projectMove from '~/issue_show/components/fields/project_move.vue'; + +describe('Project move field component', () => { + let vm; + let formState; + + beforeEach((done) => { + const Component = Vue.extend(projectMove); + + formState = { + move_to_project_id: 0, + }; + + vm = new Component({ + propsData: { + formState, + projectsAutocompleteUrl: '/autocomplete', + }, + }).$mount(); + + Vue.nextTick(done); + }); + + it('mounts select2 element', () => { + expect( + vm.$el.querySelector('.select2-container'), + ).not.toBeNull(); + }); + + it('updates formState on change', () => { + $(vm.$refs['move-dropdown']).val(2).trigger('change'); + + expect( + formState.move_to_project_id, + ).toBe(2); + }); +}); |