Commit 9b6b548b authored by Rajat Jain's avatar Rajat Jain

Prevent weightSum to be updated on child epic fetch

`weightSum` should not be updated when child subepic was
fetched

EE: true
Changelog: fixed
parent bf281cff
......@@ -124,9 +124,8 @@ export const fetchItems = ({ dispatch }, { parentItem, isSubItem = false }) => {
pageInfo: data.group.epic.issues.pageInfo,
});
dispatch('setWeightSum', data.group.epic.descendantWeightSum);
if (!isSubItem) {
dispatch('setWeightSum', data.group.epic.descendantWeightSum);
dispatch('setChildrenCount', data.group.epic.descendantCounts);
dispatch('setHealthStatus', data.group.epic.healthStatus);
}
......
......@@ -448,6 +448,71 @@ describe('RelatedItemTree', () => {
);
});
it('should not dispatch `setWeightSum`, `setChildrenCount`, `setHealthStatus` when isSubItem is true', () => {
jest.spyOn(epicUtils.gqClient, 'query').mockReturnValue(
Promise.resolve({
data: mockQueryResponse.data,
}),
);
const children = epicUtils.processQueryResponse(mockQueryResponse.data.group);
const {
children: { pageInfo: epicPageInfo },
issues: { pageInfo: issuesPageInfo },
} = mockQueryResponse.data.group.epic;
testAction(
actions.fetchItems,
{ parentItem: mockParentItem, isSubItem: true },
{},
[],
[
{
type: 'requestItems',
payload: { parentItem: mockParentItem, isSubItem: true },
},
{
type: 'receiveItemsSuccess',
payload: {
parentItem: mockParentItem,
isSubItem: true,
children,
},
},
{
type: 'setItemChildren',
payload: {
parentItem: mockParentItem,
isSubItem: true,
children,
},
},
{
type: 'setItemChildrenFlags',
payload: {
isSubItem: true,
children,
},
},
{
type: 'setEpicPageInfo',
payload: {
parentItem: mockParentItem,
pageInfo: epicPageInfo,
},
},
{
type: 'setIssuePageInfo',
payload: {
parentItem: mockParentItem,
pageInfo: issuesPageInfo,
},
},
],
);
});
it('should dispatch `receiveItemsFailure` on request failure', () => {
jest.spyOn(epicUtils.gqClient, 'query').mockReturnValue(Promise.reject());
......
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