diff --git a/awx/ui/src/components/JobList/JobList.js b/awx/ui/src/components/JobList/JobList.js index f86c848cc6..9445e58c52 100644 --- a/awx/ui/src/components/JobList/JobList.js +++ b/awx/ui/src/components/JobList/JobList.js @@ -98,15 +98,14 @@ function JobList({ defaultParams, showTypeColumn = false }) { fetchJobs(); }, [fetchJobs]); - // TODO: update QS_CONFIG to be safe for deps array const fetchJobsById = useCallback( - async (ids) => { - const params = parseQueryString(qsConfig, location.search); + async (ids, qs = {}) => { + const params = parseQueryString(qs, location.search); params.id__in = ids.join(','); const { data } = await UnifiedJobsAPI.read(params); return data.results; }, - [location.search] // eslint-disable-line react-hooks/exhaustive-deps + [location.search] ); const jobs = useWsJobs(results, fetchJobsById, qsConfig); diff --git a/awx/ui/src/components/JobList/JobList.test.js b/awx/ui/src/components/JobList/JobList.test.js index 388592d5c3..69a0ba1ed1 100644 --- a/awx/ui/src/components/JobList/JobList.test.js +++ b/awx/ui/src/components/JobList/JobList.test.js @@ -265,6 +265,61 @@ describe('', () => { jest.restoreAllMocks(); }); + test('should query jobs list after delete API requests', async () => { + UnifiedJobsAPI.read.mockResolvedValue({ + data: { + count: 1, + results: [ + { + id: 1, + url: '/api/v2/project_updates/1', + name: 'job 1', + type: 'project_update', + status: 'running', + related: { + cancel: '/api/v2/project_updates/1/cancel', + }, + summary_fields: { + user_capabilities: { + delete: true, + start: true, + }, + }, + }, + ], + }, + }); + const jobListParams = { + order_by: '-finished', + not__launch_type: 'sync', + page: 1, + page_size: 20, + }; + let wrapper; + await act(async () => { + wrapper = mountWithContexts(); + }); + await waitForLoaded(wrapper); + + act(() => { + expect(UnifiedJobsAPI.read).toHaveBeenCalledTimes(1); + wrapper.find('DataListToolbar').invoke('onSelectAll')(true); + }); + wrapper.update(); + wrapper.find('JobListItem'); + expect( + wrapper.find('ToolbarDeleteButton').prop('itemsToDelete') + ).toHaveLength(1); + + await act(async () => { + wrapper.find('ToolbarDeleteButton').invoke('onDelete')(); + expect(UnifiedJobsAPI.read).toHaveBeenCalledTimes(1); + expect(UnifiedJobsAPI.read).toHaveBeenCalledWith(jobListParams); + }); + + jest.restoreAllMocks(); + }); + test('should display message about job running status', async () => { UnifiedJobsAPI.read.mockResolvedValue({ data: {