foreman_puppet 11.0.0 → 11.1.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 (34) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/foreman_puppet/extensions/hosts_controller_extensions.rb +1 -1
  3. data/app/controllers/foreman_puppet/api/v2/hosts_bulk_actions_controller.rb +75 -1
  4. data/app/services/concerns/foreman_puppet/extensions/bulk_hosts_manager.rb +18 -0
  5. data/config/api_routes.rb +1 -0
  6. data/db/seeds.d/111_puppet_proxy_feature.rb +1 -1
  7. data/lib/foreman_puppet/register.rb +1 -0
  8. data/lib/foreman_puppet/version.rb +1 -1
  9. data/test/controllers/foreman_puppet/api/v2/hosts_bulk_actions_controller_test.rb +93 -0
  10. data/test/services/foreman_puppet/bulk_hosts_manager_test.rb +45 -0
  11. data/webpack/__mocks__/foremanReact/redux/API/index.js +8 -0
  12. data/webpack/global_index.js +18 -1
  13. data/webpack/src/Extends/Hosts/ActionsBar/index.js +20 -0
  14. data/webpack/src/Extends/Hosts/BulkActions/BulkChangeProxyCommon/__tests__/actions.test.js +0 -7
  15. data/webpack/src/Extends/Hosts/BulkActions/BulkChangePuppetEnvironment/BulkChangePuppetEnvironmentModal.js +239 -0
  16. data/webpack/src/Extends/Hosts/BulkActions/BulkChangePuppetEnvironment/__tests__/BulkChangePuppetEnvironmentModal.test.js +155 -0
  17. data/webpack/src/Extends/Hosts/BulkActions/BulkChangePuppetEnvironment/__tests__/actions.test.js +49 -0
  18. data/webpack/src/Extends/Hosts/BulkActions/BulkChangePuppetEnvironment/__tests__/index.test.js +66 -0
  19. data/webpack/src/Extends/Hosts/BulkActions/BulkChangePuppetEnvironment/actions.js +37 -0
  20. data/webpack/src/Extends/Hosts/BulkActions/BulkChangePuppetEnvironment/index.js +30 -0
  21. data/webpack/src/Extends/Hosts/BulkActions/BulkChangePuppetProxy/__tests__/index.test.js +160 -47
  22. data/webpack/src/Extends/Hosts/BulkActions/BulkRemoveProxyCommon/__tests__/actions.test.js +0 -6
  23. data/webpack/src/Extends/Hosts/BulkActions/BulkRemovePuppetCAProxy/__tests__/index.test.js +136 -39
  24. data/webpack/src/Extends/Hosts/BulkActions/BulkRemovePuppetEnvironment/BulkRemovePuppetEnvironmentModal.js +148 -0
  25. data/webpack/src/Extends/Hosts/BulkActions/BulkRemovePuppetEnvironment/__tests__/BulkRemovePuppetEnvironmentModal.test.js +80 -0
  26. data/webpack/src/Extends/Hosts/BulkActions/BulkRemovePuppetEnvironment/__tests__/index.test.js +66 -0
  27. data/webpack/src/Extends/Hosts/BulkActions/BulkRemovePuppetEnvironment/index.js +30 -0
  28. data/webpack/src/Extends/Hosts/BulkActions/BulkRemovePuppetProxy/__tests__/index.test.js +123 -34
  29. data/webpack/src/Router/routes.fixtures.js +13 -0
  30. data/webpack/src/Router/routes.test.js +68 -8
  31. data/webpack/src/foreman_puppet_host_form.test.js +3 -1
  32. data/webpack/test_setup.js +1 -0
  33. metadata +14 -3
  34. data/webpack/src/Router/__snapshots__/routes.test.js.snap +0 -3
@@ -0,0 +1,155 @@
1
+ import React from 'react';
2
+ import { render, screen, fireEvent } from '@testing-library/react';
3
+ import '@testing-library/jest-dom';
4
+ import { IntlProvider } from 'react-intl';
5
+ import { useDispatch, useSelector } from 'react-redux';
6
+
7
+ import BulkChangePuppetEnvironmentModal from '../BulkChangePuppetEnvironmentModal';
8
+ import { fetchEnvironments, bulkChangePuppetEnvironment } from '../actions';
9
+ import {
10
+ selectAPIResponse,
11
+ selectAPIStatus,
12
+ } from 'foremanReact/redux/API/APISelectors';
13
+
14
+ jest.mock('@patternfly/react-core', () => {
15
+ const React = require('react');
16
+ const actual = jest.requireActual('@patternfly/react-core');
17
+
18
+ const MenuToggle = React.forwardRef(({ children, onClick }, ref) => (
19
+ <button type="button" ref={ref} onClick={onClick}>
20
+ {children}
21
+ </button>
22
+ ));
23
+
24
+ const SelectOption = ({ children, value, onSelect }) => (
25
+ <button type="button" onClick={event => onSelect(event, value)}>
26
+ {children}
27
+ </button>
28
+ );
29
+
30
+ const SelectList = ({ children, onSelect }) => (
31
+ <div>
32
+ {React.Children.map(children, child =>
33
+ React.isValidElement(child)
34
+ ? React.cloneElement(child, { onSelect })
35
+ : child
36
+ )}
37
+ </div>
38
+ );
39
+
40
+ const Select = ({ children, isOpen, toggle, onSelect }) => (
41
+ <div>
42
+ {toggle()}
43
+ {isOpen &&
44
+ React.Children.map(children, child =>
45
+ React.isValidElement(child)
46
+ ? React.cloneElement(child, { onSelect })
47
+ : child
48
+ )}
49
+ </div>
50
+ );
51
+
52
+ return {
53
+ ...actual,
54
+ MenuToggle,
55
+ Select,
56
+ SelectList,
57
+ SelectOption,
58
+ };
59
+ });
60
+
61
+ jest.mock('react-redux', () => ({
62
+ ...jest.requireActual('react-redux'),
63
+ useDispatch: jest.fn(),
64
+ useSelector: jest.fn(),
65
+ }));
66
+
67
+ jest.mock('foremanReact/Root/Context/ForemanContext', () => ({
68
+ useForemanOrganization: jest.fn(() => ({ id: 23 })),
69
+ }));
70
+
71
+ jest.mock('foremanReact/redux/API/APISelectors', () => ({
72
+ selectAPIResponse: jest.fn(),
73
+ selectAPIStatus: jest.fn(),
74
+ }));
75
+
76
+ jest.mock('../actions', () => ({
77
+ fetchEnvironments: jest.fn(() => ({ type: 'FETCH_ENVIRONMENTS' })),
78
+ bulkChangePuppetEnvironment: jest.fn(() => ({
79
+ type: 'BULK_CHANGE_PUPPET_ENVIRONMENT',
80
+ })),
81
+ PUPPET_ENVIRONMENTS_KEY: 'PUPPET_ENVIRONMENTS_KEY',
82
+ BULK_CHANGE_PUPPET_ENVIRONMENT_KEY: 'BULK_CHANGE_PUPPET_ENVIRONMENT',
83
+ INHERIT_ENVIRONMENT: 'inherit',
84
+ }));
85
+
86
+ describe('BulkChangePuppetEnvironmentModal', () => {
87
+ const dispatch = jest.fn();
88
+ const fetchBulkParams = jest.fn(
89
+ () => 'organization = "Default Organization"'
90
+ );
91
+ const environmentsResponse = {
92
+ results: [{ id: 1, name: 'production' }],
93
+ };
94
+
95
+ const renderComponent = () =>
96
+ render(
97
+ <IntlProvider locale="en">
98
+ <BulkChangePuppetEnvironmentModal
99
+ isOpen
100
+ closeModal={jest.fn()}
101
+ fetchBulkParams={fetchBulkParams}
102
+ selectedCount={2}
103
+ selectAllHostsMode={false}
104
+ />
105
+ </IntlProvider>
106
+ );
107
+
108
+ beforeEach(() => {
109
+ jest.clearAllMocks();
110
+ useDispatch.mockReturnValue(dispatch);
111
+ selectAPIResponse.mockReturnValue(environmentsResponse);
112
+ selectAPIStatus.mockReturnValue('RESOLVED');
113
+ useSelector.mockImplementation(selector => selector({}));
114
+ });
115
+
116
+ it('renders the environment options', () => {
117
+ renderComponent();
118
+
119
+ expect(fetchEnvironments).toHaveBeenCalledWith(23);
120
+ expect(
121
+ screen.getAllByText('Change Puppet Environment')[0]
122
+ ).toBeInTheDocument();
123
+ expect(
124
+ screen.getByRole('button', { name: 'Select an Environment' })
125
+ ).toBeInTheDocument();
126
+ expect(
127
+ screen.getByText(/Changing the Puppet environment will affect/)
128
+ ).toBeInTheDocument();
129
+ });
130
+
131
+ it('submits organization scope with the bulk change request', () => {
132
+ renderComponent();
133
+
134
+ fireEvent.click(
135
+ screen.getByRole('button', { name: 'Select an Environment' })
136
+ );
137
+ expect(screen.getByText('*Inherit from host group*')).toBeInTheDocument();
138
+ fireEvent.click(screen.getByText('production'));
139
+ fireEvent.click(
140
+ screen.getByRole('button', { name: 'Change Puppet Environment' })
141
+ );
142
+
143
+ expect(bulkChangePuppetEnvironment).toHaveBeenCalledWith(
144
+ {
145
+ included: {
146
+ search: 'organization = "Default Organization"',
147
+ },
148
+ environment_id: '1',
149
+ organization_id: 23,
150
+ },
151
+ expect.any(Function),
152
+ expect.any(Function)
153
+ );
154
+ });
155
+ });
@@ -0,0 +1,49 @@
1
+ import { APIActions } from 'foremanReact/redux/API';
2
+ import {
3
+ fetchEnvironments,
4
+ PUPPET_ENVIRONMENTS_KEY,
5
+ bulkChangePuppetEnvironment,
6
+ BULK_CHANGE_PUPPET_ENVIRONMENT_KEY,
7
+ } from '../actions';
8
+
9
+ jest.mock('foremanReact/redux/API', () => ({
10
+ APIActions: {
11
+ get: jest.fn(),
12
+ put: jest.fn(),
13
+ },
14
+ }));
15
+
16
+ describe('BulkChangePuppetEnvironment actions', () => {
17
+ const environmentsUrl = '/foreman_puppet/api/v2/environments';
18
+ const bulkChangeUrl = '/api/v2/hosts/bulk/change_puppet_environment';
19
+
20
+ beforeEach(() => {
21
+ jest.clearAllMocks();
22
+ });
23
+
24
+ it('fetches environments', () => {
25
+ fetchEnvironments(23);
26
+
27
+ expect(APIActions.get).toHaveBeenCalledWith({
28
+ key: PUPPET_ENVIRONMENTS_KEY,
29
+ url: environmentsUrl,
30
+ params: { per_page: 'all', organization_id: 23 },
31
+ });
32
+ });
33
+
34
+ it('calls bulk change puppet environment endpoint', () => {
35
+ const params = { included: { ids: [1] }, environment_id: '1' };
36
+ const handleSuccess = jest.fn();
37
+ const handleError = jest.fn();
38
+
39
+ bulkChangePuppetEnvironment(params, handleSuccess, handleError);
40
+
41
+ expect(APIActions.put).toHaveBeenCalledWith({
42
+ key: BULK_CHANGE_PUPPET_ENVIRONMENT_KEY,
43
+ url: bulkChangeUrl,
44
+ handleSuccess,
45
+ handleError,
46
+ params,
47
+ });
48
+ });
49
+ });
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import renderer, { act } from 'react-test-renderer';
3
+
4
+ import { useBulkModalOpen } from 'foremanReact/common/BulkModalStateHelper';
5
+ import { ForemanActionsBarContext } from 'foremanReact/components/HostDetails/ActionsBar';
6
+
7
+ import BulkChangePuppetEnvironmentScene from '../index';
8
+ import BulkChangePuppetEnvironmentModal from '../BulkChangePuppetEnvironmentModal';
9
+
10
+ jest.mock('foremanReact/common/BulkModalStateHelper', () => ({
11
+ useBulkModalOpen: jest.fn(),
12
+ }));
13
+
14
+ jest.mock('../BulkChangePuppetEnvironmentModal', () => ({
15
+ __esModule: true,
16
+ default: jest.fn(() => null),
17
+ }));
18
+
19
+ describe('BulkChangePuppetEnvironmentScene', () => {
20
+ const fetchBulkParams = jest.fn();
21
+ const refreshTableData = jest.fn();
22
+ const contextValue = {
23
+ selectAllHostsMode: false,
24
+ selectedCount: 2,
25
+ selectedResults: [1, 2],
26
+ fetchBulkParams,
27
+ refreshTableData,
28
+ };
29
+
30
+ beforeEach(() => {
31
+ jest.clearAllMocks();
32
+ useBulkModalOpen.mockReturnValue({
33
+ isOpen: true,
34
+ close: jest.fn(),
35
+ });
36
+ });
37
+
38
+ it('opens with bulk modal state and passes expected props', () => {
39
+ let component;
40
+ act(() => {
41
+ component = renderer.create(
42
+ <ForemanActionsBarContext.Provider value={contextValue}>
43
+ <BulkChangePuppetEnvironmentScene />
44
+ </ForemanActionsBarContext.Provider>
45
+ );
46
+ });
47
+
48
+ const componentType =
49
+ BulkChangePuppetEnvironmentModal.default ||
50
+ BulkChangePuppetEnvironmentModal;
51
+ const { props } = component.root.findByType(componentType);
52
+
53
+ expect(props).toEqual(
54
+ expect.objectContaining({
55
+ fetchBulkParams,
56
+ selectedCount: 2,
57
+ selectAllHostsMode: false,
58
+ isOpen: true,
59
+ closeModal: expect.any(Function),
60
+ onSuccess: refreshTableData,
61
+ })
62
+ );
63
+
64
+ component.unmount();
65
+ });
66
+ });
@@ -0,0 +1,37 @@
1
+ import { APIActions } from 'foremanReact/redux/API';
2
+ import { foremanUrl } from 'foremanReact/common/helpers';
3
+
4
+ export const PUPPET_ENVIRONMENTS_KEY = 'PUPPET_ENVIRONMENTS_KEY';
5
+ export const BULK_CHANGE_PUPPET_ENVIRONMENT_KEY =
6
+ 'BULK_CHANGE_PUPPET_ENVIRONMENT';
7
+
8
+ export const INHERIT_ENVIRONMENT = 'inherit';
9
+
10
+ export const fetchEnvironments = organizationId => {
11
+ const url = foremanUrl('/foreman_puppet/api/v2/environments');
12
+ return APIActions.get({
13
+ key: PUPPET_ENVIRONMENTS_KEY,
14
+ url,
15
+ params: {
16
+ per_page: 'all',
17
+ ...(organizationId ? { organization_id: organizationId } : {}),
18
+ },
19
+ });
20
+ };
21
+
22
+ export const bulkChangePuppetEnvironment = (
23
+ params,
24
+ handleSuccess,
25
+ handleError
26
+ ) => {
27
+ const url = foremanUrl('/api/v2/hosts/bulk/change_puppet_environment');
28
+ return APIActions.put({
29
+ key: BULK_CHANGE_PUPPET_ENVIRONMENT_KEY,
30
+ url,
31
+ handleSuccess,
32
+ handleError,
33
+ params,
34
+ });
35
+ };
36
+
37
+ export default fetchEnvironments;
@@ -0,0 +1,30 @@
1
+ import React, { useContext } from 'react';
2
+ import { ForemanActionsBarContext } from 'foremanReact/components/HostDetails/ActionsBar';
3
+ import { useBulkModalOpen } from 'foremanReact/common/BulkModalStateHelper';
4
+ import BulkChangePuppetEnvironmentModal from './BulkChangePuppetEnvironmentModal';
5
+
6
+ const BulkChangePuppetEnvironmentScene = () => {
7
+ const {
8
+ selectAllHostsMode,
9
+ selectedCount,
10
+ fetchBulkParams,
11
+ refreshTableData,
12
+ } = useContext(ForemanActionsBarContext);
13
+ const { isOpen, close: closeModal } = useBulkModalOpen(
14
+ 'bulk-change-puppet-environment'
15
+ );
16
+
17
+ return (
18
+ <BulkChangePuppetEnvironmentModal
19
+ fetchBulkParams={fetchBulkParams}
20
+ selectedCount={selectedCount}
21
+ selectAllHostsMode={selectAllHostsMode}
22
+ isOpen={isOpen}
23
+ closeModal={closeModal}
24
+ onSuccess={refreshTableData}
25
+ />
26
+ );
27
+ };
28
+
29
+ export { BulkChangePuppetEnvironmentModal };
30
+ export default BulkChangePuppetEnvironmentScene;
@@ -1,69 +1,182 @@
1
1
  import React from 'react';
2
- import { mount } from '@theforeman/test';
2
+ import { act, screen, waitFor } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+ import '@testing-library/jest-dom';
3
5
 
4
6
  import { openBulkModal } from 'foremanReact/common/BulkModalStateHelper';
5
7
  import { ForemanActionsBarContext } from 'foremanReact/components/HostDetails/ActionsBar';
8
+ import { rtlHelpers } from 'foremanReact/common/rtlTestHelpers';
9
+ import { APIActions } from 'foremanReact/redux/API';
10
+ import API from 'foremanReact/redux/API/API';
6
11
 
7
12
  import BulkChangePuppetProxyScene from '../index';
8
- import BulkChangeProxyCommon from '../../BulkChangeProxyCommon';
13
+ import { BULK_CHANGE_PUPPET_PROXY_KEY } from '../../BulkChangeProxyCommon/actions';
9
14
 
10
- jest.mock('foremanReact/components/HostDetails/ActionsBar', () => ({
11
- ForemanActionsBarContext: jest.requireActual('react').createContext(),
12
- }));
15
+ jest.mock('foremanReact/redux/API', () => {
16
+ const actual = jest.requireActual('foremanReact/redux/API');
13
17
 
14
- jest.mock('../../BulkChangeProxyCommon', () => ({
15
- __esModule: true,
16
- default: jest.fn(() => null),
17
- }));
18
-
19
- describe('BulkChangePuppetProxyScene', () => {
20
- const fetchBulkParams = jest.fn();
21
- const refreshTableData = jest.fn();
22
- const contextValue = {
23
- selectAllHostsMode: false,
24
- selectedCount: 2,
25
- selectedResults: [1, 2],
26
- fetchBulkParams,
27
- refreshTableData,
18
+ return {
19
+ ...actual,
20
+ APIActions: {
21
+ ...actual.APIActions,
22
+ put: jest.fn(params => ({ type: 'MOCK_API_PUT', payload: params })),
23
+ },
28
24
  };
25
+ });
26
+
27
+ jest.mock('foremanReact/redux/API/APISelectors', () =>
28
+ jest.requireActual('foremanReact/redux/API/APISelectors')
29
+ );
30
+
31
+ const { renderWithStoreAndI18n } = rtlHelpers;
32
+
33
+ const MODAL_ID = 'bulk-change-puppet-proxy';
34
+
35
+ const fetchBulkParams = jest.fn(() => 'id ^ (1,2)');
36
+ const refreshTableData = jest.fn();
37
+
38
+ const defaultContextValue = {
39
+ selectAllHostsMode: false,
40
+ selectedCount: 2,
41
+ selectedResults: [1, 2],
42
+ fetchBulkParams,
43
+ refreshTableData,
44
+ };
45
+
46
+ const smartProxiesResponse = {
47
+ data: {
48
+ results: [{ id: 1, name: 'proxy1.example.com' }],
49
+ },
50
+ };
29
51
 
52
+ const renderScene = ({ contextValue = defaultContextValue } = {}) =>
53
+ renderWithStoreAndI18n(
54
+ <ForemanActionsBarContext.Provider value={contextValue}>
55
+ <BulkChangePuppetProxyScene />
56
+ </ForemanActionsBarContext.Provider>
57
+ );
58
+
59
+ const selectPuppetProxy = async () => {
60
+ await act(async () => {
61
+ await userEvent.click(await screen.findByText('Select a Puppet Proxy'));
62
+ });
63
+ await act(async () => {
64
+ await userEvent.click(screen.getByText('proxy1.example.com'));
65
+ });
66
+ };
67
+
68
+ describe('BulkChangePuppetProxyScene', () => {
30
69
  beforeEach(() => {
70
+ openBulkModal(MODAL_ID, false);
71
+ API.get.mockImplementation(() => Promise.resolve(smartProxiesResponse));
72
+ });
73
+
74
+ afterEach(() => {
31
75
  jest.clearAllMocks();
32
- openBulkModal('bulk-change-puppet-proxy', false);
33
76
  });
34
77
 
35
- it('opens with bulk modal state and passes expected props', () => {
36
- openBulkModal('bulk-change-puppet-proxy', true);
37
- const wrapper = mount(
38
- <ForemanActionsBarContext.Provider value={contextValue}>
39
- <BulkChangePuppetProxyScene />
40
- </ForemanActionsBarContext.Provider>
41
- );
78
+ it('does not show the modal when bulk modal state is closed', () => {
79
+ renderScene();
42
80
 
43
- const componentType =
44
- BulkChangeProxyCommon.default || BulkChangeProxyCommon;
45
- const props = wrapper.find(componentType).props();
81
+ expect(
82
+ screen.queryByRole('dialog', { name: 'Change Puppet Proxy' })
83
+ ).not.toBeInTheDocument();
84
+ });
46
85
 
47
- expect(props).toEqual(
86
+ it('opens the modal with Puppet Proxy content when bulk modal is open', async () => {
87
+ openBulkModal(MODAL_ID, true);
88
+ renderScene();
89
+
90
+ expect(
91
+ await screen.findByRole('dialog', { name: 'Change Puppet Proxy' })
92
+ ).toBeInTheDocument();
93
+ expect(
94
+ screen.getByText(/Changing the Puppet proxy will affect/)
95
+ ).toBeInTheDocument();
96
+ expect(screen.getByText('2')).toBeInTheDocument();
97
+ expect(
98
+ await screen.findByText('Select a Puppet Proxy')
99
+ ).toBeInTheDocument();
100
+ expect(screen.queryByText('Select a Puppet CA Proxy')).not.toBeInTheDocument();
101
+ expect(screen.queryByText('Change Puppet CA Proxy')).not.toBeInTheDocument();
102
+ expect(
103
+ await screen.findByRole('button', { name: 'Change Puppet Proxy' })
104
+ ).toBeDisabled();
105
+ expect(screen.getByRole('button', { name: 'Cancel' })).toBeInTheDocument();
106
+ });
107
+
108
+ it('shows the all-hosts warning when select all hosts mode is enabled', async () => {
109
+ openBulkModal(MODAL_ID, true);
110
+ renderScene({
111
+ contextValue: { ...defaultContextValue, selectAllHostsMode: true },
112
+ });
113
+
114
+ await screen.findByRole('dialog', { name: 'Change Puppet Proxy' });
115
+ expect(screen.getByText('All')).toBeInTheDocument();
116
+ });
117
+
118
+ it('closes the modal when Cancel is clicked', async () => {
119
+ openBulkModal(MODAL_ID, true);
120
+ renderScene();
121
+
122
+ await screen.findByRole('dialog', { name: 'Change Puppet Proxy' });
123
+ await userEvent.click(screen.getByRole('button', { name: 'Cancel' }));
124
+
125
+ await waitFor(() => {
126
+ expect(
127
+ screen.queryByRole('dialog', { name: 'Change Puppet Proxy' })
128
+ ).not.toBeInTheDocument();
129
+ });
130
+ });
131
+
132
+ it('submits puppet proxy change request when confirm is clicked', async () => {
133
+ openBulkModal(MODAL_ID, true);
134
+ renderScene();
135
+
136
+ await screen.findByRole('dialog', { name: 'Change Puppet Proxy' });
137
+ await selectPuppetProxy();
138
+ await act(async () => {
139
+ await userEvent.click(
140
+ screen.getByRole('button', { name: 'Change Puppet Proxy' })
141
+ );
142
+ });
143
+
144
+ expect(fetchBulkParams).toHaveBeenCalledTimes(1);
145
+ expect(APIActions.put).toHaveBeenCalledWith(
48
146
  expect.objectContaining({
49
- isCAProxy: false,
50
- fetchBulkParams,
51
- selectedCount: 2,
52
- selectedResults: [1, 2],
53
- selectAllHostsMode: false,
54
- isOpen: true,
55
- closeModal: expect.any(Function),
56
- onSuccess: refreshTableData,
57
- selectMessage: 'Select a Puppet Proxy',
58
- handleErrorMessage: 'Failed to change Puppet Proxy',
59
- changeMessage: 'Change Puppet Proxy',
60
- allHostsMessage:
61
- 'Changing the Puppet proxy will affect {boldCount} selected hosts. Some hosts may already have been associated with the selected Puppet proxy.',
62
- someHostsMessage:
63
- 'Changing the Puppet proxy will affect {boldCount} selected {count, plural, one {host} other {hosts}}. Some hosts may already have been associated with the selected Puppet proxy.',
147
+ key: BULK_CHANGE_PUPPET_PROXY_KEY,
148
+ params: {
149
+ included: {
150
+ search: 'id ^ (1,2)',
151
+ },
152
+ proxy_id: '1',
153
+ ca_proxy: false,
154
+ },
64
155
  })
65
156
  );
157
+ });
158
+
159
+ it('refreshes table data after successful change', async () => {
160
+ openBulkModal(MODAL_ID, true);
161
+ renderScene();
162
+
163
+ await screen.findByRole('dialog', { name: 'Change Puppet Proxy' });
164
+ await selectPuppetProxy();
165
+ await act(async () => {
166
+ await userEvent.click(
167
+ screen.getByRole('button', { name: 'Change Puppet Proxy' })
168
+ );
169
+ });
170
+
171
+ const { handleSuccess } = APIActions.put.mock.calls[0][0];
172
+
173
+ act(() => {
174
+ handleSuccess({ data: { message: 'Change started' } });
175
+ });
66
176
 
67
- wrapper.unmount();
177
+ expect(refreshTableData).toHaveBeenCalledTimes(1);
178
+ expect(
179
+ screen.queryByRole('dialog', { name: 'Change Puppet Proxy' })
180
+ ).not.toBeInTheDocument();
68
181
  });
69
182
  });
@@ -7,12 +7,6 @@ import {
7
7
  BULK_REMOVE_PUPPET_CA_PROXY_KEY,
8
8
  } from '../actions';
9
9
 
10
- jest.mock('foremanReact/redux/API', () => ({
11
- APIActions: {
12
- put: jest.fn(),
13
- },
14
- }));
15
-
16
10
  describe('BulkRemoveProxyCommon actions', () => {
17
11
  const url = foremanUrl('/api/v2/hosts/bulk/remove_puppet_proxy');
18
12