foreman_rh_cloud 14.1.2 → 14.2.0
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/services/foreman_rh_cloud/insights_api_forwarder.rb +157 -5
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +26 -4
- data/lib/foreman_inventory_upload.rb +8 -1
- data/lib/foreman_rh_cloud/plugin.rb +16 -5
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/foreman_rh_cloud.rb +36 -9
- data/lib/insights_cloud/async/insights_generate_notifications.rb +10 -1
- data/lib/inventory_sync/async/inventory_self_host_sync.rb +12 -2
- data/package.json +1 -1
- data/test/jobs/insights_generate_notifications_test.rb +26 -0
- data/test/jobs/inventory_self_host_sync_test.rb +9 -0
- data/test/unit/foreman_rh_cloud_self_host_test.rb +50 -2
- data/test/unit/metadata_generator_test.rb +24 -1
- data/test/unit/services/foreman_rh_cloud/insights_api_forwarder_test.rb +240 -4
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +0 -6
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +0 -2
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/EmptyResults.test.js +10 -9
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/EmptyState.test.js +13 -9
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/ErrorState.test.js +20 -9
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/ListItem.test.js +31 -8
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/ListItemStatus.test.js +26 -10
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +33 -9
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +53 -35
- data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/FileDownload.test.js +13 -9
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilter.test.js +12 -15
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/integration.test.js +32 -12
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +0 -2
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.scss +1 -2
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageTitle.js +13 -7
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageHeader.test.js +0 -5
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageTitle.test.js +47 -7
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +23 -9
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonSelectors.test.js +19 -17
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js +25 -37
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +0 -4
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/ToolbarButtons.test.js +18 -47
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/ScheduledRun.test.js +28 -8
- data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/StatusChart.test.js +25 -8
- data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/TabContainer.test.js +11 -9
- data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/TabFooter.test.js +11 -9
- data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +4 -4
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/InventoryAutoUpload.test.js +33 -12
- data/webpack/ForemanInventoryUpload/__tests__/ForemanInventoryHelpers.test.js +36 -8
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js +61 -47
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTable.test.js +48 -4
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js +126 -35
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableSelectors.test.js +90 -24
- data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +79 -21
- data/webpack/InsightsCloudSync/__tests__/InsightsCloudSyncActions.test.js +31 -6
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTab.test.js +42 -9
- data/webpack/__tests__/ForemanRhCloudHelpers.test.js +91 -53
- data/webpack/common/Switcher/__tests__/HelpLabel.test.js +25 -10
- data/webpack/common/Switcher/__tests__/SwitcherPF4.test.js +41 -10
- metadata +4 -77
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/__snapshots__/EmptyResults.test.js.snap +0 -18
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/__snapshots__/EmptyState.test.js.snap +0 -25
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/__snapshots__/ErrorState.test.js.snap +0 -20
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +0 -47
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/__snapshots__/ListItemStatus.test.js.snap +0 -59
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +0 -34
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +0 -14
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +0 -25
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +0 -49
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +0 -86
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +0 -75
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +0 -46
- data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/__snapshots__/FileDownload.test.js.snap +0 -26
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterActions.test.js +0 -14
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js +0 -28
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterSelectors.test.js +0 -21
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilter.test.js.snap +0 -21
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterActions.test.js.snap +0 -17
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterReducer.test.js.snap +0 -19
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterSelectors.test.js.snap +0 -9
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +0 -43
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/__tests__/AdvancedSettingActions.test.js +0 -9
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/__tests__/__snapshots__/AdvancedSettingActions.test.js.snap +0 -18
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/InventorySettingsActions.test.js +0 -14
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettingsActions.test.js.snap +0 -26
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +0 -68
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorActions.js +0 -21
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js +0 -59
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorConstants.js +0 -6
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorSelectors.js +0 -19
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorActions.test.js +0 -9
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorButton.test.js +0 -22
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorActions.test.js.snap +0 -11
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorButton.test.js.snap +0 -59
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/index.js +0 -34
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js +0 -66
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.test.js +0 -18
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/__snapshots__/SettingsWarning.test.js.snap +0 -32
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/index.js +0 -25
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +0 -15
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonSelectors.test.js.snap +0 -3
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/integrations.test.js.snap +0 -58
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/__snapshots__/ScheduledRun.test.js.snap +0 -23
- data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/__snapshots__/StatusChart.test.js.snap +0 -74
- data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/__snapshots__/TabContainer.test.js.snap +0 -18
- data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/__snapshots__/TabFooter.test.js.snap +0 -12
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/__snapshots__/InventoryAutoUpload.test.js.snap +0 -96
- data/webpack/ForemanInventoryUpload/__tests__/ForemanInventoryUpload.test.js +0 -10
- data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap +0 -5
- data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryUpload.test.js.snap +0 -14
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsReducer.test.js +0 -33
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsSelectors.test.js +0 -21
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsActions.test.js.snap +0 -65
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsReducer.test.js.snap +0 -19
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsSelectors.test.js.snap +0 -9
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableActions.test.js.snap +0 -131
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableSelectors.test.js.snap +0 -87
- data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +0 -10
- data/webpack/InsightsCloudSync/__tests__/InsightsCloudSyncHelpers.test.js +0 -9
- data/webpack/InsightsCloudSync/__tests__/__snapshots__/InsightsCloudSyncActions.test.js.snap +0 -15
- data/webpack/InsightsCloudSync/__tests__/__snapshots__/InsightsCloudSyncHelpers.test.js.snap +0 -3
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabActions.test.js +0 -19
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabReducer.test.js +0 -26
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabSelectors.test.js +0 -13
- data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTab.test.js.snap +0 -34
- data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabActions.test.js.snap +0 -56
- data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabReducer.test.js.snap +0 -32
- data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabSelectors.test.js.snap +0 -18
- data/webpack/__tests__/ForemanRhCloudSelectors.test.js +0 -22
- data/webpack/__tests__/ForemanRhCloudTestHelpers.test.js +0 -20
- data/webpack/__tests__/__snapshots__/ForemanRhCloudHelpers.test.js.snap +0 -19
- data/webpack/__tests__/__snapshots__/ForemanRhCloudSelectors.test.js.snap +0 -25
- data/webpack/__tests__/__snapshots__/ForemanRhCloudTestHelpers.test.js.snap +0 -39
- data/webpack/common/Switcher/__tests__/__snapshots__/HelpLabel.test.js.snap +0 -16
- data/webpack/common/Switcher/__tests__/__snapshots__/SwitcherPF4.test.js.snap +0 -24
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
3
|
import FileDownload from '../FileDownload';
|
|
4
4
|
|
|
5
|
-
const fixtures = {
|
|
6
|
-
'render without Props': {},
|
|
7
|
-
/** fixtures, props for the component */
|
|
8
|
-
};
|
|
9
|
-
|
|
10
5
|
describe('FileDownload', () => {
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
it('renders the download button', () => {
|
|
7
|
+
render(<FileDownload />);
|
|
8
|
+
expect(screen.getByRole('button', { name: /Download Report/ })).toBeTruthy();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('calls onClick when button is clicked', () => {
|
|
12
|
+
const onClick = jest.fn();
|
|
13
|
+
render(<FileDownload onClick={onClick} />);
|
|
14
|
+
fireEvent.click(screen.getByRole('button', { name: /Download Report/ }));
|
|
15
|
+
expect(onClick).toHaveBeenCalledTimes(1);
|
|
16
|
+
});
|
|
13
17
|
});
|
data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilter.test.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
4
3
|
import InventoryFilter from '../InventoryFilter';
|
|
5
|
-
import { filterTerm, organization } from '../InventoryFilter.fixtures';
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
'render with props': {
|
|
9
|
-
handleFilterChange: noop,
|
|
10
|
-
handleFilterClear: noop,
|
|
11
|
-
filterTerm,
|
|
12
|
-
organization,
|
|
13
|
-
},
|
|
14
|
-
/** fixtures, props for the component */
|
|
15
|
-
};
|
|
5
|
+
jest.mock('foremanReact/Root/Context/ForemanContext');
|
|
16
6
|
|
|
17
7
|
describe('InventoryFilter', () => {
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
it('renders the filter input', () => {
|
|
9
|
+
render(<InventoryFilter />);
|
|
10
|
+
expect(screen.getByPlaceholderText('Filter..')).toBeTruthy();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('displays the current filter term', () => {
|
|
14
|
+
render(<InventoryFilter filterTerm="test-filter" />);
|
|
15
|
+
expect(screen.getByDisplayValue('test-filter')).toBeTruthy();
|
|
16
|
+
});
|
|
20
17
|
});
|
data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/integration.test.js
CHANGED
|
@@ -1,18 +1,38 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
+
import { Provider } from 'react-redux';
|
|
4
|
+
import configureMockStore from 'redux-mock-store';
|
|
5
|
+
import thunk from 'redux-thunk';
|
|
6
|
+
import ConnectedInventoryFilter from '../index';
|
|
7
|
+
import { INVENTORY_FILTER_UPDATE } from '../InventoryFilterConstants';
|
|
8
|
+
|
|
9
|
+
jest.mock('foremanReact/Root/Context/ForemanContext');
|
|
10
|
+
|
|
11
|
+
const mockStore = configureMockStore([thunk]);
|
|
5
12
|
|
|
6
13
|
describe('InventoryFilter integration test', () => {
|
|
7
|
-
it('
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
it('dispatches filter update action on input change', () => {
|
|
15
|
+
const store = mockStore({
|
|
16
|
+
ForemanRhCloud: {
|
|
17
|
+
inventoryUpload: {
|
|
18
|
+
inventoryFilter: { filterTerm: '' },
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
render(
|
|
24
|
+
<Provider store={store}>
|
|
25
|
+
<ConnectedInventoryFilter />
|
|
26
|
+
</Provider>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const input = screen.getByPlaceholderText('Filter..');
|
|
30
|
+
fireEvent.change(input, { target: { value: 'some_new_filter' } });
|
|
31
|
+
|
|
32
|
+
const actions = store.getActions();
|
|
33
|
+
const filterAction = actions.find(
|
|
34
|
+
a => a.type === INVENTORY_FILTER_UPDATE && a.payload.filterTerm === 'some_new_filter'
|
|
16
35
|
);
|
|
36
|
+
expect(filterAction).toBeTruthy();
|
|
17
37
|
});
|
|
18
38
|
});
|
|
@@ -4,7 +4,6 @@ import InventorySettings from '../InventorySettings';
|
|
|
4
4
|
import PageDescription from './components/PageDescription';
|
|
5
5
|
import InventoryFilter from '../InventoryFilter';
|
|
6
6
|
import ToolbarButtons from './components/ToolbarButtons';
|
|
7
|
-
import SettingsWarning from './components/SettingsWarning';
|
|
8
7
|
import PageTitle from './PageTitle';
|
|
9
8
|
import { useIopConfig } from '../../../common/Hooks/ConfigHooks';
|
|
10
9
|
import './PageHeader.scss';
|
|
@@ -14,7 +13,6 @@ const PageHeader = () => {
|
|
|
14
13
|
|
|
15
14
|
return (
|
|
16
15
|
<div className="inventory-upload-header">
|
|
17
|
-
<SettingsWarning />
|
|
18
16
|
<PageTitle />
|
|
19
17
|
{!isIop && (
|
|
20
18
|
<div className="inventory-upload-header-description">
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
.rh-cloud-inventory-page {
|
|
2
2
|
.inventory-upload-header {
|
|
3
|
-
|
|
3
|
+
padding: var(--pf-v5-global--spacer--md) var(--pf-v5-global--spacer--lg) var(--pf-v5-global--spacer--lg) var(--pf-v5-global--spacer--lg);
|
|
4
4
|
|
|
5
5
|
h1 {
|
|
6
6
|
font-family: 'RedHatDisplay';
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
.inventory-upload-header-title {
|
|
36
|
-
margin-top: -15px;
|
|
37
36
|
margin-bottom: 8px;
|
|
38
37
|
}
|
|
39
38
|
|
|
@@ -18,9 +18,11 @@ import {
|
|
|
18
18
|
getInventoryDocsUrl,
|
|
19
19
|
} from '../../ForemanInventoryHelpers';
|
|
20
20
|
import CloudPingModal from './components/CloudPingModal';
|
|
21
|
+
import { useIopConfig } from '../../../common/Hooks/ConfigHooks';
|
|
21
22
|
|
|
22
23
|
const PageTitle = () => {
|
|
23
24
|
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
|
25
|
+
const isIop = useIopConfig();
|
|
24
26
|
const [showPingModal, setPingModal] = useState(false);
|
|
25
27
|
const togglePingModal = () => setPingModal(v => !v);
|
|
26
28
|
const dropdownItems = [
|
|
@@ -42,13 +44,17 @@ const PageTitle = () => {
|
|
|
42
44
|
>
|
|
43
45
|
{DOCS_BUTTON_TEXT}
|
|
44
46
|
</DropdownItem>,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
...(!isIop
|
|
48
|
+
? [
|
|
49
|
+
<DropdownItem
|
|
50
|
+
key="cloud-ping"
|
|
51
|
+
ouiaId="dropdownItem-cloud-ping"
|
|
52
|
+
onClick={togglePingModal}
|
|
53
|
+
>
|
|
54
|
+
{CLOUD_PING_TITLE}
|
|
55
|
+
</DropdownItem>,
|
|
56
|
+
]
|
|
57
|
+
: []),
|
|
52
58
|
];
|
|
53
59
|
return (
|
|
54
60
|
<Grid className="inventory-upload-header-title">
|
|
@@ -20,9 +20,6 @@ jest.mock('foremanReact/Root/Context/ForemanContext', () => ({
|
|
|
20
20
|
|
|
21
21
|
// Mock child components to isolate PageHeader testing
|
|
22
22
|
// This prevents child component complexity from affecting our tests
|
|
23
|
-
jest.mock('../components/SettingsWarning', () => () => (
|
|
24
|
-
<div data-testid="settings-warning">SettingsWarning</div>
|
|
25
|
-
));
|
|
26
23
|
jest.mock('../PageTitle', () => () => (
|
|
27
24
|
<div data-testid="page-title">PageTitle</div>
|
|
28
25
|
));
|
|
@@ -59,7 +56,6 @@ describe('PageHeader', () => {
|
|
|
59
56
|
});
|
|
60
57
|
|
|
61
58
|
// All components should be present when not in IoP mode
|
|
62
|
-
expect(screen.getByTestId('settings-warning')).toBeTruthy();
|
|
63
59
|
expect(screen.getByTestId('page-title')).toBeTruthy();
|
|
64
60
|
expect(screen.getByTestId('inventory-settings')).toBeTruthy();
|
|
65
61
|
expect(screen.getByTestId('page-description')).toBeTruthy();
|
|
@@ -83,7 +79,6 @@ describe('PageHeader', () => {
|
|
|
83
79
|
});
|
|
84
80
|
|
|
85
81
|
// Core components should still be present
|
|
86
|
-
expect(screen.getByTestId('settings-warning')).toBeTruthy();
|
|
87
82
|
expect(screen.getByTestId('page-title')).toBeTruthy();
|
|
88
83
|
expect(screen.getByTestId('inventory-filter')).toBeTruthy();
|
|
89
84
|
expect(screen.getByTestId('toolbar-buttons')).toBeTruthy();
|
|
@@ -1,12 +1,52 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
3
|
import PageTitle from '../PageTitle';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
let mockIopMode = false;
|
|
6
|
+
|
|
7
|
+
jest.mock('foremanReact/Root/Context/ForemanContext', () => ({
|
|
8
|
+
useForemanContext: () => ({
|
|
9
|
+
metadata: {
|
|
10
|
+
foreman_rh_cloud: {
|
|
11
|
+
iop: mockIopMode,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
UI: {},
|
|
15
|
+
}),
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
jest.mock('../components/CloudPingModal', () => () => (
|
|
19
|
+
<div data-testid="cloud-ping-modal">CloudPingModal</div>
|
|
20
|
+
));
|
|
21
|
+
jest.mock('foremanReact/common/helpers', () => ({ getDocsURL: () => {} }));
|
|
8
22
|
|
|
9
23
|
describe('PageTitle', () => {
|
|
10
|
-
|
|
11
|
-
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
mockIopMode = false;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('renders the page title', () => {
|
|
29
|
+
render(<PageTitle />);
|
|
30
|
+
expect(screen.getByText('Red Hat Inventory')).toBeTruthy();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('renders the kebab dropdown', () => {
|
|
34
|
+
const { container } = render(<PageTitle />);
|
|
35
|
+
expect(container.querySelector('.title-dropdown')).toBeTruthy();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('renders cloud-ping dropdown item when not in IoP mode', () => {
|
|
39
|
+
mockIopMode = false;
|
|
40
|
+
render(<PageTitle />);
|
|
41
|
+
fireEvent.click(screen.getByLabelText('Actions'));
|
|
42
|
+
expect(screen.getByText('Connectivity test')).toBeTruthy();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('does not render cloud-ping dropdown item when in IoP mode', () => {
|
|
46
|
+
mockIopMode = true;
|
|
47
|
+
render(<PageTitle />);
|
|
48
|
+
fireEvent.click(screen.getByLabelText('Actions'));
|
|
49
|
+
expect(screen.queryByText('Connectivity test')).toBeNull();
|
|
50
|
+
mockIopMode = false;
|
|
51
|
+
});
|
|
12
52
|
});
|
|
@@ -1,13 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
4
3
|
import SyncButton from '../SyncButton';
|
|
5
4
|
|
|
6
|
-
const fixtures = {
|
|
7
|
-
'render with Props': { handleSync: noop },
|
|
8
|
-
};
|
|
9
|
-
|
|
10
5
|
describe('SyncButton', () => {
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
it('renders the sync button text', () => {
|
|
7
|
+
render(<SyncButton handleSync={jest.fn()} />);
|
|
8
|
+
expect(screen.getByRole('button', { name: /Sync all inventory status/ })).toBeTruthy();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('calls handleSync on click', () => {
|
|
12
|
+
const handleSync = jest.fn();
|
|
13
|
+
render(<SyncButton handleSync={handleSync} />);
|
|
14
|
+
fireEvent.click(screen.getByRole('button'));
|
|
15
|
+
expect(handleSync).toHaveBeenCalledTimes(1);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('disables button when status is PENDING', () => {
|
|
19
|
+
render(<SyncButton handleSync={jest.fn()} status="PENDING" />);
|
|
20
|
+
expect(screen.getByRole('button').disabled).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('enables button when status is not PENDING', () => {
|
|
24
|
+
render(<SyncButton handleSync={jest.fn()} status="RESOLVED" />);
|
|
25
|
+
expect(screen.getByRole('button').disabled).toBe(false);
|
|
26
|
+
});
|
|
13
27
|
});
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import { testSelectorsSnapshotWithFixtures } from '@theforeman/test';
|
|
2
1
|
import { selectTaskStatus } from '../SyncButtonSelectors';
|
|
3
2
|
|
|
4
|
-
const
|
|
3
|
+
const buildState = result => ({
|
|
5
4
|
API: {
|
|
6
5
|
INVENTORY_SYNC_TASK_UPDATE: {
|
|
7
6
|
response: {
|
|
8
|
-
|
|
9
|
-
output: {
|
|
10
|
-
host_statuses: {
|
|
11
|
-
sync: 0,
|
|
12
|
-
disconnect: 2,
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
result: 'pending',
|
|
7
|
+
result,
|
|
16
8
|
},
|
|
17
|
-
status: 'RESOLVED',
|
|
18
9
|
},
|
|
19
10
|
},
|
|
20
|
-
};
|
|
11
|
+
});
|
|
21
12
|
|
|
22
|
-
|
|
23
|
-
'
|
|
24
|
-
|
|
13
|
+
describe('SyncButton selectors', () => {
|
|
14
|
+
it('uppercases the result string', () => {
|
|
15
|
+
expect(selectTaskStatus(buildState('pending'))).toBe('PENDING');
|
|
16
|
+
});
|
|
25
17
|
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
it('handles other result strings', () => {
|
|
19
|
+
expect(selectTaskStatus(buildState('success'))).toBe('SUCCESS');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('returns null when result is not a string', () => {
|
|
23
|
+
expect(selectTaskStatus(buildState(null))).toBeNull();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('returns null when result is undefined', () => {
|
|
27
|
+
expect(selectTaskStatus(buildState(undefined))).toBeNull();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -1,52 +1,40 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
+
import { Provider } from 'react-redux';
|
|
4
|
+
import configureMockStore from 'redux-mock-store';
|
|
5
|
+
import thunk from 'redux-thunk';
|
|
3
6
|
import * as API from 'foremanReact/redux/API';
|
|
4
|
-
import
|
|
5
|
-
import SyncButton from '../index';
|
|
7
|
+
import ConnectedSyncButton from '../index';
|
|
6
8
|
import { successResponse } from './SyncButtonFixtures';
|
|
7
|
-
import {
|
|
8
|
-
INVENTORY_SYNC,
|
|
9
|
-
INVENTORY_SYNC_TASK_UPDATE,
|
|
10
|
-
} from '../SyncButtonConstants';
|
|
9
|
+
import { INVENTORY_SYNC } from '../SyncButtonConstants';
|
|
11
10
|
|
|
12
11
|
jest.spyOn(API, 'post');
|
|
13
|
-
|
|
12
|
+
|
|
13
|
+
const mockStore = configureMockStore([thunk]);
|
|
14
14
|
|
|
15
15
|
describe('SyncButton integration test', () => {
|
|
16
|
-
it('
|
|
17
|
-
API.post.mockImplementation(({ handleSuccess
|
|
18
|
-
if (key === INVENTORY_SYNC) {
|
|
16
|
+
it('dispatches sync action when button is clicked', () => {
|
|
17
|
+
API.post.mockImplementation(({ handleSuccess, key, ...action }) => {
|
|
18
|
+
if (key === INVENTORY_SYNC && handleSuccess) {
|
|
19
19
|
handleSuccess(successResponse);
|
|
20
20
|
}
|
|
21
21
|
return { type: 'API_POST', ...action };
|
|
22
22
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
data: {
|
|
28
|
-
endedAt: '2021-03-22T15:59:02.468+02:00',
|
|
29
|
-
output: {
|
|
30
|
-
host_statuses: {
|
|
31
|
-
sync: 0,
|
|
32
|
-
disconnect: 2,
|
|
33
|
-
user_omitted: 1,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
result: 'success',
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
jest.fn
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
return { type: 'API_GET', ...action };
|
|
23
|
+
|
|
24
|
+
const store = mockStore({
|
|
25
|
+
API: {},
|
|
43
26
|
});
|
|
44
27
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
28
|
+
render(
|
|
29
|
+
<Provider store={store}>
|
|
30
|
+
<ConnectedSyncButton />
|
|
31
|
+
</Provider>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
fireEvent.click(screen.getByRole('button'));
|
|
35
|
+
|
|
36
|
+
const actions = store.getActions();
|
|
37
|
+
const syncAction = actions.find(a => a.type === 'API_POST');
|
|
38
|
+
expect(syncAction).toBeTruthy();
|
|
51
39
|
});
|
|
52
40
|
});
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useSelector } from 'react-redux';
|
|
3
3
|
import SyncButton from '../SyncButton';
|
|
4
|
-
import CloudConnectorButton from '../CloudConnectorButton';
|
|
5
4
|
import './toolbarButtons.scss';
|
|
6
5
|
import { selectSubscriptionConnectionEnabled } from '../../../InventorySettings/InventorySettingsSelectors';
|
|
7
|
-
import { useIopConfig } from '../../../../../common/Hooks/ConfigHooks';
|
|
8
6
|
|
|
9
7
|
const ToolbarButtons = () => {
|
|
10
8
|
const subscriptionConnectionEnabled = useSelector(
|
|
11
9
|
selectSubscriptionConnectionEnabled
|
|
12
10
|
);
|
|
13
|
-
const isIop = useIopConfig();
|
|
14
11
|
|
|
15
12
|
if (!subscriptionConnectionEnabled) {
|
|
16
13
|
return null;
|
|
@@ -18,7 +15,6 @@ const ToolbarButtons = () => {
|
|
|
18
15
|
|
|
19
16
|
return (
|
|
20
17
|
<div className="inventory_toolbar_buttons">
|
|
21
|
-
{!isIop && <CloudConnectorButton />}
|
|
22
18
|
<SyncButton />
|
|
23
19
|
</div>
|
|
24
20
|
);
|
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { screen } from '@testing-library/react';
|
|
3
|
-
import
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import * as reactRedux from 'react-redux';
|
|
4
5
|
import ToolbarButtons from '../ToolbarButtons';
|
|
5
|
-
import { useIopConfig } from '../../../../../../common/Hooks/ConfigHooks';
|
|
6
|
-
import { selectSubscriptionConnectionEnabled } from '../../../../InventorySettings/InventorySettingsSelectors';
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
jest.
|
|
10
|
-
useIopConfig: jest.fn(),
|
|
7
|
+
jest.mock('react-redux', () => ({
|
|
8
|
+
useSelector: jest.fn(),
|
|
11
9
|
}));
|
|
12
10
|
|
|
13
|
-
// Mock the selector
|
|
14
|
-
jest.mock('../../../../InventorySettings/InventorySettingsSelectors', () => ({
|
|
15
|
-
selectSubscriptionConnectionEnabled: jest.fn(),
|
|
16
|
-
}));
|
|
17
|
-
|
|
18
|
-
// Mock child components to isolate ToolbarButtons testing
|
|
19
11
|
jest.mock(
|
|
20
12
|
'../../SyncButton',
|
|
21
13
|
() =>
|
|
@@ -23,56 +15,35 @@ jest.mock(
|
|
|
23
15
|
return <div data-testid="sync-button">Sync all inventory status</div>;
|
|
24
16
|
}
|
|
25
17
|
);
|
|
26
|
-
jest.mock(
|
|
27
|
-
'../../CloudConnectorButton',
|
|
28
|
-
() =>
|
|
29
|
-
function MockCloudConnectorButton() {
|
|
30
|
-
return (
|
|
31
|
-
<div data-testid="cloud-connector-button">
|
|
32
|
-
Configure cloud connector
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const { renderWithStore } = rtlHelpers;
|
|
39
18
|
|
|
40
19
|
describe('ToolbarButtons', () => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
selectSubscriptionConnectionEnabled.mockReturnValue(true);
|
|
44
|
-
|
|
45
|
-
renderWithStore(<ToolbarButtons />);
|
|
46
|
-
|
|
47
|
-
expect(screen.getByTestId('cloud-connector-button')).toBeTruthy();
|
|
48
|
-
expect(screen.getByTestId('sync-button')).toBeTruthy();
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
jest.clearAllMocks();
|
|
49
22
|
});
|
|
50
23
|
|
|
51
|
-
test('renders
|
|
52
|
-
|
|
53
|
-
selectSubscriptionConnectionEnabled.mockReturnValue(true);
|
|
24
|
+
test('renders sync button when subscription connection is enabled', () => {
|
|
25
|
+
reactRedux.useSelector.mockReturnValue(true);
|
|
54
26
|
|
|
55
|
-
|
|
27
|
+
render(<ToolbarButtons />);
|
|
56
28
|
|
|
57
|
-
expect(screen.
|
|
58
|
-
expect(screen.getByTestId('sync-button')).toBeTruthy();
|
|
29
|
+
expect(screen.getByTestId('sync-button')).toBeInTheDocument();
|
|
59
30
|
});
|
|
60
31
|
|
|
61
32
|
test('renders nothing when subscription connection is not enabled', () => {
|
|
62
|
-
|
|
63
|
-
selectSubscriptionConnectionEnabled.mockReturnValue(false);
|
|
33
|
+
reactRedux.useSelector.mockReturnValue(false);
|
|
64
34
|
|
|
65
|
-
const { container } =
|
|
35
|
+
const { container } = render(<ToolbarButtons />);
|
|
66
36
|
|
|
67
37
|
expect(container.firstChild).toBeNull();
|
|
68
38
|
});
|
|
69
39
|
|
|
70
40
|
test('renders toolbar buttons container with correct className when enabled', () => {
|
|
71
|
-
|
|
72
|
-
selectSubscriptionConnectionEnabled.mockReturnValue(true);
|
|
41
|
+
reactRedux.useSelector.mockReturnValue(true);
|
|
73
42
|
|
|
74
|
-
const { container } =
|
|
43
|
+
const { container } = render(<ToolbarButtons />);
|
|
75
44
|
|
|
76
|
-
expect(
|
|
45
|
+
expect(
|
|
46
|
+
container.querySelector('.inventory_toolbar_buttons')
|
|
47
|
+
).toBeInTheDocument();
|
|
77
48
|
});
|
|
78
49
|
});
|
|
@@ -1,13 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { IntlProvider } from 'react-intl';
|
|
3
4
|
import ScheduledRun from '../ScheduledRun';
|
|
4
|
-
import { props } from '../ScheduledRun.fixtures';
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
};
|
|
6
|
+
const renderWithIntl = ui =>
|
|
7
|
+
render(<IntlProvider locale="en">{ui}</IntlProvider>);
|
|
9
8
|
|
|
10
9
|
describe('ScheduledRun', () => {
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
it('renders next run info when autoUploadEnabled and date are set', () => {
|
|
11
|
+
renderWithIntl(
|
|
12
|
+
<ScheduledRun date="2019-08-21T16:14:16.520+03:00" autoUploadEnabled />
|
|
13
|
+
);
|
|
14
|
+
expect(screen.getByText(/Next run:/)).toBeTruthy();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('renders nothing when autoUploadEnabled is false', () => {
|
|
18
|
+
renderWithIntl(
|
|
19
|
+
<ScheduledRun
|
|
20
|
+
date="2019-08-21T16:14:16.520+03:00"
|
|
21
|
+
autoUploadEnabled={false}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
expect(screen.queryByText(/Next run:/)).toBeNull();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('renders nothing when date is null', () => {
|
|
28
|
+
renderWithIntl(
|
|
29
|
+
<ScheduledRun date={null} autoUploadEnabled />
|
|
30
|
+
);
|
|
31
|
+
expect(screen.queryByText(/Next run:/)).toBeNull();
|
|
32
|
+
});
|
|
13
33
|
});
|
|
@@ -1,13 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
3
|
import StatusChart from '../StatusChart';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
jest.mock('patternfly-react', () => ({
|
|
6
|
+
Grid: { Col: ({ children }) => <div>{children}</div> },
|
|
7
|
+
DonutChart: ({ title }) => (
|
|
8
|
+
<div data-testid="donut-chart">
|
|
9
|
+
<span>{title?.primary}</span>
|
|
10
|
+
<span>{title?.secondary}</span>
|
|
11
|
+
</div>
|
|
12
|
+
),
|
|
13
|
+
}));
|
|
9
14
|
|
|
10
15
|
describe('StatusChart', () => {
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
it('renders the status chart container', () => {
|
|
17
|
+
const { container } = render(<StatusChart />);
|
|
18
|
+
expect(container.querySelector('.status-chart')).toBeTruthy();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('passes the completed percentage to the chart', () => {
|
|
22
|
+
const { getByText } = render(<StatusChart completed={75} />);
|
|
23
|
+
expect(getByText('75%')).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('shows Completed label', () => {
|
|
27
|
+
const { getByText } = render(<StatusChart completed={50} />);
|
|
28
|
+
expect(getByText('Completed')).toBeTruthy();
|
|
29
|
+
});
|
|
13
30
|
});
|