summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-05-18 17:37:37 +0100
committerPhil Hughes <me@iamphill.com>2017-05-18 17:37:37 +0100
commit982ab8703e7f2979cb7ac01e08f31f429fe71f43 (patch)
tree953e60bf4106723d8e8cf14d6c6b205ea3c46d93
parent6a14a51525beddcdaac99f5350964df80ae868a6 (diff)
downloadgitlab-ce-982ab8703e7f2979cb7ac01e08f31f429fe71f43.tar.gz
Added specs for testing when warning is visible
[ci skip]
-rw-r--r--app/assets/javascripts/issue_show/components/form.vue11
-rw-r--r--app/assets/javascripts/issue_show/components/locked_warning.vue14
-rw-r--r--spec/javascripts/issue_show/components/app_spec.js32
-rw-r--r--spec/javascripts/issue_show/components/form_spec.js37
4 files changed, 77 insertions, 17 deletions
diff --git a/app/assets/javascripts/issue_show/components/form.vue b/app/assets/javascripts/issue_show/components/form.vue
index e53860a77af..db80bc09be0 100644
--- a/app/assets/javascripts/issue_show/components/form.vue
+++ b/app/assets/javascripts/issue_show/components/form.vue
@@ -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
diff --git a/app/assets/javascripts/issue_show/components/locked_warning.vue b/app/assets/javascripts/issue_show/components/locked_warning.vue
index b9960b4e5f2..c31bb80d782 100644
--- a/app/assets/javascripts/issue_show/components/locked_warning.vue
+++ b/app/assets/javascripts/issue_show/components/locked_warning.vue
@@ -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>
diff --git a/spec/javascripts/issue_show/components/app_spec.js b/spec/javascripts/issue_show/components/app_spec.js
index 646fb455d7c..0a7416441fa 100644
--- a/spec/javascripts/issue_show/components/app_spec.js
+++ b/spec/javascripts/issue_show/components/app_spec.js
@@ -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);
+ });
+ });
});
diff --git a/spec/javascripts/issue_show/components/form_spec.js b/spec/javascripts/issue_show/components/form_spec.js
new file mode 100644
index 00000000000..16793a1fc9b
--- /dev/null
+++ b/spec/javascripts/issue_show/components/form_spec.js
@@ -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();
+ });
+ });
+});