Commit 168d295e authored by Florie Guibert's avatar Florie Guibert

Swimlanes - Fetch more epics button

Review feedback
parent 0b9519b3
...@@ -87,11 +87,14 @@ export default { ...@@ -87,11 +87,14 @@ export default {
shouldDisplay() { shouldDisplay() {
return this.issuesCount > 0 || this.isLoading; return this.issuesCount > 0 || this.isLoading;
}, },
showUnassignedLane() {
return !this.isCollapsed && this.issuesCount > 0;
},
}, },
watch: { watch: {
filterParams: { 'filterParams.epicId': {
handler() { handler(epicId) {
if (!this.filterParams.epicId || this.filterParams.epicId === this.epic.id) { if (!epicId || epicId === this.epic.id) {
this.fetchIssuesForEpic(this.epic.id); this.fetchIssuesForEpic(this.epic.id);
} }
}, },
...@@ -134,7 +137,6 @@ export default { ...@@ -134,7 +137,6 @@ export default {
class="gl-mr-2 gl-cursor-pointer" class="gl-mr-2 gl-cursor-pointer"
category="tertiary" category="tertiary"
size="small" size="small"
data-testid="epic-lane-chevron"
@click="toggleCollapsed" @click="toggleCollapsed"
/> />
<h4 <h4
...@@ -165,7 +167,7 @@ export default { ...@@ -165,7 +167,7 @@ export default {
</div> </div>
</div> </div>
<div <div
v-if="!isCollapsed && issuesCount > 0" v-if="showUnassignedLane"
class="gl-display-flex gl-pb-5 board-epic-lane-issues" class="gl-display-flex gl-pb-5 board-epic-lane-issues"
data-testid="board-epic-lane-issues" data-testid="board-epic-lane-issues"
> >
......
...@@ -123,11 +123,7 @@ export default { ...@@ -123,11 +123,7 @@ export default {
watch: { watch: {
filterParams: { filterParams: {
handler() { handler() {
Promise.all( Promise.all(this.epics.map((epic) => this.fetchIssuesForEpic(epic.id)))
this.epics.map((epic) => {
return this.fetchIssuesForEpic(epic.id);
}),
)
.then(() => this.doneLoadingSwimlanesItems()) .then(() => this.doneLoadingSwimlanesItems())
.catch(() => {}); .catch(() => {});
}, },
......
...@@ -92,6 +92,7 @@ export default { ...@@ -92,6 +92,7 @@ export default {
...state.epicsSwimlanesFetchInProgress, ...state.epicsSwimlanesFetchInProgress,
listItemsFetchInProgress: false, listItemsFetchInProgress: false,
}); });
state.error = undefined;
}, },
[mutationTypes.RECEIVE_BOARD_LISTS_SUCCESS]: (state, boardLists) => { [mutationTypes.RECEIVE_BOARD_LISTS_SUCCESS]: (state, boardLists) => {
......
import { GlIcon, GlLoadingIcon } from '@gitlab/ui'; import { GlButton, GlIcon, GlLoadingIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue'; import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import EpicLane from 'ee/boards/components/epic_lane.vue'; import EpicLane from 'ee/boards/components/epic_lane.vue';
import IssuesLaneList from 'ee/boards/components/issues_lane_list.vue'; import IssuesLaneList from 'ee/boards/components/issues_lane_list.vue';
import getters from 'ee/boards/stores/getters'; import getters from 'ee/boards/stores/getters';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { mockEpic, mockLists, mockIssuesByListId, issues } from '../mock_data'; import { mockEpic, mockLists, mockIssuesByListId, issues } from '../mock_data';
Vue.use(Vuex); Vue.use(Vuex);
...@@ -15,6 +14,8 @@ describe('EpicLane', () => { ...@@ -15,6 +14,8 @@ describe('EpicLane', () => {
const updateBoardEpicUserPreferencesSpy = jest.fn(); const updateBoardEpicUserPreferencesSpy = jest.fn();
const findChevronButton = () => wrapper.findComponent(GlButton);
const createStore = ({ boardItemsByListId = mockIssuesByListId, isLoading = false }) => { const createStore = ({ boardItemsByListId = mockIssuesByListId, isLoading = false }) => {
return new Vuex.Store({ return new Vuex.Store({
actions: { actions: {
...@@ -47,15 +48,13 @@ describe('EpicLane', () => { ...@@ -47,15 +48,13 @@ describe('EpicLane', () => {
disabled: false, disabled: false,
}; };
wrapper = extendedWrapper( wrapper = shallowMountExtended(EpicLane, {
shallowMount(EpicLane, {
propsData: { propsData: {
...defaultProps, ...defaultProps,
...props, ...props,
}, },
store, store,
}), });
);
}; };
afterEach(() => { afterEach(() => {
...@@ -87,7 +86,7 @@ describe('EpicLane', () => { ...@@ -87,7 +86,7 @@ describe('EpicLane', () => {
expect(wrapper.findAll(IssuesLaneList)).toHaveLength(wrapper.props('lists').length); expect(wrapper.findAll(IssuesLaneList)).toHaveLength(wrapper.props('lists').length);
expect(wrapper.vm.isCollapsed).toBe(false); expect(wrapper.vm.isCollapsed).toBe(false);
wrapper.findByTestId('epic-lane-chevron').vm.$emit('click'); findChevronButton().vm.$emit('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.findAll(IssuesLaneList)).toHaveLength(0); expect(wrapper.findAll(IssuesLaneList)).toHaveLength(0);
...@@ -96,12 +95,12 @@ describe('EpicLane', () => { ...@@ -96,12 +95,12 @@ describe('EpicLane', () => {
}); });
it('does not display loading icon when issues are not loading', () => { it('does not display loading icon when issues are not loading', () => {
expect(wrapper.find(GlLoadingIcon).exists()).toBe(false); expect(wrapper.findComponent(GlLoadingIcon).exists()).toBe(false);
}); });
it('displays loading icon and hides issues count when issues are loading', () => { it('displays loading icon and hides issues count when issues are loading', () => {
createComponent({ isLoading: true }); createComponent({ isLoading: true });
expect(wrapper.find(GlLoadingIcon).exists()).toBe(true); expect(wrapper.findComponent(GlLoadingIcon).exists()).toBe(true);
expect(wrapper.findByTestId('epic-lane-issue-count').exists()).toBe(false); expect(wrapper.findByTestId('epic-lane-issue-count').exists()).toBe(false);
}); });
...@@ -110,7 +109,7 @@ describe('EpicLane', () => { ...@@ -110,7 +109,7 @@ describe('EpicLane', () => {
expect(wrapper.vm.isCollapsed).toBe(collapsedValue); expect(wrapper.vm.isCollapsed).toBe(collapsedValue);
wrapper.findByTestId('epic-lane-chevron').vm.$emit('click'); findChevronButton().vm.$emit('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(updateBoardEpicUserPreferencesSpy).toHaveBeenCalled(); expect(updateBoardEpicUserPreferencesSpy).toHaveBeenCalled();
......
...@@ -146,15 +146,15 @@ describe('EpicsSwimlanes', () => { ...@@ -146,15 +146,15 @@ describe('EpicsSwimlanes', () => {
}); });
it('displays IssueLaneList component when toggling unassigned issues lane', async () => { it('displays IssueLaneList component when toggling unassigned issues lane', async () => {
wrapper.vm.toggleUnassignedLane(); wrapper.findByTestId('unassigned-lane-toggle').vm.$emit('click');
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
expect(wrapper.findComponent(IssueLaneList).exists()).toBe(true); expect(wrapper.findComponent(IssueLaneList).exists()).toBe(true);
}); });
it('displays issues icon and count for unassigned issue', () => { it('displays issues icon and count for unassigned issue', () => {
expect(wrapper.findComponent(GlIcon).props('name')).toEqual('issues'); expect(wrapper.findComponent(GlIcon).props('name')).toBe('issues');
expect(wrapper.findByTestId('issues-lane-issue-count').text()).toEqual('2'); expect(wrapper.findByTestId('issues-lane-issue-count').text()).toBe('2');
}); });
it('makes non preset lists draggable', () => { it('makes non preset lists draggable', () => {
......
...@@ -140,17 +140,19 @@ describe('SET_EPICS_SWIMLANES', () => { ...@@ -140,17 +140,19 @@ describe('SET_EPICS_SWIMLANES', () => {
}); });
describe('DONE_LOADING_SWIMLANES_ITEMS', () => { describe('DONE_LOADING_SWIMLANES_ITEMS', () => {
it('set listItemsFetchInProgress to false', () => { it('set listItemsFetchInProgress to false ans resets error', () => {
state = { state = {
...state, ...state,
epicsSwimlanesFetchInProgress: { epicsSwimlanesFetchInProgress: {
listItemsFetchInProgress: true, listItemsFetchInProgress: true,
}, },
error: 'Houston, we have a problem.',
}; };
mutations.DONE_LOADING_SWIMLANES_ITEMS(state); mutations.DONE_LOADING_SWIMLANES_ITEMS(state);
expect(state.epicsSwimlanesFetchInProgress.listItemsFetchInProgress).toBe(false); expect(state.epicsSwimlanesFetchInProgress.listItemsFetchInProgress).toBe(false);
expect(state.error).toBe(undefined);
}); });
}); });
......
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