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
This commit is contained in:
Filipa Lacerda 2019-08-12 09:27:45 +00:00
commit c85cbc08f7
3 changed files with 82 additions and 57 deletions

View file

@ -70,6 +70,9 @@ export default {
hasIssuableTemplates() {
return this.issuableTemplates.length;
},
showLockedWarning() {
return this.formState.lockedWarningVisible && !this.formState.updateLoading;
},
},
created() {
eventHub.$on('delete.issuable', this.resetAutosave);
@ -117,7 +120,7 @@ export default {
<template>
<form>
<locked-warning v-if="formState.lockedWarningVisible" />
<locked-warning v-if="showLockedWarning" />
<div class="row">
<div v-if="hasIssuableTemplates" class="col-sm-4 col-lg-3">
<description-template

View file

@ -0,0 +1,5 @@
---
title: Fix flashing conflict warning when editing issues
merge_request: 31469
author:
type: fixed

View file

@ -1,21 +1,11 @@
import Vue from 'vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
import formComponent from '~/issue_show/components/form.vue';
import eventHub from '~/issue_show/event_hub';
describe('Inline edit form component', () => {
let vm;
let autosave;
let autosaveObj;
beforeEach(done => {
autosaveObj = { reset: jasmine.createSpy() };
autosave = spyOnDependency(formComponent, 'Autosave').and.returnValue(autosaveObj);
const Component = Vue.extend(formComponent);
vm = new Component({
propsData: {
const defaultProps = {
canDestroy: true,
formState: {
title: 'b',
@ -27,45 +17,71 @@ describe('Inline edit form component', () => {
markdownDocsPath: '/',
projectPath: '/',
projectNamespace: '/',
},
}).$mount();
};
Vue.nextTick(done);
afterEach(() => {
vm.$destroy();
});
const createComponent = props => {
const Component = Vue.extend(formComponent);
vm = mountComponent(Component, {
...defaultProps,
...props,
});
};
it('does not render template selector if no templates exist', () => {
createComponent();
expect(vm.$el.querySelector('.js-issuable-selector-wrap')).toBeNull();
});
it('renders template selector when templates exists', done => {
vm.issuableTemplates = ['test'];
it('renders template selector when templates exists', () => {
createComponent({ issuableTemplates: ['test'] });
Vue.nextTick(() => {
expect(vm.$el.querySelector('.js-issuable-selector-wrap')).not.toBeNull();
done();
});
});
it('hides locked warning by default', () => {
createComponent();
expect(vm.$el.querySelector('.alert')).toBeNull();
});
it('shows locked warning if formState is different', done => {
vm.formState.lockedWarningVisible = true;
it('shows locked warning if formState is different', () => {
createComponent({ formState: { ...defaultProps.formState, lockedWarningVisible: true } });
Vue.nextTick(() => {
expect(vm.$el.querySelector('.alert')).not.toBeNull();
done();
});
it('hides locked warning when currently saving', () => {
createComponent({
formState: { ...defaultProps.formState, updateLoading: true, lockedWarningVisible: true },
});
expect(vm.$el.querySelector('.alert')).toBeNull();
});
describe('autosave', () => {
let autosaveObj;
let autosave;
beforeEach(() => {
autosaveObj = { reset: jasmine.createSpy() };
autosave = spyOnDependency(formComponent, 'Autosave').and.returnValue(autosaveObj);
});
it('initialized Autosave on mount', () => {
createComponent();
expect(autosave).toHaveBeenCalledTimes(2);
});
it('calls reset on autosave when eventHub emits appropriate events', () => {
createComponent();
eventHub.$emit('close.form');
expect(autosaveObj.reset).toHaveBeenCalledTimes(2);
@ -78,4 +94,5 @@ describe('Inline edit form component', () => {
expect(autosaveObj.reset).toHaveBeenCalledTimes(6);
});
});
});