summaryrefslogtreecommitdiff
path: root/spec/javascripts
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2018-12-21 01:19:41 +0100
committerFatih Acet <acetfatih@gmail.com>2019-01-30 23:18:13 +0100
commit45eabf921a9bb90677d1e4f59544f0a7abcbc879 (patch)
tree899251bb4eb01d0d4b3ac9a6f9c6189f3912af55 /spec/javascripts
parent8bcd508b4c7f559f27db3c05b6ae4a3a33dfff95 (diff)
downloadgitlab-ce-45eabf921a9bb90677d1e4f59544f0a7abcbc879.tar.gz
Accept lockVersion as a prop and add to store
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/issue_show/components/app_spec.js26
-rw-r--r--spec/javascripts/issue_show/mock_data.js2
2 files changed, 22 insertions, 6 deletions
diff --git a/spec/javascripts/issue_show/components/app_spec.js b/spec/javascripts/issue_show/components/app_spec.js
index 2bd1b3996dc..9b2b6b670c3 100644
--- a/spec/javascripts/issue_show/components/app_spec.js
+++ b/spec/javascripts/issue_show/components/app_spec.js
@@ -43,6 +43,7 @@ describe('Issuable output', () => {
initialTitleText: '',
initialDescriptionHtml: 'test',
initialDescriptionText: 'test',
+ lockVersion: 1,
markdownPreviewPath: '/',
markdownDocsPath: '/',
projectNamespace: '/',
@@ -78,6 +79,7 @@ describe('Issuable output', () => {
expect(formatText(editedText.innerText)).toMatch(/Edited[\s\S]+?by Some User/);
expect(editedText.querySelector('.author-link').href).toMatch(/\/some_user$/);
expect(editedText.querySelector('time')).toBeTruthy();
+ expect(vm.state.lock_version).toEqual(1);
})
.then(() => {
vm.poll.makeRequest();
@@ -95,6 +97,7 @@ describe('Issuable output', () => {
expect(editedText.querySelector('.author-link').href).toMatch(/\/other_user$/);
expect(editedText.querySelector('time')).toBeTruthy();
+ expect(vm.state.lock_version).toEqual(2);
})
.then(done)
.catch(done.fail);
@@ -255,15 +258,10 @@ describe('Issuable output', () => {
describe('error when updating', () => {
beforeEach(() => {
spyOn(window, 'Flash').and.callThrough();
- spyOn(vm.service, 'updateIssuable').and.callFake(
- () =>
- new Promise((resolve, reject) => {
- reject();
- }),
- );
});
it('closes form on error', done => {
+ spyOn(vm.service, 'updateIssuable').and.callFake(() => Promise.resolve());
vm.updateIssuable();
setTimeout(() => {
@@ -276,6 +274,7 @@ describe('Issuable output', () => {
});
it('returns the correct error message for issuableType', done => {
+ spyOn(vm.service, 'updateIssuable').and.callFake(() => Promise.reject());
vm.issuableType = 'merge request';
Vue.nextTick(() => {
@@ -290,6 +289,20 @@ describe('Issuable output', () => {
});
});
});
+
+ it('shows error mesage from backend if exists', done => {
+ const msg = 'Custom error message from backend';
+ spyOn(vm.service, 'updateIssuable').and.callFake(() =>
+ Promise.reject({ response: { data: { errors: msg } } }), // eslint-disable-line prefer-promise-reject-errors
+ );
+
+ vm.updateIssuable();
+ setTimeout(() => {
+ expect(window.Flash).toHaveBeenCalledWith(msg);
+
+ done();
+ });
+ });
});
});
@@ -420,6 +433,7 @@ describe('Issuable output', () => {
.then(vm.$nextTick)
.then(() => {
expect(vm.formState.lockedWarningVisible).toEqual(true);
+ expect(vm.formState.lock_version).toEqual(1);
expect(vm.$el.querySelector('.alert')).not.toBeNull();
})
.then(done)
diff --git a/spec/javascripts/issue_show/mock_data.js b/spec/javascripts/issue_show/mock_data.js
index 74b3efb014b..f4475aadb8b 100644
--- a/spec/javascripts/issue_show/mock_data.js
+++ b/spec/javascripts/issue_show/mock_data.js
@@ -8,6 +8,7 @@ export default {
updated_at: '2015-05-15T12:31:04.428Z',
updated_by_name: 'Some User',
updated_by_path: '/some_user',
+ lock_version: 1,
},
secondRequest: {
title: '<p>2</p>',
@@ -18,5 +19,6 @@ export default {
updated_at: '2016-05-15T12:31:04.428Z',
updated_by_name: 'Other User',
updated_by_path: '/other_user',
+ lock_version: 2,
},
};