Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-18 17:02:45 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-18 17:02:45 +0300
commit80f61b4035607d7cd87de993b8f5e996bde3481f (patch)
tree06b12f51e97d87192e3dd0e05edf55143645b894 /spec/javascripts/issue_show
parent4ab54c2233e91f60a80e5b6fa2181e6899fdcc3e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/javascripts/issue_show')
-rw-r--r--spec/javascripts/issue_show/components/app_spec.js60
1 files changed, 49 insertions, 11 deletions
diff --git a/spec/javascripts/issue_show/components/app_spec.js b/spec/javascripts/issue_show/components/app_spec.js
index 2770743937e..c3d1440c34e 100644
--- a/spec/javascripts/issue_show/components/app_spec.js
+++ b/spec/javascripts/issue_show/components/app_spec.js
@@ -1,3 +1,5 @@
+/* eslint-disable no-unused-vars */
+import GLDropdown from '~/gl_dropdown';
import Vue from 'vue';
import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
@@ -52,6 +54,7 @@ describe('Issuable output', () => {
markdownDocsPath: '/',
projectNamespace: '/',
projectPath: '/',
+ issuableTemplateNamesPath: '/issuable-templates-path',
},
}).$mount();
@@ -129,11 +132,11 @@ describe('Issuable output', () => {
});
it('does not update formState if form is already open', done => {
- vm.openForm();
+ vm.updateAndShowForm();
vm.state.titleText = 'testing 123';
- vm.openForm();
+ vm.updateAndShowForm();
Vue.nextTick(() => {
expect(vm.store.formState.title).not.toBe('testing 123');
@@ -284,7 +287,7 @@ describe('Issuable output', () => {
});
});
- it('shows error mesage from backend if exists', done => {
+ it('shows error message from backend if exists', done => {
const msg = 'Custom error message from backend';
spyOn(vm.service, 'updateIssuable').and.callFake(
// eslint-disable-next-line prefer-promise-reject-errors
@@ -405,20 +408,20 @@ describe('Issuable output', () => {
});
});
- describe('open form', () => {
+ describe('updateAndShowForm', () => {
it('shows locked warning if form is open & data is different', done => {
vm.$nextTick()
.then(() => {
- vm.openForm();
+ vm.updateAndShowForm();
vm.poll.makeRequest();
+
+ return new Promise(resolve => {
+ vm.$watch('formState.lockedWarningVisible', value => {
+ if (value) resolve();
+ });
+ });
})
- // Wait for the request
- .then(vm.$nextTick)
- // Wait for the successCallback to update the store state
- .then(vm.$nextTick)
- // Wait for the new state to flow to the Vue components
- .then(vm.$nextTick)
.then(() => {
expect(vm.formState.lockedWarningVisible).toEqual(true);
expect(vm.formState.lock_version).toEqual(1);
@@ -429,6 +432,41 @@ describe('Issuable output', () => {
});
});
+ describe('requestTemplatesAndShowForm', () => {
+ beforeEach(() => {
+ spyOn(vm, 'updateAndShowForm');
+ });
+
+ it('shows the form if template names request is successful', done => {
+ const mockData = [{ name: 'Bug' }];
+ mock.onGet('/issuable-templates-path').reply(() => Promise.resolve([200, mockData]));
+
+ vm.requestTemplatesAndShowForm()
+ .then(() => {
+ expect(vm.updateAndShowForm).toHaveBeenCalledWith(mockData);
+ })
+ .then(done)
+ .catch(done.fail);
+ });
+
+ it('shows the form if template names request failed', done => {
+ mock
+ .onGet('/issuable-templates-path')
+ .reply(() => Promise.reject(new Error('something went wrong')));
+
+ vm.requestTemplatesAndShowForm()
+ .then(() => {
+ expect(document.querySelector('.flash-container .flash-text').textContent).toContain(
+ 'Error updating issue',
+ );
+
+ expect(vm.updateAndShowForm).toHaveBeenCalledWith();
+ })
+ .then(done)
+ .catch(done.fail);
+ });
+ });
+
describe('show inline edit button', () => {
it('should not render by default', () => {
expect(vm.$el.querySelector('.title-container .note-action-button')).toBeDefined();