foreman_rh_cloud 13.2.11 → 14.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/foreman_rh_cloud/locale/fr/foreman_rh_cloud.js +61 -61
- data/app/assets/javascripts/foreman_rh_cloud/locale/ja/foreman_rh_cloud.js +68 -68
- data/app/assets/javascripts/foreman_rh_cloud/locale/ka/foreman_rh_cloud.js +9 -9
- data/app/assets/javascripts/foreman_rh_cloud/locale/ko/foreman_rh_cloud.js +60 -60
- data/app/assets/javascripts/foreman_rh_cloud/locale/zh_CN/foreman_rh_cloud.js +60 -60
- data/app/controllers/concerns/insights_cloud/package_profile_upload_extensions.rb +0 -9
- data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +10 -13
- data/app/controllers/insights_cloud/ui_requests_controller.rb +7 -3
- data/app/models/concerns/rh_cloud_host.rb +4 -71
- data/app/models/insights_client_report_status.rb +1 -9
- data/app/models/inventory_sync/inventory_status.rb +4 -16
- data/app/services/foreman_rh_cloud/insights_api_forwarder.rb +5 -12
- data/app/services/foreman_rh_cloud/url_remediations_retriever.rb +5 -19
- data/lib/foreman_inventory_upload/async/create_missing_insights_facets.rb +2 -8
- data/lib/foreman_inventory_upload/async/upload_report_direct_job.rb +0 -2
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +4 -34
- data/lib/foreman_inventory_upload/generators/queries.rb +1 -1
- data/lib/foreman_inventory_upload/generators/slice.rb +1 -1
- data/lib/foreman_inventory_upload.rb +1 -8
- data/lib/foreman_rh_cloud/engine.rb +0 -1
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/foreman_rh_cloud.rb +9 -36
- data/lib/insights_cloud/async/insights_generate_notifications.rb +1 -10
- data/lib/insights_cloud/async/vmaas_reposcan_sync.rb +8 -23
- data/lib/inventory_sync/async/inventory_full_sync.rb +3 -39
- data/lib/inventory_sync/async/inventory_self_host_sync.rb +2 -12
- data/locale/fr/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/fr/foreman_rh_cloud.edit.po +1032 -0
- data/locale/fr/foreman_rh_cloud.po +65 -66
- data/locale/fr/foreman_rh_cloud.po.time_stamp +0 -0
- data/locale/ja/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/ja/foreman_rh_cloud.edit.po +1026 -0
- data/locale/ja/foreman_rh_cloud.po +70 -72
- data/locale/ja/foreman_rh_cloud.po.time_stamp +0 -0
- data/locale/ka/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/ka/foreman_rh_cloud.edit.po +1025 -0
- data/locale/ka/foreman_rh_cloud.po +10 -11
- data/locale/ka/foreman_rh_cloud.po.time_stamp +0 -0
- data/locale/ko/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/ko/foreman_rh_cloud.edit.po +1029 -0
- data/locale/ko/foreman_rh_cloud.po +63 -64
- data/locale/ko/foreman_rh_cloud.po.time_stamp +0 -0
- data/locale/zh_CN/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/zh_CN/foreman_rh_cloud.edit.po +1031 -0
- data/locale/zh_CN/foreman_rh_cloud.po +64 -65
- data/locale/zh_CN/foreman_rh_cloud.po.time_stamp +0 -0
- data/package.json +1 -1
- data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +3 -57
- data/test/controllers/insights_cloud/ui_requests_controller_test.rb +2 -16
- data/test/jobs/insights_client_status_aging_test.rb +0 -40
- data/test/jobs/inventory_full_sync_test.rb +4 -219
- data/test/jobs/inventory_hosts_sync_test.rb +5 -7
- data/test/jobs/inventory_self_host_sync_test.rb +1 -10
- data/test/jobs/upload_report_direct_job_test.rb +0 -29
- data/test/models/insights_client_report_status_test.rb +0 -109
- data/test/unit/archived_report_generator_test.rb +1 -2
- data/test/unit/fact_helpers_test.rb +0 -16
- data/test/unit/foreman_rh_cloud_self_host_test.rb +2 -50
- data/test/unit/insights_facet_test.rb +0 -5
- data/test/unit/lib/insights_cloud/async/vmaas_reposcan_sync_test.rb +25 -80
- data/test/unit/metadata_generator_test.rb +1 -24
- data/test/unit/rh_cloud_host_test.rb +0 -282
- data/test/unit/services/foreman_rh_cloud/branch_info_test.rb +1 -1
- data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +1 -1
- data/test/unit/services/foreman_rh_cloud/url_remediations_retriever_test.rb +5 -82
- data/test/unit/slice_generator_test.rb +2 -21
- data/webpack/CVEsHostDetailsTab/CVEsHostDetailsTab.js +3 -30
- data/webpack/CVEsHostDetailsTab/__tests__/CVEsHostDetailsTab.test.js +10 -112
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/EmptyResults.test.js +9 -10
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/__snapshots__/EmptyResults.test.js.snap +18 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/EmptyState.test.js +9 -13
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/__snapshots__/EmptyState.test.js.snap +25 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/ErrorState.test.js +9 -20
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/__snapshots__/ErrorState.test.js.snap +20 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/ListItem.test.js +8 -31
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +47 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/ListItemStatus.test.js +10 -26
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/__snapshots__/ListItemStatus.test.js.snap +59 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +9 -33
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +34 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +35 -55
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +25 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +49 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +86 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +75 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +46 -0
- data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/FileDownload.test.js +9 -13
- data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/__snapshots__/FileDownload.test.js.snap +26 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilter.test.js +15 -12
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterActions.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js +28 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterSelectors.test.js +21 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilter.test.js.snap +21 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterActions.test.js.snap +17 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterReducer.test.js.snap +19 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterSelectors.test.js.snap +9 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +43 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/integration.test.js +12 -32
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/__tests__/AdvancedSettingActions.test.js +9 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/__tests__/__snapshots__/AdvancedSettingActions.test.js.snap +18 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/InventorySettingsActions.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettingsActions.test.js.snap +26 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageTitle.test.js +7 -15
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +68 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorActions.test.js +9 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorButton.test.js +18 -47
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorActions.test.js.snap +11 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorButton.test.js.snap +59 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +1 -3
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.test.js +15 -58
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/__snapshots__/SettingsWarning.test.js.snap +32 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +2 -8
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +9 -23
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonSelectors.test.js +17 -19
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +15 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonSelectors.test.js.snap +3 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/integrations.test.js.snap +57 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js +36 -25
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Toast.js +17 -43
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/ScheduledRun.test.js +8 -28
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/__snapshots__/ScheduledRun.test.js.snap +23 -0
- data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/StatusChart.test.js +8 -25
- data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/__snapshots__/StatusChart.test.js.snap +74 -0
- data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/TabContainer.test.js +9 -11
- data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/__snapshots__/TabContainer.test.js.snap +18 -0
- data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/TabFooter.test.js +9 -11
- data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/__snapshots__/TabFooter.test.js.snap +12 -0
- data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +1 -8
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/InventoryAutoUpload.test.js +12 -33
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/__snapshots__/InventoryAutoUpload.test.js.snap +96 -0
- data/webpack/ForemanInventoryUpload/__tests__/ForemanInventoryHelpers.test.js +8 -36
- data/webpack/ForemanInventoryUpload/__tests__/ForemanInventoryUpload.test.js +10 -0
- data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap +5 -0
- data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryUpload.test.js.snap +14 -0
- data/webpack/ForemanRhCloudHelpers.js +0 -22
- data/webpack/InsightsHostDetailsTab/NewHostDetailsTab.js +15 -71
- metadata +57 -18
- data/app/controllers/concerns/insights_cloud/candlepin_proxies_extensions.rb +0 -23
- data/test/controllers/insights_cloud/candlepin_proxies_extensions_test.rb +0 -70
- data/test/jobs/insights_generate_notifications_test.rb +0 -26
- data/test/models/inventory_sync/inventory_status_test.rb +0 -85
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/__tests__/Toast.test.js +0 -82
- data/webpack/InsightsHostDetailsTab/__tests__/NewHostDetailsTab.test.js +0 -266
|
@@ -3,10 +3,6 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import { ScalprumComponent, ScalprumProvider } from '@scalprum/react-core';
|
|
4
4
|
import { createProviderOptions } from '../common/ScalprumModule/ScalprumContext';
|
|
5
5
|
import { useInsightsPermissions } from '../common/Hooks/PermissionsHooks';
|
|
6
|
-
import {
|
|
7
|
-
vulnerabilityDisabled,
|
|
8
|
-
useTabRedirect,
|
|
9
|
-
} from '../ForemanRhCloudHelpers';
|
|
10
6
|
import './CVEsHostDetailsTab.scss';
|
|
11
7
|
|
|
12
8
|
const CVEsHostDetailsTab = ({ systemId }) => {
|
|
@@ -14,12 +10,7 @@ const CVEsHostDetailsTab = ({ systemId }) => {
|
|
|
14
10
|
const module = './SystemDetailTable';
|
|
15
11
|
return (
|
|
16
12
|
<div className="rh-cloud-insights-vulnerability-host-details-component vulnerability">
|
|
17
|
-
<ScalprumComponent
|
|
18
|
-
key={systemId}
|
|
19
|
-
scope={scope}
|
|
20
|
-
module={module}
|
|
21
|
-
systemId={systemId}
|
|
22
|
-
/>
|
|
13
|
+
<ScalprumComponent scope={scope} module={module} systemId={systemId} />
|
|
23
14
|
</div>
|
|
24
15
|
);
|
|
25
16
|
};
|
|
@@ -30,15 +21,6 @@ CVEsHostDetailsTab.propTypes = {
|
|
|
30
21
|
|
|
31
22
|
const CVEsHostDetailsTabWrapper = ({ response }) => {
|
|
32
23
|
const permissions = useInsightsPermissions();
|
|
33
|
-
const isHostDataLoaded = Boolean(response?.id);
|
|
34
|
-
const shouldHideTab = useTabRedirect(
|
|
35
|
-
isHostDataLoaded && vulnerabilityDisabled({ hostDetails: response })
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
if (shouldHideTab) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
24
|
return (
|
|
43
25
|
<ScalprumProvider {...createProviderOptions(permissions)}>
|
|
44
26
|
<CVEsHostDetailsTab
|
|
@@ -51,19 +33,10 @@ const CVEsHostDetailsTabWrapper = ({ response }) => {
|
|
|
51
33
|
|
|
52
34
|
CVEsHostDetailsTabWrapper.propTypes = {
|
|
53
35
|
response: PropTypes.shape({
|
|
54
|
-
id: PropTypes.number,
|
|
55
|
-
operatingsystem_name: PropTypes.string,
|
|
56
|
-
vulnerability: PropTypes.shape({
|
|
57
|
-
enabled: PropTypes.bool,
|
|
58
|
-
}),
|
|
59
36
|
subscription_facet_attributes: PropTypes.shape({
|
|
60
|
-
uuid: PropTypes.string,
|
|
37
|
+
uuid: PropTypes.string.isRequired,
|
|
61
38
|
}),
|
|
62
|
-
}),
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
CVEsHostDetailsTabWrapper.defaultProps = {
|
|
66
|
-
response: {},
|
|
39
|
+
}).isRequired,
|
|
67
40
|
};
|
|
68
41
|
|
|
69
42
|
export default CVEsHostDetailsTabWrapper;
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
|
-
import { MemoryRouter } from 'react-router-dom';
|
|
4
3
|
import CVEsHostDetailsTabWrapper from '../CVEsHostDetailsTab';
|
|
5
|
-
import { OVERVIEW_TAB_PATH } from '../../ForemanRhCloudHelpers';
|
|
6
|
-
|
|
7
|
-
const mockHistoryReplace = jest.fn();
|
|
8
|
-
|
|
9
|
-
jest.mock('react-router-dom', () => ({
|
|
10
|
-
...jest.requireActual('react-router-dom'),
|
|
11
|
-
useHistory: () => ({
|
|
12
|
-
replace: mockHistoryReplace,
|
|
13
|
-
}),
|
|
14
|
-
}));
|
|
15
4
|
|
|
16
5
|
jest.mock('foremanReact/Root/Context/ForemanContext', () => ({
|
|
17
6
|
useForemanContext: () => ({
|
|
@@ -22,115 +11,24 @@ jest.mock('foremanReact/Root/Context/ForemanContext', () => ({
|
|
|
22
11
|
useForemanPermissions: () => new Set(['view_vulnerability']),
|
|
23
12
|
}));
|
|
24
13
|
|
|
25
|
-
|
|
26
|
-
jest.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<div data-testid="mock-scalprum-component">{JSON.stringify(props)}</div>
|
|
33
|
-
);
|
|
34
|
-
}),
|
|
35
|
-
ScalprumProvider: jest.fn(({ children }) => <div>{children}</div>),
|
|
36
|
-
};
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const defaultResponse = {
|
|
40
|
-
id: 1,
|
|
41
|
-
operatingsystem_name: 'Red Hat Enterprise Linux 8',
|
|
42
|
-
vulnerability: { enabled: true },
|
|
43
|
-
subscription_facet_attributes: { uuid: '1-2-3' },
|
|
44
|
-
};
|
|
14
|
+
jest.mock('@scalprum/react-core', () => ({
|
|
15
|
+
ScalprumComponent: jest.fn(props => (
|
|
16
|
+
<div data-testid="mock-scalprum-component">{JSON.stringify(props)}</div>
|
|
17
|
+
)),
|
|
18
|
+
ScalprumProvider: jest.fn(({ children }) => <div>{children}</div>),
|
|
19
|
+
}));
|
|
45
20
|
|
|
46
21
|
describe('CVEsHostDetailsTabWrapper', () => {
|
|
47
|
-
|
|
48
|
-
jest.clearAllMocks();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('renders without crashing and does not redirect for valid host', () => {
|
|
22
|
+
it('renders without crashing', () => {
|
|
52
23
|
const { container } = render(
|
|
53
|
-
<
|
|
54
|
-
|
|
55
|
-
|
|
24
|
+
<CVEsHostDetailsTabWrapper
|
|
25
|
+
response={{ subscription_facet_attributes: { uuid: '1-2-3' } }}
|
|
26
|
+
/>
|
|
56
27
|
);
|
|
57
28
|
expect(
|
|
58
29
|
container.querySelector(
|
|
59
30
|
'.rh-cloud-insights-vulnerability-host-details-component'
|
|
60
31
|
)
|
|
61
32
|
).toBeTruthy();
|
|
62
|
-
expect(mockHistoryReplace).not.toHaveBeenCalled();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('remounts ScalprumComponent when systemId changes', () => {
|
|
66
|
-
const { ScalprumComponent } = require('@scalprum/react-core');
|
|
67
|
-
|
|
68
|
-
const responseHostA = {
|
|
69
|
-
...defaultResponse,
|
|
70
|
-
subscription_facet_attributes: { uuid: 'uuid-host-A' },
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const { rerender } = render(
|
|
74
|
-
<MemoryRouter>
|
|
75
|
-
<CVEsHostDetailsTabWrapper response={responseHostA} />
|
|
76
|
-
</MemoryRouter>
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
expect(mockUnmountTracker).not.toHaveBeenCalled();
|
|
80
|
-
expect(ScalprumComponent).toHaveBeenLastCalledWith(
|
|
81
|
-
expect.objectContaining({ systemId: 'uuid-host-A' }),
|
|
82
|
-
expect.anything()
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
const responseHostB = {
|
|
86
|
-
...defaultResponse,
|
|
87
|
-
subscription_facet_attributes: { uuid: 'uuid-host-B' },
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
rerender(
|
|
91
|
-
<MemoryRouter>
|
|
92
|
-
<CVEsHostDetailsTabWrapper response={responseHostB} />
|
|
93
|
-
</MemoryRouter>
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
expect(mockUnmountTracker).toHaveBeenCalledTimes(1);
|
|
97
|
-
expect(ScalprumComponent).toHaveBeenLastCalledWith(
|
|
98
|
-
expect.objectContaining({ systemId: 'uuid-host-B' }),
|
|
99
|
-
expect.anything()
|
|
100
|
-
);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('redirects to Overview when tab should be hidden', () => {
|
|
104
|
-
const nonRhelResponse = {
|
|
105
|
-
id: 2,
|
|
106
|
-
operatingsystem_name: 'Ubuntu 20.04',
|
|
107
|
-
vulnerability: { enabled: false },
|
|
108
|
-
subscription_facet_attributes: { uuid: '1-2-3' },
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const { container } = render(
|
|
112
|
-
<MemoryRouter>
|
|
113
|
-
<CVEsHostDetailsTabWrapper response={nonRhelResponse} />
|
|
114
|
-
</MemoryRouter>
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
expect(mockHistoryReplace).toHaveBeenCalledWith(OVERVIEW_TAB_PATH);
|
|
118
|
-
expect(
|
|
119
|
-
container.querySelector(
|
|
120
|
-
'.rh-cloud-insights-vulnerability-host-details-component'
|
|
121
|
-
)
|
|
122
|
-
).toBeNull();
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('does not redirect when host data is not yet loaded', () => {
|
|
126
|
-
const emptyResponse = { subscription_facet_attributes: { uuid: '1-2-3' } };
|
|
127
|
-
|
|
128
|
-
render(
|
|
129
|
-
<MemoryRouter>
|
|
130
|
-
<CVEsHostDetailsTabWrapper response={emptyResponse} />
|
|
131
|
-
</MemoryRouter>
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
expect(mockHistoryReplace).not.toHaveBeenCalled();
|
|
135
33
|
});
|
|
136
34
|
});
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
|
2
|
+
|
|
3
3
|
import EmptyResults from '../EmptyResults';
|
|
4
4
|
|
|
5
|
+
const fixtures = {
|
|
6
|
+
'render without Props': {},
|
|
7
|
+
/** fixtures, props for the component */
|
|
8
|
+
};
|
|
9
|
+
|
|
5
10
|
describe('EmptyResults', () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
expect(
|
|
9
|
-
screen.getByText(
|
|
10
|
-
"Oops! Couldn't find organization that matches your query"
|
|
11
|
-
)
|
|
12
|
-
).toBeTruthy();
|
|
13
|
-
});
|
|
11
|
+
describe('rendering', () =>
|
|
12
|
+
testComponentSnapshotsWithFixtures(EmptyResults, fixtures));
|
|
14
13
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`EmptyResults rendering render without Props 1`] = `
|
|
4
|
+
<EmptyState
|
|
5
|
+
className=""
|
|
6
|
+
>
|
|
7
|
+
<EmptyStateTitle
|
|
8
|
+
className=""
|
|
9
|
+
>
|
|
10
|
+
<Icon
|
|
11
|
+
className="no_results_icon"
|
|
12
|
+
name="meh-o"
|
|
13
|
+
type="fa"
|
|
14
|
+
/>
|
|
15
|
+
Oops! Couldn't find organization that matches your query
|
|
16
|
+
</EmptyStateTitle>
|
|
17
|
+
</EmptyState>
|
|
18
|
+
`;
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
|
2
|
+
|
|
3
3
|
import EmptyState from '../EmptyState';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
screen.getByText('Fetching data about your accounts')
|
|
10
|
-
).toBeTruthy();
|
|
11
|
-
});
|
|
5
|
+
const fixtures = {
|
|
6
|
+
'render without Props': {},
|
|
7
|
+
/** fixtures, props for the component */
|
|
8
|
+
};
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
10
|
+
describe('EmptyState', () => {
|
|
11
|
+
describe('rendering', () =>
|
|
12
|
+
testComponentSnapshotsWithFixtures(EmptyState, fixtures));
|
|
17
13
|
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`EmptyState rendering render without Props 1`] = `
|
|
4
|
+
<EmptyState
|
|
5
|
+
className=""
|
|
6
|
+
>
|
|
7
|
+
<Spinner
|
|
8
|
+
className=""
|
|
9
|
+
inline={true}
|
|
10
|
+
inverse={false}
|
|
11
|
+
loading={true}
|
|
12
|
+
size="lg"
|
|
13
|
+
/>
|
|
14
|
+
<EmptyStateTitle
|
|
15
|
+
className=""
|
|
16
|
+
>
|
|
17
|
+
Fetching data about your accounts
|
|
18
|
+
</EmptyStateTitle>
|
|
19
|
+
<EmptyStateInfo
|
|
20
|
+
className=""
|
|
21
|
+
>
|
|
22
|
+
Loading...
|
|
23
|
+
</EmptyStateInfo>
|
|
24
|
+
</EmptyState>
|
|
25
|
+
`;
|
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import ErrorState from '../ErrorState';
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
it('renders the error message heading', () => {
|
|
7
|
-
render(<ErrorState error="Something went wrong" />);
|
|
8
|
-
expect(
|
|
9
|
-
screen.getByText(
|
|
10
|
-
'Encountered an error while trying to access the server:'
|
|
11
|
-
)
|
|
12
|
-
).toBeTruthy();
|
|
13
|
-
});
|
|
3
|
+
import ErrorState from '../ErrorState';
|
|
14
4
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
const fixtures = {
|
|
6
|
+
'render without Props': {},
|
|
7
|
+
/** fixtures, props for the component */
|
|
8
|
+
};
|
|
19
9
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
10
|
+
describe('ErrorState', () => {
|
|
11
|
+
describe('rendering', () =>
|
|
12
|
+
testComponentSnapshotsWithFixtures(ErrorState, fixtures));
|
|
24
13
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ErrorState rendering render without Props 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="error_state"
|
|
6
|
+
>
|
|
7
|
+
<Icon
|
|
8
|
+
className="error_icon"
|
|
9
|
+
name="times"
|
|
10
|
+
size="2x"
|
|
11
|
+
type="fa"
|
|
12
|
+
/>
|
|
13
|
+
<p>
|
|
14
|
+
Encountered an error while trying to access the server:
|
|
15
|
+
</p>
|
|
16
|
+
<p
|
|
17
|
+
className="error_description"
|
|
18
|
+
/>
|
|
19
|
+
</div>
|
|
20
|
+
`;
|
|
@@ -1,36 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { Accordion } from '@patternfly/react-core';
|
|
4
|
-
import ListItem from '../ListItem';
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
|
5
2
|
|
|
6
|
-
|
|
3
|
+
import ListItem from '../ListItem';
|
|
4
|
+
import { props } from '../ListItem.fixtures';
|
|
7
5
|
|
|
8
|
-
const
|
|
9
|
-
render
|
|
10
|
-
|
|
11
|
-
<ListItem {...props} />
|
|
12
|
-
</Accordion>
|
|
13
|
-
);
|
|
6
|
+
const fixtures = {
|
|
7
|
+
'render with Props': props,
|
|
8
|
+
};
|
|
14
9
|
|
|
15
10
|
describe('ListItem', () => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
account: {
|
|
19
|
-
generated_status: 'unknown',
|
|
20
|
-
uploaded_status: 'unknown',
|
|
21
|
-
id: 1,
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
it('renders the account label', () => {
|
|
26
|
-
renderListItem(defaultProps);
|
|
27
|
-
expect(screen.getByText('test-org')).toBeTruthy();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('renders Generated and Uploaded status labels', () => {
|
|
31
|
-
renderListItem(defaultProps);
|
|
32
|
-
expect(screen.getByText('Generated')).toBeTruthy();
|
|
33
|
-
expect(screen.getByText('Uploaded')).toBeTruthy();
|
|
34
|
-
});
|
|
35
|
-
|
|
11
|
+
describe('rendering', () =>
|
|
12
|
+
testComponentSnapshotsWithFixtures(ListItem, fixtures));
|
|
36
13
|
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ListItem rendering render with Props 1`] = `
|
|
4
|
+
<AccordionItem>
|
|
5
|
+
<AccordionToggle
|
|
6
|
+
isExpanded={false}
|
|
7
|
+
onClick={[Function]}
|
|
8
|
+
>
|
|
9
|
+
<span>
|
|
10
|
+
<Label
|
|
11
|
+
className="account-icon"
|
|
12
|
+
color="blue"
|
|
13
|
+
icon={<UserIcon />}
|
|
14
|
+
variant="outline"
|
|
15
|
+
/>
|
|
16
|
+
test
|
|
17
|
+
</span>
|
|
18
|
+
<ListItemStatus
|
|
19
|
+
account={
|
|
20
|
+
Object {
|
|
21
|
+
"generated_status": "unknown",
|
|
22
|
+
"id": 1,
|
|
23
|
+
"report_file_paths": Array [],
|
|
24
|
+
"uploaded_status": "unknown",
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
key="test_status"
|
|
28
|
+
/>
|
|
29
|
+
</AccordionToggle>
|
|
30
|
+
<AccordionContent
|
|
31
|
+
isHidden={true}
|
|
32
|
+
>
|
|
33
|
+
<Dashboard
|
|
34
|
+
account={
|
|
35
|
+
Object {
|
|
36
|
+
"generated_status": "unknown",
|
|
37
|
+
"id": 1,
|
|
38
|
+
"report_file_paths": Array [],
|
|
39
|
+
"uploaded_status": "unknown",
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
accountID={1}
|
|
43
|
+
onTaskStart={null}
|
|
44
|
+
/>
|
|
45
|
+
</AccordionContent>
|
|
46
|
+
</AccordionItem>
|
|
47
|
+
`;
|
|
@@ -1,30 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import ListItemStatus from '../ListItemStatus';
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
render(<ListItemStatus />);
|
|
8
|
-
expect(screen.getByText('Generated')).toBeTruthy();
|
|
9
|
-
expect(screen.getByText('Uploaded')).toBeTruthy();
|
|
10
|
-
});
|
|
3
|
+
import ListItemStatus from '../ListItemStatus';
|
|
4
|
+
import { props } from '../ListItemStatus.fixtures';
|
|
11
5
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/>
|
|
17
|
-
);
|
|
18
|
-
expect(screen.getAllByText('--')).toHaveLength(2);
|
|
19
|
-
});
|
|
6
|
+
const fixtures = {
|
|
7
|
+
'render without Props': {},
|
|
8
|
+
'render with Props': props,
|
|
9
|
+
};
|
|
20
10
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
account={{ generated_status: 'success', uploaded_status: 'running' }}
|
|
25
|
-
/>
|
|
26
|
-
);
|
|
27
|
-
expect(screen.getByText('Generated')).toBeTruthy();
|
|
28
|
-
expect(screen.getByText('Uploaded')).toBeTruthy();
|
|
29
|
-
});
|
|
11
|
+
describe('ListItemStatus', () => {
|
|
12
|
+
describe('rendering', () =>
|
|
13
|
+
testComponentSnapshotsWithFixtures(ListItemStatus, fixtures));
|
|
30
14
|
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`ListItemStatus rendering render with Props 1`] = `
|
|
4
|
+
<Grid
|
|
5
|
+
className="status"
|
|
6
|
+
hasGutter={true}
|
|
7
|
+
>
|
|
8
|
+
<GridItem
|
|
9
|
+
className="item"
|
|
10
|
+
span={6}
|
|
11
|
+
>
|
|
12
|
+
<p>
|
|
13
|
+
Generated
|
|
14
|
+
</p>
|
|
15
|
+
<CheckIcon />
|
|
16
|
+
</GridItem>
|
|
17
|
+
<GridItem
|
|
18
|
+
className="item"
|
|
19
|
+
span={6}
|
|
20
|
+
>
|
|
21
|
+
<p>
|
|
22
|
+
Uploaded
|
|
23
|
+
</p>
|
|
24
|
+
<Spinner
|
|
25
|
+
size="sm"
|
|
26
|
+
/>
|
|
27
|
+
</GridItem>
|
|
28
|
+
</Grid>
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
exports[`ListItemStatus rendering render without Props 1`] = `
|
|
32
|
+
<Grid
|
|
33
|
+
className="status"
|
|
34
|
+
hasGutter={true}
|
|
35
|
+
>
|
|
36
|
+
<GridItem
|
|
37
|
+
className="item"
|
|
38
|
+
span={6}
|
|
39
|
+
>
|
|
40
|
+
<p>
|
|
41
|
+
Generated
|
|
42
|
+
</p>
|
|
43
|
+
<span>
|
|
44
|
+
--
|
|
45
|
+
</span>
|
|
46
|
+
</GridItem>
|
|
47
|
+
<GridItem
|
|
48
|
+
className="item"
|
|
49
|
+
span={6}
|
|
50
|
+
>
|
|
51
|
+
<p>
|
|
52
|
+
Uploaded
|
|
53
|
+
</p>
|
|
54
|
+
<span>
|
|
55
|
+
--
|
|
56
|
+
</span>
|
|
57
|
+
</GridItem>
|
|
58
|
+
</Grid>
|
|
59
|
+
`;
|
|
@@ -1,38 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
|
2
|
+
|
|
3
3
|
import AccountList from '../AccountList';
|
|
4
|
-
import {
|
|
4
|
+
import { props } from '../AccountList.fixtures';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const fixtures = {
|
|
7
|
+
'render with props': props,
|
|
8
|
+
'show empty results': { ...props, filterTerm: 'not_matching_term' },
|
|
9
|
+
};
|
|
9
10
|
|
|
10
11
|
describe('AccountList', () => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Object.keys(accounts).forEach(label => {
|
|
14
|
-
expect(screen.getByText(label)).toBeTruthy();
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('shows empty results when filterTerm matches nothing', () => {
|
|
19
|
-
render(<AccountList accounts={accounts} filterTerm="not_matching_term" />);
|
|
20
|
-
expect(
|
|
21
|
-
screen.getByText(
|
|
22
|
-
"Oops! Couldn't find organization that matches your query"
|
|
23
|
-
)
|
|
24
|
-
).toBeTruthy();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('shows empty state when accounts are empty', () => {
|
|
28
|
-
render(<AccountList accounts={{}} />);
|
|
29
|
-
expect(
|
|
30
|
-
screen.getByText('Fetching data about your accounts')
|
|
31
|
-
).toBeTruthy();
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('shows error state when error is present', () => {
|
|
35
|
-
render(<AccountList accounts={{}} error="Server error" />);
|
|
36
|
-
expect(screen.getByText('Server error')).toBeTruthy();
|
|
37
|
-
});
|
|
12
|
+
describe('rendering', () =>
|
|
13
|
+
testComponentSnapshotsWithFixtures(AccountList, fixtures));
|
|
38
14
|
});
|
data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { testActionSnapshotWithFixtures } from '@theforeman/test';
|
|
2
|
+
import { API } from 'foremanReact/redux/API';
|
|
3
|
+
import {
|
|
4
|
+
fetchAccountsStatus,
|
|
5
|
+
startAccountStatusPolling,
|
|
6
|
+
stopAccountStatusPolling,
|
|
7
|
+
restartProcess,
|
|
8
|
+
} from '../AccountListActions';
|
|
9
|
+
import {
|
|
10
|
+
pollingProcessID,
|
|
11
|
+
fetchAccountsStatusResponse,
|
|
12
|
+
} from '../AccountList.fixtures';
|
|
13
|
+
import { accountID, activeTab } from '../../Dashboard/Dashboard.fixtures';
|
|
14
|
+
|
|
15
|
+
jest.mock('foremanReact/redux/API');
|
|
16
|
+
API.get.mockImplementation(async () => fetchAccountsStatusResponse);
|
|
17
|
+
|
|
18
|
+
const fixtures = {
|
|
19
|
+
'should fetchAccountsStatus': () => fetchAccountsStatus(),
|
|
20
|
+
'should startAccountStatusPolling': () =>
|
|
21
|
+
startAccountStatusPolling(pollingProcessID),
|
|
22
|
+
'should stopAccountStatusPolling': () =>
|
|
23
|
+
stopAccountStatusPolling(pollingProcessID),
|
|
24
|
+
'should restartProcess': () => restartProcess(accountID, activeTab),
|
|
25
|
+
'should invoke toast notification upon failure': () => {
|
|
26
|
+
API.post.mockImplementationOnce(() =>
|
|
27
|
+
Promise.reject(new Error('test error'))
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
return restartProcess(accountID, activeTab);
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
describe('AccountList actions', () => testActionSnapshotWithFixtures(fixtures));
|
data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IntegrationTestHelper } from '@theforeman/test';
|
|
3
|
+
|
|
4
|
+
import AccountList from '../index';
|
|
5
|
+
import reducers from '../../../../ForemanRhCloudReducers';
|
|
6
|
+
|
|
7
|
+
describe('AccountList integration test', () => {
|
|
8
|
+
it('should flow', async () => {
|
|
9
|
+
const integrationTestHelper = new IntegrationTestHelper(reducers);
|
|
10
|
+
const component = integrationTestHelper.mount(<AccountList />);
|
|
11
|
+
component.update();
|
|
12
|
+
/** Create a Flow test */
|
|
13
|
+
});
|
|
14
|
+
});
|