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 {
return this.featureFlags.hasPathNavigation && !this.hasNoAccessError && this.selectedStage;
},
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;
},
isLoadingTypeOfWork() {
......
......@@ -268,9 +268,9 @@ export const initializeCycleAnalytics = ({ dispatch, commit }, initialData = {})
});
}
return Promise.resolve()
.then(() => dispatch('fetchCycleAnalyticsData'))
.then(() => dispatch('initializeCycleAnalyticsSuccess'));
return dispatch('fetchCycleAnalyticsData').then(() =>
dispatch('initializeCycleAnalyticsSuccess'),
);
}
return dispatch('initializeCycleAnalyticsSuccess');
};
......
......@@ -6,6 +6,8 @@ import * as types from './mutation_types';
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 = '' }) => {
const ms = milestonesPath || `/groups/${groupPath}/-/milestones`;
const ls = labelsPath || `/groups/${groupPath}/-/labels`;
......@@ -88,8 +90,7 @@ export const setFilters = ({ dispatch }, nextFilters) =>
export const initialize = ({ dispatch, commit }, initialFilters) => {
commit(types.INITIALIZE, initialFilters);
return Promise.resolve()
.then(() => dispatch('setPaths', initialFilters))
return dispatch('setPaths', initialFilters)
.then(() => dispatch('setFilters', initialFilters))
.then(() => dispatch('fetchTokenData'));
};
......@@ -98,7 +98,7 @@ function createComponent({
});
if (withStageSelected) {
comp.vm.$store.dispatch('setSelectedGroup', {
comp.vm.$store.commit('SET_SELECTED_GROUP', {
...selectedGroup,
});
......
......@@ -16,10 +16,15 @@ jest.mock('~/flash', () => jest.fn());
describe('Filters actions', () => {
let state;
let mock;
let mockDispatch;
let mockCommit;
beforeEach(() => {
state = initialState();
mock = new MockAdapter(axios);
mockDispatch = jest.fn().mockResolvedValue();
mockCommit = jest.fn();
});
afterEach(() => {
......@@ -34,18 +39,37 @@ describe('Filters actions', () => {
selectedMilestone: 'NEXT',
};
it('initializes the state and dispatches setPaths, setFilters and fetchTokenData', () => {
return testAction(
actions.initialize,
initialData,
state,
[{ type: types.INITIALIZE, payload: initialData }],
[
{ type: 'setPaths', payload: initialData },
{ type: 'setFilters', payload: initialData },
{ type: 'fetchTokenData' },
],
);
it('dispatches setPaths, setFilters and fetchTokenData', () => {
return actions
.initialize(
{
state,
dispatch: mockDispatch,
commit: mockCommit,
},
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,
dispatch: mockDispatch,
commit: mockCommit,
},
initialData,
)
.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