Commit 982ab870 authored by Phil Hughes's avatar Phil Hughes

Added specs for testing when warning is visible

[ci skip]
parent 6a14a515
<script>
import eventHub from '../event_hub';
import lockedWarning from './locked_warning.vue';
import titleField from './fields/title.vue';
import descriptionField from './fields/description.vue';
......@@ -32,20 +31,12 @@
editActions,
confidentialCheckbox,
},
methods: {
closeForm() {
eventHub.$emit('close.form');
this.formState.lockedWarningVisible = false;
},
},
};
</script>
<template>
<form>
<locked-warning
v-if="formState.lockedWarningVisible"
@closeForm="closeForm" />
<locked-warning v-if="formState.lockedWarningVisible" />
<title-field
:form-state="formState" />
<confidential-checkbox
......
<script>
export default {
methods: {
closeForm() {
this.$emit('closeForm');
computed: {
currentPath() {
return location.pathname;
},
},
};
......@@ -10,11 +10,11 @@
<template>
<div class="alert alert-danger">
Someone edited the issue the same time you did. Please check out
Someone edited the issue at the same time you did. Please check out
<a
href="#"
role="button"
@click.prevent="closeForm">the issue</a>
:href="currentPath"
target="_blank"
role="button">the issue</a>
and make sure your changes will not unintentionally remove theirs.
</div>
</template>
......@@ -234,4 +234,36 @@ describe('Issuable output', () => {
});
});
});
describe('open form', () => {
it('shows locked warning if form is open & data is different', (done) => {
Vue.http.interceptors.push(issueShowInterceptor(issueShowData.initialRequest));
Vue.nextTick()
.then(() => new Promise((resolve) => {
setTimeout(resolve);
}))
.then(() => {
vm.openForm();
Vue.http.interceptors.push(issueShowInterceptor(issueShowData.secondRequest));
return new Promise((resolve) => {
setTimeout(resolve);
});
})
.then(() => {
expect(
vm.formState.lockedWarningVisible,
).toBeTruthy();
expect(
vm.$el.querySelector('.alert'),
).not.toBeNull();
done();
})
.catch(done.fail);
});
});
});
import Vue from 'vue';
import formComponent from '~/issue_show/components/form.vue';
describe('Inline edit form component', () => {
let vm;
beforeEach((done) => {
const Component = Vue.extend(formComponent);
vm = new Component({
propsData: {
canDestroy: true,
formState: {
title: 'b',
description: 'a',
lockedWarningVisible: false,
},
markdownPreviewUrl: '/',
markdownDocs: '/',
},
}).$mount();
Vue.nextTick(done);
});
it('shows locked warning if formState is different', (done) => {
vm.formState.lockedWarningVisible = true;
Vue.nextTick(() => {
expect(
vm.$el.querySelector('.alert'),
).not.toBeNull();
done();
});
});
});
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