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.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/foreman_rh_cloud/locale/fr/foreman_rh_cloud.js +61 -61
  3. data/app/assets/javascripts/foreman_rh_cloud/locale/ja/foreman_rh_cloud.js +68 -68
  4. data/app/assets/javascripts/foreman_rh_cloud/locale/ka/foreman_rh_cloud.js +9 -9
  5. data/app/assets/javascripts/foreman_rh_cloud/locale/ko/foreman_rh_cloud.js +60 -60
  6. data/app/assets/javascripts/foreman_rh_cloud/locale/zh_CN/foreman_rh_cloud.js +60 -60
  7. data/app/controllers/concerns/insights_cloud/package_profile_upload_extensions.rb +0 -9
  8. data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +10 -13
  9. data/app/controllers/insights_cloud/ui_requests_controller.rb +7 -3
  10. data/app/models/concerns/rh_cloud_host.rb +4 -71
  11. data/app/models/insights_client_report_status.rb +1 -9
  12. data/app/models/inventory_sync/inventory_status.rb +4 -16
  13. data/app/services/foreman_rh_cloud/insights_api_forwarder.rb +5 -12
  14. data/app/services/foreman_rh_cloud/url_remediations_retriever.rb +5 -19
  15. data/lib/foreman_inventory_upload/async/create_missing_insights_facets.rb +2 -8
  16. data/lib/foreman_inventory_upload/async/upload_report_direct_job.rb +0 -2
  17. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +4 -34
  18. data/lib/foreman_inventory_upload/generators/queries.rb +1 -1
  19. data/lib/foreman_inventory_upload/generators/slice.rb +1 -1
  20. data/lib/foreman_inventory_upload.rb +1 -8
  21. data/lib/foreman_rh_cloud/engine.rb +0 -1
  22. data/lib/foreman_rh_cloud/version.rb +1 -1
  23. data/lib/foreman_rh_cloud.rb +9 -36
  24. data/lib/insights_cloud/async/insights_generate_notifications.rb +1 -10
  25. data/lib/insights_cloud/async/vmaas_reposcan_sync.rb +8 -23
  26. data/lib/inventory_sync/async/inventory_full_sync.rb +3 -39
  27. data/lib/inventory_sync/async/inventory_self_host_sync.rb +2 -12
  28. data/locale/fr/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  29. data/locale/fr/foreman_rh_cloud.edit.po +1032 -0
  30. data/locale/fr/foreman_rh_cloud.po +65 -66
  31. data/locale/fr/foreman_rh_cloud.po.time_stamp +0 -0
  32. data/locale/ja/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  33. data/locale/ja/foreman_rh_cloud.edit.po +1026 -0
  34. data/locale/ja/foreman_rh_cloud.po +70 -72
  35. data/locale/ja/foreman_rh_cloud.po.time_stamp +0 -0
  36. data/locale/ka/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  37. data/locale/ka/foreman_rh_cloud.edit.po +1025 -0
  38. data/locale/ka/foreman_rh_cloud.po +10 -11
  39. data/locale/ka/foreman_rh_cloud.po.time_stamp +0 -0
  40. data/locale/ko/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  41. data/locale/ko/foreman_rh_cloud.edit.po +1029 -0
  42. data/locale/ko/foreman_rh_cloud.po +63 -64
  43. data/locale/ko/foreman_rh_cloud.po.time_stamp +0 -0
  44. data/locale/zh_CN/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  45. data/locale/zh_CN/foreman_rh_cloud.edit.po +1031 -0
  46. data/locale/zh_CN/foreman_rh_cloud.po +64 -65
  47. data/locale/zh_CN/foreman_rh_cloud.po.time_stamp +0 -0
  48. data/package.json +1 -1
  49. data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +3 -57
  50. data/test/controllers/insights_cloud/ui_requests_controller_test.rb +2 -16
  51. data/test/jobs/insights_client_status_aging_test.rb +0 -40
  52. data/test/jobs/inventory_full_sync_test.rb +4 -219
  53. data/test/jobs/inventory_hosts_sync_test.rb +5 -7
  54. data/test/jobs/inventory_self_host_sync_test.rb +1 -10
  55. data/test/jobs/upload_report_direct_job_test.rb +0 -29
  56. data/test/models/insights_client_report_status_test.rb +0 -109
  57. data/test/unit/archived_report_generator_test.rb +1 -2
  58. data/test/unit/fact_helpers_test.rb +0 -16
  59. data/test/unit/foreman_rh_cloud_self_host_test.rb +2 -50
  60. data/test/unit/insights_facet_test.rb +0 -5
  61. data/test/unit/lib/insights_cloud/async/vmaas_reposcan_sync_test.rb +25 -80
  62. data/test/unit/metadata_generator_test.rb +1 -24
  63. data/test/unit/rh_cloud_host_test.rb +0 -282
  64. data/test/unit/services/foreman_rh_cloud/branch_info_test.rb +1 -1
  65. data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +1 -1
  66. data/test/unit/services/foreman_rh_cloud/url_remediations_retriever_test.rb +5 -82
  67. data/test/unit/slice_generator_test.rb +2 -21
  68. data/webpack/CVEsHostDetailsTab/CVEsHostDetailsTab.js +3 -30
  69. data/webpack/CVEsHostDetailsTab/__tests__/CVEsHostDetailsTab.test.js +10 -112
  70. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/EmptyResults.test.js +9 -10
  71. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/__snapshots__/EmptyResults.test.js.snap +18 -0
  72. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/EmptyState.test.js +9 -13
  73. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/__snapshots__/EmptyState.test.js.snap +25 -0
  74. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/ErrorState.test.js +9 -20
  75. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/__snapshots__/ErrorState.test.js.snap +20 -0
  76. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/ListItem.test.js +8 -31
  77. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +47 -0
  78. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/ListItemStatus.test.js +10 -26
  79. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/__snapshots__/ListItemStatus.test.js.snap +59 -0
  80. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +9 -33
  81. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +34 -0
  82. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +14 -0
  83. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +35 -55
  84. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +25 -0
  85. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +49 -0
  86. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +86 -0
  87. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +75 -0
  88. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +46 -0
  89. data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/FileDownload.test.js +9 -13
  90. data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/__snapshots__/FileDownload.test.js.snap +26 -0
  91. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilter.test.js +15 -12
  92. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterActions.test.js +14 -0
  93. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js +28 -0
  94. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterSelectors.test.js +21 -0
  95. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilter.test.js.snap +21 -0
  96. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterActions.test.js.snap +17 -0
  97. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterReducer.test.js.snap +19 -0
  98. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterSelectors.test.js.snap +9 -0
  99. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +43 -0
  100. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/integration.test.js +12 -32
  101. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/__tests__/AdvancedSettingActions.test.js +9 -0
  102. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/__tests__/__snapshots__/AdvancedSettingActions.test.js.snap +18 -0
  103. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/InventorySettingsActions.test.js +14 -0
  104. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettingsActions.test.js.snap +26 -0
  105. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageTitle.test.js +7 -15
  106. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +68 -0
  107. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorActions.test.js +9 -0
  108. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorButton.test.js +18 -47
  109. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorActions.test.js.snap +11 -0
  110. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorButton.test.js.snap +59 -0
  111. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +1 -3
  112. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.test.js +15 -58
  113. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/__snapshots__/SettingsWarning.test.js.snap +32 -0
  114. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +2 -8
  115. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +9 -23
  116. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonSelectors.test.js +17 -19
  117. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +15 -0
  118. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonSelectors.test.js.snap +3 -0
  119. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/integrations.test.js.snap +57 -0
  120. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js +36 -25
  121. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Toast.js +17 -43
  122. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/ScheduledRun.test.js +8 -28
  123. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/__snapshots__/ScheduledRun.test.js.snap +23 -0
  124. data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/StatusChart.test.js +8 -25
  125. data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/__snapshots__/StatusChart.test.js.snap +74 -0
  126. data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/TabContainer.test.js +9 -11
  127. data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/__snapshots__/TabContainer.test.js.snap +18 -0
  128. data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/TabFooter.test.js +9 -11
  129. data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/__snapshots__/TabFooter.test.js.snap +12 -0
  130. data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +1 -8
  131. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/InventoryAutoUpload.test.js +12 -33
  132. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/__snapshots__/InventoryAutoUpload.test.js.snap +96 -0
  133. data/webpack/ForemanInventoryUpload/__tests__/ForemanInventoryHelpers.test.js +8 -36
  134. data/webpack/ForemanInventoryUpload/__tests__/ForemanInventoryUpload.test.js +10 -0
  135. data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap +5 -0
  136. data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryUpload.test.js.snap +14 -0
  137. data/webpack/ForemanRhCloudHelpers.js +0 -22
  138. data/webpack/InsightsHostDetailsTab/NewHostDetailsTab.js +15 -71
  139. metadata +57 -18
  140. data/app/controllers/concerns/insights_cloud/candlepin_proxies_extensions.rb +0 -23
  141. data/test/controllers/insights_cloud/candlepin_proxies_extensions_test.rb +0 -70
  142. data/test/jobs/insights_generate_notifications_test.rb +0 -26
  143. data/test/models/inventory_sync/inventory_status_test.rb +0 -85
  144. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/__tests__/Toast.test.js +0 -82
  145. data/webpack/InsightsHostDetailsTab/__tests__/NewHostDetailsTab.test.js +0 -266
@@ -0,0 +1,57 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`SyncButton integration test Successful task was triggered on the server resulting in an info toast and polling on the task: handleSync was called 1`] = `
4
+ Array [
5
+ Array [
6
+ Object {
7
+ "payload": Object {
8
+ "message": Object {
9
+ "message": <Toast
10
+ disconnectHosts={2}
11
+ syncHosts={0}
12
+ />,
13
+ "sticky": true,
14
+ "type": "success",
15
+ },
16
+ },
17
+ "type": "TOASTS_ADD",
18
+ },
19
+ ],
20
+ Array [
21
+ Object {
22
+ "errorToast": [Function],
23
+ "interval": 3000,
24
+ "type": "API_GET",
25
+ "url": "/foreman_tasks/api/tasks/1/details?include_permissions",
26
+ },
27
+ ],
28
+ Array [
29
+ Object {
30
+ "payload": Object {
31
+ "message": Object {
32
+ "message": <span>
33
+ Inventory sync has started:
34
+ <br />
35
+ <a
36
+ href="/foreman_tasks/tasks/1"
37
+ rel="noopener noreferrer"
38
+ target="_blank"
39
+ >
40
+ view the task page for more details
41
+ </a>
42
+ </span>,
43
+ "type": "info",
44
+ },
45
+ },
46
+ "type": "TOASTS_ADD",
47
+ },
48
+ ],
49
+ Array [
50
+ Object {
51
+ "errorToast": [Function],
52
+ "type": "API_POST",
53
+ "url": "/foreman_inventory_upload/tasks",
54
+ },
55
+ ],
56
+ ]
57
+ `;
@@ -1,40 +1,51 @@
1
1
  import React from 'react';
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';
2
+ import { IntegrationTestHelper } from '@theforeman/test';
6
3
  import * as API from 'foremanReact/redux/API';
7
- import ConnectedSyncButton from '../index';
4
+ import { noop } from 'foremanReact/common/helpers';
5
+ import SyncButton from '../index';
8
6
  import { successResponse } from './SyncButtonFixtures';
9
- import { INVENTORY_SYNC } from '../SyncButtonConstants';
7
+ import {
8
+ INVENTORY_SYNC,
9
+ INVENTORY_SYNC_TASK_UPDATE,
10
+ } from '../SyncButtonConstants';
10
11
 
11
12
  jest.spyOn(API, 'post');
12
-
13
- const mockStore = configureMockStore([thunk]);
13
+ jest.spyOn(API, 'get');
14
14
 
15
15
  describe('SyncButton integration test', () => {
16
- it('dispatches sync action when button is clicked', () => {
17
- API.post.mockImplementation(({ handleSuccess, key, ...action }) => {
18
- if (key === INVENTORY_SYNC && handleSuccess) {
16
+ it('Successful task was triggered on the server resulting in an info toast and polling on the task', async () => {
17
+ API.post.mockImplementation(({ handleSuccess = noop, key, ...action }) => {
18
+ if (key === INVENTORY_SYNC) {
19
19
  handleSuccess(successResponse);
20
20
  }
21
21
  return { type: 'API_POST', ...action };
22
22
  });
23
-
24
- const store = mockStore({
25
- API: {},
23
+ API.get.mockImplementation(({ handleSuccess = noop, key, ...action }) => {
24
+ if (key === INVENTORY_SYNC_TASK_UPDATE) {
25
+ handleSuccess(
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
+ },
34
+ },
35
+ result: 'success',
36
+ },
37
+ },
38
+ jest.fn
39
+ );
40
+ }
41
+ return { type: 'API_GET', ...action };
26
42
  });
27
43
 
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();
44
+ const integrationTestHelper = new IntegrationTestHelper();
45
+ const wrapper = integrationTestHelper.mount(<SyncButton />);
46
+ const instance = wrapper.find('SyncButton').instance();
47
+ instance.props.handleSync();
48
+ await IntegrationTestHelper.flushAllPromises();
49
+ integrationTestHelper.takeActionsSnapshot('handleSync was called');
39
50
  });
40
51
  });
@@ -1,55 +1,33 @@
1
1
  import React from 'react';
2
- import { Link } from 'react-router-dom';
3
2
  import PropTypes from 'prop-types';
4
3
  import { translate as __ } from 'foremanReact/common/I18n';
4
+ import { foremanUrl } from '../../../../../../ForemanRhCloudHelpers';
5
5
 
6
- const statusSearchParams = statusName =>
7
- `/new/hosts?search=insights_inventory_sync_status+%3D+${statusName}&page=1`;
8
- const DISCONNECT = 'disconnect';
9
- const SYNC = 'sync';
10
- const USER_OMITTED = 'user_omitted';
11
- const HostsWithStatusLink = ({ statusName, children }) => (
12
- <Link to={statusSearchParams(statusName)}>{children}</Link>
13
- );
14
- HostsWithStatusLink.propTypes = {
15
- statusName: PropTypes.string.isRequired,
16
- children: PropTypes.node.isRequired,
17
- };
18
-
19
- const Toast = ({ syncHosts, disconnectHosts, userOmittedHosts }) => {
20
- const totalHosts = syncHosts + disconnectHosts + userOmittedHosts;
6
+ const Toast = ({ syncHosts, disconnectHosts }) => {
7
+ const totalHosts = syncHosts + disconnectHosts;
21
8
  return (
22
9
  <span>
23
10
  <p>
24
- {__('Registered hosts in organization: ')}
25
- <Link to="/new/hosts?search=set%3F+subscription_uuid&page=1">
26
- {totalHosts}
27
- </Link>
11
+ {__('Hosts with subscription in organization: ')}
12
+ <strong>{totalHosts}</strong>
28
13
  </p>
29
14
  <p>
30
- {__('Uploaded and present on console.redhat.com Inventory service: ')}
31
- <HostsWithStatusLink statusName={SYNC}>{syncHosts}</HostsWithStatusLink>
15
+ {__('Successfully synced hosts: ')}
16
+ <strong>{syncHosts}</strong>
32
17
  </p>
33
18
  <p>
34
- {__('Not present on console.redhat.com Inventory service: ')}
35
- <HostsWithStatusLink statusName={DISCONNECT}>
36
- {disconnectHosts}
37
- </HostsWithStatusLink>
19
+ {__('Disconnected hosts: ')}
20
+ <strong>{disconnectHosts}</strong>
38
21
  </p>
39
- {!!userOmittedHosts && (
40
- <p>
41
- {__(
42
- 'Excluded from upload to console.redhat.com Inventory service because host_registration_insights_inventory parameter value is false: '
43
- )}
44
- <HostsWithStatusLink statusName={USER_OMITTED}>
45
- {userOmittedHosts}
46
- </HostsWithStatusLink>
47
- </p>
48
- )}
49
22
  <p>
50
- {__(
51
- 'You can review this information later by looking at the Inventory status of each host.'
52
- )}
23
+ {__('For more info, please visit the')}{' '}
24
+ <a
25
+ href={foremanUrl('/hosts')}
26
+ target="_blank"
27
+ rel="noopener noreferrer"
28
+ >
29
+ {__('hosts page')}
30
+ </a>
53
31
  </p>
54
32
  </span>
55
33
  );
@@ -58,10 +36,6 @@ const Toast = ({ syncHosts, disconnectHosts, userOmittedHosts }) => {
58
36
  Toast.propTypes = {
59
37
  syncHosts: PropTypes.number.isRequired,
60
38
  disconnectHosts: PropTypes.number.isRequired,
61
- userOmittedHosts: PropTypes.number,
62
- };
63
- Toast.defaultProps = {
64
- userOmittedHosts: 0,
65
39
  };
66
40
 
67
41
  export default Toast;
@@ -1,33 +1,13 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
- import { IntlProvider } from 'react-intl';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+
4
3
  import ScheduledRun from '../ScheduledRun';
4
+ import { props } from '../ScheduledRun.fixtures';
5
5
 
6
- const renderWithIntl = ui =>
7
- render(<IntlProvider locale="en">{ui}</IntlProvider>);
6
+ const fixtures = {
7
+ 'render with Props': props,
8
+ };
8
9
 
9
10
  describe('ScheduledRun', () => {
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
- });
11
+ describe('rendering', () =>
12
+ testComponentSnapshotsWithFixtures(ScheduledRun, fixtures));
33
13
  });
@@ -0,0 +1,23 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ScheduledRun rendering render with Props 1`] = `
4
+ <Col
5
+ bsClass="col"
6
+ className="scheduled_run"
7
+ componentClass="div"
8
+ sm={12}
9
+ >
10
+ <p>
11
+ <Icon
12
+ name="calendar"
13
+ type="fa"
14
+ />
15
+ Next run:
16
+ <FormattedRelative
17
+ updateInterval={10000}
18
+ value="2019-08-21T16:14:16.520+03:00"
19
+ />
20
+ .
21
+ </p>
22
+ </Col>
23
+ `;
@@ -1,30 +1,13 @@
1
- import React from 'react';
2
- import { render } from '@testing-library/react';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+
3
3
  import StatusChart from '../StatusChart';
4
4
 
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
- }));
5
+ const fixtures = {
6
+ 'render without Props': {},
7
+ /** fixtures, props for the component */
8
+ };
14
9
 
15
10
  describe('StatusChart', () => {
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
- });
11
+ describe('rendering', () =>
12
+ testComponentSnapshotsWithFixtures(StatusChart, fixtures));
30
13
  });
@@ -0,0 +1,74 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`StatusChart rendering render without Props 1`] = `
4
+ <Col
5
+ bsClass="col"
6
+ componentClass="div"
7
+ sm={4}
8
+ >
9
+ <div
10
+ className="status-chart"
11
+ >
12
+ <DonutChart
13
+ className="donut-chart-pf"
14
+ color={
15
+ Object {
16
+ "pattern": Array [
17
+ "#0088ce",
18
+ "#d1d1d1",
19
+ ],
20
+ }
21
+ }
22
+ data={
23
+ Object {
24
+ "columns": Array [
25
+ Array [
26
+ "Completed",
27
+ 0,
28
+ ],
29
+ Array [
30
+ "Remain",
31
+ 100,
32
+ ],
33
+ ],
34
+ "order": null,
35
+ }
36
+ }
37
+ donut={
38
+ Object {
39
+ "label": Object {
40
+ "show": false,
41
+ },
42
+ "title": undefined,
43
+ "width": 11,
44
+ }
45
+ }
46
+ id="donut-chart-1"
47
+ legend={
48
+ Object {
49
+ "show": false,
50
+ }
51
+ }
52
+ size={
53
+ Object {
54
+ "height": 210,
55
+ "width": 210,
56
+ }
57
+ }
58
+ title={
59
+ Object {
60
+ "primary": "0%",
61
+ "secondary": "Completed",
62
+ "type": "percent",
63
+ }
64
+ }
65
+ tooltip={
66
+ Object {
67
+ "contents": [Function],
68
+ }
69
+ }
70
+ type="donut"
71
+ />
72
+ </div>
73
+ </Col>
74
+ `;
@@ -1,15 +1,13 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+
3
3
  import TabContainer from '../TabContainer';
4
4
 
5
- describe('TabContainer', () => {
6
- it('renders children', () => {
7
- render(<TabContainer><span>Tab content</span></TabContainer>);
8
- expect(screen.getByText('Tab content')).toBeTruthy();
9
- });
5
+ const fixtures = {
6
+ 'render without Props': {},
7
+ /** fixtures, props for the component */
8
+ };
10
9
 
11
- it('renders with custom className', () => {
12
- const { container } = render(<TabContainer className="my-tab" />);
13
- expect(container.querySelector('.my-tab')).toBeTruthy();
14
- });
10
+ describe('TabContainer', () => {
11
+ describe('rendering', () =>
12
+ testComponentSnapshotsWithFixtures(TabContainer, fixtures));
15
13
  });
@@ -0,0 +1,18 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`TabContainer rendering render without Props 1`] = `
4
+ <div
5
+ className=""
6
+ >
7
+ <Grid
8
+ bsClass="container"
9
+ componentClass="div"
10
+ fluid={false}
11
+ >
12
+ <Col
13
+ bsClass="col"
14
+ componentClass="div"
15
+ />
16
+ </Grid>
17
+ </div>
18
+ `;
@@ -1,15 +1,13 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+
3
3
  import TabFooter from '../TabFooter';
4
4
 
5
- describe('TabFooter', () => {
6
- it('renders children', () => {
7
- render(<TabFooter><span>Footer content</span></TabFooter>);
8
- expect(screen.getByText('Footer content')).toBeTruthy();
9
- });
5
+ const fixtures = {
6
+ 'render without Props': {},
7
+ /** fixtures, props for the component */
8
+ };
10
9
 
11
- it('renders with the tab-footer class', () => {
12
- const { container } = render(<TabFooter />);
13
- expect(container.querySelector('.tab-footer')).toBeTruthy();
14
- });
10
+ describe('TabFooter', () => {
11
+ describe('rendering', () =>
12
+ testComponentSnapshotsWithFixtures(TabFooter, fixtures));
15
13
  });
@@ -0,0 +1,12 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`TabFooter rendering render without Props 1`] = `
4
+ <Row
5
+ bsClass="row"
6
+ componentClass="div"
7
+ >
8
+ <div
9
+ className="tab-footer"
10
+ />
11
+ </Row>
12
+ `;
@@ -1,20 +1,13 @@
1
1
  import URI from 'urijs';
2
- import { getDocsURL } from 'foremanReact/common/helpers';
3
2
  import { foremanUrl } from '../ForemanRhCloudHelpers';
4
3
 
5
4
  export const inventoryUrl = path =>
6
5
  foremanUrl(`/foreman_inventory_upload/${path}`);
7
6
 
8
7
  export const getInventoryDocsUrl = () =>
9
- getDocsURL(
10
- 'Managing_Hosts',
11
- 'configuring-foreman-server-for-cloud-connection'
12
- );
13
-
14
- export const getSubscriptionServiceDocsUrl = () =>
15
8
  foremanUrl(
16
9
  `/links/manual/?root_url=${URI.encode(
17
- 'https://docs.redhat.com/en/documentation/subscription_central/1-latest/html-single/getting_started_with_the_subscriptions_service/index'
10
+ 'https://docs.redhat.com/en/documentation/red_hat_lightspeed/1-latest/html-single/red_hat_lightspeed_remediations_guide/index'
18
11
  )}`
19
12
  );
20
13
 
@@ -1,38 +1,17 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
- import InventoryAutoUpload from '../InventoryAutoUpload';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+ import { noop } from 'foremanReact/common/helpers';
4
3
 
5
- jest.mock(
6
- '../../../Components/InventorySettings/InventorySettings',
7
- () => () => <div data-testid="inventory-settings">InventorySettings</div>
8
- );
4
+ import InventoryAutoUpload from '../InventoryAutoUpload';
9
5
 
10
- describe('InventoryAutoUpload', () => {
11
- const buildProps = (overrides = {}) => ({
6
+ const fixtures = {
7
+ 'render with props': {
12
8
  autoUploadEnabled: true,
13
- setSetting: jest.fn(),
14
- getSettings: jest.fn(),
15
- ...overrides,
16
- });
17
-
18
- it('renders the heading', () => {
19
- render(<InventoryAutoUpload {...buildProps()} />);
20
- expect(screen.getByText('Red Hat Cloud Inventory')).toBeTruthy();
21
- });
9
+ setSetting: noop,
10
+ getSettings: noop,
11
+ },
12
+ };
22
13
 
23
- it('renders the auto upload switcher', () => {
24
- render(<InventoryAutoUpload {...buildProps()} />);
25
- expect(screen.getByText('Inventory Auto Upload')).toBeTruthy();
26
- });
27
-
28
- it('renders the advanced settings button', () => {
29
- render(<InventoryAutoUpload {...buildProps()} />);
30
- expect(screen.getByRole('button', { name: /Show Advanced Settings/ })).toBeTruthy();
31
- });
32
-
33
- it('calls getSettings on mount', () => {
34
- const props = buildProps();
35
- render(<InventoryAutoUpload {...props} />);
36
- expect(props.getSettings).toHaveBeenCalled();
37
- });
14
+ describe('InventoryAutoUpload', () => {
15
+ describe('rendering', () =>
16
+ testComponentSnapshotsWithFixtures(InventoryAutoUpload, fixtures));
38
17
  });
@@ -0,0 +1,96 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`InventoryAutoUpload rendering render with props 1`] = `
4
+ <FormGroup
5
+ bsClass="form-group"
6
+ >
7
+ <Grid
8
+ bsClass="container"
9
+ componentClass="div"
10
+ fluid={false}
11
+ >
12
+ <h3>
13
+ Red Hat Cloud Inventory
14
+ </h3>
15
+ <hr />
16
+ <Row
17
+ bsClass="row"
18
+ componentClass="div"
19
+ >
20
+ <Switcher
21
+ SwitchCol={2}
22
+ id="auto-upload"
23
+ isChecked={true}
24
+ label="Inventory Auto Upload"
25
+ labelCol={5}
26
+ onChange={[Function]}
27
+ tooltip="Enable automatic upload of your hosts inventory to the Red Hat cloud"
28
+ />
29
+ <Col
30
+ bsClass="col"
31
+ componentClass="div"
32
+ sm={5}
33
+ >
34
+ <Popover
35
+ bodyContent={<InventorySettings />}
36
+ headerContent={
37
+ <strong>
38
+ Advanced Inventory Settings
39
+ </strong>
40
+ }
41
+ position="right"
42
+ >
43
+ <Button
44
+ ouiaId="button-advanced-settings"
45
+ style={
46
+ Object {
47
+ "fontSize": "small",
48
+ "marginTop": "-4px",
49
+ }
50
+ }
51
+ variant="secondary"
52
+ >
53
+ Show Advanced Settings
54
+
55
+ <CaretRightIcon />
56
+ </Button>
57
+ </Popover>
58
+ </Col>
59
+ </Row>
60
+ <br />
61
+ <Row
62
+ bsClass="row"
63
+ componentClass="div"
64
+ >
65
+ <Col
66
+ bsClass="col"
67
+ componentClass="div"
68
+ sm={12}
69
+ >
70
+ <Text
71
+ component="p"
72
+ ouiaId="text-more-details"
73
+ >
74
+ <InfoAltIcon />
75
+
76
+ More details can be found in
77
+
78
+ <Text
79
+ component="a"
80
+ href="/foreman_rh_cloud/inventory_upload"
81
+ ouiaId="text-details-link"
82
+ rel="noopener noreferrer"
83
+ target="_blank"
84
+ >
85
+ <strong>
86
+ Configure
87
+ &gt;
88
+ Inventory Upload
89
+ </strong>
90
+ </Text>
91
+ </Text>
92
+ </Col>
93
+ </Row>
94
+ </Grid>
95
+ </FormGroup>
96
+ `;