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

Added specs for testing when warning is visible

[ci skip]
parent 6a14a515
<script> <script>
import eventHub from '../event_hub';
import lockedWarning from './locked_warning.vue'; import lockedWarning from './locked_warning.vue';
import titleField from './fields/title.vue'; import titleField from './fields/title.vue';
import descriptionField from './fields/description.vue'; import descriptionField from './fields/description.vue';
...@@ -32,20 +31,12 @@ ...@@ -32,20 +31,12 @@
editActions, editActions,
confidentialCheckbox, confidentialCheckbox,
}, },
methods: {
closeForm() {
eventHub.$emit('close.form');
this.formState.lockedWarningVisible = false;
},
},
}; };
</script> </script>
<template> <template>
<form> <form>
<locked-warning <locked-warning v-if="formState.lockedWarningVisible" />
v-if="formState.lockedWarningVisible"
@closeForm="closeForm" />
<title-field <title-field
:form-state="formState" /> :form-state="formState" />
<confidential-checkbox <confidential-checkbox
......
<script> <script>
export default { export default {
methods: { computed: {
closeForm() { currentPath() {
this.$emit('closeForm'); return location.pathname;
}, },
}, },
}; };
...@@ -10,11 +10,11 @@ ...@@ -10,11 +10,11 @@
<template> <template>
<div class="alert alert-danger"> <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 <a
href="#" :href="currentPath"
role="button" target="_blank"
@click.prevent="closeForm">the issue</a> role="button">the issue</a>
and make sure your changes will not unintentionally remove theirs. and make sure your changes will not unintentionally remove theirs.
</div> </div>
</template> </template>
...@@ -234,4 +234,36 @@ describe('Issuable output', () => { ...@@ -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