Commit d9ef5d1d authored by Winnie Hellmann's avatar Winnie Hellmann Committed by Filipa Lacerda

Fix cancelling of board settings modal

parent 3e3f09cd
...@@ -87,6 +87,9 @@ export default { ...@@ -87,6 +87,9 @@ export default {
isEditForm() { isEditForm() {
return this.currentPage === 'edit'; return this.currentPage === 'edit';
}, },
isVisible() {
return this.currentPage !== '';
},
buttonText() { buttonText() {
if (this.isNewForm) { if (this.isNewForm) {
return 'Create board'; return 'Create board';
...@@ -181,14 +184,14 @@ export default { ...@@ -181,14 +184,14 @@ export default {
<template> <template>
<modal <modal
v-show="currentPage" v-show="isVisible"
modal-dialog-class="board-config-modal" modal-dialog-class="board-config-modal"
:hide-footer="readonly" :hide-footer="readonly"
:title="title" :title="title"
:primary-button-label="buttonText" :primary-button-label="buttonText"
:kind="buttonKind" :kind="buttonKind"
:submit-disabled="submitDisabled" :submit-disabled="submitDisabled"
@toggle="cancel" @cancel="cancel"
@submit="submit" @submit="submit"
> >
<template slot="body"> <template slot="body">
......
import Vue from 'vue';
import boardForm from '~/boards/components/board_form.vue';
import mountComponent from '../../helpers/vue_mount_component_helper';
describe('board_form.vue', () => {
const props = {
canAdminBoard: false,
labelsPath: `${gl.TEST_HOST}/labels/path`,
milestonePath: `${gl.TEST_HOST}/milestone/path`,
};
let vm;
beforeEach(() => {
spyOn($, 'ajax');
gl.issueBoards.BoardsStore.state.currentPage = 'edit';
const Component = Vue.extend(boardForm);
vm = mountComponent(Component, props);
});
afterEach(() => {
vm.$destroy();
});
describe('methods', () => {
describe('cancel', () => {
it('resets currentPage', (done) => {
vm.cancel();
Vue.nextTick()
.then(() => {
expect(gl.issueBoards.BoardsStore.state.currentPage).toBe('');
})
.then(done)
.catch(done.fail);
});
});
});
describe('buttons', () => {
it('cancel button triggers cancel()', (done) => {
spyOn(vm, 'cancel');
Vue.nextTick()
.then(() => {
const cancelButton = vm.$el.querySelector('button[data-dismiss="modal"]');
cancelButton.click();
expect(vm.cancel).toHaveBeenCalled();
})
.then(done)
.catch(done.fail);
});
});
});
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