Commit 3112fdb6 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'vs/ee-remove-jest-test-callback' into 'master'

Remove Jest test callback in EE specs

See merge request gitlab-org/gitlab!84181
parents 25be580b a0cc00ea
--- ---
extends: ../../../spec/frontend/.eslintrc.yml extends: ../../../spec/frontend/.eslintrc.yml
rules:
jest/no-test-callback: error
...@@ -91,8 +91,8 @@ describe('Code review analytics mergeRequests actions', () => { ...@@ -91,8 +91,8 @@ describe('Code review analytics mergeRequests actions', () => {
mock.onGet(/api\/(.*)\/analytics\/code_review/).replyOnce(500); mock.onGet(/api\/(.*)\/analytics\/code_review/).replyOnce(500);
}); });
it('dispatches error', (done) => { it('dispatches error', async () => {
testAction( await testAction(
actions.fetchMergeRequests, actions.fetchMergeRequests,
null, null,
state, state,
...@@ -104,11 +104,9 @@ describe('Code review analytics mergeRequests actions', () => { ...@@ -104,11 +104,9 @@ describe('Code review analytics mergeRequests actions', () => {
}, },
], ],
[], [],
() => {
expect(createFlash).toHaveBeenCalled();
done();
},
); );
expect(createFlash).toHaveBeenCalled();
}); });
}); });
}); });
......
...@@ -5,7 +5,7 @@ import testAction from 'helpers/vuex_action_helper'; ...@@ -5,7 +5,7 @@ import testAction from 'helpers/vuex_action_helper';
describe('Productivity analytics actions', () => { describe('Productivity analytics actions', () => {
describe('setEndpoint', () => { describe('setEndpoint', () => {
it('commits the SET_ENDPOINT mutation', (done) => it('commits the SET_ENDPOINT mutation', async () =>
testAction( testAction(
actions.setEndpoint, actions.setEndpoint,
'endpoint.json', 'endpoint.json',
...@@ -17,7 +17,6 @@ describe('Productivity analytics actions', () => { ...@@ -17,7 +17,6 @@ describe('Productivity analytics actions', () => {
}, },
], ],
[], [],
done,
)); ));
}); });
}); });
...@@ -72,7 +72,7 @@ describe('Productivity analytics chart actions', () => { ...@@ -72,7 +72,7 @@ describe('Productivity analytics chart actions', () => {
expect(axios.get).toHaveBeenCalledWith(mockedState.endpoint, { params: globalParams }); expect(axios.get).toHaveBeenCalledWith(mockedState.endpoint, { params: globalParams });
}); });
it('dispatches success with received data', (done) => it('dispatches success with received data', async () =>
testAction( testAction(
actions.fetchChartData, actions.fetchChartData,
chartKey, chartKey,
...@@ -85,7 +85,6 @@ describe('Productivity analytics chart actions', () => { ...@@ -85,7 +85,6 @@ describe('Productivity analytics chart actions', () => {
payload: expect.objectContaining({ chartKey, data: mockHistogramData }), payload: expect.objectContaining({ chartKey, data: mockHistogramData }),
}, },
], ],
done,
)); ));
}); });
...@@ -94,8 +93,8 @@ describe('Productivity analytics chart actions', () => { ...@@ -94,8 +93,8 @@ describe('Productivity analytics chart actions', () => {
mock.onGet(mockedState.endpoint).replyOnce(200, mockScatterplotData); mock.onGet(mockedState.endpoint).replyOnce(200, mockScatterplotData);
}); });
it('dispatches success with received data and transformedData', (done) => { it('dispatches success with received data and transformedData', async () => {
testAction( await testAction(
actions.fetchChartData, actions.fetchChartData,
chartKeys.scatterplot, chartKeys.scatterplot,
mockedState, mockedState,
...@@ -111,7 +110,6 @@ describe('Productivity analytics chart actions', () => { ...@@ -111,7 +110,6 @@ describe('Productivity analytics chart actions', () => {
}, },
}, },
], ],
done,
); );
}); });
}); });
...@@ -122,8 +120,8 @@ describe('Productivity analytics chart actions', () => { ...@@ -122,8 +120,8 @@ describe('Productivity analytics chart actions', () => {
mock.onGet(mockedState.endpoint).replyOnce(500); mock.onGet(mockedState.endpoint).replyOnce(500);
}); });
it('dispatches error', (done) => { it('dispatches error', async () => {
testAction( await testAction(
actions.fetchChartData, actions.fetchChartData,
chartKey, chartKey,
mockedState, mockedState,
...@@ -141,7 +139,6 @@ describe('Productivity analytics chart actions', () => { ...@@ -141,7 +139,6 @@ describe('Productivity analytics chart actions', () => {
}, },
}, },
], ],
done,
); );
}); });
}); });
...@@ -149,14 +146,13 @@ describe('Productivity analytics chart actions', () => { ...@@ -149,14 +146,13 @@ describe('Productivity analytics chart actions', () => {
}); });
describe('requestChartData', () => { describe('requestChartData', () => {
it('should commit the request mutation', (done) => { it('should commit the request mutation', async () => {
testAction( await testAction(
actions.requestChartData, actions.requestChartData,
chartKey, chartKey,
mockedContext.state, mockedContext.state,
[{ type: types.REQUEST_CHART_DATA, payload: chartKey }], [{ type: types.REQUEST_CHART_DATA, payload: chartKey }],
[], [],
done,
); );
}); });
...@@ -167,8 +163,8 @@ describe('Productivity analytics chart actions', () => { ...@@ -167,8 +163,8 @@ describe('Productivity analytics chart actions', () => {
mockedState.charts[disabledChartKey].enabled = false; mockedState.charts[disabledChartKey].enabled = false;
}); });
it('does not dispatch the requestChartData action', (done) => { it('does not dispatch the requestChartData action', async () => {
testAction(actions.fetchChartData, disabledChartKey, mockedState, [], [], done); await testAction(actions.fetchChartData, disabledChartKey, mockedState, [], []);
}); });
it('does not call the API', () => { it('does not call the API', () => {
...@@ -180,8 +176,8 @@ describe('Productivity analytics chart actions', () => { ...@@ -180,8 +176,8 @@ describe('Productivity analytics chart actions', () => {
}); });
describe('receiveChartDataSuccess', () => { describe('receiveChartDataSuccess', () => {
it('should commit received data', (done) => { it('should commit received data', async () => {
testAction( await testAction(
actions.receiveChartDataSuccess, actions.receiveChartDataSuccess,
{ chartKey, data: mockHistogramData }, { chartKey, data: mockHistogramData },
mockedContext.state, mockedContext.state,
...@@ -192,15 +188,14 @@ describe('Productivity analytics chart actions', () => { ...@@ -192,15 +188,14 @@ describe('Productivity analytics chart actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveChartDataError', () => { describe('receiveChartDataError', () => {
it('should commit error', (done) => { it('should commit error', async () => {
const error = { response: { status: 500 } }; const error = { response: { status: 500 } };
testAction( await testAction(
actions.receiveChartDataError, actions.receiveChartDataError,
{ chartKey, error }, { chartKey, error },
mockedContext.state, mockedContext.state,
...@@ -214,14 +209,13 @@ describe('Productivity analytics chart actions', () => { ...@@ -214,14 +209,13 @@ describe('Productivity analytics chart actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('fetchSecondaryChartData', () => { describe('fetchSecondaryChartData', () => {
it('dispatches fetchChartData for all chart types except for the main chart', (done) => { it('dispatches fetchChartData for all chart types except for the main chart', async () => {
testAction( await testAction(
actions.fetchSecondaryChartData, actions.fetchSecondaryChartData,
null, null,
mockedContext.state, mockedContext.state,
...@@ -231,7 +225,6 @@ describe('Productivity analytics chart actions', () => { ...@@ -231,7 +225,6 @@ describe('Productivity analytics chart actions', () => {
{ type: 'fetchChartData', payload: chartKeys.commitBasedHistogram }, { type: 'fetchChartData', payload: chartKeys.commitBasedHistogram },
{ type: 'fetchChartData', payload: chartKeys.scatterplot }, { type: 'fetchChartData', payload: chartKeys.scatterplot },
], ],
done,
); );
}); });
}); });
...@@ -239,48 +232,45 @@ describe('Productivity analytics chart actions', () => { ...@@ -239,48 +232,45 @@ describe('Productivity analytics chart actions', () => {
describe('setMetricType', () => { describe('setMetricType', () => {
const metricType = 'time_to_merge'; const metricType = 'time_to_merge';
it('should commit metricType', (done) => { it('should commit metricType', async () => {
testAction( await testAction(
actions.setMetricType, actions.setMetricType,
{ chartKey, metricType }, { chartKey, metricType },
mockedContext.state, mockedContext.state,
[{ type: types.SET_METRIC_TYPE, payload: { chartKey, metricType } }], [{ type: types.SET_METRIC_TYPE, payload: { chartKey, metricType } }],
[{ type: 'fetchChartData', payload: chartKey }], [{ type: 'fetchChartData', payload: chartKey }],
done,
); );
}); });
}); });
describe('updateSelectedItems', () => { describe('updateSelectedItems', () => {
it('should commit selected chart item and dispatch fetchSecondaryChartData and setPage', (done) => { it('should commit selected chart item and dispatch fetchSecondaryChartData and setPage', async () => {
testAction( await testAction(
actions.updateSelectedItems, actions.updateSelectedItems,
{ chartKey, item: 5 }, { chartKey, item: 5 },
mockedContext.state, mockedContext.state,
[{ type: types.UPDATE_SELECTED_CHART_ITEMS, payload: { chartKey, item: 5 } }], [{ type: types.UPDATE_SELECTED_CHART_ITEMS, payload: { chartKey, item: 5 } }],
[{ type: 'fetchSecondaryChartData' }, { type: 'table/setPage', payload: 0 }], [{ type: 'fetchSecondaryChartData' }, { type: 'table/setPage', payload: 0 }],
done,
); );
}); });
}); });
describe('resetMainChartSelection', () => { describe('resetMainChartSelection', () => {
describe('when skipReload is false (by default)', () => { describe('when skipReload is false (by default)', () => {
it('should commit selected chart item and dispatch fetchSecondaryChartData and setPage', (done) => { it('should commit selected chart item and dispatch fetchSecondaryChartData and setPage', async () => {
testAction( await testAction(
actions.resetMainChartSelection, actions.resetMainChartSelection,
null, null,
mockedContext.state, mockedContext.state,
[{ type: types.UPDATE_SELECTED_CHART_ITEMS, payload: { chartKey, item: null } }], [{ type: types.UPDATE_SELECTED_CHART_ITEMS, payload: { chartKey, item: null } }],
[{ type: 'fetchSecondaryChartData' }, { type: 'table/setPage', payload: 0 }], [{ type: 'fetchSecondaryChartData' }, { type: 'table/setPage', payload: 0 }],
done,
); );
}); });
}); });
describe('when skipReload is true', () => { describe('when skipReload is true', () => {
it('should commit selected chart and it should not dispatch any further actions', (done) => { it('should commit selected chart and it should not dispatch any further actions', async () => {
testAction( await testAction(
actions.resetMainChartSelection, actions.resetMainChartSelection,
true, true,
mockedContext.state, mockedContext.state,
...@@ -291,15 +281,14 @@ describe('Productivity analytics chart actions', () => { ...@@ -291,15 +281,14 @@ describe('Productivity analytics chart actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
}); });
describe('setChartEnabled', () => { describe('setChartEnabled', () => {
it('should commit enabled state', (done) => { it('should commit enabled state', async () => {
testAction( await testAction(
actions.setChartEnabled, actions.setChartEnabled,
{ chartKey: chartKeys.scatterplot, isEnabled: false }, { chartKey: chartKeys.scatterplot, isEnabled: false },
mockedContext.state, mockedContext.state,
...@@ -310,7 +299,6 @@ describe('Productivity analytics chart actions', () => { ...@@ -310,7 +299,6 @@ describe('Productivity analytics chart actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
......
...@@ -30,10 +30,8 @@ describe('Productivity analytics filter actions', () => { ...@@ -30,10 +30,8 @@ describe('Productivity analytics filter actions', () => {
}); });
describe('setInitialData', () => { describe('setInitialData', () => {
it('commits the SET_INITIAL_DATA mutation and fetches data by default', (done) => { it('commits the SET_INITIAL_DATA mutation and fetches data by default', async () => {
actions await actions.setInitialData(store, { data: initialData });
.setInitialData(store, { data: initialData })
.then(() => {
expect(store.commit).toHaveBeenCalledWith(types.SET_INITIAL_DATA, initialData); expect(store.commit).toHaveBeenCalledWith(types.SET_INITIAL_DATA, initialData);
expect(store.dispatch.mock.calls[0]).toEqual([ expect(store.dispatch.mock.calls[0]).toEqual([
...@@ -49,12 +47,9 @@ describe('Productivity analytics filter actions', () => { ...@@ -49,12 +47,9 @@ describe('Productivity analytics filter actions', () => {
]); ]);
expect(store.dispatch.mock.calls[2]).toEqual(['table/setPage', 0, { root: true }]); expect(store.dispatch.mock.calls[2]).toEqual(['table/setPage', 0, { root: true }]);
})
.then(done)
.catch(done.fail);
}); });
it("commits the SET_INITIAL_DATA mutation and doesn't fetch data when skipFetch=true", (done) => it("commits the SET_INITIAL_DATA mutation and doesn't fetch data when skipFetch=true", async () =>
testAction( testAction(
actions.setInitialData, actions.setInitialData,
{ skipFetch: true, data: initialData }, { skipFetch: true, data: initialData },
...@@ -66,15 +61,12 @@ describe('Productivity analytics filter actions', () => { ...@@ -66,15 +61,12 @@ describe('Productivity analytics filter actions', () => {
}, },
], ],
[], [],
done,
)); ));
}); });
describe('setGroupNamespace', () => { describe('setGroupNamespace', () => {
it('commits the SET_GROUP_NAMESPACE mutation', (done) => { it('commits the SET_GROUP_NAMESPACE mutation', async () => {
actions await actions.setGroupNamespace(store, groupNamespace);
.setGroupNamespace(store, groupNamespace)
.then(() => {
expect(store.commit).toHaveBeenCalledWith(types.SET_GROUP_NAMESPACE, groupNamespace); expect(store.commit).toHaveBeenCalledWith(types.SET_GROUP_NAMESPACE, groupNamespace);
expect(store.dispatch.mock.calls[0]).toEqual([ expect(store.dispatch.mock.calls[0]).toEqual([
...@@ -96,17 +88,12 @@ describe('Productivity analytics filter actions', () => { ...@@ -96,17 +88,12 @@ describe('Productivity analytics filter actions', () => {
]); ]);
expect(store.dispatch.mock.calls[3]).toEqual(['table/setPage', 0, { root: true }]); expect(store.dispatch.mock.calls[3]).toEqual(['table/setPage', 0, { root: true }]);
})
.then(done)
.catch(done.fail);
}); });
}); });
describe('setProjectPath', () => { describe('setProjectPath', () => {
it('commits the SET_PROJECT_PATH mutation', (done) => { it('commits the SET_PROJECT_PATH mutation', async () => {
actions await actions.setProjectPath(store, projectPath);
.setProjectPath(store, projectPath)
.then(() => {
expect(store.commit).toHaveBeenCalledWith(types.SET_PROJECT_PATH, projectPath); expect(store.commit).toHaveBeenCalledWith(types.SET_PROJECT_PATH, projectPath);
expect(store.dispatch.mock.calls[0]).toEqual([ expect(store.dispatch.mock.calls[0]).toEqual([
...@@ -128,17 +115,12 @@ describe('Productivity analytics filter actions', () => { ...@@ -128,17 +115,12 @@ describe('Productivity analytics filter actions', () => {
]); ]);
expect(store.dispatch.mock.calls[3]).toEqual(['table/setPage', 0, { root: true }]); expect(store.dispatch.mock.calls[3]).toEqual(['table/setPage', 0, { root: true }]);
})
.then(done)
.catch(done.fail);
}); });
}); });
describe('setFilters', () => { describe('setFilters', () => {
it('commits the SET_FILTERS mutation', (done) => { it('commits the SET_FILTERS mutation', async () => {
actions await actions.setFilters(store, { author_username: 'root' });
.setFilters(store, { author_username: 'root' })
.then(() => {
expect(store.commit).toHaveBeenCalledWith(types.SET_FILTERS, { authorUsername: 'root' }); expect(store.commit).toHaveBeenCalledWith(types.SET_FILTERS, { authorUsername: 'root' });
expect(store.dispatch.mock.calls[0]).toEqual([ expect(store.dispatch.mock.calls[0]).toEqual([
...@@ -160,17 +142,12 @@ describe('Productivity analytics filter actions', () => { ...@@ -160,17 +142,12 @@ describe('Productivity analytics filter actions', () => {
]); ]);
expect(store.dispatch.mock.calls[3]).toEqual(['table/setPage', 0, { root: true }]); expect(store.dispatch.mock.calls[3]).toEqual(['table/setPage', 0, { root: true }]);
})
.then(done)
.catch(done.fail);
}); });
}); });
describe('setDateRange', () => { describe('setDateRange', () => {
it('commits the SET_DATE_RANGE mutation', (done) => { it('commits the SET_DATE_RANGE mutation', async () => {
actions await actions.setDateRange(store, { startDate, endDate });
.setDateRange(store, { startDate, endDate })
.then(() => {
expect(store.commit).toHaveBeenCalledWith(types.SET_DATE_RANGE, { startDate, endDate }); expect(store.commit).toHaveBeenCalledWith(types.SET_DATE_RANGE, { startDate, endDate });
expect(store.dispatch.mock.calls[0]).toEqual([ expect(store.dispatch.mock.calls[0]).toEqual([
...@@ -192,9 +169,6 @@ describe('Productivity analytics filter actions', () => { ...@@ -192,9 +169,6 @@ describe('Productivity analytics filter actions', () => {
]); ]);
expect(store.dispatch.mock.calls[3]).toEqual(['table/setPage', 0, { root: true }]); expect(store.dispatch.mock.calls[3]).toEqual(['table/setPage', 0, { root: true }]);
})
.then(done)
.catch(done.fail);
}); });
}); });
}); });
...@@ -104,7 +104,7 @@ describe('Productivity analytics table actions', () => { ...@@ -104,7 +104,7 @@ describe('Productivity analytics table actions', () => {
}); });
}); });
it('dispatches success with received data', (done) => it('dispatches success with received data', async () =>
testAction( testAction(
actions.fetchMergeRequests, actions.fetchMergeRequests,
null, null,
...@@ -117,7 +117,6 @@ describe('Productivity analytics table actions', () => { ...@@ -117,7 +117,6 @@ describe('Productivity analytics table actions', () => {
payload: { data: mockMergeRequests, headers }, payload: { data: mockMergeRequests, headers },
}, },
], ],
done,
)); ));
}); });
...@@ -126,8 +125,8 @@ describe('Productivity analytics table actions', () => { ...@@ -126,8 +125,8 @@ describe('Productivity analytics table actions', () => {
mock.onGet(mockedState.endpoint).replyOnce(500); mock.onGet(mockedState.endpoint).replyOnce(500);
}); });
it('dispatches error', (done) => { it('dispatches error', async () => {
testAction( await testAction(
actions.fetchMergeRequests, actions.fetchMergeRequests,
null, null,
mockedState, mockedState,
...@@ -139,26 +138,24 @@ describe('Productivity analytics table actions', () => { ...@@ -139,26 +138,24 @@ describe('Productivity analytics table actions', () => {
payload: new Error('Request failed with status code 500'), payload: new Error('Request failed with status code 500'),
}, },
], ],
done,
); );
}); });
}); });
}); });
describe('requestMergeRequests', () => { describe('requestMergeRequests', () => {
it('should commit the request mutation', (done) => it('should commit the request mutation', async () =>
testAction( testAction(
actions.requestMergeRequests, actions.requestMergeRequests,
null, null,
mockedContext.state, mockedContext.state,
[{ type: types.REQUEST_MERGE_REQUESTS }], [{ type: types.REQUEST_MERGE_REQUESTS }],
[], [],
done,
)); ));
}); });
describe('receiveMergeRequestsSuccess', () => { describe('receiveMergeRequestsSuccess', () => {
it('should commit received data', (done) => it('should commit received data', async () =>
testAction( testAction(
actions.receiveMergeRequestsSuccess, actions.receiveMergeRequestsSuccess,
{ headers, data: mockMergeRequests }, { headers, data: mockMergeRequests },
...@@ -170,24 +167,22 @@ describe('Productivity analytics table actions', () => { ...@@ -170,24 +167,22 @@ describe('Productivity analytics table actions', () => {
}, },
], ],
[], [],
done,
)); ));
}); });
describe('receiveMergeRequestsError', () => { describe('receiveMergeRequestsError', () => {
it('should commit error', (done) => it('should commit error', async () =>
testAction( testAction(
actions.receiveMergeRequestsError, actions.receiveMergeRequestsError,
{ response: { status: 500 } }, { response: { status: 500 } },
mockedContext.state, mockedContext.state,
[{ type: types.RECEIVE_MERGE_REQUESTS_ERROR, payload: 500 }], [{ type: types.RECEIVE_MERGE_REQUESTS_ERROR, payload: 500 }],
[], [],
done,
)); ));
}); });
describe('setSortField', () => { describe('setSortField', () => {
it('should commit setSortField', (done) => it('should commit setSortField', async () =>
testAction( testAction(
actions.setSortField, actions.setSortField,
'time_to_last_commit', 'time_to_last_commit',
...@@ -197,53 +192,48 @@ describe('Productivity analytics table actions', () => { ...@@ -197,53 +192,48 @@ describe('Productivity analytics table actions', () => {
{ type: 'setColumnMetric', payload: 'time_to_last_commit' }, { type: 'setColumnMetric', payload: 'time_to_last_commit' },
{ type: 'fetchMergeRequests' }, { type: 'fetchMergeRequests' },
], ],
done,
)); ));
it('should not dispatch setColumnMetric when metric is "days_to_merge"', (done) => it('should not dispatch setColumnMetric when metric is "days_to_merge"', async () =>
testAction( testAction(
actions.setSortField, actions.setSortField,
'days_to_merge', 'days_to_merge',
mockedContext.state, mockedContext.state,
[{ type: types.SET_SORT_FIELD, payload: 'days_to_merge' }], [{ type: types.SET_SORT_FIELD, payload: 'days_to_merge' }],
[{ type: 'fetchMergeRequests' }], [{ type: 'fetchMergeRequests' }],
done,
)); ));
}); });
describe('toggleSortOrder', () => { describe('toggleSortOrder', () => {
it('should commit toggleSortOrder', (done) => it('should commit toggleSortOrder', async () =>
testAction( testAction(
actions.toggleSortOrder, actions.toggleSortOrder,
null, null,
mockedContext.state, mockedContext.state,
[{ type: types.TOGGLE_SORT_ORDER }], [{ type: types.TOGGLE_SORT_ORDER }],
[{ type: 'fetchMergeRequests' }], [{ type: 'fetchMergeRequests' }],
done,
)); ));
}); });
describe('setColumnMetric', () => { describe('setColumnMetric', () => {
it('should commit setColumnMetric', (done) => it('should commit setColumnMetric', async () =>
testAction( testAction(
actions.setColumnMetric, actions.setColumnMetric,
'time_to_first_comment', 'time_to_first_comment',
mockedContext.state, mockedContext.state,
[{ type: types.SET_COLUMN_METRIC, payload: 'time_to_first_comment' }], [{ type: types.SET_COLUMN_METRIC, payload: 'time_to_first_comment' }],
[], [],
done,
)); ));
}); });
describe('setPage', () => { describe('setPage', () => {
it('should commit setPage', (done) => it('should commit setPage', async () =>
testAction( testAction(
actions.setPage, actions.setPage,
2, 2,
mockedContext.state, mockedContext.state,
[{ type: types.SET_PAGE, payload: 2 }], [{ type: types.SET_PAGE, payload: 2 }],
[{ type: 'fetchMergeRequests' }], [{ type: 'fetchMergeRequests' }],
done,
)); ));
}); });
}); });
...@@ -43,7 +43,7 @@ describe('Api', () => { ...@@ -43,7 +43,7 @@ describe('Api', () => {
}); });
describe('ldapGroups', () => { describe('ldapGroups', () => {
it('calls callback on completion', (done) => { it('calls callback on completion', async () => {
const query = 'query'; const query = 'query';
const provider = 'provider'; const provider = 'provider';
const callback = jest.fn(); const callback = jest.fn();
...@@ -55,17 +55,13 @@ describe('Api', () => { ...@@ -55,17 +55,13 @@ describe('Api', () => {
}, },
]); ]);
Api.ldapGroups(query, provider, callback) const response = await Api.ldapGroups(query, provider, callback);
.then((response) => {
expect(callback).toHaveBeenCalledWith(response); expect(callback).toHaveBeenCalledWith(response);
})
.then(done)
.catch(done.fail);
}); });
}); });
describe('createChildEpic', () => { describe('createChildEpic', () => {
it('calls `axios.post` using params `groupId`, `parentEpicIid` and title', (done) => { it('calls `axios.post` using params `groupId`, `parentEpicIid` and title', async () => {
const groupId = 'gitlab-org'; const groupId = 'gitlab-org';
const parentEpicId = 1; const parentEpicId = 1;
const title = 'Sample epic'; const title = 'Sample epic';
...@@ -78,19 +74,15 @@ describe('Api', () => { ...@@ -78,19 +74,15 @@ describe('Api', () => {
mock.onPost(expectedUrl).reply(httpStatus.OK, expectedRes); mock.onPost(expectedUrl).reply(httpStatus.OK, expectedRes);
Api.createChildEpic({ groupId, parentEpicId, title }) const { data } = await Api.createChildEpic({ groupId, parentEpicId, title });
.then(({ data }) => {
expect(data.title).toBe(expectedRes.title); expect(data.title).toBe(expectedRes.title);
expect(data.id).toBe(expectedRes.id); expect(data.id).toBe(expectedRes.id);
expect(data.parentId).toBe(expectedRes.parentId); expect(data.parentId).toBe(expectedRes.parentId);
})
.then(done)
.catch(done.fail);
}); });
}); });
describe('groupEpics', () => { describe('groupEpics', () => {
it('calls `axios.get` using param `groupId`', (done) => { it('calls `axios.get` using param `groupId`', async () => {
const groupId = 2; const groupId = 2;
const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/groups/${groupId}/epics`; const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/groups/${groupId}/epics`;
...@@ -103,20 +95,16 @@ describe('Api', () => { ...@@ -103,20 +95,16 @@ describe('Api', () => {
}) })
.reply(httpStatus.OK, mockEpics); .reply(httpStatus.OK, mockEpics);
Api.groupEpics({ groupId }) const { data } = await Api.groupEpics({ groupId });
.then(({ data }) => {
data.forEach((epic, index) => { data.forEach((epic, index) => {
expect(epic.id).toBe(mockEpics[index].id); expect(epic.id).toBe(mockEpics[index].id);
expect(epic.iid).toBe(mockEpics[index].iid); expect(epic.iid).toBe(mockEpics[index].iid);
expect(epic.group_id).toBe(mockEpics[index].group_id); expect(epic.group_id).toBe(mockEpics[index].group_id);
expect(epic.title).toBe(mockEpics[index].title); expect(epic.title).toBe(mockEpics[index].title);
}); });
})
.then(done)
.catch(done.fail);
}); });
it('calls `axios.get` using param `search` when it is provided', (done) => { it('calls `axios.get` using param `search` when it is provided', async () => {
const groupId = 2; const groupId = 2;
const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/groups/${groupId}/epics`; const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/groups/${groupId}/epics`;
...@@ -130,22 +118,18 @@ describe('Api', () => { ...@@ -130,22 +118,18 @@ describe('Api', () => {
}) })
.reply(httpStatus.OK, mockEpics); .reply(httpStatus.OK, mockEpics);
Api.groupEpics({ groupId, search: 'foo' }) const { data } = await Api.groupEpics({ groupId, search: 'foo' });
.then(({ data }) => {
data.forEach((epic, index) => { data.forEach((epic, index) => {
expect(epic.id).toBe(mockEpics[index].id); expect(epic.id).toBe(mockEpics[index].id);
expect(epic.iid).toBe(mockEpics[index].iid); expect(epic.iid).toBe(mockEpics[index].iid);
expect(epic.group_id).toBe(mockEpics[index].group_id); expect(epic.group_id).toBe(mockEpics[index].group_id);
expect(epic.title).toBe(mockEpics[index].title); expect(epic.title).toBe(mockEpics[index].title);
}); });
})
.then(done)
.catch(done.fail);
}); });
}); });
describe('addEpicIssue', () => { describe('addEpicIssue', () => {
it('calls `axios.post` using params `groupId`, `epicIid` and `issueId`', (done) => { it('calls `axios.post` using params `groupId`, `epicIid` and `issueId`', async () => {
const groupId = 2; const groupId = 2;
const mockIssue = { const mockIssue = {
id: 20, id: 20,
...@@ -159,19 +143,19 @@ describe('Api', () => { ...@@ -159,19 +143,19 @@ describe('Api', () => {
mock.onPost(expectedUrl).reply(httpStatus.OK, expectedRes); mock.onPost(expectedUrl).reply(httpStatus.OK, expectedRes);
Api.addEpicIssue({ groupId, epicIid: mockEpics[0].iid, issueId: mockIssue.id }) const { data } = await Api.addEpicIssue({
.then(({ data }) => { groupId,
epicIid: mockEpics[0].iid,
issueId: mockIssue.id,
});
expect(data.id).toBe(expectedRes.id); expect(data.id).toBe(expectedRes.id);
expect(data.epic).toEqual(expect.objectContaining({ ...expectedRes.epic })); expect(data.epic).toEqual(expect.objectContaining({ ...expectedRes.epic }));
expect(data.issue).toEqual(expect.objectContaining({ ...expectedRes.issue })); expect(data.issue).toEqual(expect.objectContaining({ ...expectedRes.issue }));
})
.then(done)
.catch(done.fail);
}); });
}); });
describe('removeEpicIssue', () => { describe('removeEpicIssue', () => {
it('calls `axios.delete` using params `groupId`, `epicIid` and `epicIssueId`', (done) => { it('calls `axios.delete` using params `groupId`, `epicIid` and `epicIssueId`', async () => {
const groupId = 2; const groupId = 2;
const mockIssue = { const mockIssue = {
id: 20, id: 20,
...@@ -186,18 +170,14 @@ describe('Api', () => { ...@@ -186,18 +170,14 @@ describe('Api', () => {
mock.onDelete(expectedUrl).reply(httpStatus.OK, expectedRes); mock.onDelete(expectedUrl).reply(httpStatus.OK, expectedRes);
Api.removeEpicIssue({ const { data } = await Api.removeEpicIssue({
groupId, groupId,
epicIid: mockEpics[0].iid, epicIid: mockEpics[0].iid,
epicIssueId: mockIssue.epic_issue_id, epicIssueId: mockIssue.epic_issue_id,
}) });
.then(({ data }) => {
expect(data.id).toBe(expectedRes.id); expect(data.id).toBe(expectedRes.id);
expect(data.epic).toEqual(expect.objectContaining({ ...expectedRes.epic })); expect(data.epic).toEqual(expect.objectContaining({ ...expectedRes.epic }));
expect(data.issue).toEqual(expect.objectContaining({ ...expectedRes.issue })); expect(data.issue).toEqual(expect.objectContaining({ ...expectedRes.issue }));
})
.then(done)
.catch(done.fail);
}); });
}); });
...@@ -228,7 +208,7 @@ describe('Api', () => { ...@@ -228,7 +208,7 @@ describe('Api', () => {
}; };
describe('cycleAnalyticsTasksByType', () => { describe('cycleAnalyticsTasksByType', () => {
it('fetches tasks by type data', (done) => { it('fetches tasks by type data', async () => {
const tasksByTypeResponse = [ const tasksByTypeResponse = [
{ {
label: { label: {
...@@ -256,18 +236,17 @@ describe('Api', () => { ...@@ -256,18 +236,17 @@ describe('Api', () => {
const expectedUrl = analyticsMockData.endpoints.tasksByTypeData; const expectedUrl = analyticsMockData.endpoints.tasksByTypeData;
mock.onGet(expectedUrl).reply(httpStatus.OK, tasksByTypeResponse); mock.onGet(expectedUrl).reply(httpStatus.OK, tasksByTypeResponse);
Api.cycleAnalyticsTasksByType(groupId, params) const {
.then(({ data, config: { params: reqParams } }) => { data,
config: { params: reqParams },
} = await Api.cycleAnalyticsTasksByType(groupId, params);
expect(data).toEqual(tasksByTypeResponse); expect(data).toEqual(tasksByTypeResponse);
expect(reqParams).toEqual(params); expect(reqParams).toEqual(params);
})
.then(done)
.catch(done.fail);
}); });
}); });
describe('cycleAnalyticsTopLabels', () => { describe('cycleAnalyticsTopLabels', () => {
it('fetches top group level labels', (done) => { it('fetches top group level labels', async () => {
const response = []; const response = [];
const labelIds = [10, 9, 8, 7]; const labelIds = [10, 9, 8, 7];
const params = { const params = {
...@@ -280,89 +259,85 @@ describe('Api', () => { ...@@ -280,89 +259,85 @@ describe('Api', () => {
const expectedUrl = analyticsMockData.endpoints.tasksByTypeTopLabelsData; const expectedUrl = analyticsMockData.endpoints.tasksByTypeTopLabelsData;
mock.onGet(expectedUrl).reply(httpStatus.OK, response); mock.onGet(expectedUrl).reply(httpStatus.OK, response);
Api.cycleAnalyticsTopLabels(groupId, params) const {
.then(({ data, config: { url, params: reqParams } }) => { data,
config: { url, params: reqParams },
} = await Api.cycleAnalyticsTopLabels(groupId, params);
expect(data).toEqual(response); expect(data).toEqual(response);
expect(url).toMatch(expectedUrl); expect(url).toMatch(expectedUrl);
expect(reqParams).toEqual(params); expect(reqParams).toEqual(params);
})
.then(done)
.catch(done.fail);
}); });
}); });
describe('cycleAnalyticsValueStreams', () => { describe('cycleAnalyticsValueStreams', () => {
it('fetches custom value streams', (done) => { it('fetches custom value streams', async () => {
const response = [{ name: 'value stream 1', id: 1 }]; const response = [{ name: 'value stream 1', id: 1 }];
const expectedUrl = valueStreamBaseUrl({ resource: 'value_streams' }); const expectedUrl = valueStreamBaseUrl({ resource: 'value_streams' });
mock.onGet(expectedUrl).reply(httpStatus.OK, response); mock.onGet(expectedUrl).reply(httpStatus.OK, response);
Api.cycleAnalyticsValueStreams(groupId) const responseObj = await Api.cycleAnalyticsValueStreams(groupId);
.then((responseObj) =>
expectRequestWithCorrectParameters(responseObj, { expectRequestWithCorrectParameters(responseObj, {
response, response,
expectedUrl, expectedUrl,
}), });
)
.then(done)
.catch(done.fail);
}); });
}); });
describe('cycleAnalyticsCreateValueStream', () => { describe('cycleAnalyticsCreateValueStream', () => {
it('submit the custom value stream data', (done) => { it('submit the custom value stream data', async () => {
const response = {}; const response = {};
const customValueStream = { name: 'cool-value-stream-stage' }; const customValueStream = { name: 'cool-value-stream-stage' };
const expectedUrl = valueStreamBaseUrl({ resource: 'value_streams' }); const expectedUrl = valueStreamBaseUrl({ resource: 'value_streams' });
mock.onPost(expectedUrl).reply(httpStatus.OK, response); mock.onPost(expectedUrl).reply(httpStatus.OK, response);
Api.cycleAnalyticsCreateValueStream(groupId, customValueStream) const {
.then(({ data, config: { data: reqData, url } }) => { data,
config: { data: reqData, url },
} = await Api.cycleAnalyticsCreateValueStream(groupId, customValueStream);
expect(data).toEqual(response); expect(data).toEqual(response);
expect(JSON.parse(reqData)).toMatchObject(customValueStream); expect(JSON.parse(reqData)).toMatchObject(customValueStream);
expect(url).toEqual(expectedUrl); expect(url).toEqual(expectedUrl);
})
.then(done)
.catch(done.fail);
}); });
}); });
describe('cycleAnalyticsUpdateValueStream', () => { describe('cycleAnalyticsUpdateValueStream', () => {
it('updates the custom value stream data', (done) => { it('updates the custom value stream data', async () => {
const response = {}; const response = {};
const customValueStream = { name: 'cool-value-stream-stage', stages: [] }; const customValueStream = { name: 'cool-value-stream-stage', stages: [] };
const expectedUrl = valueStreamBaseUrl({ resource: `value_streams/${valueStreamId}` }); const expectedUrl = valueStreamBaseUrl({ resource: `value_streams/${valueStreamId}` });
mock.onPut(expectedUrl).reply(httpStatus.OK, response); mock.onPut(expectedUrl).reply(httpStatus.OK, response);
Api.cycleAnalyticsUpdateValueStream({ groupId, valueStreamId, data: customValueStream }) const {
.then(({ data, config: { data: reqData, url } }) => { data,
config: { data: reqData, url },
} = await Api.cycleAnalyticsUpdateValueStream({
groupId,
valueStreamId,
data: customValueStream,
});
expect(data).toEqual(response); expect(data).toEqual(response);
expect(JSON.parse(reqData)).toMatchObject(customValueStream); expect(JSON.parse(reqData)).toMatchObject(customValueStream);
expect(url).toEqual(expectedUrl); expect(url).toEqual(expectedUrl);
})
.then(done)
.catch(done.fail);
}); });
}); });
describe('cycleAnalyticsDeleteValueStream', () => { describe('cycleAnalyticsDeleteValueStream', () => {
it('delete the custom value stream', (done) => { it('delete the custom value stream', async () => {
const response = {}; const response = {};
const expectedUrl = valueStreamBaseUrl({ resource: `value_streams/${valueStreamId}` }); const expectedUrl = valueStreamBaseUrl({ resource: `value_streams/${valueStreamId}` });
mock.onDelete(expectedUrl).reply(httpStatus.OK, response); mock.onDelete(expectedUrl).reply(httpStatus.OK, response);
Api.cycleAnalyticsDeleteValueStream(groupId, valueStreamId) const {
.then(({ data, config: { url } }) => { data,
config: { url },
} = await Api.cycleAnalyticsDeleteValueStream(groupId, valueStreamId);
expect(data).toEqual(response); expect(data).toEqual(response);
expect(url).toEqual(expectedUrl); expect(url).toEqual(expectedUrl);
})
.then(done)
.catch(done.fail);
}); });
}); });
describe('cycleAnalyticsGroupStagesAndEvents', () => { describe('cycleAnalyticsGroupStagesAndEvents', () => {
it('fetches custom stage events and all stages', (done) => { it('fetches custom stage events and all stages', async () => {
const response = { events: [], stages: [] }; const response = { events: [], stages: [] };
const params = { const params = {
group_id: groupId, group_id: groupId,
...@@ -372,21 +347,21 @@ describe('Api', () => { ...@@ -372,21 +347,21 @@ describe('Api', () => {
const expectedUrl = valueStreamBaseUrl({ id: valueStreamId, resource: 'stages' }); const expectedUrl = valueStreamBaseUrl({ id: valueStreamId, resource: 'stages' });
mock.onGet(expectedUrl).reply(httpStatus.OK, response); mock.onGet(expectedUrl).reply(httpStatus.OK, response);
Api.cycleAnalyticsGroupStagesAndEvents({ groupId, valueStreamId, params }) const responseObj = await Api.cycleAnalyticsGroupStagesAndEvents({
.then((responseObj) => groupId,
valueStreamId,
params,
});
expectRequestWithCorrectParameters(responseObj, { expectRequestWithCorrectParameters(responseObj, {
response, response,
params, params,
expectedUrl, expectedUrl,
}), });
)
.then(done)
.catch(done.fail);
}); });
}); });
describe('cycleAnalyticsStageEvents', () => { describe('cycleAnalyticsStageEvents', () => {
it('fetches stage events', (done) => { it('fetches stage events', async () => {
const response = { events: [] }; const response = { events: [] };
const params = { ...defaultParams }; const params = { ...defaultParams };
const expectedUrl = valueStreamBaseUrl({ const expectedUrl = valueStreamBaseUrl({
...@@ -395,21 +370,22 @@ describe('Api', () => { ...@@ -395,21 +370,22 @@ describe('Api', () => {
}); });
mock.onGet(expectedUrl).reply(httpStatus.OK, response); mock.onGet(expectedUrl).reply(httpStatus.OK, response);
Api.cycleAnalyticsStageEvents({ groupId, valueStreamId, stageId, params }) const responseObj = await Api.cycleAnalyticsStageEvents({
.then((responseObj) => groupId,
valueStreamId,
stageId,
params,
});
expectRequestWithCorrectParameters(responseObj, { expectRequestWithCorrectParameters(responseObj, {
response, response,
params, params,
expectedUrl, expectedUrl,
}), });
)
.then(done)
.catch(done.fail);
}); });
}); });
describe('cycleAnalyticsDurationChart', () => { describe('cycleAnalyticsDurationChart', () => {
it('fetches stage duration data', (done) => { it('fetches stage duration data', async () => {
const response = []; const response = [];
const params = { ...defaultParams }; const params = { ...defaultParams };
const expectedUrl = valueStreamBaseUrl({ const expectedUrl = valueStreamBaseUrl({
...@@ -418,50 +394,49 @@ describe('Api', () => { ...@@ -418,50 +394,49 @@ describe('Api', () => {
}); });
mock.onGet(expectedUrl).reply(httpStatus.OK, response); mock.onGet(expectedUrl).reply(httpStatus.OK, response);
Api.cycleAnalyticsDurationChart({ groupId, valueStreamId, stageId, params }) const responseObj = await Api.cycleAnalyticsDurationChart({
.then((responseObj) => groupId,
valueStreamId,
stageId,
params,
});
expectRequestWithCorrectParameters(responseObj, { expectRequestWithCorrectParameters(responseObj, {
response, response,
params, params,
expectedUrl, expectedUrl,
}), });
)
.then(done)
.catch(done.fail);
}); });
}); });
describe('cycleAnalyticsGroupLabels', () => { describe('cycleAnalyticsGroupLabels', () => {
it('fetches group level labels', (done) => { it('fetches group level labels', async () => {
const response = []; const response = [];
const expectedUrl = `${dummyUrlRoot}/groups/${groupId}/-/labels.json`; const expectedUrl = `${dummyUrlRoot}/groups/${groupId}/-/labels.json`;
mock.onGet(expectedUrl).reply(httpStatus.OK, response); mock.onGet(expectedUrl).reply(httpStatus.OK, response);
Api.cycleAnalyticsGroupLabels(groupId) const {
.then(({ data, config: { url } }) => { data,
config: { url },
} = await Api.cycleAnalyticsGroupLabels(groupId);
expect(data).toEqual(response); expect(data).toEqual(response);
expect(url).toEqual(expectedUrl); expect(url).toEqual(expectedUrl);
})
.then(done)
.catch(done.fail);
}); });
}); });
describe('cycleAnalyticsUpdateAggregation', () => { describe('cycleAnalyticsUpdateAggregation', () => {
it('updates the aggregation enabled status', (done) => { it('updates the aggregation enabled status', async () => {
const reqdata = { enabled: true }; const reqdata = { enabled: true };
const expectedUrl = `${dummyValueStreamAnalyticsUrlRoot}/use_aggregated_backend`; const expectedUrl = `${dummyValueStreamAnalyticsUrlRoot}/use_aggregated_backend`;
mock.onPut(expectedUrl).reply(httpStatus.OK, reqdata); mock.onPut(expectedUrl).reply(httpStatus.OK, reqdata);
Api.cycleAnalyticsUpdateAggregation(groupId, reqdata) const {
.then(({ data, config: { url } }) => { data,
config: { url },
} = await Api.cycleAnalyticsUpdateAggregation(groupId, reqdata);
expect(data).toEqual(reqdata); expect(data).toEqual(reqdata);
expect(url).toEqual(expectedUrl); expect(url).toEqual(expectedUrl);
})
.then(done)
.catch(done.fail);
}); });
}); });
}); });
...@@ -486,7 +461,7 @@ describe('Api', () => { ...@@ -486,7 +461,7 @@ describe('Api', () => {
}); });
describe('groupActivityIssuesCount', () => { describe('groupActivityIssuesCount', () => {
it('fetches the number of issues created for a given group', () => { it('fetches the number of issues created for a given group', async () => {
const response = { issues_count: 20 }; const response = { issues_count: 20 };
const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/analytics/group_activity/issues_count`; const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/analytics/group_activity/issues_count`;
...@@ -494,12 +469,11 @@ describe('Api', () => { ...@@ -494,12 +469,11 @@ describe('Api', () => {
jest.spyOn(axios, 'get'); jest.spyOn(axios, 'get');
mock.onGet(expectedUrl).replyOnce(httpStatus.OK, response); mock.onGet(expectedUrl).replyOnce(httpStatus.OK, response);
return Api.groupActivityIssuesCount(groupId).then(({ data }) => { const { data } = await Api.groupActivityIssuesCount(groupId);
expect(data).toEqual(response); expect(data).toEqual(response);
expect(axios.get).toHaveBeenCalledWith(expectedUrl, { params: { group_path: groupId } }); expect(axios.get).toHaveBeenCalledWith(expectedUrl, { params: { group_path: groupId } });
}); });
}); });
});
describe('groupActivityNewMembersCount', () => { describe('groupActivityNewMembersCount', () => {
it('fetches the number of new members created for a given group', () => { it('fetches the number of new members created for a given group', () => {
......
...@@ -70,6 +70,7 @@ describe('Approvals ApproversSelect', () => { ...@@ -70,6 +70,7 @@ describe('Approvals ApproversSelect', () => {
$input = $(wrapper.vm.$refs.input); $input = $(wrapper.vm.$refs.input);
}; };
const search = (term = '') => { const search = (term = '') => {
$input.select2('search', term); $input.select2('search', term);
jest.runOnlyPendingTimers(); jest.runOnlyPendingTimers();
...@@ -93,37 +94,30 @@ describe('Approvals ApproversSelect', () => { ...@@ -93,37 +94,30 @@ describe('Approvals ApproversSelect', () => {
expect(select2Container()).not.toBe(null); expect(select2Container()).not.toBe(null);
}); });
it('queries and displays groups and users', async (done) => { it('queries and displays groups and users', async () => {
await factory(); await factory();
const expected = TEST_GROUPS.concat(TEST_USERS) const expected = TEST_GROUPS.concat(TEST_USERS)
.map(({ id, ...obj }) => obj) .map(({ id, ...obj }) => obj)
.map(({ username, ...obj }) => (!username ? obj : { ...obj, username: `@${username}` })); .map(({ username, ...obj }) => (!username ? obj : { ...obj, username: `@${username}` }));
waitForEvent($input, 'select2-loaded') search();
.then(() => {
await waitForEvent($input, 'select2-loaded');
const items = select2DropdownItems(); const items = select2DropdownItems();
expect(items).toEqual(expected); expect(items).toEqual(expected);
})
.then(done)
.catch(done.fail);
search();
}); });
describe('with search term', () => { describe('with search term', () => {
const term = 'lorem'; const term = 'lorem';
beforeEach(async (done) => { beforeEach(async () => {
await factory(); await factory();
waitForEvent($input, 'select2-loaded')
.then(jest.runOnlyPendingTimers)
.then(done)
.catch(done.fail);
search(term); search(term);
await waitForEvent($input, 'select2-loaded');
}); });
it('fetches all available groups', () => { it('fetches all available groups', () => {
...@@ -151,14 +145,11 @@ describe('Approvals ApproversSelect', () => { ...@@ -151,14 +145,11 @@ describe('Approvals ApproversSelect', () => {
}); });
}); });
it('fetches all available groups including non-visible shared groups', async (done) => { it('fetches all available groups including non-visible shared groups', async () => {
waitForEvent($input, 'select2-loaded')
.then(jest.runOnlyPendingTimers)
.then(done)
.catch(done.fail);
search(); search();
await waitForEvent($input, 'select2-loaded');
expect(Api.projectGroups).toHaveBeenCalledWith(TEST_PROJECT_ID, { expect(Api.projectGroups).toHaveBeenCalledWith(TEST_PROJECT_ID, {
skip_groups: [], skip_groups: [],
with_shared: true, with_shared: true,
...@@ -172,7 +163,7 @@ describe('Approvals ApproversSelect', () => { ...@@ -172,7 +163,7 @@ describe('Approvals ApproversSelect', () => {
const skipGroupIds = [7, 8]; const skipGroupIds = [7, 8];
const skipUserIds = [9, 10]; const skipUserIds = [9, 10];
beforeEach(async (done) => { beforeEach(async () => {
await factory({ await factory({
propsData: { propsData: {
skipGroupIds, skipGroupIds,
...@@ -180,12 +171,10 @@ describe('Approvals ApproversSelect', () => { ...@@ -180,12 +171,10 @@ describe('Approvals ApproversSelect', () => {
}, },
}); });
waitForEvent($input, 'select2-loaded')
.then(jest.runOnlyPendingTimers)
.then(done)
.catch(done.fail);
search(); search();
await waitForEvent($input, 'select2-loaded');
jest.runOnlyPendingTimers();
}); });
it('skips groups and does not fetch all available', () => { it('skips groups and does not fetch all available', () => {
...@@ -202,7 +191,7 @@ describe('Approvals ApproversSelect', () => { ...@@ -202,7 +191,7 @@ describe('Approvals ApproversSelect', () => {
}); });
}); });
it('emits input when data changes', async (done) => { it('emits input when data changes', async () => {
await factory(); await factory();
const expectedFinal = [ const expectedFinal = [
...@@ -211,24 +200,14 @@ describe('Approvals ApproversSelect', () => { ...@@ -211,24 +200,14 @@ describe('Approvals ApproversSelect', () => {
]; ];
const expected = expectedFinal.map((x, idx) => [expectedFinal.slice(0, idx + 1)]); const expected = expectedFinal.map((x, idx) => [expectedFinal.slice(0, idx + 1)]);
waitForEvent($input, 'select2-loaded') search();
.then(() => {
await waitForPromises();
const options = select2DropdownOptions(); const options = select2DropdownOptions();
$(options[TEST_GROUPS.length]).trigger('mouseup'); $(options[TEST_GROUPS.length]).trigger('mouseup');
$(options[0]).trigger('mouseup'); $(options[0]).trigger('mouseup');
})
.then(jest.runOnlyPendingTimers)
.then(done)
.catch(done.fail);
waitForEvent($input, 'change')
.then(jest.runOnlyPendingTimers)
.then(() => {
expect(wrapper.emitted().input).toEqual(expected);
})
.then(done)
.catch(done.fail);
search(); await waitForPromises();
expect(wrapper.emitted().input).toEqual(expected);
}); });
}); });
...@@ -82,7 +82,7 @@ describe('EE approvals license-compliance actions', () => { ...@@ -82,7 +82,7 @@ describe('EE approvals license-compliance actions', () => {
}); });
describe('postRule', () => { describe('postRule', () => {
it('posts correct data and dispatches "fetchRules" when request is successful', () => { it('posts correct data and dispatches "fetchRules" when request is successful', async () => {
const rule = { const rule = {
name: 'Foo', name: 'Foo',
approvalsRequired: 1, approvalsRequired: 1,
...@@ -91,7 +91,7 @@ describe('EE approvals license-compliance actions', () => { ...@@ -91,7 +91,7 @@ describe('EE approvals license-compliance actions', () => {
}; };
axiosMock.onPost(mocks.state.rulesPath).replyOnce(200); axiosMock.onPost(mocks.state.rulesPath).replyOnce(200);
return testAction( await testAction(
actions.postRule, actions.postRule,
rule, rule,
state, state,
...@@ -101,12 +101,10 @@ describe('EE approvals license-compliance actions', () => { ...@@ -101,12 +101,10 @@ describe('EE approvals license-compliance actions', () => {
type: 'fetchRules', type: 'fetchRules',
}, },
], ],
() => { );
expect(axiosMock.history.post[0].data).toBe( expect(axiosMock.history.post[0].data).toBe(
'{"name":"Foo","approvals_required":1,"users":[8,9],"groups":[7]}', '{"name":"Foo","approvals_required":1,"users":[8,9],"groups":[7]}',
); );
},
);
}); });
it('creates a flash error if the request is not successful', async () => { it('creates a flash error if the request is not successful', async () => {
...@@ -122,7 +120,7 @@ describe('EE approvals license-compliance actions', () => { ...@@ -122,7 +120,7 @@ describe('EE approvals license-compliance actions', () => {
const id = 4; const id = 4;
const putUrl = `${mocks.state.rulesPath}/${4}`; const putUrl = `${mocks.state.rulesPath}/${4}`;
it('puts correct data and dispatches "fetchRules" when request is successful', () => { it('puts correct data and dispatches "fetchRules" when request is successful', async () => {
const payload = { const payload = {
id, id,
name: 'Foo', name: 'Foo',
...@@ -132,7 +130,7 @@ describe('EE approvals license-compliance actions', () => { ...@@ -132,7 +130,7 @@ describe('EE approvals license-compliance actions', () => {
}; };
axiosMock.onPut(putUrl).replyOnce(200); axiosMock.onPut(putUrl).replyOnce(200);
return testAction( await testAction(
actions.putRule, actions.putRule,
payload, payload,
state, state,
...@@ -142,12 +140,10 @@ describe('EE approvals license-compliance actions', () => { ...@@ -142,12 +140,10 @@ describe('EE approvals license-compliance actions', () => {
type: 'fetchRules', type: 'fetchRules',
}, },
], ],
() => { );
expect(axiosMock.history.put[0].data).toBe( expect(axiosMock.history.put[0].data).toBe(
'{"name":"Foo","approvals_required":1,"users":[8,9],"groups":[7]}', '{"name":"Foo","approvals_required":1,"users":[8,9],"groups":[7]}',
); );
},
);
}); });
it('creates a flash error if the request is not successful', async () => { it('creates a flash error if the request is not successful', async () => {
......
...@@ -4,21 +4,20 @@ import testAction from 'helpers/vuex_action_helper'; ...@@ -4,21 +4,20 @@ import testAction from 'helpers/vuex_action_helper';
describe('Approval MR edit module actions', () => { describe('Approval MR edit module actions', () => {
describe('setTargetBranch', () => { describe('setTargetBranch', () => {
it('commits SET_TARGET_BRANCH', (done) => { it('commits SET_TARGET_BRANCH', async () => {
testAction( await testAction(
actions.setTargetBranch, actions.setTargetBranch,
'main', 'main',
{}, {},
[{ type: types.SET_TARGET_BRANCH, payload: 'main' }], [{ type: types.SET_TARGET_BRANCH, payload: 'main' }],
[], [],
done,
); );
}); });
}); });
describe('undoRulesChange', () => { describe('undoRulesChange', () => {
it('commits UNDO_RULES', (done) => { it('commits UNDO_RULES', async () => {
testAction(actions.undoRulesChange, null, {}, [{ type: types.UNDO_RULES }], [], done); await testAction(actions.undoRulesChange, null, {}, [{ type: types.UNDO_RULES }], []);
}); });
}); });
}); });
...@@ -239,10 +239,10 @@ describe('fetchEpicsSwimlanes', () => { ...@@ -239,10 +239,10 @@ describe('fetchEpicsSwimlanes', () => {
}, },
}; };
it('should commit mutation RECEIVE_EPICS_SUCCESS on success', (done) => { it('should commit mutation RECEIVE_EPICS_SUCCESS on success', async () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse); jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
testAction( await testAction(
actions.fetchEpicsSwimlanes, actions.fetchEpicsSwimlanes,
{}, {},
state, state,
...@@ -253,14 +253,13 @@ describe('fetchEpicsSwimlanes', () => { ...@@ -253,14 +253,13 @@ describe('fetchEpicsSwimlanes', () => {
}, },
], ],
[], [],
done,
); );
}); });
it('should commit mutation REQUEST_MORE_EPICS when fetchNext is true', (done) => { it('should commit mutation REQUEST_MORE_EPICS when fetchNext is true', async () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse); jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
testAction( await testAction(
actions.fetchEpicsSwimlanes, actions.fetchEpicsSwimlanes,
{ fetchNext: true }, { fetchNext: true },
state, state,
...@@ -272,14 +271,13 @@ describe('fetchEpicsSwimlanes', () => { ...@@ -272,14 +271,13 @@ describe('fetchEpicsSwimlanes', () => {
}, },
], ],
[], [],
done,
); );
}); });
it('should commit mutation RECEIVE_EPICS_SUCCESS on success with hasMoreEpics when hasNextPage', (done) => { it('should commit mutation RECEIVE_EPICS_SUCCESS on success with hasMoreEpics when hasNextPage', async () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponseWithNextPage); jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponseWithNextPage);
testAction( await testAction(
actions.fetchEpicsSwimlanes, actions.fetchEpicsSwimlanes,
{}, {},
state, state,
...@@ -294,20 +292,18 @@ describe('fetchEpicsSwimlanes', () => { ...@@ -294,20 +292,18 @@ describe('fetchEpicsSwimlanes', () => {
}, },
], ],
[], [],
done,
); );
}); });
it('should commit mutation RECEIVE_SWIMLANES_FAILURE on failure', (done) => { it('should commit mutation RECEIVE_SWIMLANES_FAILURE on failure', async () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(Promise.reject()); jest.spyOn(gqlClient, 'query').mockResolvedValue(Promise.reject());
testAction( await testAction(
actions.fetchEpicsSwimlanes, actions.fetchEpicsSwimlanes,
{}, {},
state, state,
[{ type: types.RECEIVE_SWIMLANES_FAILURE }], [{ type: types.RECEIVE_SWIMLANES_FAILURE }],
[], [],
done,
); );
}); });
}); });
...@@ -368,14 +364,14 @@ describe('fetchItemsForList', () => { ...@@ -368,14 +364,14 @@ describe('fetchItemsForList', () => {
}); });
}); });
it('add epicWildcardId with NONE as value when noEpicIssues is true', () => { it('add epicWildcardId with NONE as value when noEpicIssues is true', async () => {
state = { state = {
...state, ...state,
isShowingEpicsSwimlanes: true, isShowingEpicsSwimlanes: true,
}; };
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse); jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
testAction( await testAction(
actions.fetchItemsForList, actions.fetchItemsForList,
{ listId, noEpicIssues: true }, { listId, noEpicIssues: true },
state, state,
...@@ -390,7 +386,7 @@ describe('fetchItemsForList', () => { ...@@ -390,7 +386,7 @@ describe('fetchItemsForList', () => {
}, },
], ],
[], [],
() => { );
expect(gqlClient.query).toHaveBeenCalledWith({ expect(gqlClient.query).toHaveBeenCalledWith({
query: listsIssuesQuery, query: listsIssuesQuery,
variables: { variables: {
...@@ -409,8 +405,6 @@ describe('fetchItemsForList', () => { ...@@ -409,8 +405,6 @@ describe('fetchItemsForList', () => {
isSingleRequest: true, isSingleRequest: true,
}, },
}); });
},
);
}); });
}); });
...@@ -428,11 +422,11 @@ describe('updateBoardEpicUserPreferences', () => { ...@@ -428,11 +422,11 @@ describe('updateBoardEpicUserPreferences', () => {
}, },
}); });
it('should send mutation', (done) => { it('should send mutation', async () => {
const collapsed = true; const collapsed = true;
jest.spyOn(gqlClient, 'mutate').mockResolvedValue(queryResponse(collapsed)); jest.spyOn(gqlClient, 'mutate').mockResolvedValue(queryResponse(collapsed));
testAction( await testAction(
actions.updateBoardEpicUserPreferences, actions.updateBoardEpicUserPreferences,
{ epicId: mockEpic.id, collapsed }, { epicId: mockEpic.id, collapsed },
state, state,
...@@ -448,24 +442,22 @@ describe('updateBoardEpicUserPreferences', () => { ...@@ -448,24 +442,22 @@ describe('updateBoardEpicUserPreferences', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('setShowLabels', () => { describe('setShowLabels', () => {
it('should commit mutation SET_SHOW_LABELS', (done) => { it('should commit mutation SET_SHOW_LABELS', async () => {
const state = { const state = {
isShowingLabels: true, isShowingLabels: true,
}; };
testAction( await testAction(
actions.setShowLabels, actions.setShowLabels,
false, false,
state, state,
[{ type: types.SET_SHOW_LABELS, payload: false }], [{ type: types.SET_SHOW_LABELS, payload: false }],
[], [],
done,
); );
}); });
}); });
...@@ -561,10 +553,10 @@ describe('fetchIssuesForEpic', () => { ...@@ -561,10 +553,10 @@ describe('fetchIssuesForEpic', () => {
const formattedIssues = formatListIssues(queryResponse.data.group.board.lists); const formattedIssues = formatListIssues(queryResponse.data.group.board.lists);
it('should commit mutations REQUEST_ISSUES_FOR_EPIC and RECEIVE_ITEMS_FOR_LIST_SUCCESS on success', (done) => { it('should commit mutations REQUEST_ISSUES_FOR_EPIC and RECEIVE_ITEMS_FOR_LIST_SUCCESS on success', async () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse); jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
testAction( await testAction(
actions.fetchIssuesForEpic, actions.fetchIssuesForEpic,
epicId, epicId,
state, state,
...@@ -573,14 +565,13 @@ describe('fetchIssuesForEpic', () => { ...@@ -573,14 +565,13 @@ describe('fetchIssuesForEpic', () => {
{ type: types.RECEIVE_ISSUES_FOR_EPIC_SUCCESS, payload: { ...formattedIssues, epicId } }, { type: types.RECEIVE_ISSUES_FOR_EPIC_SUCCESS, payload: { ...formattedIssues, epicId } },
], ],
[], [],
done,
); );
}); });
it('should commit mutations REQUEST_ISSUES_FOR_EPIC and RECEIVE_ITEMS_FOR_LIST_FAILURE on failure', (done) => { it('should commit mutations REQUEST_ISSUES_FOR_EPIC and RECEIVE_ITEMS_FOR_LIST_FAILURE on failure', async () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(Promise.reject()); jest.spyOn(gqlClient, 'query').mockResolvedValue(Promise.reject());
testAction( await testAction(
actions.fetchIssuesForEpic, actions.fetchIssuesForEpic,
epicId, epicId,
state, state,
...@@ -589,13 +580,12 @@ describe('fetchIssuesForEpic', () => { ...@@ -589,13 +580,12 @@ describe('fetchIssuesForEpic', () => {
{ type: types.RECEIVE_ISSUES_FOR_EPIC_FAILURE, payload: epicId }, { type: types.RECEIVE_ISSUES_FOR_EPIC_FAILURE, payload: epicId },
], ],
[], [],
done,
); );
}); });
}); });
describe('toggleEpicSwimlanes', () => { describe('toggleEpicSwimlanes', () => {
it('should commit mutation TOGGLE_EPICS_SWIMLANES', () => { it('should commit mutation TOGGLE_EPICS_SWIMLANES', async () => {
const startURl = `${TEST_HOST}/groups/gitlab-org/-/boards/1?group_by=epic`; const startURl = `${TEST_HOST}/groups/gitlab-org/-/boards/1?group_by=epic`;
setWindowLocation(startURl); setWindowLocation(startURl);
...@@ -687,14 +677,14 @@ describe('setActiveItemWeight', () => { ...@@ -687,14 +677,14 @@ describe('setActiveItemWeight', () => {
const testWeight = mockIssue.weight + 1; const testWeight = mockIssue.weight + 1;
const input = { weight: testWeight, id: mockIssue.id }; const input = { weight: testWeight, id: mockIssue.id };
it('should commit weight', (done) => { it('should commit weight', async () => {
const payload = { const payload = {
itemId: getters.activeBoardItem.id, itemId: getters.activeBoardItem.id,
prop: 'weight', prop: 'weight',
value: testWeight, value: testWeight,
}; };
testAction( await testAction(
actions.setActiveItemWeight, actions.setActiveItemWeight,
input, input,
{ ...state, ...getters }, { ...state, ...getters },
...@@ -705,7 +695,6 @@ describe('setActiveItemWeight', () => { ...@@ -705,7 +695,6 @@ describe('setActiveItemWeight', () => {
}, },
], ],
[], [],
done,
); );
}); });
...@@ -1280,10 +1269,10 @@ describe('fetchSubGroups', () => { ...@@ -1280,10 +1269,10 @@ describe('fetchSubGroups', () => {
}, },
}; };
it('should commit mutations REQUEST_SUB_GROUPS, RECEIVE_SUB_GROUPS_SUCCESS, and SET_SELECTED_GROUP on success', (done) => { it('should commit mutations REQUEST_SUB_GROUPS, RECEIVE_SUB_GROUPS_SUCCESS, and SET_SELECTED_GROUP on success', async () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse); jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
testAction( await testAction(
actions.fetchSubGroups, actions.fetchSubGroups,
{}, {},
state, state,
...@@ -1302,14 +1291,13 @@ describe('fetchSubGroups', () => { ...@@ -1302,14 +1291,13 @@ describe('fetchSubGroups', () => {
}, },
], ],
[], [],
done,
); );
}); });
it('should commit mutations REQUEST_SUB_GROUPS and RECEIVE_SUB_GROUPS_FAILURE on failure', (done) => { it('should commit mutations REQUEST_SUB_GROUPS and RECEIVE_SUB_GROUPS_FAILURE on failure', async () => {
jest.spyOn(gqlClient, 'query').mockRejectedValue(); jest.spyOn(gqlClient, 'query').mockRejectedValue();
testAction( await testAction(
actions.fetchSubGroups, actions.fetchSubGroups,
{}, {},
state, state,
...@@ -1323,14 +1311,13 @@ describe('fetchSubGroups', () => { ...@@ -1323,14 +1311,13 @@ describe('fetchSubGroups', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('setSelectedGroup', () => { describe('setSelectedGroup', () => {
it('should commit mutation SET_SELECTED_GROUP', (done) => { it('should commit mutation SET_SELECTED_GROUP', async () => {
testAction( await testAction(
actions.setSelectedGroup, actions.setSelectedGroup,
mockGroup0, mockGroup0,
{}, {},
...@@ -1341,7 +1328,6 @@ describe('setSelectedGroup', () => { ...@@ -1341,7 +1328,6 @@ describe('setSelectedGroup', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
......
...@@ -34,21 +34,14 @@ describe('Codequality report actions', () => { ...@@ -34,21 +34,14 @@ describe('Codequality report actions', () => {
}); });
describe('setPage', () => { describe('setPage', () => {
it('sets the page number', (done) => { it('sets the page number', async () => {
return testAction( await testAction(actions.setPage, 12, state, [{ type: types.SET_PAGE, payload: 12 }], []);
actions.setPage,
12,
state,
[{ type: types.SET_PAGE, payload: 12 }],
[],
done,
);
}); });
}); });
describe('requestReport', () => { describe('requestReport', () => {
it('sets the loading flag', (done) => { it('sets the loading flag', async () => {
testAction(actions.requestReport, null, state, [{ type: types.REQUEST_REPORT }], [], done); await testAction(actions.requestReport, null, state, [{ type: types.REQUEST_REPORT }], []);
}); });
it('tracks a service ping event', () => { it('tracks a service ping event', () => {
...@@ -59,27 +52,25 @@ describe('Codequality report actions', () => { ...@@ -59,27 +52,25 @@ describe('Codequality report actions', () => {
}); });
describe('receiveReportSuccess', () => { describe('receiveReportSuccess', () => {
it('parses the list of issues from the report', (done) => { it('parses the list of issues from the report', async () => {
return testAction( await testAction(
actions.receiveReportSuccess, actions.receiveReportSuccess,
unparsedIssues, unparsedIssues,
{ blobPath: '/root/test-codequality/blob/feature-branch', ...state }, { blobPath: '/root/test-codequality/blob/feature-branch', ...state },
[{ type: types.RECEIVE_REPORT_SUCCESS, payload: parsedIssues }], [{ type: types.RECEIVE_REPORT_SUCCESS, payload: parsedIssues }],
[], [],
done,
); );
}); });
}); });
describe('receiveReportError', () => { describe('receiveReportError', () => {
it('accepts a report error', (done) => { it('accepts a report error', async () => {
testAction( await testAction(
actions.receiveReportError, actions.receiveReportError,
'error', 'error',
state, state,
[{ type: types.RECEIVE_REPORT_ERROR, payload: 'error' }], [{ type: types.RECEIVE_REPORT_ERROR, payload: 'error' }],
[], [],
done,
); );
}); });
}); });
...@@ -89,47 +80,40 @@ describe('Codequality report actions', () => { ...@@ -89,47 +80,40 @@ describe('Codequality report actions', () => {
mock.onGet(endpoint).replyOnce(200, unparsedIssues); mock.onGet(endpoint).replyOnce(200, unparsedIssues);
}); });
it('fetches the report', (done) => { it('fetches the report', async () => {
return testAction( await testAction(
actions.fetchReport, actions.fetchReport,
null, null,
{ blobPath: 'blah', ...state }, { blobPath: 'blah', ...state },
[], [],
[{ type: 'requestReport' }, { type: 'receiveReportSuccess', payload: unparsedIssues }], [{ type: 'requestReport' }, { type: 'receiveReportSuccess', payload: unparsedIssues }],
done,
); );
}); });
it('shows a flash message when there is an error', (done) => { it('shows a flash message when there is an error', async () => {
testAction( await testAction(
actions.fetchReport, actions.fetchReport,
'error', 'error',
state, state,
[], [],
[{ type: 'requestReport' }, { type: 'receiveReportError', payload: expect.any(Error) }], [{ type: 'requestReport' }, { type: 'receiveReportError', payload: expect.any(Error) }],
() => { );
expect(createFlash).toHaveBeenCalledWith({ expect(createFlash).toHaveBeenCalledWith({
message: 'There was an error fetching the codequality report.', message: 'There was an error fetching the codequality report.',
}); });
done();
},
);
}); });
it('shows an error when blob path is missing', (done) => { it('shows an error when blob path is missing', async () => {
testAction( await testAction(
actions.fetchReport, actions.fetchReport,
null, null,
state, state,
[], [],
[{ type: 'requestReport' }, { type: 'receiveReportError', payload: expect.any(Error) }], [{ type: 'requestReport' }, { type: 'receiveReportError', payload: expect.any(Error) }],
() => { );
expect(createFlash).toHaveBeenCalledWith({ expect(createFlash).toHaveBeenCalledWith({
message: 'There was an error fetching the codequality report.', message: 'There was an error fetching the codequality report.',
}); });
done();
},
);
}); });
}); });
}); });
...@@ -17,16 +17,15 @@ jest.mock('~/flash'); ...@@ -17,16 +17,15 @@ jest.mock('~/flash');
describe('EE DiffsStoreActions', () => { describe('EE DiffsStoreActions', () => {
describe('setCodequalityEndpoint', () => { describe('setCodequalityEndpoint', () => {
it('should set given endpoint', (done) => { it('should set given endpoint', async () => {
const endpoint = '/codequality_mr_diff.json'; const endpoint = '/codequality_mr_diff.json';
testAction( await testAction(
setCodequalityEndpoint, setCodequalityEndpoint,
{ endpoint }, { endpoint },
{}, {},
[{ type: types.SET_CODEQUALITY_ENDPOINT, payload: { endpoint } }], [{ type: types.SET_CODEQUALITY_ENDPOINT, payload: { endpoint } }],
[], [],
done,
); );
}); });
}); });
...@@ -44,20 +43,19 @@ describe('EE DiffsStoreActions', () => { ...@@ -44,20 +43,19 @@ describe('EE DiffsStoreActions', () => {
clearCodequalityPoll(); clearCodequalityPoll();
}); });
it('should commit SET_CODEQUALITY_DATA with received response and stop polling', (done) => { it('should commit SET_CODEQUALITY_DATA with received response and stop polling', async () => {
const data = { const data = {
files: { 'app.js': [{ line: 1, description: 'Unexpected alert.', severity: 'minor' }] }, files: { 'app.js': [{ line: 1, description: 'Unexpected alert.', severity: 'minor' }] },
}; };
mock.onGet(endpointCodequality).reply(200, { data }); mock.onGet(endpointCodequality).reply(200, { data });
testAction( await testAction(
fetchCodequality, fetchCodequality,
{}, {},
{ endpointCodequality }, { endpointCodequality },
[{ type: types.SET_CODEQUALITY_DATA, payload: { data } }], [{ type: types.SET_CODEQUALITY_DATA, payload: { data } }],
[{ type: 'stopCodequalityPolling' }], [{ type: 'stopCodequalityPolling' }],
done,
); );
}); });
...@@ -72,21 +70,21 @@ describe('EE DiffsStoreActions', () => { ...@@ -72,21 +70,21 @@ describe('EE DiffsStoreActions', () => {
mock.onGet(endpointCodequality).reply(400); mock.onGet(endpointCodequality).reply(400);
}); });
it('should not show a flash message', (done) => { it('should not show a flash message', async () => {
testAction(fetchCodequality, {}, { endpointCodequality }, [], [], () => { await testAction(fetchCodequality, {}, { endpointCodequality }, [], []);
expect(createFlash).not.toHaveBeenCalled(); expect(createFlash).not.toHaveBeenCalled();
done();
});
}); });
it('should retry five times with a delay, then stop polling', (done) => { it('should retry five times with a delay, then stop polling', async () => {
testAction(fetchCodequality, {}, { endpointCodequality }, [], [], () => { await testAction(fetchCodequality, {}, { endpointCodequality }, [], []);
expect(pollDelayedRequest).toHaveBeenCalledTimes(1); expect(pollDelayedRequest).toHaveBeenCalledTimes(1);
expect(pollStop).toHaveBeenCalledTimes(0); expect(pollStop).toHaveBeenCalledTimes(0);
jest.advanceTimersByTime(RETRY_DELAY); jest.advanceTimersByTime(RETRY_DELAY);
waitForPromises() return waitForPromises()
.then(() => { .then(() => {
expect(pollDelayedRequest).toHaveBeenCalledTimes(2); expect(pollDelayedRequest).toHaveBeenCalledTimes(2);
...@@ -105,30 +103,24 @@ describe('EE DiffsStoreActions', () => { ...@@ -105,30 +103,24 @@ describe('EE DiffsStoreActions', () => {
.then(() => waitForPromises()) .then(() => waitForPromises())
.then(() => { .then(() => {
expect(pollStop).toHaveBeenCalledTimes(1); expect(pollStop).toHaveBeenCalledTimes(1);
})
.then(done)
.catch(done.fail);
}); });
}); });
}); });
it('with unexpected error should stop polling and show a flash message', (done) => { it('with unexpected error should stop polling and show a flash message', async () => {
mock.onGet(endpointCodequality).reply(500); mock.onGet(endpointCodequality).reply(500);
testAction( await testAction(
fetchCodequality, fetchCodequality,
{}, {},
{ endpointCodequality }, { endpointCodequality },
[], [],
[{ type: 'stopCodequalityPolling' }], [{ type: 'stopCodequalityPolling' }],
() => { );
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
expect(createFlash).toHaveBeenCalledWith({ expect(createFlash).toHaveBeenCalledWith({
message: 'An unexpected error occurred while loading the code quality diff.', message: 'An unexpected error occurred while loading the code quality diff.',
}); });
done();
},
);
}); });
}); });
}); });
...@@ -22,27 +22,25 @@ describe('Epic Store Actions', () => { ...@@ -22,27 +22,25 @@ describe('Epic Store Actions', () => {
}); });
describe('setEpicMeta', () => { describe('setEpicMeta', () => {
it('should set received Epic meta', (done) => { it('should set received Epic meta', async () => {
testAction( await testAction(
actions.setEpicMeta, actions.setEpicMeta,
mockEpicMeta, mockEpicMeta,
{}, {},
[{ type: 'SET_EPIC_META', payload: mockEpicMeta }], [{ type: 'SET_EPIC_META', payload: mockEpicMeta }],
[], [],
done,
); );
}); });
}); });
describe('setEpicData', () => { describe('setEpicData', () => {
it('should set received Epic data', (done) => { it('should set received Epic data', async () => {
testAction( await testAction(
actions.setEpicData, actions.setEpicData,
mockEpicData, mockEpicData,
{}, {},
[{ type: 'SET_EPIC_DATA', payload: mockEpicData }], [{ type: 'SET_EPIC_DATA', payload: mockEpicData }],
[], [],
done,
); );
}); });
}); });
...@@ -101,7 +99,7 @@ describe('Epic Store Actions', () => { ...@@ -101,7 +99,7 @@ describe('Epic Store Actions', () => {
mock.restore(); mock.restore();
}); });
it('dispatches setEpicData when request is successful', (done) => { it('dispatches setEpicData when request is successful', async () => {
mock.onPut(/(.*)/).replyOnce(200, {}); mock.onPut(/(.*)/).replyOnce(200, {});
jest.spyOn(epicUtils.gqClient, 'query').mockReturnValue( jest.spyOn(epicUtils.gqClient, 'query').mockReturnValue(
Promise.resolve({ Promise.resolve({
...@@ -109,7 +107,7 @@ describe('Epic Store Actions', () => { ...@@ -109,7 +107,7 @@ describe('Epic Store Actions', () => {
}), }),
); );
testAction( await testAction(
actions.fetchEpicDetails, actions.fetchEpicDetails,
payload, payload,
state, state,
...@@ -120,15 +118,14 @@ describe('Epic Store Actions', () => { ...@@ -120,15 +118,14 @@ describe('Epic Store Actions', () => {
payload: { participants: formattedParticipants }, payload: { participants: formattedParticipants },
}, },
], ],
done,
); );
}); });
it('dispatches requestEpicParticipantsFailure when request fails', (done) => { it('dispatches requestEpicParticipantsFailure when request fails', async () => {
mock.onPut(/(.*)/).replyOnce(500, {}); mock.onPut(/(.*)/).replyOnce(500, {});
jest.spyOn(epicUtils.gqClient, 'query').mockReturnValue(Promise.resolve({})); jest.spyOn(epicUtils.gqClient, 'query').mockReturnValue(Promise.resolve({}));
testAction( await testAction(
actions.fetchEpicDetails, actions.fetchEpicDetails,
payload, payload,
state, state,
...@@ -138,14 +135,13 @@ describe('Epic Store Actions', () => { ...@@ -138,14 +135,13 @@ describe('Epic Store Actions', () => {
type: 'requestEpicParticipantsFailure', type: 'requestEpicParticipantsFailure',
}, },
], ],
done,
); );
}); });
}); });
describe('requestEpicParticipantsFailure', () => { describe('requestEpicParticipantsFailure', () => {
it('does not invoke any mutations or actions', (done) => { it('does not invoke any mutations or actions', async () => {
testAction(actions.requestEpicParticipantsFailure, {}, state, [], [], done); await testAction(actions.requestEpicParticipantsFailure, {}, state, [], []);
}); });
it('shows flash error', () => { it('shows flash error', () => {
...@@ -158,40 +154,37 @@ describe('Epic Store Actions', () => { ...@@ -158,40 +154,37 @@ describe('Epic Store Actions', () => {
}); });
describe('requestEpicStatusChange', () => { describe('requestEpicStatusChange', () => {
it('should set status change flag', (done) => { it('should set status change flag', async () => {
testAction( await testAction(
actions.requestEpicStatusChange, actions.requestEpicStatusChange,
{}, {},
state, state,
[{ type: 'REQUEST_EPIC_STATUS_CHANGE' }], [{ type: 'REQUEST_EPIC_STATUS_CHANGE' }],
[], [],
done,
); );
}); });
}); });
describe('requestEpicStatusChangeSuccess', () => { describe('requestEpicStatusChangeSuccess', () => {
it('should set epic state type', (done) => { it('should set epic state type', async () => {
testAction( await testAction(
actions.requestEpicStatusChangeSuccess, actions.requestEpicStatusChangeSuccess,
{ state: statusType.close }, { state: statusType.close },
state, state,
[{ type: 'REQUEST_EPIC_STATUS_CHANGE_SUCCESS', payload: { state: statusType.close } }], [{ type: 'REQUEST_EPIC_STATUS_CHANGE_SUCCESS', payload: { state: statusType.close } }],
[], [],
done,
); );
}); });
}); });
describe('requestEpicStatusChangeFailure', () => { describe('requestEpicStatusChangeFailure', () => {
it('should set status change flag', (done) => { it('should set status change flag', async () => {
testAction( await testAction(
actions.requestEpicStatusChangeFailure, actions.requestEpicStatusChangeFailure,
{}, {},
state, state,
[{ type: 'REQUEST_EPIC_STATUS_CHANGE_FAILURE' }], [{ type: 'REQUEST_EPIC_STATUS_CHANGE_FAILURE' }],
[], [],
done,
); );
}); });
...@@ -235,12 +228,12 @@ describe('Epic Store Actions', () => { ...@@ -235,12 +228,12 @@ describe('Epic Store Actions', () => {
}); });
describe('success', () => { describe('success', () => {
it('dispatches requestEpicStatusChange and requestEpicStatusChangeSuccess when request is complete', (done) => { it('dispatches requestEpicStatusChange and requestEpicStatusChangeSuccess when request is complete', async () => {
mock.onPut(/(.*)/).replyOnce(200, { mock.onPut(/(.*)/).replyOnce(200, {
state: statusType.close, state: statusType.close,
}); });
testAction( await testAction(
actions.toggleEpicStatus, actions.toggleEpicStatus,
null, null,
state, state,
...@@ -258,16 +251,15 @@ describe('Epic Store Actions', () => { ...@@ -258,16 +251,15 @@ describe('Epic Store Actions', () => {
payload: { isEpicOpen: true }, payload: { isEpicOpen: true },
}, },
], ],
done,
); );
}); });
}); });
describe('failure', () => { describe('failure', () => {
it('dispatches requestEpicStatusChange and requestEpicStatusChangeFailure when request fails', (done) => { it('dispatches requestEpicStatusChange and requestEpicStatusChangeFailure when request fails', async () => {
mock.onPut(/(.*)/).replyOnce(500, {}); mock.onPut(/(.*)/).replyOnce(500, {});
testAction( await testAction(
actions.toggleEpicStatus, actions.toggleEpicStatus,
null, null,
state, state,
...@@ -284,23 +276,21 @@ describe('Epic Store Actions', () => { ...@@ -284,23 +276,21 @@ describe('Epic Store Actions', () => {
payload: { isEpicOpen: true }, payload: { isEpicOpen: true },
}, },
], ],
done,
); );
}); });
}); });
}); });
describe('toggleSidebarFlag', () => { describe('toggleSidebarFlag', () => {
it('should call `TOGGLE_SIDEBAR` mutation with param `sidebarCollapsed`', (done) => { it('should call `TOGGLE_SIDEBAR` mutation with param `sidebarCollapsed`', async () => {
const sidebarCollapsed = true; const sidebarCollapsed = true;
testAction( await testAction(
actions.toggleSidebarFlag, actions.toggleSidebarFlag,
sidebarCollapsed, sidebarCollapsed,
state, state,
[{ type: 'TOGGLE_SIDEBAR', payload: sidebarCollapsed }], [{ type: 'TOGGLE_SIDEBAR', payload: sidebarCollapsed }],
[], [],
done,
); );
}); });
}); });
...@@ -329,10 +319,10 @@ describe('Epic Store Actions', () => { ...@@ -329,10 +319,10 @@ describe('Epic Store Actions', () => {
}); });
describe('toggleSidebar', () => { describe('toggleSidebar', () => {
it('dispatches toggleContainerClassAndCookie and toggleSidebarFlag actions with opposite value of `isSidebarCollapsed` param', (done) => { it('dispatches toggleContainerClassAndCookie and toggleSidebarFlag actions with opposite value of `isSidebarCollapsed` param', async () => {
const sidebarCollapsed = true; const sidebarCollapsed = true;
testAction( await testAction(
actions.toggleSidebar, actions.toggleSidebar,
{ sidebarCollapsed }, { sidebarCollapsed },
state, state,
...@@ -347,46 +337,42 @@ describe('Epic Store Actions', () => { ...@@ -347,46 +337,42 @@ describe('Epic Store Actions', () => {
payload: !sidebarCollapsed, payload: !sidebarCollapsed,
}, },
], ],
done,
); );
}); });
}); });
describe('requestEpicTodoToggle', () => { describe('requestEpicTodoToggle', () => {
it('should set `state.epicTodoToggleInProgress` flag to `true`', (done) => { it('should set `state.epicTodoToggleInProgress` flag to `true`', async () => {
testAction( await testAction(
actions.requestEpicTodoToggle, actions.requestEpicTodoToggle,
{}, {},
state, state,
[{ type: 'REQUEST_EPIC_TODO_TOGGLE' }], [{ type: 'REQUEST_EPIC_TODO_TOGGLE' }],
[], [],
done,
); );
}); });
}); });
describe('requestEpicTodoToggleSuccess', () => { describe('requestEpicTodoToggleSuccess', () => {
it('should set epic state type', (done) => { it('should set epic state type', async () => {
testAction( await testAction(
actions.requestEpicTodoToggleSuccess, actions.requestEpicTodoToggleSuccess,
{ todoDeletePath: '/foo/bar' }, { todoDeletePath: '/foo/bar' },
state, state,
[{ type: 'REQUEST_EPIC_TODO_TOGGLE_SUCCESS', payload: { todoDeletePath: '/foo/bar' } }], [{ type: 'REQUEST_EPIC_TODO_TOGGLE_SUCCESS', payload: { todoDeletePath: '/foo/bar' } }],
[], [],
done,
); );
}); });
}); });
describe('requestEpicTodoToggleFailure', () => { describe('requestEpicTodoToggleFailure', () => {
it('Should set `state.epicTodoToggleInProgress` flag to `false`', (done) => { it('Should set `state.epicTodoToggleInProgress` flag to `false`', async () => {
testAction( await testAction(
actions.requestEpicTodoToggleFailure, actions.requestEpicTodoToggleFailure,
{}, {},
state, state,
[{ type: 'REQUEST_EPIC_TODO_TOGGLE_FAILURE', payload: {} }], [{ type: 'REQUEST_EPIC_TODO_TOGGLE_FAILURE', payload: {} }],
[], [],
done,
); );
}); });
...@@ -440,13 +426,13 @@ describe('Epic Store Actions', () => { ...@@ -440,13 +426,13 @@ describe('Epic Store Actions', () => {
}); });
describe('when `state.togoExists` is false', () => { describe('when `state.togoExists` is false', () => {
it('dispatches requestEpicTodoToggle, triggerTodoToggleEvent and requestEpicTodoToggleSuccess when request is successful', (done) => { it('dispatches requestEpicTodoToggle, triggerTodoToggleEvent and requestEpicTodoToggleSuccess when request is successful', async () => {
mock.onPost(/(.*)/).replyOnce(200, { mock.onPost(/(.*)/).replyOnce(200, {
count: 5, count: 5,
delete_path: '/foo/bar', delete_path: '/foo/bar',
}); });
testAction( await testAction(
actions.toggleTodo, actions.toggleTodo,
null, null,
{ todoExists: false }, { todoExists: false },
...@@ -464,14 +450,13 @@ describe('Epic Store Actions', () => { ...@@ -464,14 +450,13 @@ describe('Epic Store Actions', () => {
payload: { todoDeletePath: '/foo/bar' }, payload: { todoDeletePath: '/foo/bar' },
}, },
], ],
done,
); );
}); });
it('dispatches requestEpicTodoToggle and requestEpicTodoToggleFailure when request fails', (done) => { it('dispatches requestEpicTodoToggle and requestEpicTodoToggleFailure when request fails', async () => {
mock.onPost(/(.*)/).replyOnce(500, {}); mock.onPost(/(.*)/).replyOnce(500, {});
testAction( await testAction(
actions.toggleTodo, actions.toggleTodo,
null, null,
{ todoExists: false }, { todoExists: false },
...@@ -484,18 +469,17 @@ describe('Epic Store Actions', () => { ...@@ -484,18 +469,17 @@ describe('Epic Store Actions', () => {
type: 'requestEpicTodoToggleFailure', type: 'requestEpicTodoToggleFailure',
}, },
], ],
done,
); );
}); });
}); });
describe('when `state.togoExists` is true', () => { describe('when `state.togoExists` is true', () => {
it('dispatches requestEpicTodoToggle, triggerTodoToggleEvent and requestEpicTodoToggleSuccess when request is successful', (done) => { it('dispatches requestEpicTodoToggle, triggerTodoToggleEvent and requestEpicTodoToggleSuccess when request is successful', async () => {
mock.onDelete(/(.*)/).replyOnce(200, { mock.onDelete(/(.*)/).replyOnce(200, {
count: 5, count: 5,
}); });
testAction( await testAction(
actions.toggleTodo, actions.toggleTodo,
null, null,
{ todoExists: true }, { todoExists: true },
...@@ -513,14 +497,13 @@ describe('Epic Store Actions', () => { ...@@ -513,14 +497,13 @@ describe('Epic Store Actions', () => {
payload: { todoDeletePath: undefined }, payload: { todoDeletePath: undefined },
}, },
], ],
done,
); );
}); });
it('dispatches requestEpicTodoToggle and requestEpicTodoToggleFailure when request fails', (done) => { it('dispatches requestEpicTodoToggle and requestEpicTodoToggleFailure when request fails', async () => {
mock.onDelete(/(.*)/).replyOnce(500, {}); mock.onDelete(/(.*)/).replyOnce(500, {});
testAction( await testAction(
actions.toggleTodo, actions.toggleTodo,
null, null,
{ todoExists: true }, { todoExists: true },
...@@ -533,114 +516,107 @@ describe('Epic Store Actions', () => { ...@@ -533,114 +516,107 @@ describe('Epic Store Actions', () => {
type: 'requestEpicTodoToggleFailure', type: 'requestEpicTodoToggleFailure',
}, },
], ],
done,
); );
}); });
}); });
}); });
describe('toggleStartDateType', () => { describe('toggleStartDateType', () => {
it('should set `state.startDateIsFixed` flag to `true`', (done) => { it('should set `state.startDateIsFixed` flag to `true`', async () => {
const dateTypeIsFixed = true; const dateTypeIsFixed = true;
testAction( await testAction(
actions.toggleStartDateType, actions.toggleStartDateType,
{ dateTypeIsFixed }, { dateTypeIsFixed },
state, state,
[{ type: 'TOGGLE_EPIC_START_DATE_TYPE', payload: { dateTypeIsFixed } }], [{ type: 'TOGGLE_EPIC_START_DATE_TYPE', payload: { dateTypeIsFixed } }],
[], [],
done,
); );
}); });
}); });
describe('toggleDueDateType', () => { describe('toggleDueDateType', () => {
it('should set `state.dueDateIsFixed` flag to `true`', (done) => { it('should set `state.dueDateIsFixed` flag to `true`', async () => {
const dateTypeIsFixed = true; const dateTypeIsFixed = true;
testAction( await testAction(
actions.toggleDueDateType, actions.toggleDueDateType,
{ dateTypeIsFixed }, { dateTypeIsFixed },
state, state,
[{ type: 'TOGGLE_EPIC_DUE_DATE_TYPE', payload: { dateTypeIsFixed } }], [{ type: 'TOGGLE_EPIC_DUE_DATE_TYPE', payload: { dateTypeIsFixed } }],
[], [],
done,
); );
}); });
}); });
describe('requestEpicDateSave', () => { describe('requestEpicDateSave', () => {
it('should set `state.epicStartDateSaveInProgress` flag to `true` when called with `dateType` as `start`', (done) => { it('should set `state.epicStartDateSaveInProgress` flag to `true` when called with `dateType` as `start`', async () => {
const dateType = dateTypes.start; const dateType = dateTypes.start;
testAction( await testAction(
actions.requestEpicDateSave, actions.requestEpicDateSave,
{ dateType }, { dateType },
state, state,
[{ type: 'REQUEST_EPIC_DATE_SAVE', payload: { dateType } }], [{ type: 'REQUEST_EPIC_DATE_SAVE', payload: { dateType } }],
[], [],
done,
); );
}); });
it('should set `state.epicDueDateSaveInProgress` flag to `true` when called with `dateType` as `due`', (done) => { it('should set `state.epicDueDateSaveInProgress` flag to `true` when called with `dateType` as `due`', async () => {
const dateType = dateTypes.due; const dateType = dateTypes.due;
testAction( await testAction(
actions.requestEpicDateSave, actions.requestEpicDateSave,
{ dateType }, { dateType },
state, state,
[{ type: 'REQUEST_EPIC_DATE_SAVE', payload: { dateType } }], [{ type: 'REQUEST_EPIC_DATE_SAVE', payload: { dateType } }],
[], [],
done,
); );
}); });
}); });
describe('requestEpicDateSaveSuccess', () => { describe('requestEpicDateSaveSuccess', () => {
it('should set `state.epicStartDateSaveInProgress` flag to `false` and set values of `startDateIsFixed` & `startDate` with params `dateTypeIsFixed` & `newDate` when called with `dateType` as `start`', (done) => { it('should set `state.epicStartDateSaveInProgress` flag to `false` and set values of `startDateIsFixed` & `startDate` with params `dateTypeIsFixed` & `newDate` when called with `dateType` as `start`', async () => {
const data = { const data = {
dateType: dateTypes.start, dateType: dateTypes.start,
dateTypeIsFixed: true, dateTypeIsFixed: true,
mewDate: '2018-1-1', mewDate: '2018-1-1',
}; };
testAction( await testAction(
actions.requestEpicDateSaveSuccess, actions.requestEpicDateSaveSuccess,
data, data,
state, state,
[{ type: 'REQUEST_EPIC_DATE_SAVE_SUCCESS', payload: { ...data } }], [{ type: 'REQUEST_EPIC_DATE_SAVE_SUCCESS', payload: { ...data } }],
[], [],
done,
); );
}); });
it('should set `state.epicDueDateSaveInProgress` flag to `false` and set values of `dueDateIsFixed` & `dueDate` with params `dateTypeIsFixed` & `newDate` when called with `dateType` as `due`', (done) => { it('should set `state.epicDueDateSaveInProgress` flag to `false` and set values of `dueDateIsFixed` & `dueDate` with params `dateTypeIsFixed` & `newDate` when called with `dateType` as `due`', async () => {
const data = { const data = {
dateType: dateTypes.due, dateType: dateTypes.due,
dateTypeIsFixed: true, dateTypeIsFixed: true,
mewDate: '2018-1-1', mewDate: '2018-1-1',
}; };
testAction( await testAction(
actions.requestEpicDateSaveSuccess, actions.requestEpicDateSaveSuccess,
data, data,
state, state,
[{ type: 'REQUEST_EPIC_DATE_SAVE_SUCCESS', payload: { ...data } }], [{ type: 'REQUEST_EPIC_DATE_SAVE_SUCCESS', payload: { ...data } }],
[], [],
done,
); );
}); });
}); });
describe('requestEpicDateSaveFailure', () => { describe('requestEpicDateSaveFailure', () => {
it('should set `state.epicStartDateSaveInProgress` flag to `false` and set value of `startDateIsFixed` to that of param `dateTypeIsFixed` when called with `dateType` as `start`', (done) => { it('should set `state.epicStartDateSaveInProgress` flag to `false` and set value of `startDateIsFixed` to that of param `dateTypeIsFixed` when called with `dateType` as `start`', async () => {
const data = { const data = {
dateType: dateTypes.start, dateType: dateTypes.start,
dateTypeIsFixed: true, dateTypeIsFixed: true,
}; };
testAction( await testAction(
actions.requestEpicDateSaveFailure, actions.requestEpicDateSaveFailure,
data, data,
state, state,
...@@ -651,17 +627,16 @@ describe('Epic Store Actions', () => { ...@@ -651,17 +627,16 @@ describe('Epic Store Actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
it('should set `state.epicDueDateSaveInProgress` flag to `false` and set value of `dueDateIsFixed` to that of param `dateTypeIsFixed` when called with `dateType` as `due`', (done) => { it('should set `state.epicDueDateSaveInProgress` flag to `false` and set value of `dueDateIsFixed` to that of param `dateTypeIsFixed` when called with `dateType` as `due`', async () => {
const data = { const data = {
dateType: dateTypes.due, dateType: dateTypes.due,
dateTypeIsFixed: true, dateTypeIsFixed: true,
}; };
testAction( await testAction(
actions.requestEpicDateSaveFailure, actions.requestEpicDateSaveFailure,
data, data,
state, state,
...@@ -672,7 +647,6 @@ describe('Epic Store Actions', () => { ...@@ -672,7 +647,6 @@ describe('Epic Store Actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
...@@ -727,7 +701,7 @@ describe('Epic Store Actions', () => { ...@@ -727,7 +701,7 @@ describe('Epic Store Actions', () => {
mock.restore(); mock.restore();
}); });
it('dispatches requestEpicDateSave and requestEpicDateSaveSuccess when request is successful', (done) => { it('dispatches requestEpicDateSave and requestEpicDateSaveSuccess when request is successful', async () => {
mock.onPut(/(.*)/).replyOnce(200, {}); mock.onPut(/(.*)/).replyOnce(200, {});
jest.spyOn(epicUtils.gqClient, 'mutate').mockReturnValue( jest.spyOn(epicUtils.gqClient, 'mutate').mockReturnValue(
Promise.resolve({ Promise.resolve({
...@@ -735,7 +709,7 @@ describe('Epic Store Actions', () => { ...@@ -735,7 +709,7 @@ describe('Epic Store Actions', () => {
}), }),
); );
testAction( await testAction(
actions.saveDate, actions.saveDate,
{ ...data }, { ...data },
state, state,
...@@ -750,11 +724,10 @@ describe('Epic Store Actions', () => { ...@@ -750,11 +724,10 @@ describe('Epic Store Actions', () => {
payload: { ...data }, payload: { ...data },
}, },
], ],
done,
); );
}); });
it('dispatches requestEpicDateSave and requestEpicDateSaveFailure when request fails', (done) => { it('dispatches requestEpicDateSave and requestEpicDateSaveFailure when request fails', async () => {
mock.onPut(/(.*)/).replyOnce(500, {}); mock.onPut(/(.*)/).replyOnce(500, {});
jest.spyOn(epicUtils.gqClient, 'mutate').mockReturnValue( jest.spyOn(epicUtils.gqClient, 'mutate').mockReturnValue(
Promise.resolve({ Promise.resolve({
...@@ -767,7 +740,7 @@ describe('Epic Store Actions', () => { ...@@ -767,7 +740,7 @@ describe('Epic Store Actions', () => {
}), }),
); );
testAction( await testAction(
actions.saveDate, actions.saveDate,
{ ...data }, { ...data },
state, state,
...@@ -782,32 +755,30 @@ describe('Epic Store Actions', () => { ...@@ -782,32 +755,30 @@ describe('Epic Store Actions', () => {
payload: { dateType: data.dateType, dateTypeIsFixed: !data.dateTypeIsFixed }, payload: { dateType: data.dateType, dateTypeIsFixed: !data.dateTypeIsFixed },
}, },
], ],
done,
); );
}); });
}); });
describe('requestEpicLabelsSelect', () => { describe('requestEpicLabelsSelect', () => {
it('should set `state.epicLabelsSelectInProgress` flag to `true`', (done) => { it('should set `state.epicLabelsSelectInProgress` flag to `true`', async () => {
testAction( await testAction(
actions.requestEpicLabelsSelect, actions.requestEpicLabelsSelect,
{}, {},
state, state,
[{ type: 'REQUEST_EPIC_LABELS_SELECT' }], [{ type: 'REQUEST_EPIC_LABELS_SELECT' }],
[], [],
done,
); );
}); });
}); });
describe('receiveEpicLabelsSelectSuccess', () => { describe('receiveEpicLabelsSelectSuccess', () => {
it('should set provided labels param to `state.labels`', (done) => { it('should set provided labels param to `state.labels`', async () => {
const labels = [ const labels = [
{ id: 1, set: false }, { id: 1, set: false },
{ id: 2, set: true }, { id: 2, set: true },
]; ];
testAction( await testAction(
actions.receiveEpicLabelsSelectSuccess, actions.receiveEpicLabelsSelectSuccess,
labels, labels,
state, state,
...@@ -818,20 +789,18 @@ describe('Epic Store Actions', () => { ...@@ -818,20 +789,18 @@ describe('Epic Store Actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveEpicLabelsSelectFailure', () => { describe('receiveEpicLabelsSelectFailure', () => {
it('should set `state.epicLabelsSelectInProgress` flag to `false`', (done) => { it('should set `state.epicLabelsSelectInProgress` flag to `false`', async () => {
testAction( await testAction(
actions.receiveEpicLabelsSelectFailure, actions.receiveEpicLabelsSelectFailure,
{}, {},
state, state,
[{ type: 'RECEIVE_EPIC_LABELS_SELECT_FAILURE' }], [{ type: 'RECEIVE_EPIC_LABELS_SELECT_FAILURE' }],
[], [],
done,
); );
}); });
...@@ -855,7 +824,7 @@ describe('Epic Store Actions', () => { ...@@ -855,7 +824,7 @@ describe('Epic Store Actions', () => {
{ id: 2, set: true }, { id: 2, set: true },
]; ];
it('dispatches `requestEpicLabelsSelect` and `receiveEpicLabelsSelectSuccess` actions when request succeeds', (done) => { it('dispatches `requestEpicLabelsSelect` and `receiveEpicLabelsSelectSuccess` actions when request succeeds', async () => {
jest.spyOn(epicUtils.gqClient, 'mutate').mockReturnValue( jest.spyOn(epicUtils.gqClient, 'mutate').mockReturnValue(
Promise.resolve({ Promise.resolve({
data: { data: {
...@@ -866,7 +835,7 @@ describe('Epic Store Actions', () => { ...@@ -866,7 +835,7 @@ describe('Epic Store Actions', () => {
}), }),
); );
testAction( await testAction(
actions.updateEpicLabels, actions.updateEpicLabels,
labels, labels,
state, state,
...@@ -880,11 +849,10 @@ describe('Epic Store Actions', () => { ...@@ -880,11 +849,10 @@ describe('Epic Store Actions', () => {
payload: labels, payload: labels,
}, },
], ],
done,
); );
}); });
it('dispatches `requestEpicLabelsSelect` and `receiveEpicLabelsSelectFailure` actions when request fails', (done) => { it('dispatches `requestEpicLabelsSelect` and `receiveEpicLabelsSelectFailure` actions when request fails', async () => {
jest.spyOn(epicUtils.gqClient, 'mutate').mockReturnValue( jest.spyOn(epicUtils.gqClient, 'mutate').mockReturnValue(
Promise.resolve({ Promise.resolve({
data: { data: {
...@@ -895,7 +863,7 @@ describe('Epic Store Actions', () => { ...@@ -895,7 +863,7 @@ describe('Epic Store Actions', () => {
}), }),
); );
testAction( await testAction(
actions.updateEpicLabels, actions.updateEpicLabels,
labels, labels,
state, state,
...@@ -908,31 +876,29 @@ describe('Epic Store Actions', () => { ...@@ -908,31 +876,29 @@ describe('Epic Store Actions', () => {
type: 'receiveEpicLabelsSelectFailure', type: 'receiveEpicLabelsSelectFailure',
}, },
], ],
done,
); );
}); });
}); });
describe('requestEpicSubscriptionToggle', () => { describe('requestEpicSubscriptionToggle', () => {
it('should set `state.epicSubscriptionToggleInProgress` flag to `true`', (done) => { it('should set `state.epicSubscriptionToggleInProgress` flag to `true`', async () => {
testAction( await testAction(
actions.requestEpicSubscriptionToggle, actions.requestEpicSubscriptionToggle,
{}, {},
state, state,
[{ type: 'REQUEST_EPIC_SUBSCRIPTION_TOGGLE' }], [{ type: 'REQUEST_EPIC_SUBSCRIPTION_TOGGLE' }],
[], [],
done,
); );
}); });
}); });
describe('requestEpicSubscriptionToggleSuccess', () => { describe('requestEpicSubscriptionToggleSuccess', () => {
it('should set `state.requestEpicSubscriptionToggleSuccess` flag to `false` and passes opposite of the value of `subscribed` as param', (done) => { it('should set `state.requestEpicSubscriptionToggleSuccess` flag to `false` and passes opposite of the value of `subscribed` as param', async () => {
const stateSubscribed = { const stateSubscribed = {
subscribed: false, subscribed: false,
}; };
testAction( await testAction(
actions.requestEpicSubscriptionToggleSuccess, actions.requestEpicSubscriptionToggleSuccess,
{ subscribed: !stateSubscribed.subscribed }, { subscribed: !stateSubscribed.subscribed },
stateSubscribed, stateSubscribed,
...@@ -943,20 +909,18 @@ describe('Epic Store Actions', () => { ...@@ -943,20 +909,18 @@ describe('Epic Store Actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('requestEpicSubscriptionToggleFailure', () => { describe('requestEpicSubscriptionToggleFailure', () => {
it('should set `state.requestEpicSubscriptionToggleFailure` flag to `false`', (done) => { it('should set `state.requestEpicSubscriptionToggleFailure` flag to `false`', async () => {
testAction( await testAction(
actions.requestEpicSubscriptionToggleFailure, actions.requestEpicSubscriptionToggleFailure,
{}, {},
state, state,
[{ type: 'REQUEST_EPIC_SUBSCRIPTION_TOGGLE_FAILURE' }], [{ type: 'REQUEST_EPIC_SUBSCRIPTION_TOGGLE_FAILURE' }],
[], [],
done,
); );
}); });
...@@ -1015,7 +979,7 @@ describe('Epic Store Actions', () => { ...@@ -1015,7 +979,7 @@ describe('Epic Store Actions', () => {
}); });
describe('success', () => { describe('success', () => {
it('dispatches requestEpicSubscriptionToggle and requestEpicSubscriptionToggleSuccess with param `subscribed` when request is complete', (done) => { it('dispatches requestEpicSubscriptionToggle and requestEpicSubscriptionToggleSuccess with param `subscribed` when request is complete', async () => {
mock.onPost(/(.*)/).replyOnce(200, {}); mock.onPost(/(.*)/).replyOnce(200, {});
jest.spyOn(epicUtils.gqClient, 'mutate').mockReturnValue( jest.spyOn(epicUtils.gqClient, 'mutate').mockReturnValue(
Promise.resolve({ Promise.resolve({
...@@ -1023,7 +987,7 @@ describe('Epic Store Actions', () => { ...@@ -1023,7 +987,7 @@ describe('Epic Store Actions', () => {
}), }),
); );
testAction( await testAction(
actions.toggleEpicSubscription, actions.toggleEpicSubscription,
{ subscribed: !state.subscribed }, { subscribed: !state.subscribed },
state, state,
...@@ -1037,7 +1001,7 @@ describe('Epic Store Actions', () => { ...@@ -1037,7 +1001,7 @@ describe('Epic Store Actions', () => {
payload: { subscribed: !state.subscribed }, payload: { subscribed: !state.subscribed },
}, },
], ],
() => { );
expect(epicUtils.gqClient.mutate).toHaveBeenCalledWith( expect(epicUtils.gqClient.mutate).toHaveBeenCalledWith(
expect.objectContaining({ expect.objectContaining({
variables: expect.objectContaining({ variables: expect.objectContaining({
...@@ -1049,15 +1013,11 @@ describe('Epic Store Actions', () => { ...@@ -1049,15 +1013,11 @@ describe('Epic Store Actions', () => {
}), }),
}), }),
); );
done();
},
);
}); });
}); });
describe('failure', () => { describe('failure', () => {
it('dispatches requestEpicSubscriptionToggle and requestEpicSubscriptionToggleFailure when request fails', (done) => { it('dispatches requestEpicSubscriptionToggle and requestEpicSubscriptionToggleFailure when request fails', async () => {
mock.onPost(/(.*)/).replyOnce(500, {}); mock.onPost(/(.*)/).replyOnce(500, {});
jest.spyOn(epicUtils.gqClient, 'mutate').mockReturnValue( jest.spyOn(epicUtils.gqClient, 'mutate').mockReturnValue(
Promise.resolve({ Promise.resolve({
...@@ -1070,7 +1030,7 @@ describe('Epic Store Actions', () => { ...@@ -1070,7 +1030,7 @@ describe('Epic Store Actions', () => {
}), }),
); );
testAction( await testAction(
actions.toggleEpicSubscription, actions.toggleEpicSubscription,
{ subscribed: !state.subscribed }, { subscribed: !state.subscribed },
state, state,
...@@ -1083,68 +1043,63 @@ describe('Epic Store Actions', () => { ...@@ -1083,68 +1043,63 @@ describe('Epic Store Actions', () => {
type: 'requestEpicSubscriptionToggleFailure', type: 'requestEpicSubscriptionToggleFailure',
}, },
], ],
done,
); );
}); });
}); });
}); });
describe('setEpicCreateTitle', () => { describe('setEpicCreateTitle', () => {
it('should set `state.newEpicTitle` value to the value of `newEpicTitle` param', (done) => { it('should set `state.newEpicTitle` value to the value of `newEpicTitle` param', async () => {
const data = { const data = {
newEpicTitle: 'foobar', newEpicTitle: 'foobar',
}; };
testAction( await testAction(
actions.setEpicCreateTitle, actions.setEpicCreateTitle,
data, data,
{ newEpicTitle: '' }, { newEpicTitle: '' },
[{ type: 'SET_EPIC_CREATE_TITLE', payload: { ...data } }], [{ type: 'SET_EPIC_CREATE_TITLE', payload: { ...data } }],
[], [],
done,
); );
}); });
}); });
describe('setEpicCreateConfidential', () => { describe('setEpicCreateConfidential', () => {
it('should set `state.newEpicConfidential` value to the value of `newEpicConfidential` param', (done) => { it('should set `state.newEpicConfidential` value to the value of `newEpicConfidential` param', async () => {
const data = { const data = {
newEpicConfidential: true, newEpicConfidential: true,
}; };
testAction( await testAction(
actions.setEpicCreateConfidential, actions.setEpicCreateConfidential,
data, data,
{ newEpicConfidential: true }, { newEpicConfidential: true },
[{ type: 'SET_EPIC_CREATE_CONFIDENTIAL', payload: { ...data } }], [{ type: 'SET_EPIC_CREATE_CONFIDENTIAL', payload: { ...data } }],
[], [],
done,
); );
}); });
}); });
describe('requestEpicCreate', () => { describe('requestEpicCreate', () => {
it('should set `state.epicCreateInProgress` flag to `true`', (done) => { it('should set `state.epicCreateInProgress` flag to `true`', async () => {
testAction( await testAction(
actions.requestEpicCreate, actions.requestEpicCreate,
{}, {},
{ epicCreateInProgress: false }, { epicCreateInProgress: false },
[{ type: 'REQUEST_EPIC_CREATE' }], [{ type: 'REQUEST_EPIC_CREATE' }],
[], [],
done,
); );
}); });
}); });
describe('requestEpicCreateFailure', () => { describe('requestEpicCreateFailure', () => {
it('should set `state.epicCreateInProgress` flag to `false`', (done) => { it('should set `state.epicCreateInProgress` flag to `false`', async () => {
testAction( await testAction(
actions.requestEpicCreateFailure, actions.requestEpicCreateFailure,
{}, {},
{ epicCreateInProgress: true }, { epicCreateInProgress: true },
[{ type: 'REQUEST_EPIC_CREATE_FAILURE' }], [{ type: 'REQUEST_EPIC_CREATE_FAILURE' }],
[], [],
done,
); );
}); });
...@@ -1173,10 +1128,10 @@ describe('Epic Store Actions', () => { ...@@ -1173,10 +1128,10 @@ describe('Epic Store Actions', () => {
}); });
describe('success', () => { describe('success', () => {
it('dispatches requestEpicCreate when request is complete', (done) => { it('dispatches requestEpicCreate when request is complete', async () => {
mock.onPost(/(.*)/).replyOnce(200, {}); mock.onPost(/(.*)/).replyOnce(200, {});
testAction( await testAction(
actions.createEpic, actions.createEpic,
{ ...stateCreateEpic }, { ...stateCreateEpic },
stateCreateEpic, stateCreateEpic,
...@@ -1189,16 +1144,15 @@ describe('Epic Store Actions', () => { ...@@ -1189,16 +1144,15 @@ describe('Epic Store Actions', () => {
type: 'requestEpicCreateSuccess', type: 'requestEpicCreateSuccess',
}, },
], ],
done,
); );
}); });
}); });
describe('failure', () => { describe('failure', () => {
it('dispatches requestEpicCreate and requestEpicCreateFailure when request fails', (done) => { it('dispatches requestEpicCreate and requestEpicCreateFailure when request fails', async () => {
mock.onPost(/(.*)/).replyOnce(500, {}); mock.onPost(/(.*)/).replyOnce(500, {});
testAction( await testAction(
actions.createEpic, actions.createEpic,
{ ...stateCreateEpic }, { ...stateCreateEpic },
stateCreateEpic, stateCreateEpic,
...@@ -1211,22 +1165,20 @@ describe('Epic Store Actions', () => { ...@@ -1211,22 +1165,20 @@ describe('Epic Store Actions', () => {
type: 'requestEpicCreateFailure', type: 'requestEpicCreateFailure',
}, },
], ],
done,
); );
}); });
}); });
}); });
describe('updateConfidentialityOnIssuable', () => { describe('updateConfidentialityOnIssuable', () => {
it('should commit `SET_EPIC_CONFIDENTIAL` mutation with param `sidebarCollapsed', (done) => { it('should commit `SET_EPIC_CONFIDENTIAL` mutation with param `sidebarCollapsed', async () => {
const confidential = true; const confidential = true;
testAction( await testAction(
actions.updateConfidentialityOnIssuable, actions.updateConfidentialityOnIssuable,
confidential, confidential,
state, state,
[{ payload: true, type: 'SET_EPIC_CONFIDENTIAL' }], [{ payload: true, type: 'SET_EPIC_CONFIDENTIAL' }],
[], [],
done,
); );
}); });
}); });
......
...@@ -41,21 +41,20 @@ describe('GeoReplicable Store Actions', () => { ...@@ -41,21 +41,20 @@ describe('GeoReplicable Store Actions', () => {
}); });
describe('requestReplicableItems', () => { describe('requestReplicableItems', () => {
it('should commit mutation REQUEST_REPLICABLE_ITEMS', (done) => { it('should commit mutation REQUEST_REPLICABLE_ITEMS', async () => {
testAction( await testAction(
actions.requestReplicableItems, actions.requestReplicableItems,
null, null,
state, state,
[{ type: types.REQUEST_REPLICABLE_ITEMS }], [{ type: types.REQUEST_REPLICABLE_ITEMS }],
[], [],
done,
); );
}); });
}); });
describe('receiveReplicableItemsSuccess', () => { describe('receiveReplicableItemsSuccess', () => {
it('should commit mutation RECEIVE_REPLICABLE_ITEMS_SUCCESS', (done) => { it('should commit mutation RECEIVE_REPLICABLE_ITEMS_SUCCESS', async () => {
testAction( await testAction(
actions.receiveReplicableItemsSuccess, actions.receiveReplicableItemsSuccess,
{ data: MOCK_BASIC_FETCH_DATA_MAP, pagination: MOCK_RESTFUL_PAGINATION_DATA }, { data: MOCK_BASIC_FETCH_DATA_MAP, pagination: MOCK_RESTFUL_PAGINATION_DATA },
state, state,
...@@ -66,14 +65,13 @@ describe('GeoReplicable Store Actions', () => { ...@@ -66,14 +65,13 @@ describe('GeoReplicable Store Actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveReplicableItemsError', () => { describe('receiveReplicableItemsError', () => {
it('should commit mutation RECEIVE_REPLICABLE_ITEMS_ERROR', () => { it('should commit mutation RECEIVE_REPLICABLE_ITEMS_ERROR', async () => {
testAction( await testAction(
actions.receiveReplicableItemsError, actions.receiveReplicableItemsError,
null, null,
state, state,
...@@ -92,8 +90,8 @@ describe('GeoReplicable Store Actions', () => { ...@@ -92,8 +90,8 @@ describe('GeoReplicable Store Actions', () => {
state.useGraphQl = true; state.useGraphQl = true;
}); });
it('calls fetchReplicableItemsGraphQl', (done) => { it('calls fetchReplicableItemsGraphQl', async () => {
testAction( await testAction(
actions.fetchReplicableItems, actions.fetchReplicableItems,
null, null,
state, state,
...@@ -102,7 +100,6 @@ describe('GeoReplicable Store Actions', () => { ...@@ -102,7 +100,6 @@ describe('GeoReplicable Store Actions', () => {
{ type: 'requestReplicableItems' }, { type: 'requestReplicableItems' },
{ type: 'fetchReplicableItemsGraphQl', payload: null }, { type: 'fetchReplicableItemsGraphQl', payload: null },
], ],
done,
); );
}); });
}); });
...@@ -112,14 +109,13 @@ describe('GeoReplicable Store Actions', () => { ...@@ -112,14 +109,13 @@ describe('GeoReplicable Store Actions', () => {
state.useGraphQl = false; state.useGraphQl = false;
}); });
it('calls fetchReplicableItemsRestful', (done) => { it('calls fetchReplicableItemsRestful', async () => {
testAction( await testAction(
actions.fetchReplicableItems, actions.fetchReplicableItems,
null, null,
state, state,
[], [],
[{ type: 'requestReplicableItems' }, { type: 'fetchReplicableItemsRestful' }], [{ type: 'requestReplicableItems' }, { type: 'fetchReplicableItemsRestful' }],
done,
); );
}); });
}); });
...@@ -278,14 +274,13 @@ describe('GeoReplicable Store Actions', () => { ...@@ -278,14 +274,13 @@ describe('GeoReplicable Store Actions', () => {
jest.spyOn(mockGeoGqClient, 'query').mockRejectedValue(); jest.spyOn(mockGeoGqClient, 'query').mockRejectedValue();
}); });
it('should dispatch the request and error actions', (done) => { it('should dispatch the request and error actions', async () => {
testAction( await testAction(
actions.fetchReplicableItemsGraphQl, actions.fetchReplicableItemsGraphQl,
null, null,
state, state,
[], [],
[{ type: 'receiveReplicableItemsError' }], [{ type: 'receiveReplicableItemsError' }],
done,
); );
}); });
}); });
...@@ -366,35 +361,33 @@ describe('GeoReplicable Store Actions', () => { ...@@ -366,35 +361,33 @@ describe('GeoReplicable Store Actions', () => {
jest.spyOn(Api, 'getGeoReplicableItems').mockRejectedValue(new Error(500)); jest.spyOn(Api, 'getGeoReplicableItems').mockRejectedValue(new Error(500));
}); });
it('should dispatch the request and error actions', (done) => { it('should dispatch the request and error actions', async () => {
testAction( await testAction(
actions.fetchReplicableItemsRestful, actions.fetchReplicableItemsRestful,
{}, {},
state, state,
[], [],
[{ type: 'receiveReplicableItemsError' }], [{ type: 'receiveReplicableItemsError' }],
done,
); );
}); });
}); });
}); });
describe('requestInitiateAllReplicableSyncs', () => { describe('requestInitiateAllReplicableSyncs', () => {
it('should commit mutation REQUEST_INITIATE_ALL_REPLICABLE_SYNCS', (done) => { it('should commit mutation REQUEST_INITIATE_ALL_REPLICABLE_SYNCS', async () => {
testAction( await testAction(
actions.requestInitiateAllReplicableSyncs, actions.requestInitiateAllReplicableSyncs,
null, null,
state, state,
[{ type: types.REQUEST_INITIATE_ALL_REPLICABLE_SYNCS }], [{ type: types.REQUEST_INITIATE_ALL_REPLICABLE_SYNCS }],
[], [],
done,
); );
}); });
}); });
describe('receiveInitiateAllReplicableSyncsSuccess', () => { describe('receiveInitiateAllReplicableSyncsSuccess', () => {
it('should commit mutation RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS and call fetchReplicableItems and toast', () => { it('should commit mutation RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS and call fetchReplicableItems and toast', async () => {
testAction( await testAction(
actions.receiveInitiateAllReplicableSyncsSuccess, actions.receiveInitiateAllReplicableSyncsSuccess,
{ action: ACTION_TYPES.RESYNC }, { action: ACTION_TYPES.RESYNC },
state, state,
...@@ -460,8 +453,8 @@ describe('GeoReplicable Store Actions', () => { ...@@ -460,8 +453,8 @@ describe('GeoReplicable Store Actions', () => {
jest.spyOn(Api, 'initiateAllGeoReplicableSyncs').mockRejectedValue(new Error(500)); jest.spyOn(Api, 'initiateAllGeoReplicableSyncs').mockRejectedValue(new Error(500));
}); });
it('should dispatch the request and error actions', (done) => { it('should dispatch the request and error actions', async () => {
testAction( await testAction(
actions.initiateAllReplicableSyncs, actions.initiateAllReplicableSyncs,
action, action,
state, state,
...@@ -470,53 +463,47 @@ describe('GeoReplicable Store Actions', () => { ...@@ -470,53 +463,47 @@ describe('GeoReplicable Store Actions', () => {
{ type: 'requestInitiateAllReplicableSyncs' }, { type: 'requestInitiateAllReplicableSyncs' },
{ type: 'receiveInitiateAllReplicableSyncsError' }, { type: 'receiveInitiateAllReplicableSyncsError' },
], ],
done,
); );
}); });
}); });
}); });
describe('requestInitiateReplicableSync', () => { describe('requestInitiateReplicableSync', () => {
it('should commit mutation REQUEST_INITIATE_REPLICABLE_SYNC', (done) => { it('should commit mutation REQUEST_INITIATE_REPLICABLE_SYNC', async () => {
testAction( await testAction(
actions.requestInitiateReplicableSync, actions.requestInitiateReplicableSync,
null, null,
state, state,
[{ type: types.REQUEST_INITIATE_REPLICABLE_SYNC }], [{ type: types.REQUEST_INITIATE_REPLICABLE_SYNC }],
[], [],
done,
); );
}); });
}); });
describe('receiveInitiateReplicableSyncSuccess', () => { describe('receiveInitiateReplicableSyncSuccess', () => {
it('should commit mutation RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS and call fetchReplicableItems and toast', () => { it('should commit mutation RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS and call fetchReplicableItems and toast', async () => {
testAction( await testAction(
actions.receiveInitiateReplicableSyncSuccess, actions.receiveInitiateReplicableSyncSuccess,
{ action: ACTION_TYPES.RESYNC, projectName: 'test' }, { action: ACTION_TYPES.RESYNC, projectName: 'test' },
state, state,
[{ type: types.RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS }], [{ type: types.RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS }],
[{ type: 'fetchReplicableItems' }], [{ type: 'fetchReplicableItems' }],
() => { );
expect(toast).toHaveBeenCalledTimes(1); expect(toast).toHaveBeenCalledTimes(1);
toast.mockClear(); toast.mockClear();
},
);
}); });
}); });
describe('receiveInitiateReplicableSyncError', () => { describe('receiveInitiateReplicableSyncError', () => {
it('should commit mutation RECEIVE_INITIATE_REPLICABLE_SYNC_ERROR', () => { it('should commit mutation RECEIVE_INITIATE_REPLICABLE_SYNC_ERROR', async () => {
testAction( await testAction(
actions.receiveInitiateReplicableSyncError, actions.receiveInitiateReplicableSyncError,
{ action: ACTION_TYPES.RESYNC, projectId: 1, projectName: 'test' }, { action: ACTION_TYPES.RESYNC, projectId: 1, projectName: 'test' },
state, state,
[{ type: types.RECEIVE_INITIATE_REPLICABLE_SYNC_ERROR }], [{ type: types.RECEIVE_INITIATE_REPLICABLE_SYNC_ERROR }],
[], [],
() => {
expect(createFlash).toHaveBeenCalledTimes(1);
},
); );
expect(createFlash).toHaveBeenCalledTimes(1);
}); });
}); });
...@@ -543,13 +530,11 @@ describe('GeoReplicable Store Actions', () => { ...@@ -543,13 +530,11 @@ describe('GeoReplicable Store Actions', () => {
{ type: 'requestInitiateReplicableSync' }, { type: 'requestInitiateReplicableSync' },
{ type: 'receiveInitiateReplicableSyncSuccess', payload: { name, action } }, { type: 'receiveInitiateReplicableSyncSuccess', payload: { name, action } },
], ],
() => { );
expect(Api.initiateGeoReplicableSync).toHaveBeenCalledWith(MOCK_REPLICABLE_TYPE, { expect(Api.initiateGeoReplicableSync).toHaveBeenCalledWith(MOCK_REPLICABLE_TYPE, {
projectId, projectId,
action, action,
}); });
},
);
}); });
}); });
...@@ -561,8 +546,8 @@ describe('GeoReplicable Store Actions', () => { ...@@ -561,8 +546,8 @@ describe('GeoReplicable Store Actions', () => {
jest.spyOn(Api, 'initiateGeoReplicableSync').mockRejectedValue(new Error(500)); jest.spyOn(Api, 'initiateGeoReplicableSync').mockRejectedValue(new Error(500));
}); });
it('should dispatch the request and error actions', (done) => { it('should dispatch the request and error actions', async () => {
testAction( await testAction(
actions.initiateReplicableSync, actions.initiateReplicableSync,
{ projectId, name, action }, { projectId, name, action },
state, state,
...@@ -574,55 +559,51 @@ describe('GeoReplicable Store Actions', () => { ...@@ -574,55 +559,51 @@ describe('GeoReplicable Store Actions', () => {
payload: { name: 'test' }, payload: { name: 'test' },
}, },
], ],
done,
); );
}); });
}); });
}); });
describe('setFilter', () => { describe('setFilter', () => {
it('should commit mutation SET_FILTER', (done) => { it('should commit mutation SET_FILTER', async () => {
const testValue = 1; const testValue = 1;
testAction( await testAction(
actions.setFilter, actions.setFilter,
testValue, testValue,
state, state,
[{ type: types.SET_FILTER, payload: testValue }], [{ type: types.SET_FILTER, payload: testValue }],
[], [],
done,
); );
}); });
}); });
describe('setSearch', () => { describe('setSearch', () => {
it('should commit mutation SET_SEARCH', (done) => { it('should commit mutation SET_SEARCH', async () => {
const testValue = 'Test Search'; const testValue = 'Test Search';
testAction( await testAction(
actions.setSearch, actions.setSearch,
testValue, testValue,
state, state,
[{ type: types.SET_SEARCH, payload: testValue }], [{ type: types.SET_SEARCH, payload: testValue }],
[], [],
done,
); );
}); });
}); });
describe('setPage', () => { describe('setPage', () => {
it('should commit mutation SET_PAGE', (done) => { it('should commit mutation SET_PAGE', async () => {
state.paginationData.page = 1; state.paginationData.page = 1;
const testValue = 2; const testValue = 2;
testAction( await testAction(
actions.setPage, actions.setPage,
testValue, testValue,
state, state,
[{ type: types.SET_PAGE, payload: testValue }], [{ type: types.SET_PAGE, payload: testValue }],
[], [],
done,
); );
}); });
}); });
......
...@@ -70,41 +70,29 @@ describe('GroupMemberStore', () => { ...@@ -70,41 +70,29 @@ describe('GroupMemberStore', () => {
mock.restore(); mock.restore();
}); });
it('calls service.getContributedMembers and sets response to the store on success', (done) => { it('calls service.getContributedMembers and sets response to the store on success', async () => {
mock.onGet(contributionsPath).reply(200, rawMembers); mock.onGet(contributionsPath).reply(200, rawMembers);
jest.spyOn(store, 'setColumns').mockImplementation(() => {}); jest.spyOn(store, 'setColumns').mockImplementation(() => {});
jest.spyOn(store, 'setMembers').mockImplementation(() => {}); jest.spyOn(store, 'setMembers').mockImplementation(() => {});
store expect(store.isLoading).toBe(true);
.fetchContributedMembers() await store.fetchContributedMembers();
.then(() => {
expect(store.isLoading).toBe(false); expect(store.isLoading).toBe(false);
expect(store.setColumns).toHaveBeenCalledWith(expect.any(Object)); expect(store.setColumns).toHaveBeenCalledWith(expect.any(Object));
expect(store.setMembers).toHaveBeenCalledWith(rawMembers); expect(store.setMembers).toHaveBeenCalledWith(rawMembers);
done();
})
.catch(done.fail);
expect(store.isLoading).toBe(true);
}); });
it('calls service.getContributedMembers and sets `isLoading` to false and shows flash message if request failed', (done) => { it('calls service.getContributedMembers and sets `isLoading` to false and shows flash message if request failed', async () => {
mock.onGet(contributionsPath).reply(500, {}); mock.onGet(contributionsPath).reply(500, {});
store await expect(store.fetchContributedMembers()).rejects.toEqual(
.fetchContributedMembers() new Error('Request failed with status code 500'),
.then(() => done.fail('Expected error to be thrown!')) );
.catch((e) => {
expect(e.message).toBe('Request failed with status code 500');
expect(store.isLoading).toBe(false); expect(store.isLoading).toBe(false);
expect(createFlash).toHaveBeenCalledWith({ expect(createFlash).toHaveBeenCalledWith({
message: 'Something went wrong while fetching group member contributions', message: 'Something went wrong while fetching group member contributions',
}); });
})
.then(done)
.catch(done.fail);
expect(store.isLoading).toBe(true);
}); });
}); });
}); });
...@@ -23,7 +23,7 @@ describe('saml_members actions', () => { ...@@ -23,7 +23,7 @@ describe('saml_members actions', () => {
}); });
describe('fetchPage', () => { describe('fetchPage', () => {
it('should commit RECEIVE_SAML_MEMBERS_SUCCESS mutation on correct data', (done) => { it('should commit RECEIVE_SAML_MEMBERS_SUCCESS mutation on correct data', async () => {
const members = [ const members = [
{ id: 1, name: 'user 1', group_saml_identity: null }, { id: 1, name: 'user 1', group_saml_identity: null },
{ id: 2, name: 'user 2', group_saml_identity: { extern_uid: 'a' } }, { id: 2, name: 'user 2', group_saml_identity: { extern_uid: 'a' } },
...@@ -57,7 +57,7 @@ describe('saml_members actions', () => { ...@@ -57,7 +57,7 @@ describe('saml_members actions', () => {
previousPage: 1, previousPage: 1,
}; };
testAction( await testAction(
fetchPage, fetchPage,
undefined, undefined,
state, state,
...@@ -68,16 +68,14 @@ describe('saml_members actions', () => { ...@@ -68,16 +68,14 @@ describe('saml_members actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
it('should show flash on wrong data', (done) => { it('should show flash on wrong data', async () => {
Api.groupMembers.mockReturnValue(Promise.reject(new Error())); Api.groupMembers.mockReturnValue(Promise.reject(new Error()));
testAction(fetchPage, undefined, state, [], [], () => { await testAction(fetchPage, undefined, state, [], []);
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
done();
});
}); });
}); });
}); });
...@@ -1648,15 +1648,12 @@ describe('RelatedItemTree', () => { ...@@ -1648,15 +1648,12 @@ describe('RelatedItemTree', () => {
requestSpy.mockReturnValue([500, '']); requestSpy.mockReturnValue([500, '']);
}); });
it('fails and shows flash message', (done) => { it('fails and shows flash message', async () => {
return actions await expect(actions.createNewIssue(context, payload)).rejects.toEqual(
.createNewIssue(context, payload) new Error('Request failed with status code 500'),
.then(() => done.fail('expected action to throw error!')) );
.catch(() => {
expect(requestSpy).toHaveBeenCalledWith(expectedRequest); expect(requestSpy).toHaveBeenCalledWith(expectedRequest);
expect(context.dispatch).toHaveBeenCalledWith('receiveCreateIssueFailure'); expect(context.dispatch).toHaveBeenCalledWith('receiveCreateIssueFailure');
done();
});
}); });
}); });
}); });
......
...@@ -17,8 +17,8 @@ describe('pipeling jobs actions', () => { ...@@ -17,8 +17,8 @@ describe('pipeling jobs actions', () => {
describe('setPipelineJobsPath', () => { describe('setPipelineJobsPath', () => {
const pipelineJobsPath = 123; const pipelineJobsPath = 123;
it('should commit the SET_PIPELINE_JOBS_PATH mutation', (done) => { it('should commit the SET_PIPELINE_JOBS_PATH mutation', async () => {
testAction( await testAction(
actions.setPipelineJobsPath, actions.setPipelineJobsPath,
pipelineJobsPath, pipelineJobsPath,
state, state,
...@@ -29,7 +29,6 @@ describe('pipeling jobs actions', () => { ...@@ -29,7 +29,6 @@ describe('pipeling jobs actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -37,8 +36,8 @@ describe('pipeling jobs actions', () => { ...@@ -37,8 +36,8 @@ describe('pipeling jobs actions', () => {
describe('setProjectId', () => { describe('setProjectId', () => {
const projectId = 123; const projectId = 123;
it('should commit the SET_PIPELINE_JOBS_PATH mutation', (done) => { it('should commit the SET_PIPELINE_JOBS_PATH mutation', async () => {
testAction( await testAction(
actions.setProjectId, actions.setProjectId,
projectId, projectId,
state, state,
...@@ -49,7 +48,6 @@ describe('pipeling jobs actions', () => { ...@@ -49,7 +48,6 @@ describe('pipeling jobs actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -57,8 +55,8 @@ describe('pipeling jobs actions', () => { ...@@ -57,8 +55,8 @@ describe('pipeling jobs actions', () => {
describe('setPipelineId', () => { describe('setPipelineId', () => {
const pipelineId = 123; const pipelineId = 123;
it('should commit the SET_PIPELINE_ID mutation', (done) => { it('should commit the SET_PIPELINE_ID mutation', async () => {
testAction( await testAction(
actions.setPipelineId, actions.setPipelineId,
pipelineId, pipelineId,
state, state,
...@@ -69,7 +67,6 @@ describe('pipeling jobs actions', () => { ...@@ -69,7 +67,6 @@ describe('pipeling jobs actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -92,8 +89,8 @@ describe('pipeling jobs actions', () => { ...@@ -92,8 +89,8 @@ describe('pipeling jobs actions', () => {
mock.onGet(state.pipelineJobsPath).replyOnce(200, jobs); mock.onGet(state.pipelineJobsPath).replyOnce(200, jobs);
}); });
it('should commit the request and success mutations', (done) => { it('should commit the request and success mutations', async () => {
testAction( await testAction(
actions.fetchPipelineJobs, actions.fetchPipelineJobs,
{}, {},
state, state,
...@@ -105,7 +102,6 @@ describe('pipeling jobs actions', () => { ...@@ -105,7 +102,6 @@ describe('pipeling jobs actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -115,12 +111,12 @@ describe('pipeling jobs actions', () => { ...@@ -115,12 +111,12 @@ describe('pipeling jobs actions', () => {
mock.onGet('/api/undefined/projects/123/pipelines/321/jobs').replyOnce(200, jobs); mock.onGet('/api/undefined/projects/123/pipelines/321/jobs').replyOnce(200, jobs);
}); });
it('should commit the request and success mutations', (done) => { it('should commit the request and success mutations', async () => {
state.pipelineJobsPath = ''; state.pipelineJobsPath = '';
state.projectId = 123; state.projectId = 123;
state.pipelineId = 321; state.pipelineId = 321;
testAction( await testAction(
actions.fetchPipelineJobs, actions.fetchPipelineJobs,
{}, {},
state, state,
...@@ -132,7 +128,6 @@ describe('pipeling jobs actions', () => { ...@@ -132,7 +128,6 @@ describe('pipeling jobs actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -142,10 +137,10 @@ describe('pipeling jobs actions', () => { ...@@ -142,10 +137,10 @@ describe('pipeling jobs actions', () => {
mock.onGet(state.pipelineJobsPath).replyOnce(200, jobs); mock.onGet(state.pipelineJobsPath).replyOnce(200, jobs);
}); });
it('should commit RECEIVE_PIPELINE_JOBS_ERROR mutation', (done) => { it('should commit RECEIVE_PIPELINE_JOBS_ERROR mutation', async () => {
state.pipelineJobsPath = ''; state.pipelineJobsPath = '';
testAction( await testAction(
actions.fetchPipelineJobs, actions.fetchPipelineJobs,
{}, {},
state, state,
...@@ -155,7 +150,6 @@ describe('pipeling jobs actions', () => { ...@@ -155,7 +150,6 @@ describe('pipeling jobs actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -165,12 +159,12 @@ describe('pipeling jobs actions', () => { ...@@ -165,12 +159,12 @@ describe('pipeling jobs actions', () => {
mock.onGet(state.pipelineJobsPath).replyOnce(200, jobs); mock.onGet(state.pipelineJobsPath).replyOnce(200, jobs);
}); });
it('should commit RECEIVE_PIPELINE_JOBS_ERROR mutation', (done) => { it('should commit RECEIVE_PIPELINE_JOBS_ERROR mutation', async () => {
state.pipelineJobsPath = ''; state.pipelineJobsPath = '';
state.projectId = undefined; state.projectId = undefined;
state.pipelineId = undefined; state.pipelineId = undefined;
testAction( await testAction(
actions.fetchPipelineJobs, actions.fetchPipelineJobs,
{}, {},
state, state,
...@@ -180,7 +174,6 @@ describe('pipeling jobs actions', () => { ...@@ -180,7 +174,6 @@ describe('pipeling jobs actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -190,8 +183,8 @@ describe('pipeling jobs actions', () => { ...@@ -190,8 +183,8 @@ describe('pipeling jobs actions', () => {
mock.onGet(state.pipelineJobsPath).replyOnce(404); mock.onGet(state.pipelineJobsPath).replyOnce(404);
}); });
it('should commit REQUEST_PIPELINE_JOBS and RECEIVE_PIPELINE_JOBS_ERROR mutation', (done) => { it('should commit REQUEST_PIPELINE_JOBS and RECEIVE_PIPELINE_JOBS_ERROR mutation', async () => {
testAction( await testAction(
actions.fetchPipelineJobs, actions.fetchPipelineJobs,
{}, {},
state, state,
...@@ -202,7 +195,6 @@ describe('pipeling jobs actions', () => { ...@@ -202,7 +195,6 @@ describe('pipeling jobs actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
......
...@@ -45,10 +45,10 @@ describe('EE projectSelector actions', () => { ...@@ -45,10 +45,10 @@ describe('EE projectSelector actions', () => {
}); });
describe('toggleSelectedProject', () => { describe('toggleSelectedProject', () => {
it('adds a project to selectedProjects if it does not already exist in the list', (done) => { it('adds a project to selectedProjects if it does not already exist in the list', async () => {
const payload = getMockProjects(1); const payload = getMockProjects(1);
testAction( await testAction(
actions.toggleSelectedProject, actions.toggleSelectedProject,
payload, payload,
state, state,
...@@ -59,15 +59,14 @@ describe('EE projectSelector actions', () => { ...@@ -59,15 +59,14 @@ describe('EE projectSelector actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
it('removes a project from selectedProjects if it already exist in the list', () => { it('removes a project from selectedProjects if it already exist in the list', async () => {
const payload = getMockProjects(1)[0]; const payload = getMockProjects(1)[0];
state.selectedProjects = getMockProjects(1); state.selectedProjects = getMockProjects(1);
return testAction( await testAction(
actions.toggleSelectedProject, actions.toggleSelectedProject,
payload, payload,
state, state,
...@@ -102,12 +101,12 @@ describe('EE projectSelector actions', () => { ...@@ -102,12 +101,12 @@ describe('EE projectSelector actions', () => {
}); });
}); });
it('dispatches the correct actions when the request is successful', () => { it('dispatches the correct actions when the request is successful', async () => {
state.projectEndpoints.add = mockAddEndpoint; state.projectEndpoints.add = mockAddEndpoint;
mockAxios.onPost(mockAddEndpoint).replyOnce(200, mockResponse); mockAxios.onPost(mockAddEndpoint).replyOnce(200, mockResponse);
return testAction( await testAction(
actions.addProjects, actions.addProjects,
null, null,
state, state,
......
...@@ -43,8 +43,8 @@ describe('projects actions', () => { ...@@ -43,8 +43,8 @@ describe('projects actions', () => {
}); });
}); });
it('should dispatch the request and success actions', (done) => { it('should dispatch the request and success actions', async () => {
testAction( await testAction(
actions.fetchProjects, actions.fetchProjects,
{}, {},
state, state,
...@@ -56,7 +56,6 @@ describe('projects actions', () => { ...@@ -56,7 +56,6 @@ describe('projects actions', () => {
payload: { projects: data }, payload: { projects: data },
}, },
], ],
done,
); );
}); });
}); });
...@@ -70,8 +69,8 @@ describe('projects actions', () => { ...@@ -70,8 +69,8 @@ describe('projects actions', () => {
mock.onGet(state.projectsEndpoint, { page: '2' }).replyOnce(200, [2]); mock.onGet(state.projectsEndpoint, { page: '2' }).replyOnce(200, [2]);
}); });
it('should dispatch the request and success actions', (done) => { it('should dispatch the request and success actions', async () => {
testAction( await testAction(
actions.fetchProjects, actions.fetchProjects,
{}, {},
state, state,
...@@ -83,7 +82,6 @@ describe('projects actions', () => { ...@@ -83,7 +82,6 @@ describe('projects actions', () => {
payload: { projects: [1, 2] }, payload: { projects: [1, 2] },
}, },
], ],
done,
); );
}); });
}); });
...@@ -93,14 +91,13 @@ describe('projects actions', () => { ...@@ -93,14 +91,13 @@ describe('projects actions', () => {
mock.onGet(state.projectsEndpoint).replyOnce(404, {}); mock.onGet(state.projectsEndpoint).replyOnce(404, {});
}); });
it('should dispatch the request and error actions', (done) => { it('should dispatch the request and error actions', async () => {
testAction( await testAction(
actions.fetchProjects, actions.fetchProjects,
{}, {},
state, state,
[], [],
[{ type: 'requestProjects' }, { type: 'receiveProjectsError' }], [{ type: 'requestProjects' }, { type: 'receiveProjectsError' }],
done,
); );
}); });
}); });
...@@ -110,17 +107,17 @@ describe('projects actions', () => { ...@@ -110,17 +107,17 @@ describe('projects actions', () => {
state.projectsEndpoint = ''; state.projectsEndpoint = '';
}); });
it('should not do anything', (done) => { it('should not do anything', async () => {
testAction(actions.fetchProjects, {}, state, [], [], done); await testAction(actions.fetchProjects, {}, state, [], []);
}); });
}); });
}); });
describe('receiveProjectsSuccess', () => { describe('receiveProjectsSuccess', () => {
it('should commit the success mutation', (done) => { it('should commit the success mutation', async () => {
const state = createState(); const state = createState();
testAction( await testAction(
actions.receiveProjectsSuccess, actions.receiveProjectsSuccess,
{ projects: data }, { projects: data },
state, state,
...@@ -131,39 +128,37 @@ describe('projects actions', () => { ...@@ -131,39 +128,37 @@ describe('projects actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveProjectsError', () => { describe('receiveProjectsError', () => {
it('should commit the error mutation', (done) => { it('should commit the error mutation', async () => {
const state = createState(); const state = createState();
testAction( await testAction(
actions.receiveProjectsError, actions.receiveProjectsError,
{}, {},
state, state,
[{ type: types.RECEIVE_PROJECTS_ERROR }], [{ type: types.RECEIVE_PROJECTS_ERROR }],
[], [],
done,
); );
}); });
}); });
describe('requestProjects', () => { describe('requestProjects', () => {
it('should commit the request mutation', (done) => { it('should commit the request mutation', async () => {
const state = createState(); const state = createState();
testAction(actions.requestProjects, {}, state, [{ type: types.REQUEST_PROJECTS }], [], done); await testAction(actions.requestProjects, {}, state, [{ type: types.REQUEST_PROJECTS }], []);
}); });
}); });
describe('setProjectsEndpoint', () => { describe('setProjectsEndpoint', () => {
it('should commit the correct mutuation', (done) => { it('should commit the correct mutuation', async () => {
const state = createState(); const state = createState();
testAction( await testAction(
actions.setProjectsEndpoint, actions.setProjectsEndpoint,
endpoint, endpoint,
state, state,
...@@ -174,7 +169,6 @@ describe('projects actions', () => { ...@@ -174,7 +169,6 @@ describe('projects actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
......
...@@ -98,22 +98,20 @@ describe('Status Page actions', () => { ...@@ -98,22 +98,20 @@ describe('Status Page actions', () => {
}); });
describe('receiveStatusPageSettingsUpdateSuccess', () => { describe('receiveStatusPageSettingsUpdateSuccess', () => {
it('should handle successful settings update', (done) => { it('should handle successful settings update', async () => {
testAction(actions.receiveStatusPageSettingsUpdateSuccess, null, null, [], [], () => { await testAction(actions.receiveStatusPageSettingsUpdateSuccess, null, null, [], []);
expect(refreshCurrentPage).toHaveBeenCalledTimes(1); expect(refreshCurrentPage).toHaveBeenCalledTimes(1);
done();
});
}); });
}); });
describe('receiveStatusPageSettingsUpdateError', () => { describe('receiveStatusPageSettingsUpdateError', () => {
const error = { response: { data: { message: 'Update error' } } }; const error = { response: { data: { message: 'Update error' } } };
it('should handle error update', (done) => { it('should handle error update', async () => {
testAction(actions.receiveStatusPageSettingsUpdateError, error, null, [], [], () => { await testAction(actions.receiveStatusPageSettingsUpdateError, error, null, [], [], () => {
expect(createFlash).toHaveBeenCalledWith({ expect(createFlash).toHaveBeenCalledWith({
message: `There was an error saving your changes. ${error.response.data.message}`, message: `There was an error saving your changes. ${error.response.data.message}`,
}); });
done();
}); });
}); });
}); });
......
...@@ -4,10 +4,6 @@ import ApprovalsAuth from 'ee/vue_merge_request_widget/components/approvals/appr ...@@ -4,10 +4,6 @@ import ApprovalsAuth from 'ee/vue_merge_request_widget/components/approvals/appr
const TEST_PASSWORD = 'password'; const TEST_PASSWORD = 'password';
// For some reason, the `Promise.resolve` needs to be deferred
// or the timing doesn't work.
const waitForTick = (done) => Promise.resolve().then(done).catch(done.fail);
describe('Approval auth component', () => { describe('Approval auth component', () => {
let wrapper; let wrapper;
...@@ -22,16 +18,14 @@ describe('Approval auth component', () => { ...@@ -22,16 +18,14 @@ describe('Approval auth component', () => {
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
}); });
const findInput = () => wrapper.find('input[type=password]'); const findInput = () => wrapper.find('input[type=password]');
const findErrorMessage = () => wrapper.find('.gl-field-error'); const findErrorMessage = () => wrapper.find('.gl-field-error');
describe('when created', () => { describe('when created', () => {
beforeEach((done) => { beforeEach(() => {
createComponent(); createComponent();
waitForTick(done);
}); });
it('password input control is rendered', () => { it('password input control is rendered', () => {
...@@ -54,24 +48,21 @@ describe('Approval auth component', () => { ...@@ -54,24 +48,21 @@ describe('Approval auth component', () => {
}); });
describe('when approve clicked', () => { describe('when approve clicked', () => {
beforeEach((done) => { beforeEach(() => {
createComponent(); createComponent();
waitForTick(done);
}); });
it('emits the approve event', (done) => { it('emits the approve event', async () => {
findInput().setValue(TEST_PASSWORD); findInput().setValue(TEST_PASSWORD);
wrapper.findComponent(GlModal).vm.$emit('ok', { preventDefault: () => null }); wrapper.findComponent(GlModal).vm.$emit('ok', { preventDefault: () => null });
waitForTick(done);
expect(wrapper.emitted().approve).toEqual([[TEST_PASSWORD]]); expect(wrapper.emitted().approve).toEqual([[TEST_PASSWORD]]);
}); });
}); });
describe('when isApproving is true', () => { describe('when isApproving is true', () => {
beforeEach((done) => { beforeEach(() => {
createComponent({ isApproving: true }); createComponent({ isApproving: true });
waitForTick(done);
}); });
it('disables the approve button', () => { it('disables the approve button', () => {
...@@ -82,9 +73,8 @@ describe('Approval auth component', () => { ...@@ -82,9 +73,8 @@ describe('Approval auth component', () => {
}); });
describe('when hasError is true', () => { describe('when hasError is true', () => {
beforeEach((done) => { beforeEach(() => {
createComponent({ hasError: true }); createComponent({ hasError: true });
waitForTick(done);
}); });
it('shows the invalid password message', () => { it('shows the invalid password message', () => {
......
...@@ -27,7 +27,7 @@ describe('EpicsSelect', () => { ...@@ -27,7 +27,7 @@ describe('EpicsSelect', () => {
}); });
describe('setInitialData', () => { describe('setInitialData', () => {
it('should set initial data on state', (done) => { it('should set initial data on state', async () => {
const mockInitialConfig = { const mockInitialConfig = {
groupId: mockEpic1.group_id, groupId: mockEpic1.group_id,
issueId: mockIssue.id, issueId: mockIssue.id,
...@@ -35,90 +35,84 @@ describe('EpicsSelect', () => { ...@@ -35,90 +35,84 @@ describe('EpicsSelect', () => {
selectedEpicIssueId: mockIssue.epic_issue_id, selectedEpicIssueId: mockIssue.epic_issue_id,
}; };
testAction( await testAction(
actions.setInitialData, actions.setInitialData,
mockInitialConfig, mockInitialConfig,
state, state,
[{ type: types.SET_INITIAL_DATA, payload: mockInitialConfig }], [{ type: types.SET_INITIAL_DATA, payload: mockInitialConfig }],
[], [],
done,
); );
}); });
}); });
describe('setIssueId', () => { describe('setIssueId', () => {
it('should set `issueId` on state', (done) => { it('should set `issueId` on state', async () => {
const issueId = mockIssue.id; const issueId = mockIssue.id;
testAction( await testAction(
actions.setIssueId, actions.setIssueId,
issueId, issueId,
state, state,
[{ type: types.SET_ISSUE_ID, payload: issueId }], [{ type: types.SET_ISSUE_ID, payload: issueId }],
[], [],
done,
); );
}); });
}); });
describe('setSearchQuery', () => { describe('setSearchQuery', () => {
it('should set `searchQuery` param on state', (done) => { it('should set `searchQuery` param on state', async () => {
const searchQuery = 'foo'; const searchQuery = 'foo';
testAction( await testAction(
actions.setSearchQuery, actions.setSearchQuery,
searchQuery, searchQuery,
state, state,
[{ type: types.SET_SEARCH_QUERY, payload: searchQuery }], [{ type: types.SET_SEARCH_QUERY, payload: searchQuery }],
[], [],
done,
); );
}); });
}); });
describe('setSelectedEpic', () => { describe('setSelectedEpic', () => {
it('should set `selectedEpic` param on state', (done) => { it('should set `selectedEpic` param on state', async () => {
testAction( await testAction(
actions.setSelectedEpic, actions.setSelectedEpic,
mockEpic1, mockEpic1,
state, state,
[{ type: types.SET_SELECTED_EPIC, payload: mockEpic1 }], [{ type: types.SET_SELECTED_EPIC, payload: mockEpic1 }],
[], [],
done,
); );
}); });
}); });
describe('setSelectedEpicIssueId', () => { describe('setSelectedEpicIssueId', () => {
it('should set `selectedEpicIssueId` param on state', (done) => { it('should set `selectedEpicIssueId` param on state', async () => {
testAction( await testAction(
actions.setSelectedEpicIssueId, actions.setSelectedEpicIssueId,
mockIssue.epic_issue_id, mockIssue.epic_issue_id,
state, state,
[{ type: types.SET_SELECTED_EPIC_ISSUE_ID, payload: mockIssue.epic_issue_id }], [{ type: types.SET_SELECTED_EPIC_ISSUE_ID, payload: mockIssue.epic_issue_id }],
[], [],
done,
); );
}); });
}); });
describe('requestEpics', () => { describe('requestEpics', () => {
it('should set `state.epicsFetchInProgress` to true', (done) => { it('should set `state.epicsFetchInProgress` to true', async () => {
testAction(actions.requestEpics, {}, state, [{ type: types.REQUEST_EPICS }], [], done); await testAction(actions.requestEpics, {}, state, [{ type: types.REQUEST_EPICS }], []);
}); });
}); });
describe('receiveEpicsSuccess', () => { describe('receiveEpicsSuccess', () => {
it('should set processed Epics array to `state.epics`', (done) => { it('should set processed Epics array to `state.epics`', async () => {
state.groupId = mockEpic1.group_id; state.groupId = mockEpic1.group_id;
testAction( await testAction(
actions.receiveEpicsSuccess, actions.receiveEpicsSuccess,
mockEpics, mockEpics,
state, state,
[{ type: types.RECEIVE_EPICS_SUCCESS, payload: { epics: normalizedEpics } }], [{ type: types.RECEIVE_EPICS_SUCCESS, payload: { epics: normalizedEpics } }],
[], [],
done,
); );
}); });
}); });
...@@ -134,14 +128,13 @@ describe('EpicsSelect', () => { ...@@ -134,14 +128,13 @@ describe('EpicsSelect', () => {
}); });
}); });
it('should set `state.epicsFetchInProgress` to false', (done) => { it('should set `state.epicsFetchInProgress` to false', async () => {
testAction( await testAction(
actions.receiveEpicsFailure, actions.receiveEpicsFailure,
{}, {},
state, state,
[{ type: types.RECEIVE_EPICS_FAILURE }], [{ type: types.RECEIVE_EPICS_FAILURE }],
[], [],
done,
); );
}); });
}); });
...@@ -151,14 +144,14 @@ describe('EpicsSelect', () => { ...@@ -151,14 +144,14 @@ describe('EpicsSelect', () => {
state.groupId = mockEpic1.group_id; state.groupId = mockEpic1.group_id;
}); });
it('should dispatch `requestEpics` & call `Api.groupEpics` and then dispatch `receiveEpicsSuccess` on request success', (done) => { it('should dispatch `requestEpics` & call `Api.groupEpics` and then dispatch `receiveEpicsSuccess` on request success', async () => {
jest.spyOn(Api, 'groupEpics').mockReturnValue( jest.spyOn(Api, 'groupEpics').mockReturnValue(
Promise.resolve({ Promise.resolve({
data: mockEpics, data: mockEpics,
}), }),
); );
testAction( await testAction(
actions.fetchEpics, actions.fetchEpics,
mockEpics, mockEpics,
state, state,
...@@ -172,14 +165,13 @@ describe('EpicsSelect', () => { ...@@ -172,14 +165,13 @@ describe('EpicsSelect', () => {
payload: mockEpics, payload: mockEpics,
}, },
], ],
done,
); );
}); });
it('should dispatch `requestEpics` & call `Api.groupEpics` and then dispatch `receiveEpicsFailure` on request failure', (done) => { it('should dispatch `requestEpics` & call `Api.groupEpics` and then dispatch `receiveEpicsFailure` on request failure', async () => {
jest.spyOn(Api, 'groupEpics').mockReturnValue(Promise.reject()); jest.spyOn(Api, 'groupEpics').mockReturnValue(Promise.reject());
testAction( await testAction(
actions.fetchEpics, actions.fetchEpics,
mockEpics, mockEpics,
state, state,
...@@ -192,7 +184,6 @@ describe('EpicsSelect', () => { ...@@ -192,7 +184,6 @@ describe('EpicsSelect', () => {
type: 'receiveEpicsFailure', type: 'receiveEpicsFailure',
}, },
], ],
done,
); );
}); });
...@@ -221,23 +212,22 @@ describe('EpicsSelect', () => { ...@@ -221,23 +212,22 @@ describe('EpicsSelect', () => {
}); });
describe('requestIssueUpdate', () => { describe('requestIssueUpdate', () => {
it('should set `state.epicSelectInProgress` to true', (done) => { it('should set `state.epicSelectInProgress` to true', async () => {
testAction( await testAction(
actions.requestIssueUpdate, actions.requestIssueUpdate,
{}, {},
state, state,
[{ type: types.REQUEST_ISSUE_UPDATE }], [{ type: types.REQUEST_ISSUE_UPDATE }],
[], [],
done,
); );
}); });
}); });
describe('receiveIssueUpdateSuccess', () => { describe('receiveIssueUpdateSuccess', () => {
it('should set updated selectedEpic with passed Epic instance to state when payload has matching Epic and Issue IDs', (done) => { it('should set updated selectedEpic with passed Epic instance to state when payload has matching Epic and Issue IDs', async () => {
state.issueId = mockIssue.id; state.issueId = mockIssue.id;
testAction( await testAction(
actions.receiveIssueUpdateSuccess, actions.receiveIssueUpdateSuccess,
{ {
data: mockAssignRemoveRes, data: mockAssignRemoveRes,
...@@ -254,14 +244,13 @@ describe('EpicsSelect', () => { ...@@ -254,14 +244,13 @@ describe('EpicsSelect', () => {
}, },
], ],
[], [],
done,
); );
}); });
it('should set updated selectedEpic with noneEpic to state when payload has matching Epic and Issue IDs and isRemoval param is true', (done) => { it('should set updated selectedEpic with noneEpic to state when payload has matching Epic and Issue IDs and isRemoval param is true', async () => {
state.issueId = mockIssue.id; state.issueId = mockIssue.id;
testAction( await testAction(
actions.receiveIssueUpdateSuccess, actions.receiveIssueUpdateSuccess,
{ {
data: mockAssignRemoveRes, data: mockAssignRemoveRes,
...@@ -279,12 +268,11 @@ describe('EpicsSelect', () => { ...@@ -279,12 +268,11 @@ describe('EpicsSelect', () => {
}, },
], ],
[], [],
done,
); );
}); });
it('should not do any mutation to the state whe payload does not have matching Epic and Issue IDs', (done) => { it('should not do any mutation to the state whe payload does not have matching Epic and Issue IDs', async () => {
testAction( await testAction(
actions.receiveIssueUpdateSuccess, actions.receiveIssueUpdateSuccess,
{ {
data: mockAssignRemoveRes, data: mockAssignRemoveRes,
...@@ -293,7 +281,6 @@ describe('EpicsSelect', () => { ...@@ -293,7 +281,6 @@ describe('EpicsSelect', () => {
state, state,
[], [],
[], [],
done,
); );
}); });
}); });
...@@ -311,14 +298,13 @@ describe('EpicsSelect', () => { ...@@ -311,14 +298,13 @@ describe('EpicsSelect', () => {
expect(createFlash).toHaveBeenCalledWith({ message }); expect(createFlash).toHaveBeenCalledWith({ message });
}); });
it('should set `state.epicSelectInProgress` to false', (done) => { it('should set `state.epicSelectInProgress` to false', async () => {
testAction( await testAction(
actions.receiveIssueUpdateFailure, actions.receiveIssueUpdateFailure,
{}, {},
state, state,
[{ type: types.RECEIVE_ISSUE_UPDATE_FAILURE }], [{ type: types.RECEIVE_ISSUE_UPDATE_FAILURE }],
[], [],
done,
); );
}); });
}); });
...@@ -328,14 +314,14 @@ describe('EpicsSelect', () => { ...@@ -328,14 +314,14 @@ describe('EpicsSelect', () => {
state.issueId = mockIssue.id; state.issueId = mockIssue.id;
}); });
it('should dispatch `requestIssueUpdate` & call `Api.addEpicIssue` and then dispatch `receiveIssueUpdateSuccess` on request success', (done) => { it('should dispatch `requestIssueUpdate` & call `Api.addEpicIssue` and then dispatch `receiveIssueUpdateSuccess` on request success', async () => {
jest.spyOn(Api, 'addEpicIssue').mockReturnValue( jest.spyOn(Api, 'addEpicIssue').mockReturnValue(
Promise.resolve({ Promise.resolve({
data: mockAssignRemoveRes, data: mockAssignRemoveRes,
}), }),
); );
testAction( await testAction(
actions.assignIssueToEpic, actions.assignIssueToEpic,
normalizedEpics[0], normalizedEpics[0],
state, state,
...@@ -349,14 +335,13 @@ describe('EpicsSelect', () => { ...@@ -349,14 +335,13 @@ describe('EpicsSelect', () => {
payload: { data: mockAssignRemoveRes, epic: normalizedEpics[0] }, payload: { data: mockAssignRemoveRes, epic: normalizedEpics[0] },
}, },
], ],
done,
); );
}); });
it('should dispatch `requestIssueUpdate` & call `Api.addEpicIssue` and then dispatch `receiveIssueUpdateFailure` on request failure', (done) => { it('should dispatch `requestIssueUpdate` & call `Api.addEpicIssue` and then dispatch `receiveIssueUpdateFailure` on request failure', async () => {
jest.spyOn(Api, 'addEpicIssue').mockReturnValue(Promise.reject()); jest.spyOn(Api, 'addEpicIssue').mockReturnValue(Promise.reject());
testAction( await testAction(
actions.assignIssueToEpic, actions.assignIssueToEpic,
normalizedEpics[0], normalizedEpics[0],
state, state,
...@@ -370,7 +355,6 @@ describe('EpicsSelect', () => { ...@@ -370,7 +355,6 @@ describe('EpicsSelect', () => {
payload: 'Something went wrong while assigning issue to epic.', payload: 'Something went wrong while assigning issue to epic.',
}, },
], ],
done,
); );
}); });
...@@ -402,14 +386,14 @@ describe('EpicsSelect', () => { ...@@ -402,14 +386,14 @@ describe('EpicsSelect', () => {
state.selectedEpicIssueId = mockIssue.epic_issue_id; state.selectedEpicIssueId = mockIssue.epic_issue_id;
}); });
it('should dispatch `requestIssueUpdate` & call `Api.removeEpicIssue` and then dispatch `receiveIssueUpdateSuccess` on request success', (done) => { it('should dispatch `requestIssueUpdate` & call `Api.removeEpicIssue` and then dispatch `receiveIssueUpdateSuccess` on request success', async () => {
jest.spyOn(Api, 'removeEpicIssue').mockReturnValue( jest.spyOn(Api, 'removeEpicIssue').mockReturnValue(
Promise.resolve({ Promise.resolve({
data: mockAssignRemoveRes, data: mockAssignRemoveRes,
}), }),
); );
testAction( await testAction(
actions.removeIssueFromEpic, actions.removeIssueFromEpic,
normalizedEpics[0], normalizedEpics[0],
state, state,
...@@ -423,14 +407,13 @@ describe('EpicsSelect', () => { ...@@ -423,14 +407,13 @@ describe('EpicsSelect', () => {
payload: { data: mockAssignRemoveRes, epic: normalizedEpics[0], isRemoval: true }, payload: { data: mockAssignRemoveRes, epic: normalizedEpics[0], isRemoval: true },
}, },
], ],
done,
); );
}); });
it('should dispatch `requestIssueUpdate` & call `Api.removeEpicIssue` and then dispatch `receiveIssueUpdateFailure` on request failure', (done) => { it('should dispatch `requestIssueUpdate` & call `Api.removeEpicIssue` and then dispatch `receiveIssueUpdateFailure` on request failure', async () => {
jest.spyOn(Api, 'removeEpicIssue').mockReturnValue(Promise.reject()); jest.spyOn(Api, 'removeEpicIssue').mockReturnValue(Promise.reject());
testAction( await testAction(
actions.removeIssueFromEpic, actions.removeIssueFromEpic,
normalizedEpics[0], normalizedEpics[0],
state, state,
...@@ -444,7 +427,6 @@ describe('EpicsSelect', () => { ...@@ -444,7 +427,6 @@ describe('EpicsSelect', () => {
payload: 'Something went wrong while removing issue from epic.', payload: 'Something went wrong while removing issue from epic.',
}, },
], ],
done,
); );
}); });
......
...@@ -46,7 +46,7 @@ describe('AddLicenseFormDropdown', () => { ...@@ -46,7 +46,7 @@ describe('AddLicenseFormDropdown', () => {
expect(vm.$el.value).toContain(value); expect(vm.$el.value).toContain(value);
}); });
it('shows all defined licenses', async (done) => { it('shows all defined licenses', async () => {
await createComponent(); await createComponent();
const element = $(vm.$el); const element = $(vm.$el);
...@@ -58,7 +58,6 @@ describe('AddLicenseFormDropdown', () => { ...@@ -58,7 +58,6 @@ describe('AddLicenseFormDropdown', () => {
options.each((index, optionEl) => { options.each((index, optionEl) => {
expect(KNOWN_LICENSES).toContain($(optionEl).text()); expect(KNOWN_LICENSES).toContain($(optionEl).text());
}); });
done();
}); });
element.select2('open'); element.select2('open');
......
...@@ -46,74 +46,64 @@ describe('License store actions', () => { ...@@ -46,74 +46,64 @@ describe('License store actions', () => {
}); });
describe('setAPISettings', () => { describe('setAPISettings', () => {
it('commits SET_API_SETTINGS', (done) => { it('commits SET_API_SETTINGS', async () => {
const payload = { apiUrlManageLicenses }; const payload = { apiUrlManageLicenses };
testAction( await testAction(
actions.setAPISettings, actions.setAPISettings,
payload, payload,
state, state,
[{ type: mutationTypes.SET_API_SETTINGS, payload }], [{ type: mutationTypes.SET_API_SETTINGS, payload }],
[], [],
) );
.then(done)
.catch(done.fail);
}); });
}); });
describe('setKnownLicenses', () => { describe('setKnownLicenses', () => {
it('commits SET_KNOWN_LICENSES', (done) => { it('commits SET_KNOWN_LICENSES', async () => {
const payload = [{ name: 'BSD' }, { name: 'Apache' }]; const payload = [{ name: 'BSD' }, { name: 'Apache' }];
testAction( await testAction(
actions.setKnownLicenses, actions.setKnownLicenses,
payload, payload,
state, state,
[{ type: mutationTypes.SET_KNOWN_LICENSES, payload }], [{ type: mutationTypes.SET_KNOWN_LICENSES, payload }],
[], [],
) );
.then(done)
.catch(done.fail);
}); });
}); });
describe('setLicenseInModal', () => { describe('setLicenseInModal', () => {
it('commits SET_LICENSE_IN_MODAL with license', (done) => { it('commits SET_LICENSE_IN_MODAL with license', async () => {
testAction( await testAction(
actions.setLicenseInModal, actions.setLicenseInModal,
allowedLicense, allowedLicense,
state, state,
[{ type: mutationTypes.SET_LICENSE_IN_MODAL, payload: allowedLicense }], [{ type: mutationTypes.SET_LICENSE_IN_MODAL, payload: allowedLicense }],
[], [],
) );
.then(done)
.catch(done.fail);
}); });
}); });
describe('setIsAdmin', () => { describe('setIsAdmin', () => {
it('commits SET_IS_ADMIN', (done) => { it('commits SET_IS_ADMIN', async () => {
testAction( await testAction(
actions.setIsAdmin, actions.setIsAdmin,
false, false,
state, state,
[{ type: mutationTypes.SET_IS_ADMIN, payload: false }], [{ type: mutationTypes.SET_IS_ADMIN, payload: false }],
[], [],
) );
.then(done)
.catch(done.fail);
}); });
}); });
describe('resetLicenseInModal', () => { describe('resetLicenseInModal', () => {
it('commits RESET_LICENSE_IN_MODAL', (done) => { it('commits RESET_LICENSE_IN_MODAL', async () => {
testAction( await testAction(
actions.resetLicenseInModal, actions.resetLicenseInModal,
null, null,
state, state,
[{ type: mutationTypes.RESET_LICENSE_IN_MODAL }], [{ type: mutationTypes.RESET_LICENSE_IN_MODAL }],
[], [],
) );
.then(done)
.catch(done.fail);
}); });
}); });
...@@ -129,16 +119,14 @@ describe('License store actions', () => { ...@@ -129,16 +119,14 @@ describe('License store actions', () => {
}); });
describe('receiveDeleteLicenseError', () => { describe('receiveDeleteLicenseError', () => {
it('commits RESET_LICENSE_IN_MODAL', (done) => { it('commits RESET_LICENSE_IN_MODAL', async () => {
testAction( await testAction(
actions.receiveDeleteLicenseError, actions.receiveDeleteLicenseError,
null, null,
state, state,
[{ type: mutationTypes.RESET_LICENSE_IN_MODAL }], [{ type: mutationTypes.RESET_LICENSE_IN_MODAL }],
[], [],
) );
.then(done)
.catch(done.fail);
}); });
}); });
...@@ -179,8 +167,8 @@ describe('License store actions', () => { ...@@ -179,8 +167,8 @@ describe('License store actions', () => {
describe('receiveSetLicenseApproval', () => { describe('receiveSetLicenseApproval', () => {
describe('given the licensesApiPath is provided', () => { describe('given the licensesApiPath is provided', () => {
it('commits RESET_LICENSE_IN_MODAL and dispatches licenseList/fetchLicenses and fetchParsedLicenseReport', (done) => { it('commits RESET_LICENSE_IN_MODAL and dispatches licenseList/fetchLicenses and fetchParsedLicenseReport', async () => {
testAction( await testAction(
actions.receiveSetLicenseApproval, actions.receiveSetLicenseApproval,
null, null,
{ ...state, licensesApiPath }, { ...state, licensesApiPath },
...@@ -189,9 +177,7 @@ describe('License store actions', () => { ...@@ -189,9 +177,7 @@ describe('License store actions', () => {
{ type: `licenseList/fetchLicenses`, payload: null }, { type: `licenseList/fetchLicenses`, payload: null },
{ type: 'fetchParsedLicenseReport' }, { type: 'fetchParsedLicenseReport' },
], ],
) );
.then(done)
.catch(done.fail);
}); });
}); });
...@@ -208,16 +194,14 @@ describe('License store actions', () => { ...@@ -208,16 +194,14 @@ describe('License store actions', () => {
}); });
describe('receiveSetLicenseApprovalError', () => { describe('receiveSetLicenseApprovalError', () => {
it('commits RESET_LICENSE_IN_MODAL', (done) => { it('commits RESET_LICENSE_IN_MODAL', async () => {
testAction( await testAction(
actions.receiveSetLicenseApprovalError, actions.receiveSetLicenseApprovalError,
null, null,
state, state,
[{ type: mutationTypes.RESET_LICENSE_IN_MODAL }], [{ type: mutationTypes.RESET_LICENSE_IN_MODAL }],
[], [],
) );
.then(done)
.catch(done.fail);
}); });
}); });
...@@ -310,116 +294,102 @@ describe('License store actions', () => { ...@@ -310,116 +294,102 @@ describe('License store actions', () => {
describe('allowLicense', () => { describe('allowLicense', () => {
const newStatus = LICENSE_APPROVAL_STATUS.ALLOWED; const newStatus = LICENSE_APPROVAL_STATUS.ALLOWED;
it('dispatches setLicenseApproval for un-allowed licenses', (done) => { it('dispatches setLicenseApproval for un-allowed licenses', async () => {
const license = { name: 'FOO' }; const license = { name: 'FOO' };
testAction( await testAction(
actions.allowLicense, actions.allowLicense,
license, license,
state, state,
[], [],
[{ type: 'setLicenseApproval', payload: { license, newStatus } }], [{ type: 'setLicenseApproval', payload: { license, newStatus } }],
) );
.then(done)
.catch(done.fail);
}); });
it('dispatches setLicenseApproval for denied licenses', (done) => { it('dispatches setLicenseApproval for denied licenses', async () => {
const license = deniedLicense; const license = deniedLicense;
testAction( await testAction(
actions.allowLicense, actions.allowLicense,
license, license,
state, state,
[], [],
[{ type: 'setLicenseApproval', payload: { license, newStatus } }], [{ type: 'setLicenseApproval', payload: { license, newStatus } }],
) );
.then(done)
.catch(done.fail);
}); });
it('does not dispatch setLicenseApproval for allowed licenses', (done) => { it('does not dispatch setLicenseApproval for allowed licenses', async () => {
testAction(actions.allowLicense, allowedLicense, state, [], []).then(done).catch(done.fail); await testAction(actions.allowLicense, allowedLicense, state, [], []);
}); });
}); });
describe('denyLicense', () => { describe('denyLicense', () => {
const newStatus = LICENSE_APPROVAL_STATUS.DENIED; const newStatus = LICENSE_APPROVAL_STATUS.DENIED;
it('dispatches setLicenseApproval for un-allowed licenses', (done) => { it('dispatches setLicenseApproval for un-allowed licenses', async () => {
const license = { name: 'FOO' }; const license = { name: 'FOO' };
testAction( await testAction(
actions.denyLicense, actions.denyLicense,
license, license,
state, state,
[], [],
[{ type: 'setLicenseApproval', payload: { license, newStatus } }], [{ type: 'setLicenseApproval', payload: { license, newStatus } }],
) );
.then(done)
.catch(done.fail);
}); });
it('dispatches setLicenseApproval for allowed licenses', (done) => { it('dispatches setLicenseApproval for allowed licenses', async () => {
const license = allowedLicense; const license = allowedLicense;
testAction( await testAction(
actions.denyLicense, actions.denyLicense,
license, license,
state, state,
[], [],
[{ type: 'setLicenseApproval', payload: { license, newStatus } }], [{ type: 'setLicenseApproval', payload: { license, newStatus } }],
) );
.then(done)
.catch(done.fail);
}); });
it('does not dispatch setLicenseApproval for denied licenses', (done) => { it('does not dispatch setLicenseApproval for denied licenses', async () => {
testAction(actions.denyLicense, deniedLicense, state, [], []).then(done).catch(done.fail); await testAction(actions.denyLicense, deniedLicense, state, [], []);
}); });
}); });
describe('requestManagedLicenses', () => { describe('requestManagedLicenses', () => {
it('commits REQUEST_MANAGED_LICENSES', (done) => { it('commits REQUEST_MANAGED_LICENSES', async () => {
testAction( await testAction(
actions.requestManagedLicenses, actions.requestManagedLicenses,
null, null,
state, state,
[{ type: mutationTypes.REQUEST_MANAGED_LICENSES }], [{ type: mutationTypes.REQUEST_MANAGED_LICENSES }],
[], [],
) );
.then(done)
.catch(done.fail);
}); });
}); });
describe('receiveManagedLicensesSuccess', () => { describe('receiveManagedLicensesSuccess', () => {
it('commits RECEIVE_MANAGED_LICENSES_SUCCESS', (done) => { it('commits RECEIVE_MANAGED_LICENSES_SUCCESS', async () => {
const payload = [allowedLicense]; const payload = [allowedLicense];
testAction( await testAction(
actions.receiveManagedLicensesSuccess, actions.receiveManagedLicensesSuccess,
payload, payload,
state, state,
[{ type: mutationTypes.RECEIVE_MANAGED_LICENSES_SUCCESS, payload }], [{ type: mutationTypes.RECEIVE_MANAGED_LICENSES_SUCCESS, payload }],
[], [],
) );
.then(done)
.catch(done.fail);
}); });
}); });
describe('receiveManagedLicensesError', () => { describe('receiveManagedLicensesError', () => {
it('commits RECEIVE_MANAGED_LICENSES_ERROR', (done) => { it('commits RECEIVE_MANAGED_LICENSES_ERROR', async () => {
const error = new Error('Test'); const error = new Error('Test');
testAction( await testAction(
actions.receiveManagedLicensesError, actions.receiveManagedLicensesError,
error, error,
state, state,
[{ type: mutationTypes.RECEIVE_MANAGED_LICENSES_ERROR }], [{ type: mutationTypes.RECEIVE_MANAGED_LICENSES_ERROR }],
[], [],
) );
.then(done)
.catch(done.fail);
}); });
}); });
...@@ -430,45 +400,41 @@ describe('License store actions', () => { ...@@ -430,45 +400,41 @@ describe('License store actions', () => {
endpointMock = axiosMock.onGet(apiUrlManageLicenses, { params: { per_page: 100 } }); endpointMock = axiosMock.onGet(apiUrlManageLicenses, { params: { per_page: 100 } });
}); });
it('dispatches requestManagedLicenses and receiveManagedLicensesSuccess for successful response', (done) => { it('dispatches requestManagedLicenses and receiveManagedLicensesSuccess for successful response', async () => {
const payload = [{ name: 'foo', approval_status: LICENSE_APPROVAL_STATUS.DENIED }]; const payload = [{ name: 'foo', approval_status: LICENSE_APPROVAL_STATUS.DENIED }];
endpointMock.replyOnce(() => [200, payload]); endpointMock.replyOnce(() => [200, payload]);
testAction( await testAction(
actions.fetchManagedLicenses, actions.fetchManagedLicenses,
null, null,
state, state,
[], [],
[{ type: 'requestManagedLicenses' }, { type: 'receiveManagedLicensesSuccess', payload }], [{ type: 'requestManagedLicenses' }, { type: 'receiveManagedLicensesSuccess', payload }],
) );
.then(done)
.catch(done.fail);
}); });
it('dispatches requestManagedLicenses and receiveManagedLicensesError for error response', (done) => { it('dispatches requestManagedLicenses and receiveManagedLicensesError for error response', async () => {
endpointMock.replyOnce(() => [500, '']); endpointMock.replyOnce(() => [500, '']);
testAction( await testAction(
actions.fetchManagedLicenses, actions.fetchManagedLicenses,
null, null,
state, state,
[], [],
[{ type: 'requestManagedLicenses' }, { type: 'receiveManagedLicensesError' }], [{ type: 'requestManagedLicenses' }, { type: 'receiveManagedLicensesError' }],
) );
.then(done)
.catch(done.fail);
}); });
}); });
describe('fetchLicenseCheckApprovalRule ', () => { describe('fetchLicenseCheckApprovalRule ', () => {
it('dispatches request/receive with detected approval rule', (done) => { it('dispatches request/receive with detected approval rule', async () => {
const APPROVAL_RULE_RESPONSE = { const APPROVAL_RULE_RESPONSE = {
approval_rules_left: [{ name: LICENSE_CHECK_NAME }], approval_rules_left: [{ name: LICENSE_CHECK_NAME }],
}; };
axiosMock.onGet(approvalsApiPath).replyOnce(200, APPROVAL_RULE_RESPONSE); axiosMock.onGet(approvalsApiPath).replyOnce(200, APPROVAL_RULE_RESPONSE);
testAction( await testAction(
actions.fetchLicenseCheckApprovalRule, actions.fetchLicenseCheckApprovalRule,
null, null,
state, state,
...@@ -480,18 +446,17 @@ describe('License store actions', () => { ...@@ -480,18 +446,17 @@ describe('License store actions', () => {
payload: { hasLicenseCheckApprovalRule: true }, payload: { hasLicenseCheckApprovalRule: true },
}, },
], ],
done,
); );
}); });
it('dispatches request/receive without detected approval rule', (done) => { it('dispatches request/receive without detected approval rule', async () => {
const APPROVAL_RULE_RESPONSE = { const APPROVAL_RULE_RESPONSE = {
approval_rules_left: [{ name: 'Another Approval Rule' }], approval_rules_left: [{ name: 'Another Approval Rule' }],
}; };
axiosMock.onGet(approvalsApiPath).replyOnce(200, APPROVAL_RULE_RESPONSE); axiosMock.onGet(approvalsApiPath).replyOnce(200, APPROVAL_RULE_RESPONSE);
testAction( await testAction(
actions.fetchLicenseCheckApprovalRule, actions.fetchLicenseCheckApprovalRule,
null, null,
state, state,
...@@ -503,15 +468,14 @@ describe('License store actions', () => { ...@@ -503,15 +468,14 @@ describe('License store actions', () => {
payload: { hasLicenseCheckApprovalRule: false }, payload: { hasLicenseCheckApprovalRule: false },
}, },
], ],
done,
); );
}); });
it('dispatches request/receive error when no approvalsAPiPath is provided', (done) => { it('dispatches request/receive error when no approvalsAPiPath is provided', async () => {
const error = new Error('approvalsApiPath not provided'); const error = new Error('approvalsApiPath not provided');
axiosMock.onGet(approvalsApiPath).replyOnce(500); axiosMock.onGet(approvalsApiPath).replyOnce(500);
testAction( await testAction(
actions.fetchLicenseCheckApprovalRule, actions.fetchLicenseCheckApprovalRule,
null, null,
{ ...state, approvalsApiPath: '' }, { ...state, approvalsApiPath: '' },
...@@ -520,15 +484,14 @@ describe('License store actions', () => { ...@@ -520,15 +484,14 @@ describe('License store actions', () => {
{ type: 'requestLicenseCheckApprovalRule' }, { type: 'requestLicenseCheckApprovalRule' },
{ type: 'receiveLicenseCheckApprovalRuleError', payload: error }, { type: 'receiveLicenseCheckApprovalRuleError', payload: error },
], ],
done,
); );
}); });
it('dispatches request/receive on error', (done) => { it('dispatches request/receive on error', async () => {
const error = new Error('Request failed with status code 500'); const error = new Error('Request failed with status code 500');
axiosMock.onGet(approvalsApiPath).replyOnce(500); axiosMock.onGet(approvalsApiPath).replyOnce(500);
testAction( await testAction(
actions.fetchLicenseCheckApprovalRule, actions.fetchLicenseCheckApprovalRule,
null, null,
state, state,
...@@ -537,30 +500,27 @@ describe('License store actions', () => { ...@@ -537,30 +500,27 @@ describe('License store actions', () => {
{ type: 'requestLicenseCheckApprovalRule' }, { type: 'requestLicenseCheckApprovalRule' },
{ type: 'receiveLicenseCheckApprovalRuleError', payload: error }, { type: 'receiveLicenseCheckApprovalRuleError', payload: error },
], ],
done,
); );
}); });
}); });
describe('requestLicenseCheckApprovalRule', () => { describe('requestLicenseCheckApprovalRule', () => {
it('commits REQUEST_LICENSE_CHECK_APPROVAL_RULE', (done) => { it('commits REQUEST_LICENSE_CHECK_APPROVAL_RULE', async () => {
testAction( await testAction(
actions.requestLicenseCheckApprovalRule, actions.requestLicenseCheckApprovalRule,
null, null,
state, state,
[{ type: mutationTypes.REQUEST_LICENSE_CHECK_APPROVAL_RULE }], [{ type: mutationTypes.REQUEST_LICENSE_CHECK_APPROVAL_RULE }],
[], [],
) );
.then(done)
.catch(done.fail);
}); });
}); });
describe('receiveLicenseCheckApprovalRuleSuccess', () => { describe('receiveLicenseCheckApprovalRuleSuccess', () => {
it('commits REQUEST_LICENSE_CHECK_APPROVAL_RULE', (done) => { it('commits REQUEST_LICENSE_CHECK_APPROVAL_RULE', async () => {
const hasLicenseCheckApprovalRule = true; const hasLicenseCheckApprovalRule = true;
testAction( await testAction(
actions.receiveLicenseCheckApprovalRuleSuccess, actions.receiveLicenseCheckApprovalRuleSuccess,
{ hasLicenseCheckApprovalRule }, { hasLicenseCheckApprovalRule },
state, state,
...@@ -571,71 +531,61 @@ describe('License store actions', () => { ...@@ -571,71 +531,61 @@ describe('License store actions', () => {
}, },
], ],
[], [],
) );
.then(done)
.catch(done.fail);
}); });
}); });
describe('receiveLicenseCheckApprovalRuleError', () => { describe('receiveLicenseCheckApprovalRuleError', () => {
it('commits RECEIVE_LICENSE_CHECK_APPROVAL_RULE_ERROR', (done) => { it('commits RECEIVE_LICENSE_CHECK_APPROVAL_RULE_ERROR', async () => {
const error = new Error('Error'); const error = new Error('Error');
testAction( await testAction(
actions.receiveLicenseCheckApprovalRuleError, actions.receiveLicenseCheckApprovalRuleError,
error, error,
state, state,
[{ type: mutationTypes.RECEIVE_LICENSE_CHECK_APPROVAL_RULE_ERROR, payload: error }], [{ type: mutationTypes.RECEIVE_LICENSE_CHECK_APPROVAL_RULE_ERROR, payload: error }],
[], [],
) );
.then(done)
.catch(done.fail);
}); });
}); });
describe('requestParsedLicenseReport', () => { describe('requestParsedLicenseReport', () => {
it(`should commit ${mutationTypes.REQUEST_PARSED_LICENSE_REPORT}`, (done) => { it(`should commit ${mutationTypes.REQUEST_PARSED_LICENSE_REPORT}`, async () => {
testAction( await testAction(
actions.requestParsedLicenseReport, actions.requestParsedLicenseReport,
null, null,
state, state,
[{ type: mutationTypes.REQUEST_PARSED_LICENSE_REPORT }], [{ type: mutationTypes.REQUEST_PARSED_LICENSE_REPORT }],
[], [],
) );
.then(done)
.catch(done.fail);
}); });
}); });
describe('receiveParsedLicenseReportSuccess', () => { describe('receiveParsedLicenseReportSuccess', () => {
it(`should commit ${mutationTypes.RECEIVE_PARSED_LICENSE_REPORT_SUCCESS} with the correct payload`, (done) => { it(`should commit ${mutationTypes.RECEIVE_PARSED_LICENSE_REPORT_SUCCESS} with the correct payload`, async () => {
const payload = { newLicenses: [{ name: 'foo' }] }; const payload = { newLicenses: [{ name: 'foo' }] };
testAction( await testAction(
actions.receiveParsedLicenseReportSuccess, actions.receiveParsedLicenseReportSuccess,
payload, payload,
state, state,
[{ type: mutationTypes.RECEIVE_PARSED_LICENSE_REPORT_SUCCESS, payload }], [{ type: mutationTypes.RECEIVE_PARSED_LICENSE_REPORT_SUCCESS, payload }],
[], [],
) );
.then(done)
.catch(done.fail);
}); });
}); });
describe('receiveParsedLicenseReportError', () => { describe('receiveParsedLicenseReportError', () => {
it(`should commit ${mutationTypes.RECEIVE_PARSED_LICENSE_REPORT_ERROR}`, (done) => { it(`should commit ${mutationTypes.RECEIVE_PARSED_LICENSE_REPORT_ERROR}`, async () => {
const payload = new Error('Test'); const payload = new Error('Test');
testAction( await testAction(
actions.receiveParsedLicenseReportError, actions.receiveParsedLicenseReportError,
payload, payload,
state, state,
[{ type: mutationTypes.RECEIVE_PARSED_LICENSE_REPORT_ERROR, payload }], [{ type: mutationTypes.RECEIVE_PARSED_LICENSE_REPORT_ERROR, payload }],
[], [],
) );
.then(done)
.catch(done.fail);
}); });
}); });
...@@ -664,7 +614,7 @@ describe('License store actions', () => { ...@@ -664,7 +614,7 @@ describe('License store actions', () => {
]; ];
}); });
it('should fetch, parse, and dispatch the new licenses on a successful request', (done) => { it('should fetch, parse, and dispatch the new licenses on a successful request', async () => {
licensesApiMock.replyOnce(() => [200, rawLicenseReport]); licensesApiMock.replyOnce(() => [200, rawLicenseReport]);
const parsedLicenses = { const parsedLicenses = {
...@@ -680,7 +630,7 @@ describe('License store actions', () => { ...@@ -680,7 +630,7 @@ describe('License store actions', () => {
], ],
}; };
testAction( await testAction(
actions.fetchParsedLicenseReport, actions.fetchParsedLicenseReport,
null, null,
state, state,
...@@ -689,15 +639,13 @@ describe('License store actions', () => { ...@@ -689,15 +639,13 @@ describe('License store actions', () => {
{ type: 'requestParsedLicenseReport' }, { type: 'requestParsedLicenseReport' },
{ type: 'receiveParsedLicenseReportSuccess', payload: parsedLicenses }, { type: 'receiveParsedLicenseReportSuccess', payload: parsedLicenses },
], ],
) );
.then(done)
.catch(done.fail);
}); });
it('should send an error on an unsuccesful request', (done) => { it('should send an error on an unsuccesful request', async () => {
licensesApiMock.replyOnce(400); licensesApiMock.replyOnce(400);
testAction( await testAction(
actions.fetchParsedLicenseReport, actions.fetchParsedLicenseReport,
null, null,
state, state,
...@@ -706,9 +654,7 @@ describe('License store actions', () => { ...@@ -706,9 +654,7 @@ describe('License store actions', () => {
{ type: 'requestParsedLicenseReport' }, { type: 'requestParsedLicenseReport' },
{ type: 'receiveParsedLicenseReportError', payload: expect.any(Error) }, { type: 'receiveParsedLicenseReportError', payload: expect.any(Error) },
], ],
) );
.then(done)
.catch(done.fail);
}); });
}); });
...@@ -752,7 +698,7 @@ describe('License store actions', () => { ...@@ -752,7 +698,7 @@ describe('License store actions', () => {
}; };
}); });
it('should fetch, parse, and dispatch the new licenses on a successful request', (done) => { it('should fetch, parse, and dispatch the new licenses on a successful request', async () => {
licensesApiMock.replyOnce(() => [200, rawLicenseReport]); licensesApiMock.replyOnce(() => [200, rawLicenseReport]);
const parsedLicenses = { const parsedLicenses = {
...@@ -783,7 +729,7 @@ describe('License store actions', () => { ...@@ -783,7 +729,7 @@ describe('License store actions', () => {
], ],
}; };
testAction( await testAction(
actions.fetchParsedLicenseReport, actions.fetchParsedLicenseReport,
null, null,
state, state,
...@@ -792,9 +738,7 @@ describe('License store actions', () => { ...@@ -792,9 +738,7 @@ describe('License store actions', () => {
{ type: 'requestParsedLicenseReport' }, { type: 'requestParsedLicenseReport' },
{ type: 'receiveParsedLicenseReportSuccess', payload: parsedLicenses }, { type: 'receiveParsedLicenseReportSuccess', payload: parsedLicenses },
], ],
) );
.then(done)
.catch(done.fail);
}); });
}); });
}); });
......
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { import * as securityReportsAction from 'ee/vue_shared/security_reports/store/actions';
setHeadBlobPath,
setBaseBlobPath,
setCanReadVulnerabilityFeedback,
setVulnerabilityFeedbackPath,
setPipelineId,
requestContainerScanningDiff,
requestDastDiff,
requestDependencyScanningDiff,
requestCoverageFuzzingDiff,
setModalData,
requestDismissVulnerability,
receiveDismissVulnerability,
receiveDismissVulnerabilityError,
dismissVulnerability,
revertDismissVulnerability,
requestCreateIssue,
receiveCreateIssue,
receiveCreateIssueError,
createNewIssue,
downloadPatch,
requestCreateMergeRequest,
receiveCreateMergeRequestSuccess,
receiveCreateMergeRequestError,
createMergeRequest,
updateDependencyScanningIssue,
updateContainerScanningIssue,
updateDastIssue,
updateCoverageFuzzingIssue,
addDismissalComment,
receiveAddDismissalCommentError,
receiveAddDismissalCommentSuccess,
requestAddDismissalComment,
deleteDismissalComment,
receiveDeleteDismissalCommentError,
receiveDeleteDismissalCommentSuccess,
requestDeleteDismissalComment,
showDismissalDeleteButtons,
hideDismissalDeleteButtons,
setContainerScanningDiffEndpoint,
receiveContainerScanningDiffSuccess,
receiveContainerScanningDiffError,
fetchContainerScanningDiff,
setDependencyScanningDiffEndpoint,
receiveDependencyScanningDiffSuccess,
receiveDependencyScanningDiffError,
fetchDependencyScanningDiff,
setDastDiffEndpoint,
receiveDastDiffSuccess,
receiveDastDiffError,
fetchDastDiff,
setCoverageFuzzingDiffEndpoint,
receiveCoverageFuzzingDiffSuccess,
receiveCoverageFuzzingDiffError,
fetchCoverageFuzzingDiff,
} from 'ee/vue_shared/security_reports/store/actions';
import * as types from 'ee/vue_shared/security_reports/store/mutation_types'; import * as types from 'ee/vue_shared/security_reports/store/mutation_types';
import state from 'ee/vue_shared/security_reports/store/state'; import state from 'ee/vue_shared/security_reports/store/state';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
...@@ -115,9 +60,9 @@ describe('security reports actions', () => { ...@@ -115,9 +60,9 @@ describe('security reports actions', () => {
}); });
describe('setHeadBlobPath', () => { describe('setHeadBlobPath', () => {
it('should commit set head blob path', (done) => { it('should commit set head blob path', async () => {
testAction( await testAction(
setHeadBlobPath, securityReportsAction.setHeadBlobPath,
'path', 'path',
mockedState, mockedState,
[ [
...@@ -127,15 +72,14 @@ describe('security reports actions', () => { ...@@ -127,15 +72,14 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('setBaseBlobPath', () => { describe('setBaseBlobPath', () => {
it('should commit set head blob path', (done) => { it('should commit set head blob path', async () => {
testAction( await testAction(
setBaseBlobPath, securityReportsAction.setBaseBlobPath,
'path', 'path',
mockedState, mockedState,
[ [
...@@ -145,15 +89,14 @@ describe('security reports actions', () => { ...@@ -145,15 +89,14 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('setCanReadVulnerabilityFeedback', () => { describe('setCanReadVulnerabilityFeedback', () => {
it('should commit set vulnerabulity feedback path', (done) => { it('should commit set vulnerabulity feedback path', async () => {
testAction( await testAction(
setCanReadVulnerabilityFeedback, securityReportsAction.setCanReadVulnerabilityFeedback,
true, true,
mockedState, mockedState,
[ [
...@@ -163,15 +106,14 @@ describe('security reports actions', () => { ...@@ -163,15 +106,14 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('setVulnerabilityFeedbackPath', () => { describe('setVulnerabilityFeedbackPath', () => {
it('should commit set vulnerabulity feedback path', (done) => { it('should commit set vulnerabulity feedback path', async () => {
testAction( await testAction(
setVulnerabilityFeedbackPath, securityReportsAction.setVulnerabilityFeedbackPath,
'path', 'path',
mockedState, mockedState,
[ [
...@@ -181,15 +123,14 @@ describe('security reports actions', () => { ...@@ -181,15 +123,14 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('setPipelineId', () => { describe('setPipelineId', () => {
it('should commit set vulnerability feedback path', (done) => { it('should commit set vulnerability feedback path', async () => {
testAction( await testAction(
setPipelineId, securityReportsAction.setPipelineId,
123, 123,
mockedState, mockedState,
[ [
...@@ -199,15 +140,14 @@ describe('security reports actions', () => { ...@@ -199,15 +140,14 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('requestContainerScanningDiff', () => { describe('requestContainerScanningDiff', () => {
it('should commit request mutation', (done) => { it('should commit request mutation', async () => {
testAction( await testAction(
requestContainerScanningDiff, securityReportsAction.requestContainerScanningDiff,
null, null,
mockedState, mockedState,
[ [
...@@ -216,15 +156,14 @@ describe('security reports actions', () => { ...@@ -216,15 +156,14 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('requestDastDiff', () => { describe('requestDastDiff', () => {
it('should commit request mutation', (done) => { it('should commit request mutation', async () => {
testAction( await testAction(
requestDastDiff, securityReportsAction.requestDastDiff,
null, null,
mockedState, mockedState,
[ [
...@@ -233,15 +172,14 @@ describe('security reports actions', () => { ...@@ -233,15 +172,14 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('requestDependencyScanningDiff', () => { describe('requestDependencyScanningDiff', () => {
it('should commit request mutation', (done) => { it('should commit request mutation', async () => {
testAction( await testAction(
requestDependencyScanningDiff, securityReportsAction.requestDependencyScanningDiff,
null, null,
mockedState, mockedState,
[ [
...@@ -250,15 +188,14 @@ describe('security reports actions', () => { ...@@ -250,15 +188,14 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('requestCoverageFuzzingDiff', () => { describe('requestCoverageFuzzingDiff', () => {
it('should commit request mutation', (done) => { it('should commit request mutation', async () => {
testAction( await testAction(
requestCoverageFuzzingDiff, securityReportsAction.requestCoverageFuzzingDiff,
null, null,
mockedState, mockedState,
[ [
...@@ -267,15 +204,14 @@ describe('security reports actions', () => { ...@@ -267,15 +204,14 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('setModalData', () => { describe('setModalData', () => {
it('commits set issue modal data', (done) => { it('commits set issue modal data', async () => {
testAction( await testAction(
setModalData, securityReportsAction.setModalData,
{ issue: { id: 1 }, status: 'success' }, { issue: { id: 1 }, status: 'success' },
mockedState, mockedState,
[ [
...@@ -285,15 +221,14 @@ describe('security reports actions', () => { ...@@ -285,15 +221,14 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('requestDismissVulnerability', () => { describe('requestDismissVulnerability', () => {
it('commits request dismiss issue', (done) => { it('commits request dismiss issue', async () => {
testAction( await testAction(
requestDismissVulnerability, securityReportsAction.requestDismissVulnerability,
null, null,
mockedState, mockedState,
[ [
...@@ -302,17 +237,16 @@ describe('security reports actions', () => { ...@@ -302,17 +237,16 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveDismissVulnerability', () => { describe('receiveDismissVulnerability', () => {
it(`should pass the payload to the ${types.RECEIVE_DISMISS_VULNERABILITY_SUCCESS} mutation`, (done) => { it(`should pass the payload to the ${types.RECEIVE_DISMISS_VULNERABILITY_SUCCESS} mutation`, async () => {
const payload = createDismissedVulnerability(); const payload = createDismissedVulnerability();
testAction( await testAction(
receiveDismissVulnerability, securityReportsAction.receiveDismissVulnerability,
payload, payload,
mockedState, mockedState,
[ [
...@@ -322,15 +256,14 @@ describe('security reports actions', () => { ...@@ -322,15 +256,14 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveDismissVulnerabilityError', () => { describe('receiveDismissVulnerabilityError', () => {
it('commits receive dismiss issue error with payload', (done) => { it('commits receive dismiss issue error with payload', async () => {
testAction( await testAction(
receiveDismissVulnerabilityError, securityReportsAction.receiveDismissVulnerabilityError,
'error', 'error',
mockedState, mockedState,
[ [
...@@ -340,7 +273,6 @@ describe('security reports actions', () => { ...@@ -340,7 +273,6 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -362,9 +294,9 @@ describe('security reports actions', () => { ...@@ -362,9 +294,9 @@ describe('security reports actions', () => {
mockedState.createVulnerabilityFeedbackDismissalPath = 'dismiss_vulnerability_path'; mockedState.createVulnerabilityFeedbackDismissalPath = 'dismiss_vulnerability_path';
}); });
it(`should dispatch receiveDismissVulnerability`, (done) => { it(`should dispatch receiveDismissVulnerability`, async () => {
testAction( await testAction(
dismissVulnerability, securityReportsAction.dismissVulnerability,
payload, payload,
mockedState, mockedState,
[], [],
...@@ -380,18 +312,12 @@ describe('security reports actions', () => { ...@@ -380,18 +312,12 @@ describe('security reports actions', () => {
payload, payload,
}, },
], ],
done,
); );
}); });
it('show dismiss vulnerability toast message', (done) => { it('show dismiss vulnerability toast message', async () => {
const checkToastMessage = () => { await testAction(
expect(toasted).toHaveBeenCalledTimes(1); securityReportsAction.dismissVulnerability,
done();
};
testAction(
dismissVulnerability,
payload, payload,
mockedState, mockedState,
[], [],
...@@ -407,8 +333,9 @@ describe('security reports actions', () => { ...@@ -407,8 +333,9 @@ describe('security reports actions', () => {
payload, payload,
}, },
], ],
checkToastMessage,
); );
expect(toasted).toHaveBeenCalledTimes(1);
}); });
}); });
...@@ -422,13 +349,13 @@ describe('security reports actions', () => { ...@@ -422,13 +349,13 @@ describe('security reports actions', () => {
mockedState.canReadVulnerabilityFeedback = true; mockedState.canReadVulnerabilityFeedback = true;
}); });
it('should dispatch `receiveDismissVulnerabilityError` with the correct payload', (done) => { it('should dispatch `receiveDismissVulnerabilityError` with the correct payload', async () => {
mock mock
.onPost(mockedState.createVulnerabilityFeedbackDismissalPath) .onPost(mockedState.createVulnerabilityFeedbackDismissalPath)
.replyOnce(httpStatusErrorCode); .replyOnce(httpStatusErrorCode);
testAction( await testAction(
dismissVulnerability, securityReportsAction.dismissVulnerability,
null, null,
mockedState, mockedState,
[], [],
...@@ -441,7 +368,6 @@ describe('security reports actions', () => { ...@@ -441,7 +368,6 @@ describe('security reports actions', () => {
payload: expectedErrorMessage, payload: expectedErrorMessage,
}, },
], ],
done,
); );
}); });
}); });
...@@ -462,9 +388,9 @@ describe('security reports actions', () => { ...@@ -462,9 +388,9 @@ describe('security reports actions', () => {
mock.onPatch(url).replyOnce(200, data); mock.onPatch(url).replyOnce(200, data);
}); });
it('should dispatch the request and success actions', (done) => { it('should dispatch the request and success actions', async () => {
testAction( await testAction(
addDismissalComment, securityReportsAction.addDismissalComment,
{ comment }, { comment },
{ modal: { vulnerability } }, { modal: { vulnerability } },
[], [],
...@@ -476,18 +402,12 @@ describe('security reports actions', () => { ...@@ -476,18 +402,12 @@ describe('security reports actions', () => {
payload: { data }, payload: { data },
}, },
], ],
done,
); );
}); });
it('should show added dismissal comment toast message', (done) => { it('should show added dismissal comment toast message', async () => {
const checkToastMessage = () => { await testAction(
expect(toasted).toHaveBeenCalledTimes(1); securityReportsAction.addDismissalComment,
done();
};
testAction(
addDismissalComment,
{ comment }, { comment },
{ modal: { vulnerability } }, { modal: { vulnerability } },
[], [],
...@@ -499,8 +419,9 @@ describe('security reports actions', () => { ...@@ -499,8 +419,9 @@ describe('security reports actions', () => {
payload: { data }, payload: { data },
}, },
], ],
checkToastMessage,
); );
expect(toasted).toHaveBeenCalledTimes(1);
}); });
}); });
...@@ -509,9 +430,9 @@ describe('security reports actions', () => { ...@@ -509,9 +430,9 @@ describe('security reports actions', () => {
mock.onPatch(url).replyOnce(404); mock.onPatch(url).replyOnce(404);
}); });
it('should dispatch the request and error actions', (done) => { it('should dispatch the request and error actions', async () => {
testAction( await testAction(
addDismissalComment, securityReportsAction.addDismissalComment,
{ comment }, { comment },
{ modal: { vulnerability } }, { modal: { vulnerability } },
[], [],
...@@ -522,28 +443,26 @@ describe('security reports actions', () => { ...@@ -522,28 +443,26 @@ describe('security reports actions', () => {
payload: 'There was an error adding the comment.', payload: 'There was an error adding the comment.',
}, },
], ],
done,
); );
}); });
}); });
describe('receiveAddDismissalCommentSuccess', () => { describe('receiveAddDismissalCommentSuccess', () => {
it('should commit the success mutation', (done) => { it('should commit the success mutation', async () => {
testAction( await testAction(
receiveAddDismissalCommentSuccess, securityReportsAction.receiveAddDismissalCommentSuccess,
{ data }, { data },
state, state,
[{ type: types.RECEIVE_ADD_DISMISSAL_COMMENT_SUCCESS, payload: { data } }], [{ type: types.RECEIVE_ADD_DISMISSAL_COMMENT_SUCCESS, payload: { data } }],
[], [],
done,
); );
}); });
}); });
describe('receiveAddDismissalCommentError', () => { describe('receiveAddDismissalCommentError', () => {
it('should commit the error mutation', (done) => { it('should commit the error mutation', async () => {
testAction( await testAction(
receiveAddDismissalCommentError, securityReportsAction.receiveAddDismissalCommentError,
{}, {},
state, state,
[ [
...@@ -553,20 +472,18 @@ describe('security reports actions', () => { ...@@ -553,20 +472,18 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('requestAddDismissalComment', () => { describe('requestAddDismissalComment', () => {
it('should commit the request mutation', (done) => { it('should commit the request mutation', async () => {
testAction( await testAction(
requestAddDismissalComment, securityReportsAction.requestAddDismissalComment,
{}, {},
state, state,
[{ type: types.REQUEST_ADD_DISMISSAL_COMMENT }], [{ type: types.REQUEST_ADD_DISMISSAL_COMMENT }],
[], [],
done,
); );
}); });
}); });
...@@ -587,9 +504,9 @@ describe('security reports actions', () => { ...@@ -587,9 +504,9 @@ describe('security reports actions', () => {
mock.onPatch(url).replyOnce(200, data); mock.onPatch(url).replyOnce(200, data);
}); });
it('should dispatch the request and success actions', (done) => { it('should dispatch the request and success actions', async () => {
testAction( await testAction(
deleteDismissalComment, securityReportsAction.deleteDismissalComment,
{ comment }, { comment },
{ modal: { vulnerability } }, { modal: { vulnerability } },
[], [],
...@@ -601,18 +518,12 @@ describe('security reports actions', () => { ...@@ -601,18 +518,12 @@ describe('security reports actions', () => {
payload: { data }, payload: { data },
}, },
], ],
done,
); );
}); });
it('should show deleted dismissal comment toast message', (done) => { it('should show deleted dismissal comment toast message', async () => {
const checkToastMessage = () => { await testAction(
expect(toasted).toHaveBeenCalledTimes(1); securityReportsAction.deleteDismissalComment,
done();
};
testAction(
deleteDismissalComment,
{ comment }, { comment },
{ modal: { vulnerability } }, { modal: { vulnerability } },
[], [],
...@@ -624,8 +535,9 @@ describe('security reports actions', () => { ...@@ -624,8 +535,9 @@ describe('security reports actions', () => {
payload: { data }, payload: { data },
}, },
], ],
checkToastMessage,
); );
expect(toasted).toHaveBeenCalledTimes(1);
}); });
}); });
...@@ -634,9 +546,9 @@ describe('security reports actions', () => { ...@@ -634,9 +546,9 @@ describe('security reports actions', () => {
mock.onPatch(url).replyOnce(404); mock.onPatch(url).replyOnce(404);
}); });
it('should dispatch the request and error actions', (done) => { it('should dispatch the request and error actions', async () => {
testAction( await testAction(
deleteDismissalComment, securityReportsAction.deleteDismissalComment,
{ comment }, { comment },
{ modal: { vulnerability } }, { modal: { vulnerability } },
[], [],
...@@ -647,28 +559,26 @@ describe('security reports actions', () => { ...@@ -647,28 +559,26 @@ describe('security reports actions', () => {
payload: 'There was an error deleting the comment.', payload: 'There was an error deleting the comment.',
}, },
], ],
done,
); );
}); });
}); });
describe('receiveDeleteDismissalCommentSuccess', () => { describe('receiveDeleteDismissalCommentSuccess', () => {
it('should commit the success mutation', (done) => { it('should commit the success mutation', async () => {
testAction( await testAction(
receiveDeleteDismissalCommentSuccess, securityReportsAction.receiveDeleteDismissalCommentSuccess,
{ data }, { data },
state, state,
[{ type: types.RECEIVE_DELETE_DISMISSAL_COMMENT_SUCCESS, payload: { data } }], [{ type: types.RECEIVE_DELETE_DISMISSAL_COMMENT_SUCCESS, payload: { data } }],
[], [],
done,
); );
}); });
}); });
describe('receiveDeleteDismissalCommentError', () => { describe('receiveDeleteDismissalCommentError', () => {
it('should commit the error mutation', (done) => { it('should commit the error mutation', async () => {
testAction( await testAction(
receiveDeleteDismissalCommentError, securityReportsAction.receiveDeleteDismissalCommentError,
{}, {},
state, state,
[ [
...@@ -678,29 +588,27 @@ describe('security reports actions', () => { ...@@ -678,29 +588,27 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('requestDeleteDismissalComment', () => { describe('requestDeleteDismissalComment', () => {
it('should commit the request mutation', (done) => { it('should commit the request mutation', async () => {
testAction( await testAction(
requestDeleteDismissalComment, securityReportsAction.requestDeleteDismissalComment,
{}, {},
state, state,
[{ type: types.REQUEST_DELETE_DISMISSAL_COMMENT }], [{ type: types.REQUEST_DELETE_DISMISSAL_COMMENT }],
[], [],
done,
); );
}); });
}); });
}); });
describe('showDismissalDeleteButtons', () => { describe('showDismissalDeleteButtons', () => {
it('commits show dismissal delete buttons', (done) => { it('commits show dismissal delete buttons', async () => {
testAction( await testAction(
showDismissalDeleteButtons, securityReportsAction.showDismissalDeleteButtons,
null, null,
mockedState, mockedState,
[ [
...@@ -709,15 +617,14 @@ describe('security reports actions', () => { ...@@ -709,15 +617,14 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('hideDismissalDeleteButtons', () => { describe('hideDismissalDeleteButtons', () => {
it('commits hide dismissal delete buttons', (done) => { it('commits hide dismissal delete buttons', async () => {
testAction( await testAction(
hideDismissalDeleteButtons, securityReportsAction.hideDismissalDeleteButtons,
null, null,
mockedState, mockedState,
[ [
...@@ -726,7 +633,6 @@ describe('security reports actions', () => { ...@@ -726,7 +633,6 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -744,9 +650,9 @@ describe('security reports actions', () => { ...@@ -744,9 +650,9 @@ describe('security reports actions', () => {
payload = createNonDismissedVulnerability({ ...mockedState.modal.vulnerability }); payload = createNonDismissedVulnerability({ ...mockedState.modal.vulnerability });
}); });
it('should dispatch `receiveDismissVulnerability`', (done) => { it('should dispatch `receiveDismissVulnerability`', async () => {
testAction( await testAction(
revertDismissVulnerability, securityReportsAction.revertDismissVulnerability,
payload, payload,
mockedState, mockedState,
[], [],
...@@ -759,18 +665,17 @@ describe('security reports actions', () => { ...@@ -759,18 +665,17 @@ describe('security reports actions', () => {
payload, payload,
}, },
], ],
done,
); );
}); });
}); });
it('with error should dispatch `receiveDismissVulnerabilityError`', (done) => { it('with error should dispatch `receiveDismissVulnerabilityError`', async () => {
mock.onDelete('dismiss_vulnerability_path/123').reply(500, {}); mock.onDelete('dismiss_vulnerability_path/123').reply(500, {});
mockedState.modal.vulnerability.dismissalFeedback = { id: 123 }; mockedState.modal.vulnerability.dismissalFeedback = { id: 123 };
mockedState.createVulnerabilityFeedbackDismissalPath = 'dismiss_vulnerability_path'; mockedState.createVulnerabilityFeedbackDismissalPath = 'dismiss_vulnerability_path';
testAction( await testAction(
revertDismissVulnerability, securityReportsAction.revertDismissVulnerability,
null, null,
mockedState, mockedState,
[], [],
...@@ -783,15 +688,14 @@ describe('security reports actions', () => { ...@@ -783,15 +688,14 @@ describe('security reports actions', () => {
payload: 'There was an error reverting the dismissal. Please try again.', payload: 'There was an error reverting the dismissal. Please try again.',
}, },
], ],
done,
); );
}); });
}); });
describe('requestCreateIssue', () => { describe('requestCreateIssue', () => {
it('commits request create issue', (done) => { it('commits request create issue', async () => {
testAction( await testAction(
requestCreateIssue, securityReportsAction.requestCreateIssue,
null, null,
mockedState, mockedState,
[ [
...@@ -800,15 +704,14 @@ describe('security reports actions', () => { ...@@ -800,15 +704,14 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveCreateIssue', () => { describe('receiveCreateIssue', () => {
it('commits receive create issue', (done) => { it('commits receive create issue', async () => {
testAction( await testAction(
receiveCreateIssue, securityReportsAction.receiveCreateIssue,
null, null,
mockedState, mockedState,
[ [
...@@ -817,15 +720,14 @@ describe('security reports actions', () => { ...@@ -817,15 +720,14 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveCreateIssueError', () => { describe('receiveCreateIssueError', () => {
it('commits receive create issue error with payload', (done) => { it('commits receive create issue error with payload', async () => {
testAction( await testAction(
receiveCreateIssueError, securityReportsAction.receiveCreateIssueError,
'error', 'error',
mockedState, mockedState,
[ [
...@@ -835,18 +737,17 @@ describe('security reports actions', () => { ...@@ -835,18 +737,17 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('createNewIssue', () => { describe('createNewIssue', () => {
it('with success should dispatch `requestCreateIssue` and `receiveCreateIssue`', (done) => { it('with success should dispatch `requestCreateIssue` and `receiveCreateIssue`', async () => {
mock.onPost('create_issue_path').reply(200, { issue_path: 'new_issue' }); mock.onPost('create_issue_path').reply(200, { issue_path: 'new_issue' });
mockedState.createVulnerabilityFeedbackIssuePath = 'create_issue_path'; mockedState.createVulnerabilityFeedbackIssuePath = 'create_issue_path';
testAction( await testAction(
createNewIssue, securityReportsAction.createNewIssue,
null, null,
mockedState, mockedState,
[], [],
...@@ -858,17 +759,16 @@ describe('security reports actions', () => { ...@@ -858,17 +759,16 @@ describe('security reports actions', () => {
type: 'receiveCreateIssue', type: 'receiveCreateIssue',
}, },
], ],
done,
); );
}); });
it('with error should dispatch `receiveCreateIssueError`', (done) => { it('with error should dispatch `receiveCreateIssueError`', async () => {
mock.onPost('create_issue_path').reply(500, {}); mock.onPost('create_issue_path').reply(500, {});
mockedState.vulnerabilityFeedbackPath = 'create_issue_path'; mockedState.vulnerabilityFeedbackPath = 'create_issue_path';
mockedState.canReadVulnerabilityFeedback = true; mockedState.canReadVulnerabilityFeedback = true;
testAction( await testAction(
createNewIssue, securityReportsAction.createNewIssue,
null, null,
mockedState, mockedState,
[], [],
...@@ -881,7 +781,6 @@ describe('security reports actions', () => { ...@@ -881,7 +781,6 @@ describe('security reports actions', () => {
payload: 'There was an error creating the issue. Please try again.', payload: 'There was an error creating the issue. Please try again.',
}, },
], ],
done,
); );
}); });
}); });
...@@ -891,7 +790,7 @@ describe('security reports actions', () => { ...@@ -891,7 +790,7 @@ describe('security reports actions', () => {
const a = { click: jest.fn() }; const a = { click: jest.fn() };
jest.spyOn(document, 'createElement').mockImplementation(() => a); jest.spyOn(document, 'createElement').mockImplementation(() => a);
downloadPatch({ securityReportsAction.downloadPatch({
state: { state: {
modal: { modal: {
vulnerability: { vulnerability: {
...@@ -914,9 +813,9 @@ describe('security reports actions', () => { ...@@ -914,9 +813,9 @@ describe('security reports actions', () => {
}); });
describe('requestCreateMergeRequest', () => { describe('requestCreateMergeRequest', () => {
it('commits request create merge request', (done) => { it('commits request create merge request', async () => {
testAction( await testAction(
requestCreateMergeRequest, securityReportsAction.requestCreateMergeRequest,
null, null,
mockedState, mockedState,
[ [
...@@ -925,17 +824,16 @@ describe('security reports actions', () => { ...@@ -925,17 +824,16 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveCreateMergeRequestSuccess', () => { describe('receiveCreateMergeRequestSuccess', () => {
it('commits receive create merge request', (done) => { it('commits receive create merge request', async () => {
const data = { foo: 'bar' }; const data = { foo: 'bar' };
testAction( await testAction(
receiveCreateMergeRequestSuccess, securityReportsAction.receiveCreateMergeRequestSuccess,
data, data,
mockedState, mockedState,
[ [
...@@ -945,15 +843,14 @@ describe('security reports actions', () => { ...@@ -945,15 +843,14 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveCreateMergeRequestError', () => { describe('receiveCreateMergeRequestError', () => {
it('commits receive create merge request error', (done) => { it('commits receive create merge request error', async () => {
testAction( await testAction(
receiveCreateMergeRequestError, securityReportsAction.receiveCreateMergeRequestError,
'', '',
mockedState, mockedState,
[ [
...@@ -962,19 +859,18 @@ describe('security reports actions', () => { ...@@ -962,19 +859,18 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('createMergeRequest', () => { describe('createMergeRequest', () => {
it('with success should dispatch `receiveCreateMergeRequestSuccess`', (done) => { it('with success should dispatch `receiveCreateMergeRequestSuccess`', async () => {
const data = { merge_request_path: 'fakepath.html' }; const data = { merge_request_path: 'fakepath.html' };
mockedState.createVulnerabilityFeedbackMergeRequestPath = 'create_merge_request_path'; mockedState.createVulnerabilityFeedbackMergeRequestPath = 'create_merge_request_path';
mock.onPost('create_merge_request_path').reply(200, data); mock.onPost('create_merge_request_path').reply(200, data);
testAction( await testAction(
createMergeRequest, securityReportsAction.createMergeRequest,
null, null,
mockedState, mockedState,
[], [],
...@@ -987,17 +883,16 @@ describe('security reports actions', () => { ...@@ -987,17 +883,16 @@ describe('security reports actions', () => {
payload: data, payload: data,
}, },
], ],
done,
); );
}); });
it('with error should dispatch `receiveCreateMergeRequestError`', (done) => { it('with error should dispatch `receiveCreateMergeRequestError`', async () => {
mock.onPost('create_merge_request_path').reply(500, {}); mock.onPost('create_merge_request_path').reply(500, {});
mockedState.vulnerabilityFeedbackPath = 'create_merge_request_path'; mockedState.vulnerabilityFeedbackPath = 'create_merge_request_path';
mockedState.canReadVulnerabilityFeedback = true; mockedState.canReadVulnerabilityFeedback = true;
testAction( await testAction(
createMergeRequest, securityReportsAction.createMergeRequest,
null, null,
mockedState, mockedState,
[], [],
...@@ -1010,17 +905,16 @@ describe('security reports actions', () => { ...@@ -1010,17 +905,16 @@ describe('security reports actions', () => {
payload: 'There was an error creating the merge request. Please try again.', payload: 'There was an error creating the merge request. Please try again.',
}, },
], ],
done,
); );
}); });
}); });
describe('updateDependencyScanningIssue', () => { describe('updateDependencyScanningIssue', () => {
it('commits update dependency scanning issue', (done) => { it('commits update dependency scanning issue', async () => {
const payload = { foo: 'bar' }; const payload = { foo: 'bar' };
testAction( await testAction(
updateDependencyScanningIssue, securityReportsAction.updateDependencyScanningIssue,
payload, payload,
mockedState, mockedState,
[ [
...@@ -1030,17 +924,16 @@ describe('security reports actions', () => { ...@@ -1030,17 +924,16 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('updateContainerScanningIssue', () => { describe('updateContainerScanningIssue', () => {
it('commits update container scanning issue', (done) => { it('commits update container scanning issue', async () => {
const payload = { foo: 'bar' }; const payload = { foo: 'bar' };
testAction( await testAction(
updateContainerScanningIssue, securityReportsAction.updateContainerScanningIssue,
payload, payload,
mockedState, mockedState,
[ [
...@@ -1050,17 +943,16 @@ describe('security reports actions', () => { ...@@ -1050,17 +943,16 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('updateDastIssue', () => { describe('updateDastIssue', () => {
it('commits update dast issue', (done) => { it('commits update dast issue', async () => {
const payload = { foo: 'bar' }; const payload = { foo: 'bar' };
testAction( await testAction(
updateDastIssue, securityReportsAction.updateDastIssue,
payload, payload,
mockedState, mockedState,
[ [
...@@ -1070,17 +962,16 @@ describe('security reports actions', () => { ...@@ -1070,17 +962,16 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('updateCoverageFuzzingIssue', () => { describe('updateCoverageFuzzingIssue', () => {
it('commits update coverageFuzzing issue', (done) => { it('commits update coverageFuzzing issue', async () => {
const payload = { foo: 'bar' }; const payload = { foo: 'bar' };
testAction( await testAction(
updateCoverageFuzzingIssue, securityReportsAction.updateCoverageFuzzingIssue,
payload, payload,
mockedState, mockedState,
[ [
...@@ -1090,17 +981,16 @@ describe('security reports actions', () => { ...@@ -1090,17 +981,16 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('setContainerScanningDiffEndpoint', () => { describe('setContainerScanningDiffEndpoint', () => {
it('should pass down the endpoint to the mutation', (done) => { it('should pass down the endpoint to the mutation', async () => {
const payload = '/container_scanning_endpoint.json'; const payload = '/container_scanning_endpoint.json';
testAction( await testAction(
setContainerScanningDiffEndpoint, securityReportsAction.setContainerScanningDiffEndpoint,
payload, payload,
mockedState, mockedState,
[ [
...@@ -1110,17 +1000,16 @@ describe('security reports actions', () => { ...@@ -1110,17 +1000,16 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveContainerScanningDiffSuccess', () => { describe('receiveContainerScanningDiffSuccess', () => {
it('should pass down the response to the mutation', (done) => { it('should pass down the response to the mutation', async () => {
const payload = { data: 'Effort yields its own rewards.' }; const payload = { data: 'Effort yields its own rewards.' };
testAction( await testAction(
receiveContainerScanningDiffSuccess, securityReportsAction.receiveContainerScanningDiffSuccess,
payload, payload,
mockedState, mockedState,
[ [
...@@ -1130,15 +1019,14 @@ describe('security reports actions', () => { ...@@ -1130,15 +1019,14 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveContainerScanningDiffError', () => { describe('receiveContainerScanningDiffError', () => {
it('should commit container diff error mutation', (done) => { it('should commit container diff error mutation', async () => {
testAction( await testAction(
receiveContainerScanningDiffError, securityReportsAction.receiveContainerScanningDiffError,
undefined, undefined,
mockedState, mockedState,
[ [
...@@ -1147,7 +1035,6 @@ describe('security reports actions', () => { ...@@ -1147,7 +1035,6 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -1163,7 +1050,7 @@ describe('security reports actions', () => { ...@@ -1163,7 +1050,7 @@ describe('security reports actions', () => {
}); });
describe('on success', () => { describe('on success', () => {
it('should dispatch `receiveContainerScanningDiffSuccess`', (done) => { it('should dispatch `receiveContainerScanningDiffSuccess`', async () => {
mock.onGet(endpoint).reply(200, diff); mock.onGet(endpoint).reply(200, diff);
mock mock
.onGet('vulnerabilities_feedback', { .onGet('vulnerabilities_feedback', {
...@@ -1173,8 +1060,8 @@ describe('security reports actions', () => { ...@@ -1173,8 +1060,8 @@ describe('security reports actions', () => {
}) })
.reply(200, containerScanningFeedbacks); .reply(200, containerScanningFeedbacks);
testAction( await testAction(
fetchContainerScanningDiff, securityReportsAction.fetchContainerScanningDiff,
null, null,
mockedState, mockedState,
[], [],
...@@ -1190,7 +1077,6 @@ describe('security reports actions', () => { ...@@ -1190,7 +1077,6 @@ describe('security reports actions', () => {
}, },
}, },
], ],
done,
); );
}); });
}); });
...@@ -1201,9 +1087,9 @@ describe('security reports actions', () => { ...@@ -1201,9 +1087,9 @@ describe('security reports actions', () => {
mock.onGet(endpoint).reply(200, diff); mock.onGet(endpoint).reply(200, diff);
}); });
it('should dispatch `receiveContainerScanningDiffSuccess`', (done) => { it('should dispatch `receiveContainerScanningDiffSuccess`', async () => {
testAction( await testAction(
fetchContainerScanningDiff, securityReportsAction.fetchContainerScanningDiff,
null, null,
mockedState, mockedState,
[], [],
...@@ -1219,13 +1105,12 @@ describe('security reports actions', () => { ...@@ -1219,13 +1105,12 @@ describe('security reports actions', () => {
}, },
}, },
], ],
done,
); );
}); });
}); });
describe('when vulnerabilities path errors', () => { describe('when vulnerabilities path errors', () => {
it('should dispatch `receiveContainerScanningError`', (done) => { it('should dispatch `receiveContainerScanningError`', async () => {
mock.onGet(endpoint).reply(500); mock.onGet(endpoint).reply(500);
mock mock
.onGet('vulnerabilities_feedback', { .onGet('vulnerabilities_feedback', {
...@@ -1235,8 +1120,8 @@ describe('security reports actions', () => { ...@@ -1235,8 +1120,8 @@ describe('security reports actions', () => {
}) })
.reply(200, containerScanningFeedbacks); .reply(200, containerScanningFeedbacks);
testAction( await testAction(
fetchContainerScanningDiff, securityReportsAction.fetchContainerScanningDiff,
null, null,
mockedState, mockedState,
[], [],
...@@ -1248,13 +1133,12 @@ describe('security reports actions', () => { ...@@ -1248,13 +1133,12 @@ describe('security reports actions', () => {
type: 'receiveContainerScanningDiffError', type: 'receiveContainerScanningDiffError',
}, },
], ],
done,
); );
}); });
}); });
describe('when feedback path errors', () => { describe('when feedback path errors', () => {
it('should dispatch `receiveContainerScanningError`', (done) => { it('should dispatch `receiveContainerScanningError`', async () => {
mock.onGet(endpoint).reply(200, diff); mock.onGet(endpoint).reply(200, diff);
mock mock
.onGet('vulnerabilities_feedback', { .onGet('vulnerabilities_feedback', {
...@@ -1264,8 +1148,8 @@ describe('security reports actions', () => { ...@@ -1264,8 +1148,8 @@ describe('security reports actions', () => {
}) })
.reply(500); .reply(500);
testAction( await testAction(
fetchContainerScanningDiff, securityReportsAction.fetchContainerScanningDiff,
null, null,
mockedState, mockedState,
[], [],
...@@ -1277,18 +1161,17 @@ describe('security reports actions', () => { ...@@ -1277,18 +1161,17 @@ describe('security reports actions', () => {
type: 'receiveContainerScanningDiffError', type: 'receiveContainerScanningDiffError',
}, },
], ],
done,
); );
}); });
}); });
}); });
describe('setDependencyScanningDiffEndpoint', () => { describe('setDependencyScanningDiffEndpoint', () => {
it('should pass down the endpoint to the mutation', (done) => { it('should pass down the endpoint to the mutation', async () => {
const payload = '/dependency_scanning_endpoint.json'; const payload = '/dependency_scanning_endpoint.json';
testAction( await testAction(
setDependencyScanningDiffEndpoint, securityReportsAction.setDependencyScanningDiffEndpoint,
payload, payload,
mockedState, mockedState,
[ [
...@@ -1298,17 +1181,16 @@ describe('security reports actions', () => { ...@@ -1298,17 +1181,16 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveDependencyScanningDiffSuccess', () => { describe('receiveDependencyScanningDiffSuccess', () => {
it('should pass down the response to the mutation', (done) => { it('should pass down the response to the mutation', async () => {
const payload = { data: 'Effort yields its own rewards.' }; const payload = { data: 'Effort yields its own rewards.' };
testAction( await testAction(
receiveDependencyScanningDiffSuccess, securityReportsAction.receiveDependencyScanningDiffSuccess,
payload, payload,
mockedState, mockedState,
[ [
...@@ -1318,15 +1200,14 @@ describe('security reports actions', () => { ...@@ -1318,15 +1200,14 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveDependencyScanningDiffError', () => { describe('receiveDependencyScanningDiffError', () => {
it('should commit dependency scanning diff error mutation', (done) => { it('should commit dependency scanning diff error mutation', async () => {
testAction( await testAction(
receiveDependencyScanningDiffError, securityReportsAction.receiveDependencyScanningDiffError,
undefined, undefined,
mockedState, mockedState,
[ [
...@@ -1335,7 +1216,6 @@ describe('security reports actions', () => { ...@@ -1335,7 +1216,6 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -1350,7 +1230,7 @@ describe('security reports actions', () => { ...@@ -1350,7 +1230,7 @@ describe('security reports actions', () => {
}); });
describe('on success', () => { describe('on success', () => {
it('should dispatch `receiveDependencyScanningDiffSuccess`', (done) => { it('should dispatch `receiveDependencyScanningDiffSuccess`', async () => {
mock.onGet('dependency_scanning_diff.json').reply(200, diff); mock.onGet('dependency_scanning_diff.json').reply(200, diff);
mock mock
.onGet('vulnerabilities_feedback', { .onGet('vulnerabilities_feedback', {
...@@ -1360,8 +1240,8 @@ describe('security reports actions', () => { ...@@ -1360,8 +1240,8 @@ describe('security reports actions', () => {
}) })
.reply(200, dependencyScanningFeedbacks); .reply(200, dependencyScanningFeedbacks);
testAction( await testAction(
fetchDependencyScanningDiff, securityReportsAction.fetchDependencyScanningDiff,
null, null,
mockedState, mockedState,
[], [],
...@@ -1377,7 +1257,6 @@ describe('security reports actions', () => { ...@@ -1377,7 +1257,6 @@ describe('security reports actions', () => {
}, },
}, },
], ],
done,
); );
}); });
}); });
...@@ -1388,9 +1267,9 @@ describe('security reports actions', () => { ...@@ -1388,9 +1267,9 @@ describe('security reports actions', () => {
mock.onGet('dependency_scanning_diff.json').reply(200, diff); mock.onGet('dependency_scanning_diff.json').reply(200, diff);
}); });
it('should dispatch `receiveDependencyScanningDiffSuccess`', (done) => { it('should dispatch `receiveDependencyScanningDiffSuccess`', async () => {
testAction( await testAction(
fetchDependencyScanningDiff, securityReportsAction.fetchDependencyScanningDiff,
null, null,
mockedState, mockedState,
[], [],
...@@ -1406,13 +1285,12 @@ describe('security reports actions', () => { ...@@ -1406,13 +1285,12 @@ describe('security reports actions', () => {
}, },
}, },
], ],
done,
); );
}); });
}); });
describe('when vulnerabilities path errors', () => { describe('when vulnerabilities path errors', () => {
it('should dispatch `receiveDependencyScanningError`', (done) => { it('should dispatch `receiveDependencyScanningError`', async () => {
mock.onGet('dependency_scanning_diff.json').reply(500); mock.onGet('dependency_scanning_diff.json').reply(500);
mock mock
.onGet('vulnerabilities_feedback', { .onGet('vulnerabilities_feedback', {
...@@ -1422,8 +1300,8 @@ describe('security reports actions', () => { ...@@ -1422,8 +1300,8 @@ describe('security reports actions', () => {
}) })
.reply(200, dependencyScanningFeedbacks); .reply(200, dependencyScanningFeedbacks);
testAction( await testAction(
fetchDependencyScanningDiff, securityReportsAction.fetchDependencyScanningDiff,
null, null,
mockedState, mockedState,
[], [],
...@@ -1435,13 +1313,12 @@ describe('security reports actions', () => { ...@@ -1435,13 +1313,12 @@ describe('security reports actions', () => {
type: 'receiveDependencyScanningDiffError', type: 'receiveDependencyScanningDiffError',
}, },
], ],
done,
); );
}); });
}); });
describe('when feedback path errors', () => { describe('when feedback path errors', () => {
it('should dispatch `receiveDependencyScanningError`', (done) => { it('should dispatch `receiveDependencyScanningError`', async () => {
mock.onGet('dependency_scanning_diff.json').reply(200, diff); mock.onGet('dependency_scanning_diff.json').reply(200, diff);
mock mock
.onGet('vulnerabilities_feedback', { .onGet('vulnerabilities_feedback', {
...@@ -1451,8 +1328,8 @@ describe('security reports actions', () => { ...@@ -1451,8 +1328,8 @@ describe('security reports actions', () => {
}) })
.reply(500); .reply(500);
testAction( await testAction(
fetchDependencyScanningDiff, securityReportsAction.fetchDependencyScanningDiff,
null, null,
mockedState, mockedState,
[], [],
...@@ -1464,18 +1341,17 @@ describe('security reports actions', () => { ...@@ -1464,18 +1341,17 @@ describe('security reports actions', () => {
type: 'receiveDependencyScanningDiffError', type: 'receiveDependencyScanningDiffError',
}, },
], ],
done,
); );
}); });
}); });
}); });
describe('setDastDiffEndpoint', () => { describe('setDastDiffEndpoint', () => {
it('should pass down the endpoint to the mutation', (done) => { it('should pass down the endpoint to the mutation', async () => {
const payload = '/dast_endpoint.json'; const payload = '/dast_endpoint.json';
testAction( await testAction(
setDastDiffEndpoint, securityReportsAction.setDastDiffEndpoint,
payload, payload,
mockedState, mockedState,
[ [
...@@ -1485,17 +1361,16 @@ describe('security reports actions', () => { ...@@ -1485,17 +1361,16 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveDastDiffSuccess', () => { describe('receiveDastDiffSuccess', () => {
it('should pass down the response to the mutation', (done) => { it('should pass down the response to the mutation', async () => {
const payload = { data: 'Effort yields its own rewards.' }; const payload = { data: 'Effort yields its own rewards.' };
testAction( await testAction(
receiveDastDiffSuccess, securityReportsAction.receiveDastDiffSuccess,
payload, payload,
mockedState, mockedState,
[ [
...@@ -1505,15 +1380,14 @@ describe('security reports actions', () => { ...@@ -1505,15 +1380,14 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveDastDiffError', () => { describe('receiveDastDiffError', () => {
it('should commit dast diff error mutation', (done) => { it('should commit dast diff error mutation', async () => {
testAction( await testAction(
receiveDastDiffError, securityReportsAction.receiveDastDiffError,
undefined, undefined,
mockedState, mockedState,
[ [
...@@ -1522,7 +1396,6 @@ describe('security reports actions', () => { ...@@ -1522,7 +1396,6 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -1537,7 +1410,7 @@ describe('security reports actions', () => { ...@@ -1537,7 +1410,7 @@ describe('security reports actions', () => {
}); });
describe('on success', () => { describe('on success', () => {
it('should dispatch `receiveDastDiffSuccess`', (done) => { it('should dispatch `receiveDastDiffSuccess`', async () => {
mock.onGet('dast_diff.json').reply(200, diff); mock.onGet('dast_diff.json').reply(200, diff);
mock mock
.onGet('vulnerabilities_feedback', { .onGet('vulnerabilities_feedback', {
...@@ -1547,8 +1420,8 @@ describe('security reports actions', () => { ...@@ -1547,8 +1420,8 @@ describe('security reports actions', () => {
}) })
.reply(200, dastFeedbacks); .reply(200, dastFeedbacks);
testAction( await testAction(
fetchDastDiff, securityReportsAction.fetchDastDiff,
null, null,
mockedState, mockedState,
[], [],
...@@ -1564,7 +1437,6 @@ describe('security reports actions', () => { ...@@ -1564,7 +1437,6 @@ describe('security reports actions', () => {
}, },
}, },
], ],
done,
); );
}); });
}); });
...@@ -1575,9 +1447,9 @@ describe('security reports actions', () => { ...@@ -1575,9 +1447,9 @@ describe('security reports actions', () => {
mock.onGet('dast_diff.json').reply(200, diff); mock.onGet('dast_diff.json').reply(200, diff);
}); });
it('should dispatch `receiveDastDiffSuccess`', (done) => { it('should dispatch `receiveDastDiffSuccess`', async () => {
testAction( await testAction(
fetchDastDiff, securityReportsAction.fetchDastDiff,
null, null,
mockedState, mockedState,
[], [],
...@@ -1593,13 +1465,12 @@ describe('security reports actions', () => { ...@@ -1593,13 +1465,12 @@ describe('security reports actions', () => {
}, },
}, },
], ],
done,
); );
}); });
}); });
describe('when vulnerabilities path errors', () => { describe('when vulnerabilities path errors', () => {
it('should dispatch `receiveDastError`', (done) => { it('should dispatch `receiveDastError`', async () => {
mock.onGet('dast_diff.json').reply(500); mock.onGet('dast_diff.json').reply(500);
mock mock
.onGet('vulnerabilities_feedback', { .onGet('vulnerabilities_feedback', {
...@@ -1609,8 +1480,8 @@ describe('security reports actions', () => { ...@@ -1609,8 +1480,8 @@ describe('security reports actions', () => {
}) })
.reply(200, dastFeedbacks); .reply(200, dastFeedbacks);
testAction( await testAction(
fetchDastDiff, securityReportsAction.fetchDastDiff,
null, null,
mockedState, mockedState,
[], [],
...@@ -1622,13 +1493,12 @@ describe('security reports actions', () => { ...@@ -1622,13 +1493,12 @@ describe('security reports actions', () => {
type: 'receiveDastDiffError', type: 'receiveDastDiffError',
}, },
], ],
done,
); );
}); });
}); });
describe('when feedback path errors', () => { describe('when feedback path errors', () => {
it('should dispatch `receiveDastError`', (done) => { it('should dispatch `receiveDastError`', async () => {
mock.onGet('dast_diff.json').reply(200, diff); mock.onGet('dast_diff.json').reply(200, diff);
mock mock
.onGet('vulnerabilities_feedback', { .onGet('vulnerabilities_feedback', {
...@@ -1638,8 +1508,8 @@ describe('security reports actions', () => { ...@@ -1638,8 +1508,8 @@ describe('security reports actions', () => {
}) })
.reply(500); .reply(500);
testAction( await testAction(
fetchDastDiff, securityReportsAction.fetchDastDiff,
null, null,
mockedState, mockedState,
[], [],
...@@ -1651,18 +1521,17 @@ describe('security reports actions', () => { ...@@ -1651,18 +1521,17 @@ describe('security reports actions', () => {
type: 'receiveDastDiffError', type: 'receiveDastDiffError',
}, },
], ],
done,
); );
}); });
}); });
}); });
describe('setCoverageFuzzingDiffEndpoint', () => { describe('setCoverageFuzzingDiffEndpoint', () => {
it('should pass down the endpoint to the mutation', (done) => { it('should pass down the endpoint to the mutation', async () => {
const payload = '/coverage_fuzzing_endpoint.json'; const payload = '/coverage_fuzzing_endpoint.json';
testAction( await testAction(
setCoverageFuzzingDiffEndpoint, securityReportsAction.setCoverageFuzzingDiffEndpoint,
payload, payload,
mockedState, mockedState,
[ [
...@@ -1672,17 +1541,16 @@ describe('security reports actions', () => { ...@@ -1672,17 +1541,16 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveCoverageFuzzingDiffSuccess', () => { describe('receiveCoverageFuzzingDiffSuccess', () => {
it('should pass down the response to the mutation', (done) => { it('should pass down the response to the mutation', async () => {
const payload = { data: 'Effort yields its own rewards.' }; const payload = { data: 'Effort yields its own rewards.' };
testAction( await testAction(
receiveCoverageFuzzingDiffSuccess, securityReportsAction.receiveCoverageFuzzingDiffSuccess,
payload, payload,
mockedState, mockedState,
[ [
...@@ -1692,15 +1560,14 @@ describe('security reports actions', () => { ...@@ -1692,15 +1560,14 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveCoverageFuzzingDiffError', () => { describe('receiveCoverageFuzzingDiffError', () => {
it('should commit coverage fuzzing diff error mutation', (done) => { it('should commit coverage fuzzing diff error mutation', async () => {
testAction( await testAction(
receiveCoverageFuzzingDiffError, securityReportsAction.receiveCoverageFuzzingDiffError,
undefined, undefined,
mockedState, mockedState,
[ [
...@@ -1709,7 +1576,6 @@ describe('security reports actions', () => { ...@@ -1709,7 +1576,6 @@ describe('security reports actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -1723,7 +1589,7 @@ describe('security reports actions', () => { ...@@ -1723,7 +1589,7 @@ describe('security reports actions', () => {
}); });
describe('on success', () => { describe('on success', () => {
it('should dispatch `receiveCoverageFuzzingDiffSuccess`', (done) => { it('should dispatch `receiveCoverageFuzzingDiffSuccess`', async () => {
mock.onGet('coverage_fuzzing_diff.json').reply(200, diff); mock.onGet('coverage_fuzzing_diff.json').reply(200, diff);
mock mock
.onGet('vulnerabilities_feedback', { .onGet('vulnerabilities_feedback', {
...@@ -1733,8 +1599,8 @@ describe('security reports actions', () => { ...@@ -1733,8 +1599,8 @@ describe('security reports actions', () => {
}) })
.reply(200, coverageFuzzingFeedbacks); .reply(200, coverageFuzzingFeedbacks);
testAction( await testAction(
fetchCoverageFuzzingDiff, securityReportsAction.fetchCoverageFuzzingDiff,
null, null,
mockedState, mockedState,
[], [],
...@@ -1750,13 +1616,12 @@ describe('security reports actions', () => { ...@@ -1750,13 +1616,12 @@ describe('security reports actions', () => {
}, },
}, },
], ],
done,
); );
}); });
}); });
describe('when vulnerabilities path errors', () => { describe('when vulnerabilities path errors', () => {
it('should dispatch `receiveCoverageFuzzingError`', (done) => { it('should dispatch `receiveCoverageFuzzingError`', async () => {
mock.onGet('coverage_fuzzing_diff.json').reply(500); mock.onGet('coverage_fuzzing_diff.json').reply(500);
mock mock
.onGet('vulnerabilities_feedback', { .onGet('vulnerabilities_feedback', {
...@@ -1766,8 +1631,8 @@ describe('security reports actions', () => { ...@@ -1766,8 +1631,8 @@ describe('security reports actions', () => {
}) })
.reply(200, coverageFuzzingFeedbacks); .reply(200, coverageFuzzingFeedbacks);
testAction( await testAction(
fetchCoverageFuzzingDiff, securityReportsAction.fetchCoverageFuzzingDiff,
null, null,
mockedState, mockedState,
[], [],
...@@ -1779,13 +1644,12 @@ describe('security reports actions', () => { ...@@ -1779,13 +1644,12 @@ describe('security reports actions', () => {
type: 'receiveCoverageFuzzingDiffError', type: 'receiveCoverageFuzzingDiffError',
}, },
], ],
done,
); );
}); });
}); });
describe('when feedback path errors', () => { describe('when feedback path errors', () => {
it('should dispatch `receiveCoverageFuzzingError`', (done) => { it('should dispatch `receiveCoverageFuzzingError`', async () => {
mock.onGet('coverage_fuzzing_diff.json').reply(200, diff); mock.onGet('coverage_fuzzing_diff.json').reply(200, diff);
mock mock
.onGet('vulnerabilities_feedback', { .onGet('vulnerabilities_feedback', {
...@@ -1795,8 +1659,8 @@ describe('security reports actions', () => { ...@@ -1795,8 +1659,8 @@ describe('security reports actions', () => {
}) })
.reply(500); .reply(500);
testAction( await testAction(
fetchCoverageFuzzingDiff, securityReportsAction.fetchCoverageFuzzingDiff,
null, null,
mockedState, mockedState,
[], [],
...@@ -1808,7 +1672,6 @@ describe('security reports actions', () => { ...@@ -1808,7 +1672,6 @@ describe('security reports actions', () => {
type: 'receiveCoverageFuzzingDiffError', type: 'receiveCoverageFuzzingDiffError',
}, },
], ],
done,
); );
}); });
}); });
......
...@@ -25,8 +25,8 @@ describe('EE api fuzzing report actions', () => { ...@@ -25,8 +25,8 @@ describe('EE api fuzzing report actions', () => {
}); });
describe('updateVulnerability', () => { describe('updateVulnerability', () => {
it(`should commit ${types.UPDATE_VULNERABILITY} with the correct response`, (done) => { it(`should commit ${types.UPDATE_VULNERABILITY} with the correct response`, async () => {
testAction( await testAction(
actions.updateVulnerability, actions.updateVulnerability,
issue, issue,
state, state,
...@@ -37,14 +37,13 @@ describe('EE api fuzzing report actions', () => { ...@@ -37,14 +37,13 @@ describe('EE api fuzzing report actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('setDiffEndpoint', () => { describe('setDiffEndpoint', () => {
it(`should commit ${types.SET_DIFF_ENDPOINT} with the correct path`, (done) => { it(`should commit ${types.SET_DIFF_ENDPOINT} with the correct path`, async () => {
testAction( await testAction(
actions.setDiffEndpoint, actions.setDiffEndpoint,
diffEndpoint, diffEndpoint,
state, state,
...@@ -55,20 +54,19 @@ describe('EE api fuzzing report actions', () => { ...@@ -55,20 +54,19 @@ describe('EE api fuzzing report actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('requestDiff', () => { describe('requestDiff', () => {
it(`should commit ${types.REQUEST_DIFF}`, (done) => { it(`should commit ${types.REQUEST_DIFF}`, async () => {
testAction(actions.requestDiff, {}, state, [{ type: types.REQUEST_DIFF }], [], done); await testAction(actions.requestDiff, {}, state, [{ type: types.REQUEST_DIFF }], []);
}); });
}); });
describe('receiveDiffSuccess', () => { describe('receiveDiffSuccess', () => {
it(`should commit ${types.RECEIVE_DIFF_SUCCESS} with the correct response`, (done) => { it(`should commit ${types.RECEIVE_DIFF_SUCCESS} with the correct response`, async () => {
testAction( await testAction(
actions.receiveDiffSuccess, actions.receiveDiffSuccess,
reports, reports,
state, state,
...@@ -79,14 +77,13 @@ describe('EE api fuzzing report actions', () => { ...@@ -79,14 +77,13 @@ describe('EE api fuzzing report actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveDiffError', () => { describe('receiveDiffError', () => {
it(`should commit ${types.RECEIVE_DIFF_ERROR} with the correct response`, (done) => { it(`should commit ${types.RECEIVE_DIFF_ERROR} with the correct response`, async () => {
testAction( await testAction(
actions.receiveDiffError, actions.receiveDiffError,
error, error,
state, state,
...@@ -97,7 +94,6 @@ describe('EE api fuzzing report actions', () => { ...@@ -97,7 +94,6 @@ describe('EE api fuzzing report actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -124,9 +120,9 @@ describe('EE api fuzzing report actions', () => { ...@@ -124,9 +120,9 @@ describe('EE api fuzzing report actions', () => {
.replyOnce(200, reports.enrichData); .replyOnce(200, reports.enrichData);
}); });
it('should dispatch the `receiveDiffSuccess` action', (done) => { it('should dispatch the `receiveDiffSuccess` action', async () => {
const { diff, enrichData } = reports; const { diff, enrichData } = reports;
testAction( await testAction(
actions.fetchDiff, actions.fetchDiff,
{}, {},
{ ...rootState, ...state }, { ...rootState, ...state },
...@@ -141,7 +137,6 @@ describe('EE api fuzzing report actions', () => { ...@@ -141,7 +137,6 @@ describe('EE api fuzzing report actions', () => {
}, },
}, },
], ],
done,
); );
}); });
}); });
...@@ -152,10 +147,10 @@ describe('EE api fuzzing report actions', () => { ...@@ -152,10 +147,10 @@ describe('EE api fuzzing report actions', () => {
mock.onGet(diffEndpoint).replyOnce(200, reports.diff); mock.onGet(diffEndpoint).replyOnce(200, reports.diff);
}); });
it('should dispatch the `receiveDiffSuccess` action with empty enrich data', (done) => { it('should dispatch the `receiveDiffSuccess` action with empty enrich data', async () => {
const { diff } = reports; const { diff } = reports;
const enrichData = []; const enrichData = [];
testAction( await testAction(
actions.fetchDiff, actions.fetchDiff,
{}, {},
{ ...rootState, ...state }, { ...rootState, ...state },
...@@ -170,7 +165,6 @@ describe('EE api fuzzing report actions', () => { ...@@ -170,7 +165,6 @@ describe('EE api fuzzing report actions', () => {
}, },
}, },
], ],
done,
); );
}); });
}); });
...@@ -184,14 +178,13 @@ describe('EE api fuzzing report actions', () => { ...@@ -184,14 +178,13 @@ describe('EE api fuzzing report actions', () => {
.replyOnce(404); .replyOnce(404);
}); });
it('should dispatch the `receiveError` action', (done) => { it('should dispatch the `receiveError` action', async () => {
testAction( await testAction(
actions.fetchDiff, actions.fetchDiff,
{}, {},
{ ...rootState, ...state }, { ...rootState, ...state },
[], [],
[{ type: 'requestDiff' }, { type: 'receiveDiffError' }], [{ type: 'requestDiff' }, { type: 'receiveDiffError' }],
done,
); );
}); });
}); });
...@@ -205,14 +198,13 @@ describe('EE api fuzzing report actions', () => { ...@@ -205,14 +198,13 @@ describe('EE api fuzzing report actions', () => {
.replyOnce(200, reports.enrichData); .replyOnce(200, reports.enrichData);
}); });
it('should dispatch the `receiveDiffError` action', (done) => { it('should dispatch the `receiveDiffError` action', async () => {
testAction( await testAction(
actions.fetchDiff, actions.fetchDiff,
{}, {},
{ ...rootState, ...state }, { ...rootState, ...state },
[], [],
[{ type: 'requestDiff' }, { type: 'receiveDiffError' }], [{ type: 'requestDiff' }, { type: 'receiveDiffError' }],
done,
); );
}); });
}); });
......
...@@ -14,8 +14,8 @@ describe('EE sast report actions', () => { ...@@ -14,8 +14,8 @@ describe('EE sast report actions', () => {
}); });
describe('updateVulnerability', () => { describe('updateVulnerability', () => {
it(`should commit ${types.UPDATE_VULNERABILITY} with the correct response`, (done) => { it(`should commit ${types.UPDATE_VULNERABILITY} with the correct response`, async () => {
testAction( await testAction(
actions.updateVulnerability, actions.updateVulnerability,
issue, issue,
state, state,
...@@ -26,7 +26,6 @@ describe('EE sast report actions', () => { ...@@ -26,7 +26,6 @@ describe('EE sast report actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
......
...@@ -14,8 +14,8 @@ describe('EE secret detection report actions', () => { ...@@ -14,8 +14,8 @@ describe('EE secret detection report actions', () => {
}); });
describe('updateVulnerability', () => { describe('updateVulnerability', () => {
it(`should commit ${types.UPDATE_VULNERABILITY} with the correct response`, (done) => { it(`should commit ${types.UPDATE_VULNERABILITY} with the correct response`, async () => {
testAction( await testAction(
actions.updateVulnerability, actions.updateVulnerability,
issue, issue,
state, state,
...@@ -26,7 +26,6 @@ describe('EE secret detection report actions', () => { ...@@ -26,7 +26,6 @@ describe('EE secret detection report actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
......
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