Commit ed72783e authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'psi-col-form-com' into 'master'

Split new column form into data/display components

See merge request gitlab-org/gitlab!55460
parents e93b6138 1d59a6fb
<script> <script>
import { import {
GlButton,
GlFormGroup,
GlFormRadio, GlFormRadio,
GlFormRadioGroup, GlFormRadioGroup,
GlLabel, GlLabel,
GlSearchBoxByType,
GlSkeletonLoader,
GlTooltipDirective as GlTooltip, GlTooltipDirective as GlTooltip,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { mapActions, mapGetters, mapState } from 'vuex'; import { mapActions, mapGetters, mapState } from 'vuex';
import BoardAddNewColumnForm from '~/boards/components/board_add_new_column_form.vue';
import { ListType } from '~/boards/constants';
import boardsStore from '~/boards/stores/boards_store';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { isScopedLabel } from '~/lib/utils/common_utils'; import { isScopedLabel } from '~/lib/utils/common_utils';
import { __ } from '~/locale';
import boardsStore from '../stores/boards_store';
export default { export default {
i18n: {
add: __('Add'),
cancel: __('Cancel'),
formDescription: __('A label list displays all issues with the selected label.'),
newLabelList: __('New label list'),
noLabelSelected: __('No label selected'),
searchPlaceholder: __('Search labels'),
selectLabel: __('Select label'),
selected: __('Selected'),
},
components: { components: {
GlButton, BoardAddNewColumnForm,
GlFormGroup,
GlFormRadio, GlFormRadio,
GlFormRadioGroup, GlFormRadioGroup,
GlLabel, GlLabel,
GlSearchBoxByType,
GlSkeletonLoader,
}, },
directives: { directives: {
GlTooltip, GlTooltip,
...@@ -40,31 +25,27 @@ export default { ...@@ -40,31 +25,27 @@ export default {
inject: ['scopedLabelsAvailable'], inject: ['scopedLabelsAvailable'],
data() { data() {
return { return {
searchTerm: '', selectedId: null,
selectedLabelId: null,
}; };
}, },
computed: { computed: {
...mapState(['labels', 'labelsLoading', 'isEpicBoard']), ...mapState(['labels', 'labelsLoading', 'isEpicBoard']),
...mapGetters(['getListByLabelId', 'shouldUseGraphQL']), ...mapGetters(['getListByLabelId', 'shouldUseGraphQL']),
selectedLabel() { selectedLabel() {
return this.labels.find(({ id }) => id === this.selectedLabelId); if (!this.selectedId) {
return null;
}
return this.labels.find(({ id }) => id === this.selectedId);
},
columnForSelected() {
return this.getListByLabelId(this.selectedId);
}, },
}, },
created() { created() {
this.filterLabels(); this.filterItems();
}, },
methods: { methods: {
...mapActions(['createList', 'fetchLabels', 'highlightList', 'setAddColumnFormVisibility']), ...mapActions(['createList', 'fetchLabels', 'highlightList', 'setAddColumnFormVisibility']),
getListByLabel(label) {
if (this.shouldUseGraphQL || this.isEpicBoard) {
return this.getListByLabelId(label);
}
return boardsStore.findListByLabelId(label.id);
},
columnExists(label) {
return Boolean(this.getListByLabel(label));
},
highlight(listId) { highlight(listId) {
if (this.shouldUseGraphQL || this.isEpicBoard) { if (this.shouldUseGraphQL || this.isEpicBoard) {
this.highlightList(listId); this.highlightList(listId);
...@@ -77,44 +58,35 @@ export default { ...@@ -77,44 +58,35 @@ export default {
} }
}, },
addList() { addList() {
if (!this.selectedLabelId) { if (!this.selectedLabel) {
return;
}
const label = this.selectedLabel;
if (!label) {
return; return;
} }
this.setAddColumnFormVisibility(false); this.setAddColumnFormVisibility(false);
if (this.columnExists({ id: this.selectedLabelId })) { if (this.columnForSelected) {
const listId = this.getListByLabel(label).id; const listId = this.columnForSelected.id;
this.highlight(listId); this.highlight(listId);
return; return;
} }
if (this.shouldUseGraphQL || this.isEpicBoard) { if (this.shouldUseGraphQL || this.isEpicBoard) {
this.createList({ labelId: this.selectedLabelId }); this.createList({ labelId: this.selectedId });
} else { } else {
boardsStore.new({ const listObj = {
title: label.title, labelId: getIdFromGraphQLId(this.selectedId),
title: this.selectedLabel.title,
position: boardsStore.state.lists.length - 2, position: boardsStore.state.lists.length - 2,
list_type: 'label', list_type: ListType.label,
label: { label: this.selectedLabel,
id: label.id, };
title: label.title,
color: label.color,
},
});
this.highlight(boardsStore.findListByLabelId(label.id).id); boardsStore.new(listObj);
} }
}, },
filterLabels() { filterItems(searchTerm) {
this.fetchLabels(this.searchTerm); this.fetchLabels(searchTerm);
}, },
showScopedLabels(label) { showScopedLabels(label) {
...@@ -125,103 +97,43 @@ export default { ...@@ -125,103 +97,43 @@ export default {
</script> </script>
<template> <template>
<div <board-add-new-column-form
class="board-add-new-list board gl-display-inline-block gl-h-full gl-px-3 gl-vertical-align-top gl-white-space-normal gl-flex-shrink-0" :loading="labelsLoading"
data-testid="board-add-new-column" :form-description="__('A label list displays issues with the selected label.')"
data-qa-selector="board_add_new_list" :search-label="__('Select label')"
:search-placeholder="__('Search labels')"
:selected-id="selectedId"
@filter-items="filterItems"
@add-list="addList"
> >
<div <template slot="selected">
class="board-inner gl-display-flex gl-flex-direction-column gl-relative gl-h-full gl-rounded-base gl-bg-white" <gl-label
> v-if="selectedLabel"
<h3 v-gl-tooltip
class="gl-font-base gl-px-5 gl-py-5 gl-m-0 gl-border-b-1 gl-border-b-solid gl-border-b-gray-100" :title="selectedLabel.title"
data-testid="board-add-column-form-title" :description="selectedLabel.description"
> :background-color="selectedLabel.color"
{{ $options.i18n.newLabelList }} :scoped="showScopedLabels(selectedLabel)"
</h3> />
</template>
<div class="gl-display-flex gl-flex-direction-column gl-h-full gl-overflow-hidden">
<!-- selectbox is here in EE --> <template slot="items">
<gl-form-radio-group v-model="selectedId" class="gl-overflow-y-auto gl-px-5 gl-pt-3">
<p class="gl-m-5">{{ $options.i18n.formDescription }}</p> <label
v-for="label in labels"
<div class="gl-px-5 gl-pb-4"> :key="label.id"
<label class="gl-mb-2">{{ $options.i18n.selected }}</label> class="gl-display-flex gl-flex-align-items-center gl-mb-5 gl-font-weight-normal"
<div>
<gl-label
v-if="selectedLabel"
v-gl-tooltip
:title="selectedLabel.title"
:description="selectedLabel.description"
:background-color="selectedLabel.color"
:scoped="showScopedLabels(selectedLabel)"
/>
<div v-else class="gl-text-gray-500">{{ $options.i18n.noLabelSelected }}</div>
</div>
</div>
<gl-form-group
class="gl-mx-5 gl-mb-3"
:label="$options.i18n.selectLabel"
label-for="board-available-labels"
>
<gl-search-box-by-type
id="board-available-labels"
v-model.trim="searchTerm"
debounce="250"
:placeholder="$options.i18n.searchPlaceholder"
@input="filterLabels"
/>
</gl-form-group>
<div v-if="labelsLoading" class="gl-m-5">
<gl-skeleton-loader :width="500" :height="172">
<rect width="480" height="20" x="10" y="15" rx="4" />
<rect width="380" height="20" x="10" y="50" rx="4" />
<rect width="430" height="20" x="10" y="85" rx="4" />
</gl-skeleton-loader>
</div>
<gl-form-radio-group
v-else
v-model="selectedLabelId"
class="gl-overflow-y-auto gl-px-5 gl-pt-3"
>
<label
v-for="label in labels"
:key="label.id"
class="gl-display-flex gl-flex-align-items-center gl-mb-5 gl-font-weight-normal"
>
<gl-form-radio :value="label.id" class="gl-mb-0 gl-mr-3" />
<span
class="dropdown-label-box gl-top-0"
:style="{
backgroundColor: label.color,
}"
></span>
<span>{{ label.title }}</span>
</label>
</gl-form-radio-group>
</div>
<div
class="gl-display-flex gl-p-3 gl-border-t-1 gl-border-t-solid gl-border-gray-100 gl-bg-gray-10"
>
<gl-button
data-testid="cancelAddNewColumn"
class="gl-ml-auto gl-mr-3"
@click="setAddColumnFormVisibility(false)"
>{{ $options.i18n.cancel }}</gl-button
>
<gl-button
data-testid="addNewColumnButton"
:disabled="!selectedLabelId"
variant="success"
class="gl-mr-4"
@click="addList"
>{{ $options.i18n.add }}</gl-button
> >
</div> <gl-form-radio :value="label.id" class="gl-mb-0 gl-mr-3" />
</div> <span
</div> class="dropdown-label-box gl-top-0"
:style="{
backgroundColor: label.color,
}"
></span>
<span>{{ label.title }}</span>
</label>
</gl-form-radio-group>
</template>
</board-add-new-column-form>
</template> </template>
<script>
import { GlButton, GlFormGroup, GlSearchBoxByType, GlSkeletonLoader } from '@gitlab/ui';
import { mapActions } from 'vuex';
import { __ } from '~/locale';
export default {
i18n: {
add: __('Add'),
cancel: __('Cancel'),
newList: __('New list'),
noneSelected: __('None'),
selected: __('Selected'),
},
components: {
GlButton,
GlFormGroup,
GlSearchBoxByType,
GlSkeletonLoader,
},
props: {
loading: {
type: Boolean,
required: true,
},
formDescription: {
type: String,
required: true,
},
searchLabel: {
type: String,
required: true,
},
searchPlaceholder: {
type: String,
required: true,
},
selectedId: {
type: [Number, String],
required: false,
default: null,
},
},
methods: {
...mapActions(['setAddColumnFormVisibility']),
},
};
</script>
<template>
<div
class="board-add-new-list board gl-display-inline-block gl-h-full gl-px-3 gl-vertical-align-top gl-white-space-normal gl-flex-shrink-0"
data-testid="board-add-new-column"
data-qa-selector="board_add_new_list"
>
<div
class="board-inner gl-display-flex gl-flex-direction-column gl-relative gl-h-full gl-rounded-base gl-bg-white"
>
<h3
class="gl-font-base gl-px-5 gl-py-5 gl-m-0 gl-border-b-1 gl-border-b-solid gl-border-b-gray-100"
data-testid="board-add-column-form-title"
>
{{ $options.i18n.newList }}
</h3>
<div class="gl-display-flex gl-flex-direction-column gl-h-full gl-overflow-hidden">
<slot name="select-list-type">
<div class="gl-mb-5"></div>
</slot>
<p class="gl-px-5">{{ formDescription }}</p>
<div class="gl-px-5 gl-pb-4">
<label class="gl-mb-2">{{ $options.i18n.selected }}</label>
<slot name="selected">
<div class="gl-text-gray-500">{{ $options.i18n.noneSelected }}</div>
</slot>
</div>
<gl-form-group
class="gl-mx-5 gl-mb-3"
:label="searchLabel"
label-for="board-available-column-entities"
>
<gl-search-box-by-type
id="board-available-column-entities"
debounce="250"
:placeholder="searchPlaceholder"
@input="$emit('filter-items', $event)"
/>
</gl-form-group>
<div v-if="loading" class="gl-px-5">
<gl-skeleton-loader :width="500" :height="172">
<rect width="480" height="20" x="10" y="15" rx="4" />
<rect width="380" height="20" x="10" y="50" rx="4" />
<rect width="430" height="20" x="10" y="85" rx="4" />
</gl-skeleton-loader>
</div>
<slot v-else name="items"></slot>
</div>
<div
class="gl-display-flex gl-p-3 gl-border-t-1 gl-border-t-solid gl-border-gray-100 gl-bg-gray-10"
>
<gl-button
data-testid="cancelAddNewColumn"
class="gl-ml-auto gl-mr-3"
@click="setAddColumnFormVisibility(false)"
>{{ $options.i18n.cancel }}</gl-button
>
<gl-button
data-testid="addNewColumnButton"
:disabled="!selectedId"
variant="success"
class="gl-mr-4"
@click="$emit('add-list')"
>{{ $options.i18n.add }}</gl-button
>
</div>
</div>
</div>
</template>
...@@ -157,8 +157,8 @@ export default { ...@@ -157,8 +157,8 @@ export default {
}, },
}) })
.then(({ data }) => { .then(({ data }) => {
if (data?.boardListCreate?.errors.length) { if (data.boardListCreate?.errors.length) {
commit(types.CREATE_LIST_FAILURE); commit(types.CREATE_LIST_FAILURE, data.boardListCreate.errors[0]);
} else { } else {
const list = data.boardListCreate?.list; const list = data.boardListCreate?.list;
dispatch('addList', list); dispatch('addList', list);
......
...@@ -60,8 +60,11 @@ export default { ...@@ -60,8 +60,11 @@ export default {
state.filterParams = filterParams; state.filterParams = filterParams;
}, },
[mutationTypes.CREATE_LIST_FAILURE]: (state) => { [mutationTypes.CREATE_LIST_FAILURE]: (
state.error = s__('Boards|An error occurred while creating the list. Please try again.'); state,
error = s__('Boards|An error occurred while creating the list. Please try again.'),
) => {
state.error = error;
}, },
[mutationTypes.RECEIVE_LABELS_REQUEST]: (state) => { [mutationTypes.RECEIVE_LABELS_REQUEST]: (state) => {
......
...@@ -587,7 +587,7 @@ export default { ...@@ -587,7 +587,7 @@ export default {
}) })
.then(({ data }) => { .then(({ data }) => {
if (data?.epicBoardListCreate?.errors.length) { if (data?.epicBoardListCreate?.errors.length) {
commit(types.CREATE_LIST_FAILURE); commit(types.CREATE_LIST_FAILURE, data.epicBoardListCreate.errors[0]);
} else { } else {
const list = data.epicBoardListCreate?.list; const list = data.epicBoardListCreate?.list;
dispatch('addList', list); dispatch('addList', list);
......
...@@ -1026,14 +1026,14 @@ describe('moveIssue', () => { ...@@ -1026,14 +1026,14 @@ describe('moveIssue', () => {
data: { data: {
epicBoardListCreate: { epicBoardListCreate: {
list: {}, list: {},
errors: [{ foo: 'bar' }], errors: ['foo'],
}, },
}, },
}); });
await actions.createEpicList({ getters, state, commit, dispatch }, { backlog: true }); await actions.createEpicList({ getters, state, commit, dispatch }, { backlog: true });
expect(commit).toHaveBeenCalledWith(types.CREATE_LIST_FAILURE); expect(commit).toHaveBeenCalledWith(types.CREATE_LIST_FAILURE, 'foo');
}); });
it('highlights list and does not re-query if it already exists', async () => { it('highlights list and does not re-query if it already exists', async () => {
......
...@@ -1330,7 +1330,7 @@ msgstr "" ...@@ -1330,7 +1330,7 @@ msgstr ""
msgid "A job artifact is an archive of files and directories saved by a job when it finishes." msgid "A job artifact is an archive of files and directories saved by a job when it finishes."
msgstr "" msgstr ""
msgid "A label list displays all issues with the selected label." msgid "A label list displays issues with the selected label."
msgstr "" msgstr ""
msgid "A limit of %{ci_project_subscriptions_limit} subscriptions to or from a project applies." msgid "A limit of %{ci_project_subscriptions_limit} subscriptions to or from a project applies."
...@@ -20298,7 +20298,7 @@ msgstr "" ...@@ -20298,7 +20298,7 @@ msgstr ""
msgid "New label" msgid "New label"
msgstr "" msgstr ""
msgid "New label list" msgid "New list"
msgstr "" msgstr ""
msgid "New merge request" msgid "New merge request"
...@@ -20520,9 +20520,6 @@ msgstr "" ...@@ -20520,9 +20520,6 @@ msgstr ""
msgid "No label" msgid "No label"
msgstr "" msgstr ""
msgid "No label selected"
msgstr ""
msgid "No labels with such name or description" msgid "No labels with such name or description"
msgstr "" msgstr ""
......
import { GlFormGroup, GlSearchBoxByType, GlSkeletonLoader } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import Vue, { nextTick } from 'vue';
import Vuex from 'vuex';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import BoardAddNewColumnForm from '~/boards/components/board_add_new_column_form.vue';
import defaultState from '~/boards/stores/state';
import { mockLabelList } from '../mock_data';
Vue.use(Vuex);
describe('Board card layout', () => {
let wrapper;
const createStore = ({ actions = {}, getters = {}, state = {} } = {}) => {
return new Vuex.Store({
state: {
...defaultState,
...state,
},
actions,
getters,
});
};
const mountComponent = ({
loading = false,
formDescription = '',
searchLabel = '',
searchPlaceholder = '',
selectedId,
actions,
slots,
} = {}) => {
wrapper = extendedWrapper(
shallowMount(BoardAddNewColumnForm, {
stubs: {
GlFormGroup: true,
},
propsData: {
loading,
formDescription,
searchLabel,
searchPlaceholder,
selectedId,
},
slots,
store: createStore({
actions: {
setAddColumnFormVisibility: jest.fn(),
...actions,
},
}),
}),
);
};
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
const formTitle = () => wrapper.findByTestId('board-add-column-form-title').text();
const findSearchInput = () => wrapper.find(GlSearchBoxByType);
const findSearchLabel = () => wrapper.find(GlFormGroup);
const cancelButton = () => wrapper.findByTestId('cancelAddNewColumn');
const submitButton = () => wrapper.findByTestId('addNewColumnButton');
it('shows form title & search input', () => {
mountComponent();
expect(formTitle()).toEqual(BoardAddNewColumnForm.i18n.newList);
expect(findSearchInput().exists()).toBe(true);
});
it('clicking cancel hides the form', () => {
const setAddColumnFormVisibility = jest.fn();
mountComponent({
actions: {
setAddColumnFormVisibility,
},
});
cancelButton().vm.$emit('click');
expect(setAddColumnFormVisibility).toHaveBeenCalledWith(expect.anything(), false);
});
it('sets placeholder and description from props', () => {
const props = {
formDescription: 'Some description of a list',
};
mountComponent(props);
expect(wrapper.html()).toHaveText(props.formDescription);
});
describe('items', () => {
const mountWithItems = (loading) =>
mountComponent({
loading,
slots: {
items: '<div class="item-slot">Some kind of list</div>',
},
});
it('hides items slot and shows skeleton while loading', () => {
mountWithItems(true);
expect(wrapper.findComponent(GlSkeletonLoader).exists()).toBe(true);
expect(wrapper.find('.item-slot').exists()).toBe(false);
});
it('shows items slot and hides skeleton while not loading', () => {
mountWithItems(false);
expect(wrapper.findComponent(GlSkeletonLoader).exists()).toBe(false);
expect(wrapper.find('.item-slot').exists()).toBe(true);
});
});
describe('search box', () => {
it('sets label and placeholder text from props', () => {
const props = {
searchLabel: 'Some items',
searchPlaceholder: 'Search for an item',
};
mountComponent(props);
expect(findSearchLabel().attributes('label')).toEqual(props.searchLabel);
expect(findSearchInput().attributes('placeholder')).toEqual(props.searchPlaceholder);
});
it('emits filter event on input', () => {
mountComponent();
const searchText = 'some text';
findSearchInput().vm.$emit('input', searchText);
expect(wrapper.emitted('filter-items')).toEqual([[searchText]]);
});
});
describe('Add list button', () => {
it('is disabled if no item is selected', () => {
mountComponent();
expect(submitButton().props('disabled')).toBe(true);
});
it('emits add-list event on click', async () => {
mountComponent({
selectedId: mockLabelList.label.id,
});
await nextTick();
submitButton().vm.$emit('click');
expect(wrapper.emitted('add-list')).toEqual([[]]);
});
});
});
import { GlSearchBoxByType } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue, { nextTick } from 'vue'; import Vue, { nextTick } from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import BoardAddNewColumn from '~/boards/components/board_add_new_column.vue'; import BoardAddNewColumn from '~/boards/components/board_add_new_column.vue';
import BoardAddNewColumnForm from '~/boards/components/board_add_new_column_form.vue';
import defaultState from '~/boards/stores/state'; import defaultState from '~/boards/stores/state';
import { mockLabelList } from '../mock_data'; import { mockLabelList } from '../mock_data';
...@@ -11,7 +11,6 @@ Vue.use(Vuex); ...@@ -11,7 +11,6 @@ Vue.use(Vuex);
describe('Board card layout', () => { describe('Board card layout', () => {
let wrapper; let wrapper;
let shouldUseGraphQL;
const createStore = ({ actions = {}, getters = {}, state = {} } = {}) => { const createStore = ({ actions = {}, getters = {}, state = {} } = {}) => {
return new Vuex.Store({ return new Vuex.Store({
...@@ -25,19 +24,16 @@ describe('Board card layout', () => { ...@@ -25,19 +24,16 @@ describe('Board card layout', () => {
}; };
const mountComponent = ({ const mountComponent = ({
selectedLabelId, selectedId,
labels = [], labels = [],
getListByLabelId = jest.fn(), getListByLabelId = jest.fn(),
actions = {}, actions = {},
} = {}) => { } = {}) => {
wrapper = extendedWrapper( wrapper = extendedWrapper(
shallowMount(BoardAddNewColumn, { shallowMount(BoardAddNewColumn, {
stubs: {
GlFormGroup: true,
},
data() { data() {
return { return {
selectedLabelId, selectedId,
}; };
}, },
store: createStore({ store: createStore({
...@@ -47,12 +43,13 @@ describe('Board card layout', () => { ...@@ -47,12 +43,13 @@ describe('Board card layout', () => {
...actions, ...actions,
}, },
getters: { getters: {
shouldUseGraphQL: () => shouldUseGraphQL, shouldUseGraphQL: () => true,
getListByLabelId: () => getListByLabelId, getListByLabelId: () => getListByLabelId,
}, },
state: { state: {
labels, labels,
labelsLoading: false, labelsLoading: false,
isEpicBoard: false,
}, },
}), }),
provide: { provide: {
...@@ -64,65 +61,32 @@ describe('Board card layout', () => { ...@@ -64,65 +61,32 @@ describe('Board card layout', () => {
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
});
const formTitle = () => wrapper.findByTestId('board-add-column-form-title').text();
const findSearchInput = () => wrapper.find(GlSearchBoxByType);
const cancelButton = () => wrapper.findByTestId('cancelAddNewColumn');
const submitButton = () => wrapper.findByTestId('addNewColumnButton');
beforeEach(() => {
shouldUseGraphQL = true;
});
it('shows form title & search input', () => {
mountComponent();
expect(formTitle()).toEqual(BoardAddNewColumn.i18n.newLabelList);
expect(findSearchInput().exists()).toBe(true);
});
it('clicking cancel hides the form', () => {
const setAddColumnFormVisibility = jest.fn();
mountComponent({
actions: {
setAddColumnFormVisibility,
},
});
cancelButton().vm.$emit('click');
expect(setAddColumnFormVisibility).toHaveBeenCalledWith(expect.anything(), false);
}); });
describe('Add list button', () => { describe('Add list button', () => {
it('is disabled if no item is selected', () => { it('calls addList', async () => {
mountComponent(); const getListByLabelId = jest.fn().mockReturnValue(null);
expect(submitButton().props('disabled')).toBe(true);
});
it('adds a new list on click', async () => {
const labelId = mockLabelList.label.id;
const highlightList = jest.fn(); const highlightList = jest.fn();
const createList = jest.fn(); const createList = jest.fn();
mountComponent({ mountComponent({
labels: [mockLabelList.label], labels: [mockLabelList.label],
selectedLabelId: labelId, selectedId: mockLabelList.label.id,
getListByLabelId,
actions: { actions: {
createList, createList,
highlightList, highlightList,
}, },
}); });
await nextTick(); wrapper.findComponent(BoardAddNewColumnForm).vm.$emit('add-list');
submitButton().vm.$emit('click'); await nextTick();
expect(highlightList).not.toHaveBeenCalled(); expect(highlightList).not.toHaveBeenCalled();
expect(createList).toHaveBeenCalledWith(expect.anything(), { labelId }); expect(createList).toHaveBeenCalledWith(expect.anything(), {
labelId: mockLabelList.label.id,
});
}); });
it('highlights existing list if trying to re-add', async () => { it('highlights existing list if trying to re-add', async () => {
...@@ -132,7 +96,7 @@ describe('Board card layout', () => { ...@@ -132,7 +96,7 @@ describe('Board card layout', () => {
mountComponent({ mountComponent({
labels: [mockLabelList.label], labels: [mockLabelList.label],
selectedLabelId: mockLabelList.label.id, selectedId: mockLabelList.label.id,
getListByLabelId, getListByLabelId,
actions: { actions: {
createList, createList,
...@@ -140,9 +104,9 @@ describe('Board card layout', () => { ...@@ -140,9 +104,9 @@ describe('Board card layout', () => {
}, },
}); });
await nextTick(); wrapper.findComponent(BoardAddNewColumnForm).vm.$emit('add-list');
submitButton().vm.$emit('click'); await nextTick();
expect(highlightList).toHaveBeenCalledWith(expect.anything(), mockLabelList.id); expect(highlightList).toHaveBeenCalledWith(expect.anything(), mockLabelList.id);
expect(createList).not.toHaveBeenCalled(); expect(createList).not.toHaveBeenCalled();
......
...@@ -293,7 +293,7 @@ describe('createIssueList', () => { ...@@ -293,7 +293,7 @@ describe('createIssueList', () => {
data: { data: {
boardListCreate: { boardListCreate: {
list: {}, list: {},
errors: [{ foo: 'bar' }], errors: ['foo'],
}, },
}, },
}), }),
...@@ -301,7 +301,7 @@ describe('createIssueList', () => { ...@@ -301,7 +301,7 @@ describe('createIssueList', () => {
await actions.createIssueList({ getters, state, commit, dispatch }, { backlog: true }); await actions.createIssueList({ getters, state, commit, dispatch }, { backlog: true });
expect(commit).toHaveBeenCalledWith(types.CREATE_LIST_FAILURE); expect(commit).toHaveBeenCalledWith(types.CREATE_LIST_FAILURE, 'foo');
}); });
it('highlights list and does not re-query if it already exists', async () => { it('highlights list and does not re-query if it already exists', async () => {
......
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