Commit c85cbc08 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch...

Merge branch '44036-someone-edited-the-issue-at-the-same-time-is-regularly-seen-despite-that-being-a-filthy-lie' into 'master'

Fix incorrectly displayed conflict warning

See merge request gitlab-org/gitlab-ce!31469
parents 0d9068b4 45064348
...@@ -70,6 +70,9 @@ export default { ...@@ -70,6 +70,9 @@ export default {
hasIssuableTemplates() { hasIssuableTemplates() {
return this.issuableTemplates.length; return this.issuableTemplates.length;
}, },
showLockedWarning() {
return this.formState.lockedWarningVisible && !this.formState.updateLoading;
},
}, },
created() { created() {
eventHub.$on('delete.issuable', this.resetAutosave); eventHub.$on('delete.issuable', this.resetAutosave);
...@@ -117,7 +120,7 @@ export default { ...@@ -117,7 +120,7 @@ export default {
<template> <template>
<form> <form>
<locked-warning v-if="formState.lockedWarningVisible" /> <locked-warning v-if="showLockedWarning" />
<div class="row"> <div class="row">
<div v-if="hasIssuableTemplates" class="col-sm-4 col-lg-3"> <div v-if="hasIssuableTemplates" class="col-sm-4 col-lg-3">
<description-template <description-template
......
---
title: Fix flashing conflict warning when editing issues
merge_request: 31469
author:
type: fixed
import Vue from 'vue'; import Vue from 'vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
import formComponent from '~/issue_show/components/form.vue'; import formComponent from '~/issue_show/components/form.vue';
import eventHub from '~/issue_show/event_hub'; import eventHub from '~/issue_show/event_hub';
describe('Inline edit form component', () => { describe('Inline edit form component', () => {
let vm; let vm;
let autosave; const defaultProps = {
let autosaveObj; canDestroy: true,
formState: {
beforeEach(done => { title: 'b',
autosaveObj = { reset: jasmine.createSpy() }; description: 'a',
lockedWarningVisible: false,
autosave = spyOnDependency(formComponent, 'Autosave').and.returnValue(autosaveObj); },
issuableType: 'issue',
markdownPreviewPath: '/',
markdownDocsPath: '/',
projectPath: '/',
projectNamespace: '/',
};
afterEach(() => {
vm.$destroy();
});
const createComponent = props => {
const Component = Vue.extend(formComponent); const Component = Vue.extend(formComponent);
vm = new Component({ vm = mountComponent(Component, {
propsData: { ...defaultProps,
canDestroy: true, ...props,
formState: { });
title: 'b', };
description: 'a',
lockedWarningVisible: false,
},
issuableType: 'issue',
markdownPreviewPath: '/',
markdownDocsPath: '/',
projectPath: '/',
projectNamespace: '/',
},
}).$mount();
Vue.nextTick(done);
});
it('does not render template selector if no templates exist', () => { it('does not render template selector if no templates exist', () => {
createComponent();
expect(vm.$el.querySelector('.js-issuable-selector-wrap')).toBeNull(); expect(vm.$el.querySelector('.js-issuable-selector-wrap')).toBeNull();
}); });
it('renders template selector when templates exists', done => { it('renders template selector when templates exists', () => {
vm.issuableTemplates = ['test']; createComponent({ issuableTemplates: ['test'] });
Vue.nextTick(() => {
expect(vm.$el.querySelector('.js-issuable-selector-wrap')).not.toBeNull();
done(); expect(vm.$el.querySelector('.js-issuable-selector-wrap')).not.toBeNull();
});
}); });
it('hides locked warning by default', () => { it('hides locked warning by default', () => {
createComponent();
expect(vm.$el.querySelector('.alert')).toBeNull(); expect(vm.$el.querySelector('.alert')).toBeNull();
}); });
it('shows locked warning if formState is different', done => { it('shows locked warning if formState is different', () => {
vm.formState.lockedWarningVisible = true; createComponent({ formState: { ...defaultProps.formState, lockedWarningVisible: true } });
Vue.nextTick(() => { expect(vm.$el.querySelector('.alert')).not.toBeNull();
expect(vm.$el.querySelector('.alert')).not.toBeNull(); });
done(); it('hides locked warning when currently saving', () => {
createComponent({
formState: { ...defaultProps.formState, updateLoading: true, lockedWarningVisible: true },
}); });
});
it('initialized Autosave on mount', () => { expect(vm.$el.querySelector('.alert')).toBeNull();
expect(autosave).toHaveBeenCalledTimes(2);
}); });
it('calls reset on autosave when eventHub emits appropriate events', () => { describe('autosave', () => {
eventHub.$emit('close.form'); let autosaveObj;
let autosave;
beforeEach(() => {
autosaveObj = { reset: jasmine.createSpy() };
autosave = spyOnDependency(formComponent, 'Autosave').and.returnValue(autosaveObj);
});
it('initialized Autosave on mount', () => {
createComponent();
expect(autosaveObj.reset).toHaveBeenCalledTimes(2); expect(autosave).toHaveBeenCalledTimes(2);
});
it('calls reset on autosave when eventHub emits appropriate events', () => {
createComponent();
eventHub.$emit('close.form');
eventHub.$emit('delete.issuable'); expect(autosaveObj.reset).toHaveBeenCalledTimes(2);
expect(autosaveObj.reset).toHaveBeenCalledTimes(4); eventHub.$emit('delete.issuable');
eventHub.$emit('update.issuable'); expect(autosaveObj.reset).toHaveBeenCalledTimes(4);
expect(autosaveObj.reset).toHaveBeenCalledTimes(6); eventHub.$emit('update.issuable');
expect(autosaveObj.reset).toHaveBeenCalledTimes(6);
});
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment