foreman_rh_cloud 13.2.12 → 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 (147) 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/tags_auth.rb +13 -28
  15. data/app/services/foreman_rh_cloud/url_remediations_retriever.rb +5 -19
  16. data/lib/foreman_inventory_upload/async/create_missing_insights_facets.rb +2 -8
  17. data/lib/foreman_inventory_upload/async/upload_report_direct_job.rb +0 -2
  18. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +4 -34
  19. data/lib/foreman_inventory_upload/generators/queries.rb +1 -1
  20. data/lib/foreman_inventory_upload/generators/slice.rb +1 -1
  21. data/lib/foreman_inventory_upload.rb +1 -8
  22. data/lib/foreman_rh_cloud/engine.rb +0 -1
  23. data/lib/foreman_rh_cloud/version.rb +1 -1
  24. data/lib/foreman_rh_cloud.rb +9 -36
  25. data/lib/insights_cloud/async/insights_generate_notifications.rb +1 -10
  26. data/lib/insights_cloud/async/vmaas_reposcan_sync.rb +8 -23
  27. data/lib/inventory_sync/async/inventory_full_sync.rb +3 -39
  28. data/lib/inventory_sync/async/inventory_self_host_sync.rb +2 -12
  29. data/locale/fr/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  30. data/locale/fr/foreman_rh_cloud.edit.po +1032 -0
  31. data/locale/fr/foreman_rh_cloud.po +65 -66
  32. data/locale/fr/foreman_rh_cloud.po.time_stamp +0 -0
  33. data/locale/ja/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  34. data/locale/ja/foreman_rh_cloud.edit.po +1026 -0
  35. data/locale/ja/foreman_rh_cloud.po +70 -72
  36. data/locale/ja/foreman_rh_cloud.po.time_stamp +0 -0
  37. data/locale/ka/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  38. data/locale/ka/foreman_rh_cloud.edit.po +1025 -0
  39. data/locale/ka/foreman_rh_cloud.po +10 -11
  40. data/locale/ka/foreman_rh_cloud.po.time_stamp +0 -0
  41. data/locale/ko/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  42. data/locale/ko/foreman_rh_cloud.edit.po +1029 -0
  43. data/locale/ko/foreman_rh_cloud.po +63 -64
  44. data/locale/ko/foreman_rh_cloud.po.time_stamp +0 -0
  45. data/locale/zh_CN/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  46. data/locale/zh_CN/foreman_rh_cloud.edit.po +1031 -0
  47. data/locale/zh_CN/foreman_rh_cloud.po +64 -65
  48. data/locale/zh_CN/foreman_rh_cloud.po.time_stamp +0 -0
  49. data/package.json +1 -1
  50. data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +3 -57
  51. data/test/controllers/insights_cloud/ui_requests_controller_test.rb +2 -16
  52. data/test/jobs/insights_client_status_aging_test.rb +0 -40
  53. data/test/jobs/inventory_full_sync_test.rb +4 -219
  54. data/test/jobs/inventory_hosts_sync_test.rb +5 -7
  55. data/test/jobs/inventory_self_host_sync_test.rb +1 -10
  56. data/test/jobs/upload_report_direct_job_test.rb +0 -29
  57. data/test/models/insights_client_report_status_test.rb +0 -109
  58. data/test/unit/archived_report_generator_test.rb +1 -2
  59. data/test/unit/fact_helpers_test.rb +0 -16
  60. data/test/unit/foreman_rh_cloud_self_host_test.rb +2 -50
  61. data/test/unit/insights_facet_test.rb +0 -5
  62. data/test/unit/lib/insights_cloud/async/vmaas_reposcan_sync_test.rb +25 -80
  63. data/test/unit/metadata_generator_test.rb +1 -24
  64. data/test/unit/rh_cloud_host_test.rb +0 -282
  65. data/test/unit/services/foreman_rh_cloud/branch_info_test.rb +1 -1
  66. data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +1 -1
  67. data/test/unit/services/foreman_rh_cloud/tags_auth_test.rb +0 -26
  68. data/test/unit/services/foreman_rh_cloud/url_remediations_retriever_test.rb +5 -82
  69. data/test/unit/slice_generator_test.rb +2 -21
  70. data/webpack/CVEsHostDetailsTab/CVEsHostDetailsTab.js +3 -30
  71. data/webpack/CVEsHostDetailsTab/__tests__/CVEsHostDetailsTab.test.js +10 -112
  72. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/EmptyResults.test.js +9 -10
  73. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/__snapshots__/EmptyResults.test.js.snap +18 -0
  74. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/EmptyState.test.js +9 -13
  75. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/__snapshots__/EmptyState.test.js.snap +25 -0
  76. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/ErrorState.test.js +9 -20
  77. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/__snapshots__/ErrorState.test.js.snap +20 -0
  78. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/ListItem.test.js +8 -31
  79. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +47 -0
  80. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/ListItemStatus.test.js +10 -26
  81. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/__snapshots__/ListItemStatus.test.js.snap +59 -0
  82. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +9 -33
  83. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +34 -0
  84. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +14 -0
  85. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +35 -55
  86. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +25 -0
  87. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +49 -0
  88. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +86 -0
  89. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +75 -0
  90. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +46 -0
  91. data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/FileDownload.test.js +9 -13
  92. data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/__snapshots__/FileDownload.test.js.snap +26 -0
  93. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilter.test.js +15 -12
  94. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterActions.test.js +14 -0
  95. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js +28 -0
  96. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterSelectors.test.js +21 -0
  97. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilter.test.js.snap +21 -0
  98. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterActions.test.js.snap +17 -0
  99. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterReducer.test.js.snap +19 -0
  100. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterSelectors.test.js.snap +9 -0
  101. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +43 -0
  102. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/integration.test.js +12 -32
  103. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/__tests__/AdvancedSettingActions.test.js +9 -0
  104. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/__tests__/__snapshots__/AdvancedSettingActions.test.js.snap +18 -0
  105. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/InventorySettingsActions.test.js +14 -0
  106. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettingsActions.test.js.snap +26 -0
  107. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageTitle.test.js +7 -15
  108. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +68 -0
  109. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorActions.test.js +9 -0
  110. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorButton.test.js +18 -47
  111. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorActions.test.js.snap +11 -0
  112. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorButton.test.js.snap +59 -0
  113. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +1 -3
  114. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.test.js +15 -58
  115. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/__snapshots__/SettingsWarning.test.js.snap +32 -0
  116. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +2 -8
  117. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +9 -23
  118. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonSelectors.test.js +17 -19
  119. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +15 -0
  120. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonSelectors.test.js.snap +3 -0
  121. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/integrations.test.js.snap +57 -0
  122. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js +36 -25
  123. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Toast.js +17 -43
  124. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/ScheduledRun.test.js +8 -28
  125. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/__snapshots__/ScheduledRun.test.js.snap +23 -0
  126. data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/StatusChart.test.js +8 -25
  127. data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/__snapshots__/StatusChart.test.js.snap +74 -0
  128. data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/TabContainer.test.js +9 -11
  129. data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/__snapshots__/TabContainer.test.js.snap +18 -0
  130. data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/TabFooter.test.js +9 -11
  131. data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/__snapshots__/TabFooter.test.js.snap +12 -0
  132. data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +1 -8
  133. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/InventoryAutoUpload.test.js +12 -33
  134. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/__snapshots__/InventoryAutoUpload.test.js.snap +96 -0
  135. data/webpack/ForemanInventoryUpload/__tests__/ForemanInventoryHelpers.test.js +8 -36
  136. data/webpack/ForemanInventoryUpload/__tests__/ForemanInventoryUpload.test.js +10 -0
  137. data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap +5 -0
  138. data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryUpload.test.js.snap +14 -0
  139. data/webpack/ForemanRhCloudHelpers.js +0 -22
  140. data/webpack/InsightsHostDetailsTab/NewHostDetailsTab.js +15 -71
  141. metadata +57 -18
  142. data/app/controllers/concerns/insights_cloud/candlepin_proxies_extensions.rb +0 -23
  143. data/test/controllers/insights_cloud/candlepin_proxies_extensions_test.rb +0 -70
  144. data/test/jobs/insights_generate_notifications_test.rb +0 -26
  145. data/test/models/inventory_sync/inventory_status_test.rb +0 -85
  146. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/__tests__/Toast.test.js +0 -82
  147. data/webpack/InsightsHostDetailsTab/__tests__/NewHostDetailsTab.test.js +0 -266
@@ -641,6 +641,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
641
641
  assert_tag('1', actual_host, 'int_param', 'satellite_parameter')
642
642
 
643
643
  assert_equal false, satellite_facts['is_hostname_obfuscated']
644
+ assert_equal true, satellite_facts['is_simple_content_access']
644
645
 
645
646
  version = satellite_facts['satellite_version']
646
647
  if defined?(ForemanThemeSatellite)
@@ -702,22 +703,6 @@ class SliceGeneratorTest < ActiveSupport::TestCase
702
703
  assert_equal 'test_sla', fact_values['system_purpose_sla']
703
704
  end
704
705
 
705
- test 'generates a report for a golden ticket' do
706
- batch = Host.where(id: @host.id).in_batches.first
707
- generator = create_generator(batch) do |generator|
708
- generator.stubs(:golden_ticket?).returns(true)
709
- end
710
-
711
- json_str = generator.render
712
- actual = JSON.parse(json_str.join("\n"))
713
-
714
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
715
- assert_not_nil(actual_host = actual['hosts'].first)
716
- assert_equal @host.fqdn, actual_host['fqdn']
717
- assert_equal '1234', actual_host['account']
718
- assert_equal 1, generator.hosts_count
719
- end
720
-
721
706
  test 'skips hosts without subscription' do
722
707
  a_host = FactoryBot.create(
723
708
  :host,
@@ -1131,11 +1116,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
1131
1116
 
1132
1117
  def create_generator(batch, name = '00000000-0000-0000-0000-000000000000')
1133
1118
  generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], name)
1134
- if block_given?
1135
- yield(generator)
1136
- else
1137
- generator.stubs(:golden_ticket?).returns(false)
1138
- end
1119
+ yield(generator) if block_given?
1139
1120
  generator
1140
1121
  end
1141
1122
 
@@ -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
- const mockUnmountTracker = jest.fn();
26
- jest.mock('@scalprum/react-core', () => {
27
- const ReactMock = require('react');
28
- return {
29
- ScalprumComponent: jest.fn(props => {
30
- ReactMock.useEffect(() => mockUnmountTracker, []);
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
- beforeEach(() => {
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
- <MemoryRouter>
54
- <CVEsHostDetailsTabWrapper response={defaultResponse} />
55
- </MemoryRouter>
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 React from 'react';
2
- import { render, screen } from '@testing-library/react';
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
- it('renders the empty results message', () => {
7
- render(<EmptyResults />);
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 React from 'react';
2
- import { render, screen } from '@testing-library/react';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+
3
3
  import EmptyState from '../EmptyState';
4
4
 
5
- describe('EmptyState', () => {
6
- it('renders fetching data message', () => {
7
- render(<EmptyState />);
8
- expect(
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
- it('renders loading indicator', () => {
14
- render(<EmptyState />);
15
- expect(screen.getByText('Loading...')).toBeTruthy();
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 React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
- import ErrorState from '../ErrorState';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
4
2
 
5
- describe('ErrorState', () => {
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
- it('renders the error description', () => {
16
- render(<ErrorState error="Connection refused" />);
17
- expect(screen.getByText('Connection refused')).toBeTruthy();
18
- });
5
+ const fixtures = {
6
+ 'render without Props': {},
7
+ /** fixtures, props for the component */
8
+ };
19
9
 
20
- it('renders with empty error by default', () => {
21
- const { container } = render(<ErrorState />);
22
- expect(container.querySelector('.error_description')).toBeTruthy();
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 React from 'react';
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
- jest.mock('../../../../Dashboard', () => () => null);
3
+ import ListItem from '../ListItem';
4
+ import { props } from '../ListItem.fixtures';
7
5
 
8
- const renderListItem = props =>
9
- render(
10
- <Accordion>
11
- <ListItem {...props} />
12
- </Accordion>
13
- );
6
+ const fixtures = {
7
+ 'render with Props': props,
8
+ };
14
9
 
15
10
  describe('ListItem', () => {
16
- const defaultProps = {
17
- label: 'test-org',
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 React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
- import ListItemStatus from '../ListItemStatus';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
4
2
 
5
- describe('ListItemStatus', () => {
6
- it('renders Generated and Uploaded labels', () => {
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
- it('shows dash placeholders for unknown status', () => {
13
- render(
14
- <ListItemStatus
15
- account={{ generated_status: 'unknown', uploaded_status: 'unknown' }}
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
- it('renders with provided account statuses', () => {
22
- render(
23
- <ListItemStatus
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 React from 'react';
2
- import { render, screen } from '@testing-library/react';
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+
3
3
  import AccountList from '../AccountList';
4
- import { accounts } from '../AccountList.fixtures';
4
+ import { props } from '../AccountList.fixtures';
5
5
 
6
- jest.mock('../Components/ListItem', () => ({ label }) => (
7
- <div>{label}</div>
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
- it('renders account labels', () => {
12
- render(<AccountList accounts={accounts} />);
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
  });