foreman_rh_cloud 12.2.10 → 13.0.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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/foreman_rh_cloud/locale/fr/foreman_rh_cloud.js +17 -50
  3. data/app/assets/javascripts/foreman_rh_cloud/locale/ja/foreman_rh_cloud.js +17 -50
  4. data/app/assets/javascripts/foreman_rh_cloud/locale/ka/foreman_rh_cloud.js +16 -49
  5. data/app/assets/javascripts/foreman_rh_cloud/locale/ko/foreman_rh_cloud.js +17 -50
  6. data/app/assets/javascripts/foreman_rh_cloud/locale/zh_CN/foreman_rh_cloud.js +17 -50
  7. data/app/controllers/concerns/insights_cloud/package_profile_upload_extensions.rb +3 -2
  8. data/app/models/insights_hit.rb +1 -1
  9. data/app/services/foreman_rh_cloud/cert_auth.rb +3 -13
  10. data/app/services/foreman_rh_cloud/gateway_request.rb +26 -0
  11. data/app/services/foreman_rh_cloud/insights_api_forwarder.rb +1 -3
  12. data/app/services/foreman_rh_cloud/tags_auth.rb +1 -2
  13. data/lib/foreman_inventory_upload/async/generate_report_job.rb +8 -13
  14. data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +4 -4
  15. data/lib/foreman_inventory_upload/async/upload_report_job.rb +5 -6
  16. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +2 -2
  17. data/lib/foreman_inventory_upload/generators/slice.rb +3 -3
  18. data/lib/foreman_inventory_upload/scripts/uploader.sh.erb +1 -7
  19. data/lib/foreman_rh_cloud/engine.rb +15 -33
  20. data/lib/foreman_rh_cloud/plugin.rb +9 -9
  21. data/lib/foreman_rh_cloud/version.rb +1 -1
  22. data/lib/tasks/rh_cloud_inventory.rake +31 -14
  23. data/locale/foreman_rh_cloud.pot +152 -219
  24. data/locale/fr/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  25. data/locale/fr/foreman_rh_cloud.po +18 -50
  26. data/locale/ja/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  27. data/locale/ja/foreman_rh_cloud.po +18 -50
  28. data/locale/ka/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  29. data/locale/ka/foreman_rh_cloud.po +17 -49
  30. data/locale/ko/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  31. data/locale/ko/foreman_rh_cloud.po +18 -50
  32. data/locale/zh_CN/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
  33. data/locale/zh_CN/foreman_rh_cloud.po +18 -50
  34. data/package.json +1 -1
  35. data/test/jobs/upload_report_job_test.rb +1 -2
  36. data/test/unit/fact_helpers_test.rb +0 -47
  37. data/test/unit/slice_generator_test.rb +0 -57
  38. data/webpack/ForemanRhCloudFills.js +2 -6
  39. data/webpack/ForemanRhCloudHelpers.js +0 -4
  40. data/webpack/InsightsHostDetailsTab/InsightsTab.scss +0 -4
  41. data/webpack/InsightsHostDetailsTab/InsightsTotalRiskChart.js +23 -59
  42. data/webpack/InsightsHostDetailsTab/NewHostDetailsTab.js +16 -3
  43. data/webpack/__tests__/ForemanRhCloudHelpers.test.js +1 -16
  44. data/webpack/__tests__/__snapshots__/ForemanRhCloudHelpers.test.js.snap +0 -6
  45. metadata +4 -10
  46. data/lib/foreman_inventory_upload/async/create_missing_insights_facets.rb +0 -29
  47. data/lib/foreman_inventory_upload/async/generate_host_report.rb +0 -20
  48. data/lib/foreman_inventory_upload/async/host_inventory_report_job.rb +0 -39
  49. data/lib/foreman_inventory_upload/async/single_host_report_job.rb +0 -20
  50. data/test/jobs/queue_for_upload_job_test.rb +0 -63
  51. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTotalRiskChart.test.js +0 -194
@@ -131,15 +131,28 @@ const IopInsightsTabWrapped = props => (
131
131
  );
132
132
 
133
133
  const InsightsTab = props => {
134
- const isLocalIop = useAdvisorEngineConfig();
134
+ const { response } = props;
135
+ const isLocalAdvisorEngine =
136
+ // eslint-disable-next-line camelcase
137
+ response?.insights_attributes?.use_iop_mode;
135
138
 
136
- return isLocalIop ? (
139
+ return isLocalAdvisorEngine ? (
137
140
  <IopInsightsTabWrapped {...props} />
138
141
  ) : (
139
142
  <NewHostDetailsTab {...props} />
140
143
  );
141
144
  };
142
145
 
143
- InsightsTab.defaultProps = {};
146
+ InsightsTab.propTypes = {
147
+ response: PropTypes.shape({
148
+ insights_attributes: {
149
+ use_iop_mode: PropTypes.bool,
150
+ },
151
+ }),
152
+ };
153
+
154
+ InsightsTab.defaultProps = {
155
+ response: {},
156
+ };
144
157
 
145
158
  export default InsightsTab;
@@ -1,5 +1,5 @@
1
1
  import { testSelectorsSnapshotWithFixtures } from '@theforeman/test';
2
- import { foremanUrl, vulnerabilityDisabled, hasNoInsightsFacet } from '../ForemanRhCloudHelpers';
2
+ import { foremanUrl, vulnerabilityDisabled } from '../ForemanRhCloudHelpers';
3
3
 
4
4
  global.URL_PREFIX = 'MY_TEST_URL_PREFIX.example.com';
5
5
 
@@ -34,21 +34,6 @@ const fixtures = {
34
34
  }),
35
35
  'vulnerabilityDisabled returns true for missing hostDetails': () =>
36
36
  vulnerabilityDisabled({}),
37
- 'hasNoInsightsFacet returns false when insights_attributes is present': () =>
38
- hasNoInsightsFacet({
39
- response: {
40
- insights_attributes: {
41
- uuid: 'test-uuid',
42
- insights_hits_count: 5,
43
- },
44
- },
45
- }),
46
- 'hasNoInsightsFacet returns true when insights_attributes is missing': () =>
47
- hasNoInsightsFacet({
48
- response: {},
49
- }),
50
- 'hasNoInsightsFacet returns true when response is missing': () =>
51
- hasNoInsightsFacet({}),
52
37
  };
53
38
 
54
39
  describe('ForemanRhCloud helpers', () =>
@@ -1,11 +1,5 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`ForemanRhCloud helpers hasNoInsightsFacet returns false when insights_attributes is present 1`] = `false`;
4
-
5
- exports[`ForemanRhCloud helpers hasNoInsightsFacet returns true when insights_attributes is missing 1`] = `true`;
6
-
7
- exports[`ForemanRhCloud helpers hasNoInsightsFacet returns true when response is missing 1`] = `true`;
8
-
9
3
  exports[`ForemanRhCloud helpers should return foreman Url 1`] = `"MY_TEST_URL_PREFIX.example.com/test_path"`;
10
4
 
11
5
  exports[`ForemanRhCloud helpers vulnerabilityDisabled returns false for RHEL host with vulnerability enabled 1`] = `false`;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_rh_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.2.10
4
+ version: 13.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Red Hat Cloud team
@@ -43,14 +43,14 @@ dependencies:
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: '4.18'
46
+ version: 4.14.0.rc1.1
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: '4.18'
53
+ version: 4.14.0.rc1.1
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: rdoc
56
56
  requirement: !ruby/object:Gem::Requirement
@@ -139,6 +139,7 @@ files:
139
139
  - app/services/foreman_rh_cloud/cloud_presence.rb
140
140
  - app/services/foreman_rh_cloud/cloud_request.rb
141
141
  - app/services/foreman_rh_cloud/cloud_request_forwarder.rb
142
+ - app/services/foreman_rh_cloud/gateway_request.rb
142
143
  - app/services/foreman_rh_cloud/hit_remediations_retriever.rb
143
144
  - app/services/foreman_rh_cloud/hits_uploader.rb
144
145
  - app/services/foreman_rh_cloud/insights_api_forwarder.rb
@@ -184,17 +185,13 @@ files:
184
185
  - db/seeds.d/50_job_templates.rb
185
186
  - lib/foreman_inventory_upload.rb
186
187
  - lib/foreman_inventory_upload/async/async_helpers.rb
187
- - lib/foreman_inventory_upload/async/create_missing_insights_facets.rb
188
188
  - lib/foreman_inventory_upload/async/delayed_start.rb
189
189
  - lib/foreman_inventory_upload/async/generate_all_reports_job.rb
190
- - lib/foreman_inventory_upload/async/generate_host_report.rb
191
190
  - lib/foreman_inventory_upload/async/generate_report_job.rb
192
- - lib/foreman_inventory_upload/async/host_inventory_report_job.rb
193
191
  - lib/foreman_inventory_upload/async/progress_output.rb
194
192
  - lib/foreman_inventory_upload/async/queue_for_upload_job.rb
195
193
  - lib/foreman_inventory_upload/async/remove_insights_hosts_job.rb
196
194
  - lib/foreman_inventory_upload/async/shell_process.rb
197
- - lib/foreman_inventory_upload/async/single_host_report_job.rb
198
195
  - lib/foreman_inventory_upload/async/upload_report_job.rb
199
196
  - lib/foreman_inventory_upload/generators/archived_report.rb
200
197
  - lib/foreman_inventory_upload/generators/fact_helpers.rb
@@ -270,7 +267,6 @@ files:
270
267
  - test/jobs/inventory_hosts_sync_test.rb
271
268
  - test/jobs/inventory_scheduled_sync_test.rb
272
269
  - test/jobs/inventory_self_host_sync_test.rb
273
- - test/jobs/queue_for_upload_job_test.rb
274
270
  - test/jobs/remove_insights_hosts_job_test.rb
275
271
  - test/jobs/upload_report_job_test.rb
276
272
  - test/models/insights_client_report_status_test.rb
@@ -622,7 +618,6 @@ files:
622
618
  - webpack/InsightsHostDetailsTab/__tests__/InsightsTabIntegration.test.js
623
619
  - webpack/InsightsHostDetailsTab/__tests__/InsightsTabReducer.test.js
624
620
  - webpack/InsightsHostDetailsTab/__tests__/InsightsTabSelectors.test.js
625
- - webpack/InsightsHostDetailsTab/__tests__/InsightsTotalRiskChart.test.js
626
621
  - webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTab.test.js.snap
627
622
  - webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabActions.test.js.snap
628
623
  - webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabReducer.test.js.snap
@@ -724,7 +719,6 @@ test_files:
724
719
  - test/jobs/inventory_hosts_sync_test.rb
725
720
  - test/jobs/inventory_scheduled_sync_test.rb
726
721
  - test/jobs/inventory_self_host_sync_test.rb
727
- - test/jobs/queue_for_upload_job_test.rb
728
722
  - test/jobs/remove_insights_hosts_job_test.rb
729
723
  - test/jobs/upload_report_job_test.rb
730
724
  - test/models/insights_client_report_status_test.rb
@@ -1,29 +0,0 @@
1
- module ForemanInventoryUpload
2
- module Async
3
- class CreateMissingInsightsFacets < ::Actions::EntryAction
4
- def plan(organization_id)
5
- plan_self(organization_id: organization_id)
6
- end
7
-
8
- def run
9
- organization = ::Organization.find(input[:organization_id])
10
- hosts_without_facets = ::ForemanInventoryUpload::Generators::Queries.for_org(organization, hosts_query: 'null? insights_uuid')
11
- facet_count = hosts_without_facets.count
12
- hosts_without_facets.each do |batch|
13
- facets = batch.pluck(:id, 'katello_subscription_facets.uuid').map do |host_id, uuid|
14
- {
15
- host_id: host_id,
16
- uuid: uuid,
17
- }
18
- end
19
- # We don't need to validate the facets here as we create the necessary fields.
20
- # rubocop:disable Rails/SkipsModelValidations
21
- InsightsFacet.upsert_all(facets, unique_by: :host_id) unless facets.empty?
22
- # rubocop:enable Rails/SkipsModelValidations
23
- end
24
- output[:result] = facet_count.zero? ? _("There were no missing Insights facets") : format(_("Missing Insights facets created: %s"), facet_count)
25
- Rails.logger.info output[:result]
26
- end
27
- end
28
- end
29
- end
@@ -1,20 +0,0 @@
1
- module ForemanInventoryUpload
2
- module Async
3
- class GenerateHostReport < ::Actions::EntryAction
4
- def plan(base_folder, organization_id, filter)
5
- plan_self(
6
- base_folder: base_folder,
7
- organization_id: organization_id,
8
- filter: filter
9
- )
10
- input[:target] = File.join(base_folder, ForemanInventoryUpload.facts_archive_name(input[:organization_id], input[:filter]))
11
- end
12
-
13
- def run
14
- archived_report_generator = ForemanInventoryUpload::Generators::ArchivedReport.new(input[:target])
15
- archived_report_generator.render(organization: input[:organization_id], filter: input[:filter])
16
- output[:result] = "Generated #{input[:target]} for organization id #{input[:organization_id]}"
17
- end
18
- end
19
- end
20
- end
@@ -1,39 +0,0 @@
1
- module ForemanInventoryUpload
2
- module Async
3
- class HostInventoryReportJob < ::Actions::EntryAction
4
- def plan(base_folder, organization_id, hosts_filter = "", upload = true)
5
- sequence do
6
- plan_action(
7
- GenerateHostReport,
8
- base_folder,
9
- organization_id,
10
- hosts_filter
11
- )
12
- if upload
13
- plan_action(
14
- QueueForUploadJob,
15
- base_folder,
16
- ForemanInventoryUpload.facts_archive_name(organization_id, hosts_filter),
17
- organization_id
18
- )
19
- end
20
-
21
- if ForemanRhCloud.with_iop_smart_proxy?
22
- plan_action(
23
- CreateMissingInsightsFacets,
24
- organization_id
25
- )
26
- end
27
- end
28
- end
29
-
30
- def humanized_name
31
- _("Host inventory report job")
32
- end
33
-
34
- def organization_id
35
- input[:organization_id]
36
- end
37
- end
38
- end
39
- end
@@ -1,20 +0,0 @@
1
- module ForemanInventoryUpload
2
- module Async
3
- class SingleHostReportJob < HostInventoryReportJob
4
- def plan(base_folder, organization_id, host_id)
5
- input[:host_id] = host_id
6
- super(base_folder, organization_id, "id=#{input[:host_id]}")
7
- end
8
-
9
- def hostname(host_id)
10
- host = ::Host.find_by(id: host_id)
11
- host&.name
12
- end
13
-
14
- def humanized_name
15
- hostname_result = hostname(input[:host_id])
16
- hostname_result.present? ? format(_("Single-host report job for host %s"), hostname_result) : _("Single-host report job")
17
- end
18
- end
19
- end
20
- end
@@ -1,63 +0,0 @@
1
- require 'test_plugin_helper'
2
- require 'foreman_tasks/test_helpers'
3
-
4
- class QueueForUploadJobTest < ActiveSupport::TestCase
5
- include ForemanTasks::TestHelpers::WithInThreadExecutor
6
- include FolderIsolation
7
-
8
- let(:organization) { FactoryBot.create(:organization) }
9
- let(:base_folder) { @tmpdir }
10
- let(:report_file) { 'test_report.tar.xz' }
11
- let(:report_path) { File.join(base_folder, report_file) }
12
- let(:uploads_folder) { ForemanInventoryUpload.uploads_folder }
13
- subject { ForemanTasks.sync_task(ForemanInventoryUpload::Async::QueueForUploadJob, base_folder, report_file, organization.id) }
14
-
15
- setup do
16
- # Stub the script template source
17
- script_source = File.join(ForemanRhCloud::Engine.root, 'lib/foreman_inventory_upload/scripts/uploader.sh.erb')
18
- File.stubs(:read).with(script_source).returns('#!/bin/bash\necho "Test script"')
19
-
20
- # Stub template rendering
21
- Foreman::Renderer.stubs(:render).returns('#!/bin/bash\necho "Rendered script"')
22
-
23
- # Stub additional settings that are accessed
24
- Setting.stubs(:[]).with(:content_default_http_proxy).returns(nil)
25
- Setting.stubs(:[]).with(:http_proxy).returns(nil)
26
- Setting.stubs(:[]).with("foreman_tasks_sync_task_timeout").returns(120)
27
- FileUtils.touch(report_path)
28
- end
29
-
30
- teardown do
31
- FileUtils.rm_rf(uploads_folder) if Dir.exist?(uploads_folder)
32
- end
33
-
34
- test 'plan method sets up the job correctly and calls plan_upload_report' do
35
- # Mock plan_upload_report to verify it's called
36
- ForemanInventoryUpload::Async::QueueForUploadJob.any_instance.expects(:plan_upload_report).once
37
-
38
- assert_equal 'success', subject.result
39
- end
40
-
41
- test 'run method processes file and moves it to uploads folder' do
42
- ForemanInventoryUpload::Async::QueueForUploadJob.any_instance.stubs(:plan_upload_report)
43
-
44
- assert_equal 'success', subject.result
45
-
46
- # Verify the file was moved
47
- refute File.exist?(report_path), "Original file should be moved"
48
- assert File.exist?(File.join(uploads_folder, report_file)), "File should exist in uploads folder"
49
- end
50
-
51
- test 'creates necessary folders and scripts' do
52
- ForemanInventoryUpload::Async::QueueForUploadJob.any_instance.stubs(:plan_upload_report)
53
-
54
- assert_equal 'success', subject.result
55
-
56
- # Verify the uploads folder was created
57
- assert Dir.exist?(uploads_folder), "Uploads folder should be created"
58
-
59
- # Verify the script file was created
60
- script_path = File.join(uploads_folder, ForemanInventoryUpload.upload_script_file)
61
- assert File.exist?(script_path), "Upload script should be created"
62
- end
63
- end
@@ -1,194 +0,0 @@
1
- import React from 'react';
2
- import { render, screen, waitFor } from '@testing-library/react';
3
- import '@testing-library/jest-dom';
4
- import { Provider } from 'react-redux';
5
- import { ConnectedRouter } from 'connected-react-router';
6
- import { createMemoryHistory } from 'history';
7
- import configureMockStore from 'redux-mock-store';
8
- import { STATUS } from 'foremanReact/constants';
9
- import * as APIHooks from 'foremanReact/common/hooks/API/APIHooks';
10
- import InsightsTotalRiskCard from '../InsightsTotalRiskChart';
11
-
12
- jest.mock('foremanReact/common/hooks/API/APIHooks');
13
- jest.mock('foremanReact/common/I18n', () => ({
14
- translate: jest.fn(str => str),
15
- }));
16
-
17
- const mockStore = configureMockStore();
18
- const history = createMemoryHistory();
19
- const store = mockStore({
20
- router: {
21
- location: {
22
- pathname: '/',
23
- search: '',
24
- hash: '',
25
- state: null,
26
- },
27
- action: 'POP',
28
- },
29
- });
30
-
31
- const defaultHostDetails = {
32
- id: 1,
33
- insights_attributes: {
34
- uuid: 'test-uuid',
35
- use_iop_mode: false,
36
- },
37
- };
38
-
39
- const renderComponent = (props = {}) => {
40
- const allProps = {
41
- hostDetails: defaultHostDetails,
42
- ...props,
43
- };
44
-
45
- return render(
46
- <Provider store={store}>
47
- <ConnectedRouter history={history}>
48
- <InsightsTotalRiskCard {...allProps} />
49
- </ConnectedRouter>
50
- </Provider>
51
- );
52
- };
53
-
54
- describe('InsightsTotalRiskChart', () => {
55
- beforeEach(() => {
56
- store.clearActions();
57
- jest.clearAllMocks();
58
- });
59
-
60
- it('should show loading state initially', () => {
61
- APIHooks.useAPI.mockReturnValue({
62
- status: STATUS.PENDING,
63
- response: null,
64
- });
65
-
66
- renderComponent();
67
- // SkeletonLoader shows loading state when status is PENDING
68
- expect(screen.queryByText('No results found')).not.toBeInTheDocument();
69
- expect(
70
- screen.queryByTestId('rh-cloud-total-risk-card')
71
- ).not.toBeInTheDocument();
72
- });
73
-
74
- it('should display error state when API fails', async () => {
75
- APIHooks.useAPI.mockReturnValue({
76
- status: STATUS.ERROR,
77
- response: null,
78
- });
79
-
80
- renderComponent();
81
- expect(screen.getByText('No results found')).toBeInTheDocument();
82
- expect(
83
- screen.queryByTestId('rh-cloud-total-risk-card')
84
- ).not.toBeInTheDocument();
85
- });
86
-
87
- it('should handle non-IoP mode API response correctly', async () => {
88
- const mockResponse = {
89
- hits: [
90
- { total_risk: 1 },
91
- { total_risk: 2 },
92
- { total_risk: 2 },
93
- { total_risk: 3 },
94
- { total_risk: 4 },
95
- ],
96
- };
97
-
98
- APIHooks.useAPI.mockReturnValue({
99
- status: STATUS.RESOLVED,
100
- response: mockResponse,
101
- });
102
-
103
- renderComponent();
104
-
105
- await waitFor(() => {
106
- // Check if total number of recommendations is displayed
107
- expect(screen.getByText('5')).toBeInTheDocument();
108
- // Check if risk levels are displayed correctly
109
- expect(screen.getByText(/Low: 1/)).toBeInTheDocument();
110
- expect(screen.getByText(/Moderate: 2/)).toBeInTheDocument();
111
- expect(screen.getByText(/Important: 1/)).toBeInTheDocument();
112
- expect(screen.getByText(/Critical: 1/)).toBeInTheDocument();
113
- });
114
- });
115
-
116
- it('should handle IOP mode API response correctly', async () => {
117
- const mockResponse = {
118
- low_hits: 2,
119
- moderate_hits: 3,
120
- important_hits: 1,
121
- critical_hits: 2,
122
- hits: 8,
123
- };
124
-
125
- APIHooks.useAPI.mockReturnValue({
126
- status: STATUS.RESOLVED,
127
- response: mockResponse,
128
- });
129
-
130
- renderComponent({
131
- hostDetails: {
132
- ...defaultHostDetails,
133
- insights_attributes: {
134
- ...defaultHostDetails.insights_attributes,
135
- use_iop_mode: true,
136
- },
137
- },
138
- });
139
-
140
- await waitFor(() => {
141
- // Check if total number of recommendations is displayed
142
- expect(screen.getByText('8')).toBeInTheDocument();
143
- // Check if risk levels are displayed correctly
144
- expect(screen.getByText(/Low: 2/)).toBeInTheDocument();
145
- expect(screen.getByText(/Moderate: 3/)).toBeInTheDocument();
146
- expect(screen.getByText(/Important: 1/)).toBeInTheDocument();
147
- expect(screen.getByText(/Critical: 2/)).toBeInTheDocument();
148
- });
149
- });
150
-
151
- it('should show empty state when no recommendations exist', async () => {
152
- APIHooks.useAPI.mockReturnValue({
153
- status: STATUS.RESOLVED,
154
- response: { hits: [] },
155
- });
156
-
157
- renderComponent();
158
-
159
- await waitFor(() => {
160
- expect(screen.getByText(/Low: 0/)).toBeInTheDocument();
161
- expect(screen.getByText(/Moderate: 0/)).toBeInTheDocument();
162
- expect(screen.getByText(/Important: 0/)).toBeInTheDocument();
163
- expect(screen.getByText(/Critical: 0/)).toBeInTheDocument();
164
- });
165
- });
166
-
167
- it('should use correct API endpoint based on IOP mode', () => {
168
- renderComponent({
169
- hostDetails: {
170
- ...defaultHostDetails,
171
- insights_attributes: {
172
- ...defaultHostDetails.insights_attributes,
173
- use_iop_mode: true,
174
- },
175
- },
176
- });
177
-
178
- expect(APIHooks.useAPI).toHaveBeenCalledWith(
179
- 'get',
180
- expect.stringContaining('/api/insights/v1/system/test-uuid'),
181
- expect.any(Object)
182
- );
183
-
184
- jest.clearAllMocks();
185
-
186
- renderComponent();
187
-
188
- expect(APIHooks.useAPI).toHaveBeenCalledWith(
189
- 'get',
190
- expect.stringContaining('/hits/1'),
191
- expect.any(Object)
192
- );
193
- });
194
- });