foreman_rh_cloud 13.0.5 → 13.0.6

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.
@@ -2,8 +2,11 @@ import React from 'react';
2
2
  import { render, screen } from '@testing-library/react';
3
3
  import { API } from 'foremanReact/redux/API';
4
4
  import { CVECountCell } from '../CVECountCell';
5
+ import * as ConfigHooks from '../../common/Hooks/ConfigHooks';
5
6
 
6
7
  jest.mock('foremanReact/redux/API');
8
+ jest.mock('../../common/Hooks/ConfigHooks');
9
+
7
10
  API.get.mockImplementation(async () => ({
8
11
  data: [
9
12
  {
@@ -14,15 +17,58 @@ API.get.mockImplementation(async () => ({
14
17
  ],
15
18
  }));
16
19
 
20
+ const hostDetailsMock = {
21
+ name: 'test-host.example.com',
22
+ subscription_facet_attributes: {
23
+ uuid: 'test-uuid-123',
24
+ },
25
+ };
26
+
17
27
  describe('CVECountCell', () => {
18
- it('renders an empty cves count column', () => {
19
- const hostDetailsMock = {
28
+ beforeEach(() => {
29
+ ConfigHooks.useAdvisorEngineConfig.mockReturnValue(true);
30
+ });
31
+
32
+ afterEach(() => {
33
+ jest.clearAllMocks();
34
+ });
35
+
36
+ it('renders an empty cves count column when no subscription UUID', () => {
37
+ const hostDetailsMockIoP = {
20
38
  name: 'test-host.example.com',
21
39
  subscription_facet_attributes: {
22
40
  uuid: null, // no subscription
23
41
  },
24
42
  };
43
+ render(<CVECountCell hostDetails={hostDetailsMockIoP} />);
44
+ expect(screen.getByRole('img', { hidden: true })).toBeTruthy();
45
+ });
46
+
47
+ it('renders UnknownIcon when IoP is not enabled', () => {
48
+ ConfigHooks.useAdvisorEngineConfig.mockReturnValue(false);
49
+ render(<CVECountCell hostDetails={hostDetailsMock} />);
50
+ expect(screen.getByRole('img', { hidden: true })).toBeTruthy();
51
+ expect(ConfigHooks.useAdvisorEngineConfig).toHaveBeenCalled();
52
+ });
53
+
54
+ it('renders UnknownIcon when IoP is enabled but CVE API call fails', () => {
55
+ // Mock successful IoP config
56
+ ConfigHooks.useAdvisorEngineConfig.mockReturnValue(true);
57
+ // Mock CVE API failure - override the global mock for this test
58
+ API.get.mockImplementationOnce(async () => {
59
+ throw new Error('CVE API call failed');
60
+ });
61
+
62
+ render(<CVECountCell hostDetails={hostDetailsMock} />);
63
+ // Should render UnknownIcon when CVE API fails
64
+ expect(screen.getByRole('img', { hidden: true })).toBeTruthy();
65
+ expect(ConfigHooks.useAdvisorEngineConfig).toHaveBeenCalled();
66
+ });
67
+
68
+ it('renders UnknownIcon when IoP is undefined (API call pending)', () => {
69
+ ConfigHooks.useAdvisorEngineConfig.mockReturnValue(undefined);
25
70
  render(<CVECountCell hostDetails={hostDetailsMock} />);
26
71
  expect(screen.getByRole('img', { hidden: true })).toBeTruthy();
72
+ expect(ConfigHooks.useAdvisorEngineConfig).toHaveBeenCalled();
27
73
  });
28
74
  });
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: 13.0.5
4
+ version: 13.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Red Hat Cloud team