foreman_rh_cloud 13.2.6 → 13.2.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d11a81329e083956595eae07e1b13a0f337722d2316b73e37eaece51a05ff92
4
- data.tar.gz: 925d50c3713f68be27c6290fe67ac5a68b5a5cd7a3f78578ce5acc574469fcd8
3
+ metadata.gz: 59eab13298515d3f87c52f499b2d79522b5455985ed8c2652400df1790fe7133
4
+ data.tar.gz: 14f62161dbd0e8b635b9d7728f41d121c6be2b76cc042b4c7168d20ca2376641
5
5
  SHA512:
6
- metadata.gz: 9f0071fcff2a17f1e8d5ac6dacba1b7383a47822a179e6681a7fdb37469be9d4a0b3f3752d044ae64a34b839ded062ebe70db2a572c8b41368fe8b5e630c7d0b
7
- data.tar.gz: 26ee66163cb1b8e802b5c52c2cbfef4e3c4cdc25f2094b7de5a68c083bede2d046317b9e965d9df2c9cbecdabb7be0638b599928ceb87b9e6678195914d518e4
6
+ metadata.gz: 2da9750fa293b99a458766c2b08ed045f1d39c07f5275918d8900f146764226654579a92ced0fe033666faf94e4067b8522e2991c19522be5bd067e6f705ef68
7
+ data.tar.gz: e3a262a6166e9c4c5901f4c57d052b24c405756ed0a71acfb3dd71d62a66e99f09d6ff5f0df904d3a932c68d58204466689a587d1c1f723a27e769b9c9789234
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '13.2.6'.freeze
2
+ VERSION = '13.2.7'.freeze
3
3
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foreman_rh_cloud",
3
- "version": "13.2.6",
3
+ "version": "13.2.7",
4
4
  "description": "Inventory Upload =============",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -10,7 +10,12 @@ const CVEsHostDetailsTab = ({ systemId }) => {
10
10
  const module = './SystemDetailTable';
11
11
  return (
12
12
  <div className="rh-cloud-insights-vulnerability-host-details-component vulnerability">
13
- <ScalprumComponent scope={scope} module={module} systemId={systemId} />
13
+ <ScalprumComponent
14
+ key={systemId}
15
+ scope={scope}
16
+ module={module}
17
+ systemId={systemId}
18
+ />
14
19
  </div>
15
20
  );
16
21
  };
@@ -11,14 +11,25 @@ jest.mock('foremanReact/Root/Context/ForemanContext', () => ({
11
11
  useForemanPermissions: () => new Set(['view_vulnerability']),
12
12
  }));
13
13
 
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
- }));
14
+ const mockUnmountTracker = jest.fn();
15
+ jest.mock('@scalprum/react-core', () => {
16
+ const ReactMock = require('react');
17
+ return {
18
+ ScalprumComponent: jest.fn(props => {
19
+ ReactMock.useEffect(() => mockUnmountTracker, []);
20
+ return (
21
+ <div data-testid="mock-scalprum-component">{JSON.stringify(props)}</div>
22
+ );
23
+ }),
24
+ ScalprumProvider: jest.fn(({ children }) => <div>{children}</div>),
25
+ };
26
+ });
20
27
 
21
28
  describe('CVEsHostDetailsTabWrapper', () => {
29
+ beforeEach(() => {
30
+ jest.clearAllMocks();
31
+ });
32
+
22
33
  it('renders without crashing', () => {
23
34
  const { container } = render(
24
35
  <CVEsHostDetailsTabWrapper
@@ -31,4 +42,32 @@ describe('CVEsHostDetailsTabWrapper', () => {
31
42
  )
32
43
  ).toBeTruthy();
33
44
  });
45
+
46
+ it('remounts ScalprumComponent when systemId changes', () => {
47
+ const { ScalprumComponent } = require('@scalprum/react-core');
48
+
49
+ const { rerender } = render(
50
+ <CVEsHostDetailsTabWrapper
51
+ response={{ subscription_facet_attributes: { uuid: 'uuid-host-A' } }}
52
+ />
53
+ );
54
+
55
+ expect(mockUnmountTracker).not.toHaveBeenCalled();
56
+ expect(ScalprumComponent).toHaveBeenLastCalledWith(
57
+ expect.objectContaining({ systemId: 'uuid-host-A' }),
58
+ expect.anything()
59
+ );
60
+
61
+ rerender(
62
+ <CVEsHostDetailsTabWrapper
63
+ response={{ subscription_facet_attributes: { uuid: 'uuid-host-B' } }}
64
+ />
65
+ );
66
+
67
+ expect(mockUnmountTracker).toHaveBeenCalledTimes(1);
68
+ expect(ScalprumComponent).toHaveBeenLastCalledWith(
69
+ expect.objectContaining({ systemId: 'uuid-host-B' }),
70
+ expect.anything()
71
+ );
72
+ });
34
73
  });
@@ -128,17 +128,32 @@ NewHostDetailsTab.defaultProps = {
128
128
  const scope = 'advisor';
129
129
  const module = './SystemDetailWrapped';
130
130
 
131
- const IopInsightsTab = props => (
132
- <div className="advisor">
133
- <ScalprumComponent
134
- scope={scope}
135
- module={module}
136
- IopRemediationModal={RemediationModal}
137
- generateRuleUrl={generateRuleUrl}
138
- {...props}
139
- />
140
- </div>
141
- );
131
+ const IopInsightsTab = props => {
132
+ // eslint-disable-next-line camelcase
133
+ const systemId = props.response?.subscription_facet_attributes?.uuid;
134
+ return (
135
+ <div className="advisor">
136
+ <ScalprumComponent
137
+ key={systemId || props.hostName}
138
+ scope={scope}
139
+ module={module}
140
+ IopRemediationModal={RemediationModal}
141
+ generateRuleUrl={generateRuleUrl}
142
+ {...props}
143
+ />
144
+ </div>
145
+ );
146
+ };
147
+
148
+ IopInsightsTab.propTypes = {
149
+ hostName: PropTypes.string,
150
+ response: PropTypes.object,
151
+ };
152
+
153
+ IopInsightsTab.defaultProps = {
154
+ hostName: '',
155
+ response: {},
156
+ };
142
157
 
143
158
  const IopInsightsTabWrapped = props => {
144
159
  const permissions = useInsightsPermissions();
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.2.6
4
+ version: 13.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Red Hat Cloud team