Commit 941c2341 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Minor review comments

Removed an unecessary returned promise
and update related specs
parent 419bf867
...@@ -108,6 +108,8 @@ export default { ...@@ -108,6 +108,8 @@ export default {
return this.featureFlags.hasPathNavigation && !this.hasNoAccessError && this.selectedStage; return this.featureFlags.hasPathNavigation && !this.hasNoAccessError && this.selectedStage;
}, },
shouldDisplayFilterBar() { shouldDisplayFilterBar() {
// TODO: After we remove instance VSA currentGroupPath will be always set
// https://gitlab.com/gitlab-org/gitlab/-/issues/223735
return this.featureFlags.hasFilterBar && this.currentGroupPath; return this.featureFlags.hasFilterBar && this.currentGroupPath;
}, },
isLoadingTypeOfWork() { isLoadingTypeOfWork() {
......
...@@ -268,9 +268,9 @@ export const initializeCycleAnalytics = ({ dispatch, commit }, initialData = {}) ...@@ -268,9 +268,9 @@ export const initializeCycleAnalytics = ({ dispatch, commit }, initialData = {})
}); });
} }
return Promise.resolve() return dispatch('fetchCycleAnalyticsData').then(() =>
.then(() => dispatch('fetchCycleAnalyticsData')) dispatch('initializeCycleAnalyticsSuccess'),
.then(() => dispatch('initializeCycleAnalyticsSuccess')); );
} }
return dispatch('initializeCycleAnalyticsSuccess'); return dispatch('initializeCycleAnalyticsSuccess');
}; };
......
...@@ -6,6 +6,8 @@ import * as types from './mutation_types'; ...@@ -6,6 +6,8 @@ import * as types from './mutation_types';
const appendExtension = path => (path.indexOf('.') > -1 ? path : `${path}.json`); const appendExtension = path => (path.indexOf('.') > -1 ? path : `${path}.json`);
// TODO: After we remove instance VSA we can rely on the paths from the BE
// https://gitlab.com/gitlab-org/gitlab/-/issues/223735
export const setPaths = ({ commit }, { groupPath = '', milestonesPath = '', labelsPath = '' }) => { export const setPaths = ({ commit }, { groupPath = '', milestonesPath = '', labelsPath = '' }) => {
const ms = milestonesPath || `/groups/${groupPath}/-/milestones`; const ms = milestonesPath || `/groups/${groupPath}/-/milestones`;
const ls = labelsPath || `/groups/${groupPath}/-/labels`; const ls = labelsPath || `/groups/${groupPath}/-/labels`;
...@@ -88,8 +90,7 @@ export const setFilters = ({ dispatch }, nextFilters) => ...@@ -88,8 +90,7 @@ export const setFilters = ({ dispatch }, nextFilters) =>
export const initialize = ({ dispatch, commit }, initialFilters) => { export const initialize = ({ dispatch, commit }, initialFilters) => {
commit(types.INITIALIZE, initialFilters); commit(types.INITIALIZE, initialFilters);
return Promise.resolve() return dispatch('setPaths', initialFilters)
.then(() => dispatch('setPaths', initialFilters))
.then(() => dispatch('setFilters', initialFilters)) .then(() => dispatch('setFilters', initialFilters))
.then(() => dispatch('fetchTokenData')); .then(() => dispatch('fetchTokenData'));
}; };
...@@ -98,7 +98,7 @@ function createComponent({ ...@@ -98,7 +98,7 @@ function createComponent({
}); });
if (withStageSelected) { if (withStageSelected) {
comp.vm.$store.dispatch('setSelectedGroup', { comp.vm.$store.commit('SET_SELECTED_GROUP', {
...selectedGroup, ...selectedGroup,
}); });
......
...@@ -16,10 +16,15 @@ jest.mock('~/flash', () => jest.fn()); ...@@ -16,10 +16,15 @@ jest.mock('~/flash', () => jest.fn());
describe('Filters actions', () => { describe('Filters actions', () => {
let state; let state;
let mock; let mock;
let mockDispatch;
let mockCommit;
beforeEach(() => { beforeEach(() => {
state = initialState(); state = initialState();
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
mockDispatch = jest.fn().mockResolvedValue();
mockCommit = jest.fn();
}); });
afterEach(() => { afterEach(() => {
...@@ -34,18 +39,37 @@ describe('Filters actions', () => { ...@@ -34,18 +39,37 @@ describe('Filters actions', () => {
selectedMilestone: 'NEXT', selectedMilestone: 'NEXT',
}; };
it('initializes the state and dispatches setPaths, setFilters and fetchTokenData', () => { it('dispatches setPaths, setFilters and fetchTokenData', () => {
return testAction( return actions
actions.initialize, .initialize(
{
state,
dispatch: mockDispatch,
commit: mockCommit,
},
initialData, initialData,
)
.then(() => {
expect(mockDispatch).toHaveBeenCalledTimes(3);
expect(mockDispatch).toHaveBeenCalledWith('setPaths', initialData);
expect(mockDispatch).toHaveBeenCalledWith('setFilters', initialData);
expect(mockDispatch).toHaveBeenCalledWith('fetchTokenData');
});
});
it(`commits the ${types.INITIALIZE}`, () => {
return actions
.initialize(
{
state, state,
[{ type: types.INITIALIZE, payload: initialData }], dispatch: mockDispatch,
[ commit: mockCommit,
{ type: 'setPaths', payload: initialData }, },
{ type: 'setFilters', payload: initialData }, initialData,
{ type: 'fetchTokenData' }, )
], .then(() => {
); expect(mockCommit).toHaveBeenCalledWith(types.INITIALIZE, initialData);
});
}); });
}); });
......
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