Added specs for testing when warning is visible
[ci skip]
This commit is contained in:
parent
6a14a51525
commit
982ab8703e
4 changed files with 77 additions and 17 deletions
|
@ -1,5 +1,4 @@
|
|||
<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
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
37
spec/javascripts/issue_show/components/form_spec.js
Normal file
37
spec/javascripts/issue_show/components/form_spec.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
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();
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue