summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-05-19 09:10:16 +0000
committerFilipa Lacerda <filipa@gitlab.com>2017-05-19 09:10:16 +0000
commit3c3b17a5a4b4f85f3f81f918a7e0c3a57f469eb7 (patch)
tree666184027fa57a31338248aa1ee230704b31bb53 /spec
parenteee88bca762d531256705ffe1c16767fe5bb2a6e (diff)
parent1c463586c4b1aa39f8c55ec7de684faa13aa5d8b (diff)
downloadgitlab-ce-3c3b17a5a4b4f85f3f81f918a7e0c3a57f469eb7.tar.gz
Merge branch 'issue-edit-inline-move-project' into 'issue-edit-inline'
Added move to project in issue inline edit form See merge request !11437
Diffstat (limited to 'spec')
-rw-r--r--spec/javascripts/issue_show/components/app_spec.js65
-rw-r--r--spec/javascripts/issue_show/components/fields/project_move_spec.js38
2 files changed, 96 insertions, 7 deletions
diff --git a/spec/javascripts/issue_show/components/app_spec.js b/spec/javascripts/issue_show/components/app_spec.js
index 646fb455d7c..91ae3cfd97c 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/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);
+ });
+});