foreman_rh_cloud 13.2.5 → 13.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57ce80b0bae4a115918ce35f98537e6b1c300b01c8b6ccf17f472b9249068754
4
- data.tar.gz: 2068954bb5a0d6ae8c8a3463eb56fa6ef7d62340d6b8b874517e9667253db360
3
+ metadata.gz: 0d11a81329e083956595eae07e1b13a0f337722d2316b73e37eaece51a05ff92
4
+ data.tar.gz: 925d50c3713f68be27c6290fe67ac5a68b5a5cd7a3f78578ce5acc574469fcd8
5
5
  SHA512:
6
- metadata.gz: 1a96441f4ab3b127d838b29ed8c763c23d2b4e1ade1bcf10739f411018da0506c58b9b044806aec9d977c4c90a83820cc625f58b96a03104302ba244a2db9e2e
7
- data.tar.gz: def92bf339332df4f82f2716996e57df7774856459dcdf626497c97b8dfc887ae39a7a0a9979e4f5efda0d53f201ac3500f12c19eb99ab6964e0ae0e95e7fe3e
6
+ metadata.gz: 9f0071fcff2a17f1e8d5ac6dacba1b7383a47822a179e6681a7fdb37469be9d4a0b3f3752d044ae64a34b839ded062ebe70db2a572c8b41368fe8b5e630c7d0b
7
+ data.tar.gz: 26ee66163cb1b8e802b5c52c2cbfef4e3c4cdc25f2094b7de5a68c083bede2d046317b9e965d9df2c9cbecdabb7be0638b599928ceb87b9e6678195914d518e4
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '13.2.5'.freeze
2
+ VERSION = '13.2.6'.freeze
3
3
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foreman_rh_cloud",
3
- "version": "13.2.5",
3
+ "version": "13.2.6",
4
4
  "description": "Inventory Upload =============",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -33,13 +33,28 @@ const NewHostDetailsTab = ({ hostName, router }) => {
33
33
  const hits = useSelector(selectHits);
34
34
  const isIop = useIopConfig();
35
35
 
36
- useEffect(() => () => router.replace({ search: null }), [router]);
36
+ useEffect(
37
+ () => () => {
38
+ // Preserve hash when clearing search params to prevent tab navigation bugs
39
+ if (router && typeof router.replace === 'function') {
40
+ const replaceOptions = { search: null };
41
+ if (router.location && router.location.hash) {
42
+ replaceOptions.hash = router.location.hash;
43
+ }
44
+ router.replace(replaceOptions);
45
+ }
46
+ },
47
+ [router]
48
+ );
37
49
 
38
50
  const onSearch = q => dispatch(fetchInsights({ query: q, page: 1 }));
39
51
 
40
52
  const [isDropdownOpen, setIsDropdownOpen] = useState(false);
41
- const onSatInsightsClick = () =>
42
- router.push({ pathname: '/foreman_rh_cloud/insights_cloud' });
53
+ const onSatInsightsClick = () => {
54
+ if (router && typeof router.push === 'function') {
55
+ router.push({ pathname: '/foreman_rh_cloud/insights_cloud' });
56
+ }
57
+ };
43
58
 
44
59
  const dropdownItems = [
45
60
  <DropdownItem key="insights-link" ouiaId="insights-link">
@@ -0,0 +1,154 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import '@testing-library/jest-dom';
4
+ import { Provider } from 'react-redux';
5
+ import configureMockStore from 'redux-mock-store';
6
+ import thunk from 'redux-thunk';
7
+ import NewHostDetailsTab from '../NewHostDetailsTab';
8
+
9
+ jest.mock('../../common/Hooks/ConfigHooks', () => ({
10
+ useIopConfig: jest.fn(() => false),
11
+ }));
12
+
13
+ jest.mock('foremanReact/common/I18n', () => ({
14
+ translate: jest.fn(str => str),
15
+ }));
16
+
17
+ const mockStore = configureMockStore([thunk]);
18
+
19
+ describe('NewHostDetailsTab', () => {
20
+ let store;
21
+ let mockRouter;
22
+
23
+ beforeEach(() => {
24
+ mockRouter = {
25
+ push: jest.fn(),
26
+ replace: jest.fn(),
27
+ location: {
28
+ pathname: '/new/hosts/test-host.example.com',
29
+ search: '?page=1&per_page=20',
30
+ hash: '#/Insights',
31
+ query: { page: '1', per_page: '20' },
32
+ },
33
+ };
34
+
35
+ store = mockStore({
36
+ API: {},
37
+ ForemanRhCloud: {
38
+ InsightsCloudSync: {
39
+ table: {
40
+ selectedIds: {},
41
+ isAllSelected: false,
42
+ showSelectAllAlert: false,
43
+ },
44
+ },
45
+ },
46
+ insightsHostDetailsTab: {
47
+ query: '',
48
+ hits: [],
49
+ selectedIds: {},
50
+ error: null,
51
+ },
52
+ router: {
53
+ location: {
54
+ pathname: '/new/hosts/test-host.example.com',
55
+ search: '?page=1&per_page=20',
56
+ hash: '#/Insights',
57
+ query: { page: '1', per_page: '20' },
58
+ },
59
+ },
60
+ });
61
+ });
62
+
63
+ afterEach(() => {
64
+ jest.clearAllMocks();
65
+ });
66
+
67
+ describe('cleanup effect', () => {
68
+ it('should preserve hash when clearing search params on unmount', () => {
69
+ const { unmount } = render(
70
+ <Provider store={store}>
71
+ <NewHostDetailsTab
72
+ hostName="test-host.example.com"
73
+ router={mockRouter}
74
+ />
75
+ </Provider>
76
+ );
77
+
78
+ // Unmount the component to trigger cleanup
79
+ unmount();
80
+
81
+ // Verify router.replace was called with both search: null AND the existing hash
82
+ expect(mockRouter.replace).toHaveBeenCalledWith({
83
+ search: null,
84
+ hash: '#/Insights',
85
+ });
86
+ });
87
+
88
+ it('should only clear search params when no hash exists', () => {
89
+ mockRouter.location.hash = '';
90
+
91
+ const { unmount } = render(
92
+ <Provider store={store}>
93
+ <NewHostDetailsTab
94
+ hostName="test-host.example.com"
95
+ router={mockRouter}
96
+ />
97
+ </Provider>
98
+ );
99
+
100
+ unmount();
101
+
102
+ // When there's no hash, should only pass search: null
103
+ expect(mockRouter.replace).toHaveBeenCalledWith({
104
+ search: null,
105
+ });
106
+ });
107
+
108
+ it('should handle router.location being undefined gracefully', () => {
109
+ const routerWithoutLocation = {
110
+ push: jest.fn(),
111
+ replace: jest.fn(),
112
+ location: undefined,
113
+ };
114
+
115
+ const { unmount } = render(
116
+ <Provider store={store}>
117
+ <NewHostDetailsTab
118
+ hostName="test-host.example.com"
119
+ router={routerWithoutLocation}
120
+ />
121
+ </Provider>
122
+ );
123
+
124
+ unmount();
125
+
126
+ // Should still call replace with search: null even if location is undefined
127
+ expect(routerWithoutLocation.replace).toHaveBeenCalledWith({
128
+ search: null,
129
+ });
130
+ });
131
+
132
+ it('should use the latest hash value at unmount time, not a stale captured value', () => {
133
+ const { unmount } = render(
134
+ <Provider store={store}>
135
+ <NewHostDetailsTab
136
+ hostName="test-host.example.com"
137
+ router={mockRouter}
138
+ />
139
+ </Provider>
140
+ );
141
+
142
+ // Change the hash after mount, before unmount
143
+ mockRouter.location.hash = '#/Overview';
144
+
145
+ unmount();
146
+
147
+ // Verify router.replace was called with the UPDATED hash, not the initial '#/Insights'
148
+ expect(mockRouter.replace).toHaveBeenCalledWith({
149
+ search: null,
150
+ hash: '#/Overview',
151
+ });
152
+ });
153
+ });
154
+ });
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.5
4
+ version: 13.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Red Hat Cloud team
@@ -586,6 +586,7 @@ files:
586
586
  - webpack/InsightsHostDetailsTab/__tests__/InsightsTabReducer.test.js
587
587
  - webpack/InsightsHostDetailsTab/__tests__/InsightsTabSelectors.test.js
588
588
  - webpack/InsightsHostDetailsTab/__tests__/InsightsTotalRiskChart.test.js
589
+ - webpack/InsightsHostDetailsTab/__tests__/NewHostDetailsTab.test.js
589
590
  - webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTab.test.js.snap
590
591
  - webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabActions.test.js.snap
591
592
  - webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabReducer.test.js.snap
@@ -668,7 +669,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
668
669
  - !ruby/object:Gem::Version
669
670
  version: '0'
670
671
  requirements: []
671
- rubygems_version: 4.0.3
672
+ rubygems_version: 4.0.6
672
673
  specification_version: 4
673
674
  summary: Summary of ForemanRhCloud.
674
675
  test_files: