From 7e846cc1b6c47d6121ed05c9cb50e05398572343 Mon Sep 17 00:00:00 2001 From: Muslimjon Date: Mon, 12 Feb 2024 13:01:50 +0100 Subject: [PATCH 1/7] feat(RHINENG): limit -1 is removed from template feature codebase --- .../PatchSetWrapper/PatchSetWrapper.js | 7 ++- .../Modals/AssignSystemsModal.js | 17 +++++--- src/SmartComponents/Modals/Helpers.js | 43 +++++++++++-------- .../Modals/UnassignSystemsModal.js | 14 ++++-- .../Systems/SystemsListAssets.js | 4 +- src/SmartComponents/Systems/SystemsTable.js | 3 +- src/Utilities/RemediationPairs.js | 4 +- src/Utilities/hooks/useFetchBatched.js | 17 ++++++-- src/Utilities/hooks/useOnSelect.js | 24 +++++++---- src/Utilities/hooks/usePatchSetState.js | 2 +- 10 files changed, 91 insertions(+), 44 deletions(-) diff --git a/src/PresentationalComponents/PatchSetWrapper/PatchSetWrapper.js b/src/PresentationalComponents/PatchSetWrapper/PatchSetWrapper.js index a72525c58..532c5a8a8 100644 --- a/src/PresentationalComponents/PatchSetWrapper/PatchSetWrapper.js +++ b/src/PresentationalComponents/PatchSetWrapper/PatchSetWrapper.js @@ -5,17 +5,19 @@ import PatchSetWizard from '../../SmartComponents/PatchSetWizard/PatchSetWizard' import UnassignSystemsModal from '../../SmartComponents/Modals/UnassignSystemsModal'; import AssignSystemsModal from '../../SmartComponents/Modals/AssignSystemsModal'; -const PatchSetWrapper = ({ patchSetState, setPatchSetState }) => { +const PatchSetWrapper = ({ patchSetState, setPatchSetState, totalItems }) => { return (<> {(patchSetState.isUnassignSystemsModalOpen) && } {(patchSetState.isPatchSetWizardOpen) && } @@ -24,6 +26,7 @@ const PatchSetWrapper = ({ patchSetState, setPatchSetState }) => { PatchSetWrapper.propTypes = { patchSetState: propTypes.object, - setPatchSetState: propTypes.func + setPatchSetState: propTypes.func, + totalItems: propTypes.number }; export default PatchSetWrapper; diff --git a/src/SmartComponents/Modals/AssignSystemsModal.js b/src/SmartComponents/Modals/AssignSystemsModal.js index 9893a85e1..9d8f24a11 100644 --- a/src/SmartComponents/Modals/AssignSystemsModal.js +++ b/src/SmartComponents/Modals/AssignSystemsModal.js @@ -10,8 +10,10 @@ import { addNotification } from '@redhat-cloud-services/frontend-components-noti import { patchSetAssignSystemsNotifications } from '../PatchSet/PatchSetAssets'; import { filterSelectedActiveSystemIDs } from '../../Utilities/Helpers'; import { filterSatelliteManagedSystems } from './Helpers'; +import { useFetchBatched } from '../../Utilities/hooks'; +import isEmpty from 'lodash/isEmpty'; -const AssignSystemsModal = ({ patchSetState = {}, setPatchSetState, intl }) => { +const AssignSystemsModal = ({ patchSetState = {}, setPatchSetState, intl, totalItems }) => { const dispatch = useDispatch(); const { systemsIDs, isAssignSystemsModalOpen } = patchSetState; @@ -20,6 +22,7 @@ const AssignSystemsModal = ({ patchSetState = {}, setPatchSetState, intl }) => { const [systemsNotManagedBySatellite, setSystemsNotManagedBySatellite] = useState([]); const [systemsLoading, setSystemsLoading] = useState(true); + const { fetchBatched } = useFetchBatched(); const closeModal = () => { setPatchSetState({ @@ -66,10 +69,13 @@ const AssignSystemsModal = ({ patchSetState = {}, setPatchSetState, intl }) => { }; useEffect(() => { - if (systemsIDs) { + if (systemsIDs && !isEmpty(systemsIDs)) { setSystemsLoading(true); - - filterSatelliteManagedSystems(Object.keys(systemsIDs)).then(result => { + filterSatelliteManagedSystems( + Object.keys(systemsIDs), + fetchBatched, + totalItems + ).then(result => { setSystemsNotManagedBySatellite(result); setSystemsLoading(false); }); @@ -144,7 +150,8 @@ const AssignSystemsModal = ({ patchSetState = {}, setPatchSetState, intl }) => { AssignSystemsModal.propTypes = { intl: propTypes.any, setPatchSetState: propTypes.func, - patchSetState: propTypes.object + patchSetState: propTypes.object, + totalItems: propTypes.number }; export default injectIntl(AssignSystemsModal); diff --git a/src/SmartComponents/Modals/Helpers.js b/src/SmartComponents/Modals/Helpers.js index 8b1ea8648..127c1b623 100644 --- a/src/SmartComponents/Modals/Helpers.js +++ b/src/SmartComponents/Modals/Helpers.js @@ -2,28 +2,37 @@ import React from 'react'; import { GridItem } from '@patternfly/react-core'; import messages from '../../Messages'; -import { fetchIDs, fetchSystems } from '../../Utilities/api'; +import { fetchIDs } from '../../Utilities/api'; -export const filterSystemsWithoutSets = (systemsIDs) => { - return fetchSystems({ - limit: -1, 'filter[baseline_name]': 'neq:', - filter: { stale: [true, false] } - }).then((allSystemsWithPatchSet) => { - return systemsIDs.filter(systemID => - allSystemsWithPatchSet?.data?.some(system => system.id === systemID) +const filterChosenSystems = (urlFilter, systemsIDs, fetchBatched, totalItems) => { + return fetchBatched( + (filter) => fetchIDs( + '/ids/systems', + filter + ), + { + ...urlFilter, + filter: { stale: [true, false] } + }, + totalItems, + 100 + ).then((systemsNotManagedBySatellite) => { + const aggregatedResult = systemsNotManagedBySatellite.flatMap(({ data }) => data); + return systemsIDs.filter(systemID =>{ + return aggregatedResult?.some(system => system.id === systemID); + } ); }); }; -export const filterSatelliteManagedSystems = (systemsIDs) => { - return fetchIDs('/ids/systems', { - limit: -1, 'filter[satellite_managed]': 'false', - filter: { stale: [true, false] } - }).then((systemsNotManagedBySatellite) => { - return systemsIDs.filter(systemID => - systemsNotManagedBySatellite?.data?.some(system => system.id === systemID) - ); - }); +export const filterSystemsWithoutSets = (systemsIDs, fetchBatched, totalItems) => { + const urlFilter = { 'filter[baseline_name]': 'neq:' }; + return filterChosenSystems(urlFilter, systemsIDs, fetchBatched, totalItems); +}; + +export const filterSatelliteManagedSystems = (systemsIDs, fetchBatched, totalItems) => { + const urlFilter = { 'filter[satellite_managed]': 'false' }; + return filterChosenSystems(urlFilter, systemsIDs, fetchBatched, totalItems); }; export const renderUnassignModalMessages = (bodyMessage, systemsCount, intl) => ( diff --git a/src/SmartComponents/Modals/UnassignSystemsModal.js b/src/SmartComponents/Modals/UnassignSystemsModal.js index 956957307..600e89273 100644 --- a/src/SmartComponents/Modals/UnassignSystemsModal.js +++ b/src/SmartComponents/Modals/UnassignSystemsModal.js @@ -6,11 +6,13 @@ import { injectIntl } from 'react-intl'; import messages from '../../Messages'; import { useUnassignSystemsHook } from './useUnassignSystemsHook'; import { renderUnassignModalMessages, filterSystemsWithoutSets } from './Helpers'; +import { useFetchBatched } from '../../Utilities/hooks'; -const UnassignSystemsModal = ({ unassignSystemsModalState = {}, setUnassignSystemsModalOpen, intl }) => { +const UnassignSystemsModal = ({ unassignSystemsModalState = {}, setUnassignSystemsModalOpen, intl, totalItems }) => { const { systemsIDs, isUnassignSystemsModalOpen } = unassignSystemsModalState; const [systemsWithPatchSet, setSystemWithPatchSet] = useState([]); const [systemsLoading, setSystemsLoading] = useState(true); + const { fetchBatched } = useFetchBatched(); const handleModalToggle = (shouldRefresh) => { setUnassignSystemsModalOpen({ @@ -29,7 +31,12 @@ const UnassignSystemsModal = ({ unassignSystemsModalState = {}, setUnassignSyste useEffect(() => { setSystemsLoading(true); - filterSystemsWithoutSets(systemsIDs).then(result => { + filterSystemsWithoutSets( + systemsIDs, + fetchBatched, + totalItems + ) + .then(result => { setSystemWithPatchSet(result); setSystemsLoading(false); }); @@ -82,6 +89,7 @@ const UnassignSystemsModal = ({ unassignSystemsModalState = {}, setUnassignSyste UnassignSystemsModal.propTypes = { intl: propTypes.any, setUnassignSystemsModalOpen: propTypes.func, - unassignSystemsModalState: propTypes.object + unassignSystemsModalState: propTypes.object, + totalItems: propTypes.number }; export default injectIntl(UnassignSystemsModal); diff --git a/src/SmartComponents/Systems/SystemsListAssets.js b/src/SmartComponents/Systems/SystemsListAssets.js index 15d17dd4b..cacb631c6 100644 --- a/src/SmartComponents/Systems/SystemsListAssets.js +++ b/src/SmartComponents/Systems/SystemsListAssets.js @@ -180,8 +180,8 @@ export const useActivateRemediationModal = (setRemediationIssues, setRemediation fetchBatched( (__, pagination) => fetchApplicableSystemAdvisoriesApi({ ...filter, ...pagination }), - totalCount, - filter + filter, + totalCount ).then(response => { const advisories = response.flatMap(({ data }) => data); const remediationIssues = remediationProvider( diff --git a/src/SmartComponents/Systems/SystemsTable.js b/src/SmartComponents/Systems/SystemsTable.js index 6211669b5..c3a3a3e96 100644 --- a/src/SmartComponents/Systems/SystemsTable.js +++ b/src/SmartComponents/Systems/SystemsTable.js @@ -85,7 +85,8 @@ const SystemsTable = ({ { endpoint: ID_API_ENDPOINTS.systems, queryParams, - selectionDispatcher: systemSelectAction + selectionDispatcher: systemSelectAction, + totalItems } ); diff --git a/src/Utilities/RemediationPairs.js b/src/Utilities/RemediationPairs.js index c7080b0bf..958325759 100644 --- a/src/Utilities/RemediationPairs.js +++ b/src/Utilities/RemediationPairs.js @@ -1,7 +1,7 @@ import chunk from 'lodash/chunk'; -const REQUEST_CHUNK_SIZE = 1000; -const BATCH_REQUEST_SIZE = 5; +const REQUEST_CHUNK_SIZE = 100; +const BATCH_REQUEST_SIZE = 10; const REQUEST_INTERVAL = 15000; //15 seconds. AKAMAI allowed life for 5 API calls const fetchDataCallback = (endpoint, authToken) => (input) => { diff --git a/src/Utilities/hooks/useFetchBatched.js b/src/Utilities/hooks/useFetchBatched.js index 63fd1fa86..87679d2d9 100644 --- a/src/Utilities/hooks/useFetchBatched.js +++ b/src/Utilities/hooks/useFetchBatched.js @@ -5,14 +5,25 @@ export const useFetchBatched = () => { return { isLoading, - fetchBatched: (fetchFunction, total, filter, batchSize = 50) => { + fetchBatched: async (fetchFunction, filter, total, batchSize = 50) => { + if (!total) { + total = await fetchFunction({ limit: 1 }).then( + response => response?.meta?.total_items || 0 + ); + } + const pages = Math.ceil(total / batchSize) || 1; const results = resolve( [...new Array(pages)].map( // eslint-disable-next-line camelcase - (_, pageIdx) => () => - fetchFunction(filter, { offset: pageIdx + 1, limit: batchSize }) + (_, pageIdx) => () => { + return fetchFunction({ + ...filter, + offset: pageIdx * batchSize, + limit: batchSize + }); + } ) ); diff --git a/src/Utilities/hooks/useOnSelect.js b/src/Utilities/hooks/useOnSelect.js index 0c1f9c72b..b0c8205ff 100644 --- a/src/Utilities/hooks/useOnSelect.js +++ b/src/Utilities/hooks/useOnSelect.js @@ -3,6 +3,7 @@ import { useDispatch } from 'react-redux'; import { fetchIDs } from '../api'; import { toggleAllSelectedAction } from '../../store/Actions/Actions'; import { isObject } from '../Helpers'; +import { useFetchBatched } from './useFetchBatched'; export const ID_API_ENDPOINTS = { advisories: '/ids/advisories', @@ -17,15 +18,21 @@ export const ID_API_ENDPOINTS = { const useFetchAllIDs = ( endpoint, - apiResponseTransformer -) => - useCallback((queryParams) => - fetchIDs(endpoint, { ...queryParams, limit: -1 }) + apiResponseTransformer, + totalItems +) => { + const { fetchBatched } = useFetchBatched(); + return useCallback((queryParams) => + fetchBatched( + (__, pagination) => fetchIDs(endpoint, { ...queryParams, ...pagination }), + totalItems, + queryParams + ) .then(response => apiResponseTransformer ? apiResponseTransformer(response) : response ), - [] - ); + [totalItems, endpoint]); +}; const useCreateSelectedRow = (transformKey, constructFilename) => useCallback((rows, toSelect = []) => { @@ -103,11 +110,12 @@ export const useOnSelect = (rawData, selectedRows, config) => { transformKey, apiResponseTransformer, //TODO: get rid of this custom selector - customSelector + customSelector, + totalItems } = config; const dispatch = useDispatch(); - const fetchIDs = useFetchAllIDs(endpoint, apiResponseTransformer); + const fetchIDs = useFetchAllIDs(endpoint, apiResponseTransformer, totalItems); const createSelectedRow = useCreateSelectedRow(transformKey, constructFilename); const toggleAllSystemsSelected = (flagState) => { diff --git a/src/Utilities/hooks/usePatchSetState.js b/src/Utilities/hooks/usePatchSetState.js index 0251b3b5c..b730c0fbc 100644 --- a/src/Utilities/hooks/usePatchSetState.js +++ b/src/Utilities/hooks/usePatchSetState.js @@ -14,7 +14,7 @@ export const usePatchSetState = (selectedRows) => { isUnassignSystemsModalOpen: false, isAssignSystemsModalOpen: false, shouldRefresh: false, - systemsIDs: [] + systemsIDs: {} }); const openPatchSetAssignWizard = (systemID) => { From 52cc823345014fac86d8449a315caf35847cc79a Mon Sep 17 00:00:00 2001 From: Muslimjon Date: Thu, 15 Feb 2024 21:30:04 +0100 Subject: [PATCH 2/7] feat(RHINENG): limit -1 is removed from table row selection --- config/dev.webpack.config.js | 2 +- src/SmartComponents/Advisories/Advisories.js | 3 +- .../AdvisorySystems/AdvisorySystems.js | 3 +- .../PackageSystems/PackageSystems.js | 3 +- src/SmartComponents/PatchSet/PatchSet.js | 3 +- .../SystemPackages/SystemPackages.js | 3 +- .../Systems/SystemsListAssets.js | 2 +- .../Systems/SystemsMainContent.js | 6 +++- src/Utilities/hooks/useOnSelect.js | 28 ++++++++++++------- 9 files changed, 35 insertions(+), 18 deletions(-) diff --git a/config/dev.webpack.config.js b/config/dev.webpack.config.js index 2b455152e..2bcb07e20 100644 --- a/config/dev.webpack.config.js +++ b/config/dev.webpack.config.js @@ -7,7 +7,7 @@ const proxyConfiguration = { useProxy: process.env.PROXY === 'true', appUrl: process.env.BETA ? ['/beta/insights/patch', '/preview/insights/patch'] : ['/insights/patch'], deployment: process.env.BETA ? 'beta/apps' : 'apps', - env: process.env.BETA ? 'stage-beta' : 'stage-stable', + env: process.env.BETA ? 'prod-beta' : 'prod-stable', proxyVerbose: true, debug: true }; diff --git a/src/SmartComponents/Advisories/Advisories.js b/src/SmartComponents/Advisories/Advisories.js index 6d27e2def..6144d2fb3 100644 --- a/src/SmartComponents/Advisories/Advisories.js +++ b/src/SmartComponents/Advisories/Advisories.js @@ -100,7 +100,8 @@ const Advisories = () => { { endpoint: ID_API_ENDPOINTS.advisories, queryParams, - selectionDispatcher: selectAdvisoryRow + selectionDispatcher: selectAdvisoryRow, + totalItems: metadata?.total_items } ); diff --git a/src/SmartComponents/AdvisorySystems/AdvisorySystems.js b/src/SmartComponents/AdvisorySystems/AdvisorySystems.js index 0052b4064..957095518 100644 --- a/src/SmartComponents/AdvisorySystems/AdvisorySystems.js +++ b/src/SmartComponents/AdvisorySystems/AdvisorySystems.js @@ -102,7 +102,8 @@ const AdvisorySystems = ({ advisoryName }) => { { endpoint: ID_API_ENDPOINTS.advisorySystems(advisoryName), queryParams, - selectionDispatcher: systemSelectAction + selectionDispatcher: systemSelectAction, + totalItems } ); diff --git a/src/SmartComponents/PackageSystems/PackageSystems.js b/src/SmartComponents/PackageSystems/PackageSystems.js index 7c1a6b078..4ba3ac2b2 100644 --- a/src/SmartComponents/PackageSystems/PackageSystems.js +++ b/src/SmartComponents/PackageSystems/PackageSystems.js @@ -100,7 +100,8 @@ const PackageSystems = ({ packageName }) => { queryParams, selectionDispatcher: systemSelectAction, constructFilename, - apiResponseTransformer: filterRemediatablePackageSystems + apiResponseTransformer: filterRemediatablePackageSystems, + totalItems } ); diff --git a/src/SmartComponents/PatchSet/PatchSet.js b/src/SmartComponents/PatchSet/PatchSet.js index d18ff445f..2ce399f90 100644 --- a/src/SmartComponents/PatchSet/PatchSet.js +++ b/src/SmartComponents/PatchSet/PatchSet.js @@ -106,7 +106,8 @@ const PatchSet = () => { { endpoint: ID_API_ENDPOINTS.templates, queryParams, - selectionDispatcher: selectPatchSetRow + selectionDispatcher: selectPatchSetRow, + totalItems: metadata.total_items } ); diff --git a/src/SmartComponents/SystemPackages/SystemPackages.js b/src/SmartComponents/SystemPackages/SystemPackages.js index aff183613..4004cc68a 100644 --- a/src/SmartComponents/SystemPackages/SystemPackages.js +++ b/src/SmartComponents/SystemPackages/SystemPackages.js @@ -78,7 +78,8 @@ const SystemPackages = ({ handleNoSystemData, inventoryId, shouldRefresh }) => { queryParams, selectionDispatcher: selectSystemPackagesRow, constructFilename, - transformKey + transformKey, + totalItems: metadata?.total_items } ); diff --git a/src/SmartComponents/Systems/SystemsListAssets.js b/src/SmartComponents/Systems/SystemsListAssets.js index cacb631c6..413e9274c 100644 --- a/src/SmartComponents/Systems/SystemsListAssets.js +++ b/src/SmartComponents/Systems/SystemsListAssets.js @@ -179,7 +179,7 @@ export const useActivateRemediationModal = (setRemediationIssues, setRemediation ); fetchBatched( - (__, pagination) => fetchApplicableSystemAdvisoriesApi({ ...filter, ...pagination }), + (filterWithPagination) => fetchApplicableSystemAdvisoriesApi(filterWithPagination), filter, totalCount ).then(response => { diff --git a/src/SmartComponents/Systems/SystemsMainContent.js b/src/SmartComponents/Systems/SystemsMainContent.js index 74214d1d4..dac67ac89 100644 --- a/src/SmartComponents/Systems/SystemsMainContent.js +++ b/src/SmartComponents/Systems/SystemsMainContent.js @@ -58,7 +58,11 @@ const SystemsMainContent = () => { return ( - + {isRemediationOpen && { const { fetchBatched } = useFetchBatched(); - return useCallback((queryParams) => - fetchBatched( - (__, pagination) => fetchIDs(endpoint, { ...queryParams, ...pagination }), + return useCallback(async (queryParams) => { + const response = await fetchBatched( + (filter) => fetchIDs(endpoint, filter), + queryParams, totalItems, - queryParams - ) - .then(response => - apiResponseTransformer ? apiResponseTransformer(response) : response - ), + 100 + ); + + const aggregatedResponse = response.reduce((accumulator = {}, currentValue) => { + Object.keys(accumulator).forEach(key => { + accumulator[key] = accumulator[key].concat(currentValue[key]); + }); + + return accumulator; + }, { data: [], ids: [] }); + + return apiResponseTransformer ? apiResponseTransformer(aggregatedResponse) : aggregatedResponse; + }, [totalItems, endpoint]); }; const useCreateSelectedRow = (transformKey, constructFilename) => useCallback((rows, toSelect = []) => { const { ids, data } = rows; - const shouldUseOnlyIDs = Array.isArray(ids); + const shouldUseOnlyIDs = !data; const items = shouldUseOnlyIDs ? ids : data; items.forEach((item) => { @@ -86,7 +95,6 @@ const createSelectors = ( }; const selectAll = (fetchIDs, queryParams) => { - queryParams.offset = 0; return fetchIDs(queryParams).then(response => { if (Array.isArray(response.data)) { let rowsToSelect = response.data.filter(row => row.status !== 'Applicable'); From 66891d33394e445deedc6c676819acc4b0c637eb Mon Sep 17 00:00:00 2001 From: Muslimjon Date: Fri, 16 Feb 2024 14:07:11 +0100 Subject: [PATCH 3/7] chore(test): fix tests --- config/dev.webpack.config.js | 2 +- .../PatchSetWrapper/PatchSetWrapper.test.js | 4 +- .../Advisories/Advisories.test.js | 4 +- .../AdvisorySystems/AdvisorySystem.test.js | 4 +- .../Modals/UnassignSystemsModal.test.js | 2 +- .../PackageSystems/PackageSystems.test.js | 2 +- .../SystemPackages/SystemPackages.test.js | 2 +- .../__snapshots__/SystemPackages.test.js.snap | 2130 +++++++++++++++++ src/Utilities/hooks/useOnSelect.test.js | 24 +- 9 files changed, 2157 insertions(+), 17 deletions(-) create mode 100644 src/SmartComponents/SystemPackages/__snapshots__/SystemPackages.test.js.snap diff --git a/config/dev.webpack.config.js b/config/dev.webpack.config.js index 2bcb07e20..2b455152e 100644 --- a/config/dev.webpack.config.js +++ b/config/dev.webpack.config.js @@ -7,7 +7,7 @@ const proxyConfiguration = { useProxy: process.env.PROXY === 'true', appUrl: process.env.BETA ? ['/beta/insights/patch', '/preview/insights/patch'] : ['/insights/patch'], deployment: process.env.BETA ? 'beta/apps' : 'apps', - env: process.env.BETA ? 'prod-beta' : 'prod-stable', + env: process.env.BETA ? 'stage-beta' : 'stage-stable', proxyVerbose: true, debug: true }; diff --git a/src/PresentationalComponents/PatchSetWrapper/PatchSetWrapper.test.js b/src/PresentationalComponents/PatchSetWrapper/PatchSetWrapper.test.js index 2f55ca9e0..0cddd0d41 100644 --- a/src/PresentationalComponents/PatchSetWrapper/PatchSetWrapper.test.js +++ b/src/PresentationalComponents/PatchSetWrapper/PatchSetWrapper.test.js @@ -5,6 +5,7 @@ import { mountWithRouterAndProviderAndIntl } from '../../../config/rtlwrapper'; jest.mock('../../SmartComponents/PatchSetWizard/PatchSetWizard', () => () =>
); jest.mock('../../SmartComponents/Modals/UnassignSystemsModal', () => () =>
); +jest.mock('../../SmartComponents/Modals/AssignSystemsModal', () => () =>
); const mockState = {}; @@ -28,7 +29,8 @@ const testProps = { isPatchSetWizardOpen: true, systemsIDs: ['system-1', 'system-2'] }, - setPatchSetState: jest.fn() + setPatchSetState: jest.fn(), + totalItems: 101 }; describe('PatchSetWrapper', () => { it('should display PatchSetWizard when isPatchSetWizardOpen prop is true', () => { diff --git a/src/SmartComponents/Advisories/Advisories.test.js b/src/SmartComponents/Advisories/Advisories.test.js index f9c42a1dd..9f8657660 100644 --- a/src/SmartComponents/Advisories/Advisories.test.js +++ b/src/SmartComponents/Advisories/Advisories.test.js @@ -24,7 +24,7 @@ jest.mock('../../Utilities/api', () => ({ exportAdvisoriesCSV: jest.fn(() => Promise.resolve({ success: true }).catch((err) => console.log(err))), fetchSystems: jest.fn(() => Promise.resolve({ data: { id: 'testId' } }).catch((err) => console.log(err))), fetchViewAdvisoriesSystems: jest.fn(() => Promise.resolve({ success: true }).catch((err) => console.log(err))), - fetchIDs: jest.fn(() => Promise.resolve({ ids: [] }).catch((err) => console.log(err))), + fetchIDs: jest.fn(() => Promise.resolve({ data: [{ id: 'test_id-1' }] }).catch((err) => console.log(err))), fetchApplicableAdvisoriesApi: jest.fn(() => Promise.resolve({ success: true }).catch((err) => console.log(err))) })); @@ -52,7 +52,7 @@ const mockState = { ...storeListDefaults, metadata: { limit: 25, offset: 0, - total_items: 10 + total_items: 101 } }; diff --git a/src/SmartComponents/AdvisorySystems/AdvisorySystem.test.js b/src/SmartComponents/AdvisorySystems/AdvisorySystem.test.js index cf7c415e6..fd8fbe583 100644 --- a/src/SmartComponents/AdvisorySystems/AdvisorySystem.test.js +++ b/src/SmartComponents/AdvisorySystems/AdvisorySystem.test.js @@ -11,7 +11,7 @@ initMocks(); jest.mock('../../Utilities/api', () => ({ ...jest.requireActual('../../Utilities/api'), - fetchIDs: jest.fn(() => Promise.resolve({ ids: [] }).catch((err) => console.log(err))) + fetchIDs: jest.fn(() => Promise.resolve({ data: [{ id: 'test_id-1' }] }).catch((err) => console.log(err))) })); jest.mock( @@ -30,7 +30,7 @@ const mockState = { selectedRows: { 'test-system-1': true }, error: {}, status: 'resolved', - total: 2 + total: 101 }, AdvisorySystemsStore: { queryParams: {} diff --git a/src/SmartComponents/Modals/UnassignSystemsModal.test.js b/src/SmartComponents/Modals/UnassignSystemsModal.test.js index 1d5a76b8f..f3ca13551 100644 --- a/src/SmartComponents/Modals/UnassignSystemsModal.test.js +++ b/src/SmartComponents/Modals/UnassignSystemsModal.test.js @@ -12,7 +12,7 @@ initMocks(); jest.mock('../../Utilities/api', () => ({ ...jest.requireActual('../../Utilities/api'), unassignSystemFromPatchSet: jest.fn(), - fetchSystems: jest.fn() + fetchIDs: jest.fn(() => Promise.resolve({ data: [{ id: 'test_1' }] })) })); jest.mock('react-redux', () => ({ diff --git a/src/SmartComponents/PackageSystems/PackageSystems.test.js b/src/SmartComponents/PackageSystems/PackageSystems.test.js index 09b8630b7..d01f78740 100644 --- a/src/SmartComponents/PackageSystems/PackageSystems.test.js +++ b/src/SmartComponents/PackageSystems/PackageSystems.test.js @@ -47,7 +47,7 @@ const mockState = { selectedRows: { 'test-system-1': 'packageEvra' }, error: {}, status: 'resolved', - total: 2 + total: 101 }, PackageSystemsStore: { queryParams: {} diff --git a/src/SmartComponents/SystemPackages/SystemPackages.test.js b/src/SmartComponents/SystemPackages/SystemPackages.test.js index f9b88960c..1941ea4e0 100644 --- a/src/SmartComponents/SystemPackages/SystemPackages.test.js +++ b/src/SmartComponents/SystemPackages/SystemPackages.test.js @@ -53,7 +53,7 @@ const mockState = { metadata: { limit: 25, offset: 0, - total_items: 10 + total_items: 101 } }; diff --git a/src/SmartComponents/SystemPackages/__snapshots__/SystemPackages.test.js.snap b/src/SmartComponents/SystemPackages/__snapshots__/SystemPackages.test.js.snap new file mode 100644 index 000000000..4a434d326 --- /dev/null +++ b/src/SmartComponents/SystemPackages/__snapshots__/SystemPackages.test.js.snap @@ -0,0 +1,2130 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`SystemPackages.js Should match the snapshots 1`] = ` + +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+ +
+
+
+ + +
+
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+