foreman_snapshot_management 4.3.0 → 4.4.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 (24) hide show
  1. checksums.yaml +4 -4
  2. data/lib/foreman_snapshot_management/version.rb +1 -1
  3. data/webpack/components/SnapshotManagement/SnapshotManagementReducer.js +0 -7
  4. data/webpack/components/SnapshotManagement/SnapshotManagementSelectors.js +0 -1
  5. data/webpack/components/SnapshotManagement/__tests__/SnapshotManagement.test.js +35 -0
  6. data/webpack/components/SnapshotManagement/__tests__/__snapshots__/SnapshotManagementReducer.test.js.snap +0 -3
  7. data/webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotForm.js +33 -67
  8. data/webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotFormField.js +62 -0
  9. data/webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotFormHelper.js +64 -0
  10. data/webpack/components/SnapshotManagement/components/SnapshotForm/__tests__/SnapshotForm.test.js +72 -24
  11. data/webpack/components/SnapshotManagement/components/SnapshotFormModal/SnapshotFormModal.js +1 -0
  12. data/webpack/components/SnapshotManagement/components/SnapshotFormModal/__tests__/SnapshotFormModal.test.js +36 -9
  13. data/webpack/components/SnapshotManagement/components/SnapshotList/SnapshotList.js +185 -229
  14. data/webpack/components/SnapshotManagement/components/SnapshotList/SnapshotListHelper.js +55 -22
  15. data/webpack/components/SnapshotManagement/components/SnapshotList/__tests__/SnapshotList.test.js +73 -54
  16. data/webpack/components/SnapshotManagement/components/SnapshotList/snapshotList.scss +6 -0
  17. data/webpack/components/SnapshotManagement/index.js +0 -1
  18. data/webpack/components/SnapshotManagementCard/__tests__/SnapshotManagementCard.test.js +28 -17
  19. data/webpack/test_setup.js +0 -5
  20. metadata +6 -7
  21. data/webpack/components/SnapshotManagement/components/SnapshotForm/__tests__/__snapshots__/SnapshotForm.test.js.snap +0 -571
  22. data/webpack/components/SnapshotManagement/components/SnapshotFormModal/__tests__/__snapshots__/SnapshotFormModal.test.js.snap +0 -57
  23. data/webpack/components/SnapshotManagement/components/SnapshotList/__tests__/__snapshots__/SnapshotList.test.js.snap +0 -1081
  24. data/webpack/components/SnapshotManagementCard/__tests__/__snapshots__/SnapshotManagementCard.test.js.snap +0 -122
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: deb81c67b22c5ed30be8993938a52780abca3e9b9412e2877c4c3a38df2e7ba6
4
- data.tar.gz: 3eb82b7b35720848b9da71162fe726ae4f3964797fcdf7d55be84cf23425327e
3
+ metadata.gz: 3b2e76449b98ca917dcf0ad387d49d524c61493f099c55315b7a4ee5adb53096
4
+ data.tar.gz: 2302e1a8ec12c4913f844d49d843e274338ed571e36ecef118be115ad97e5ace
5
5
  SHA512:
6
- metadata.gz: 3e03c5e9461b79df46c914d14aab0a326511e9380c65ae9e94ca41f3d80516320ae7e9162e3758520492520dd90c637fc7377b22d62e30ce6cfc932124377aa8
7
- data.tar.gz: a390ad53d5eef28fb75a9ad0705b33614643bb6b3d68beafd0d8eeadf87beb6a268e39eb0cff8811488c6f7923cd6a7b606400f4731cf973f668cbb7cc9b1327
6
+ metadata.gz: 73eb608bd9c6a6803a2310016535c5420e055291e5c269d3aac90be0a9babd7d662d68c34d5c3adf3f35716c953c1aa97e50b826d73511ac57e29dd1cfb01817
7
+ data.tar.gz: 37dfd4c7bafc970c9ac719948c5c8ca8c53c1c5a1d0d46e720687532aa2a040dac5f68a7ff9ede1ecffee9c408a5c9a832307ffb48318f286ec42a4650104fd7
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanSnapshotManagement
4
- VERSION = '4.3.0'
4
+ VERSION = '4.4.0'
5
5
  end
@@ -30,29 +30,22 @@ export default (state = initialState, action) => {
30
30
  const rollbackTypes = actionTypeGenerator(SNAPSHOT_ROLLBACK);
31
31
 
32
32
  switch (action.type) {
33
- case 'SNAPSHOT_FORM_SUBMITTED':
34
- return state.merge({
35
- needsReload: true,
36
- });
37
33
  case listTypes.REQUEST:
38
34
  return state.merge({
39
35
  snapshots: [],
40
36
  isLoading: true,
41
37
  hasError: false,
42
- needsReload: false,
43
38
  });
44
39
  case listTypes.SUCCESS:
45
40
  return state.merge({
46
41
  snapshots: response.results,
47
42
  isLoading: false,
48
- needsReload: false,
49
43
  });
50
44
  case listTypes.FAILURE:
51
45
  return state.merge({
52
46
  error: response,
53
47
  hasError: true,
54
48
  isLoading: false,
55
- needsReload: false,
56
49
  });
57
50
  case deleteTypes.REQUEST:
58
51
  return state.merge({
@@ -5,4 +5,3 @@ export const selectIsLoading = state => snapshotMgmt(state).isLoading;
5
5
  export const selectIsWorking = state => snapshotMgmt(state).isWorking;
6
6
  export const selectHasError = state => snapshotMgmt(state).hasError;
7
7
  export const selectError = state => snapshotMgmt(state).error;
8
- export const selectNeedsReload = state => snapshotMgmt(state).needsReload;
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+
5
+ import SnapshotManagement from '../SnapshotManagement';
6
+
7
+ const mockSetModalOpen = jest.fn();
8
+
9
+ jest.mock('../components/SnapshotFormModal', () => () => (
10
+ <div data-testid="form-modal" />
11
+ ));
12
+ jest.mock('../components/SnapshotFormModal/useSnapshotFormModal', () => ({
13
+ __esModule: true,
14
+ default: () => ({ setModalOpen: mockSetModalOpen }),
15
+ }));
16
+ jest.mock('../components/SnapshotList/SnapshotList', () => () => (
17
+ <div data-testid="snapshot-list" />
18
+ ));
19
+
20
+ const host = { id: 42, name: 'deep.thought', ignored: 'x' };
21
+
22
+ describe('SnapshotManagement', () => {
23
+ it('renders only the list without create permission', () => {
24
+ render(<SnapshotManagement host={host} onSubmit={jest.fn()} />);
25
+ expect(screen.getByTestId('snapshot-list')).toBeInTheDocument();
26
+ expect(screen.queryByTestId('form-modal')).not.toBeInTheDocument();
27
+ });
28
+
29
+ it('opens the modal from the create button', () => {
30
+ render(<SnapshotManagement host={host} canCreate onSubmit={jest.fn()} />);
31
+ expect(screen.getByTestId('form-modal')).toBeInTheDocument();
32
+ userEvent.click(screen.getByText('Create Snapshot'));
33
+ expect(mockSetModalOpen).toHaveBeenCalled();
34
+ });
35
+ });
@@ -62,7 +62,6 @@ Object {
62
62
  "hasError": true,
63
63
  "isLoading": false,
64
64
  "isWorking": false,
65
- "needsReload": false,
66
65
  "snapshots": Array [
67
66
  Object {
68
67
  "children_ids": null,
@@ -81,7 +80,6 @@ Object {
81
80
  "hasError": false,
82
81
  "isLoading": true,
83
82
  "isWorking": false,
84
- "needsReload": false,
85
83
  "snapshots": Array [],
86
84
  }
87
85
  `;
@@ -91,7 +89,6 @@ Object {
91
89
  "hasError": false,
92
90
  "isLoading": false,
93
91
  "isWorking": false,
94
- "needsReload": false,
95
92
  "snapshots": Array [],
96
93
  }
97
94
  `;
@@ -1,10 +1,8 @@
1
1
  import React, { useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import * as Yup from 'yup';
4
3
  import { Formik } from 'formik';
5
4
 
6
5
  import { translate as __ } from 'foremanReact/common/I18n';
7
- import TextField from 'foremanReact/components/common/forms/TextField';
8
6
 
9
7
  import {
10
8
  Form as PfForm,
@@ -13,6 +11,7 @@ import {
13
11
  Card,
14
12
  CardBody,
15
13
  FormGroup,
14
+ Popover,
16
15
  Select,
17
16
  SelectList,
18
17
  SelectOption,
@@ -22,10 +21,14 @@ import {
22
21
  Spinner,
23
22
  } from '@patternfly/react-core';
24
23
 
25
- import './snapshotForm.scss';
24
+ import { HelpIcon } from '@patternfly/react-icons';
26
25
 
27
- const MAX_SNAPSHOT_NAME_LENGTH = 80;
28
- const LIMITED_MAX_SNAPSHOT_NAME_LENGTH = 40;
26
+ import SnapshotFormField from './SnapshotFormField';
27
+ import {
28
+ buildValidationSchema,
29
+ buildSnapshotPayload,
30
+ } from './SnapshotFormHelper';
31
+ import './snapshotForm.scss';
29
32
 
30
33
  const SnapshotForm = ({
31
34
  initialValues,
@@ -37,25 +40,7 @@ const SnapshotForm = ({
37
40
  host,
38
41
  selectAllMode,
39
42
  }) => {
40
- let nameValidation = Yup.string().max(MAX_SNAPSHOT_NAME_LENGTH, 'Too Long!');
41
- if (capabilities.limitSnapshotNameFormat)
42
- nameValidation = nameValidation
43
- .min(2, 'Too Short!')
44
- .matches(
45
- /^[A-z]\w+$/,
46
- __(
47
- 'Name must contain at least 2 characters starting with alphabet. Valid characters are A-Z a-z 0-9 _'
48
- )
49
- )
50
- .max(LIMITED_MAX_SNAPSHOT_NAME_LENGTH, 'Too Long!');
51
-
52
- const validationSchema = Yup.object().shape({
53
- name: nameValidation.required('is required'),
54
- description: Yup.string(),
55
- includeRam: Yup.bool(),
56
- useQuiesce: Yup.bool(),
57
- snapshotMode: Yup.string(),
58
- });
43
+ const validationSchema = buildValidationSchema(capabilities);
59
44
 
60
45
  const [snapshotMode, setSnapshotMode] = useState('');
61
46
  const [isSelectOpen, setIsSelectOpen] = useState(false);
@@ -84,38 +69,12 @@ const SnapshotForm = ({
84
69
  actions.setSubmitting(true);
85
70
 
86
71
  try {
87
- if (snapshotMode === 'quiesce') {
88
- values.useQuiesce = true;
89
- values.includeRam = false;
90
- } else if (snapshotMode === 'include_ram') {
91
- values.includeRam = true;
92
- values.useQuiesce = false;
93
- }
94
-
95
- let mode = 'full';
96
- if (values.includeRam) {
97
- mode = 'include_ram';
98
- } else if (values.useQuiesce) {
99
- mode = 'quiesce';
100
- }
101
-
102
- const submitValues = {
103
- mode,
104
- snapshot: {
105
- name: values.name,
106
- description: values.description || '',
107
- },
108
- };
109
-
110
- const singleHostId = host?.id;
111
-
112
- const payload = {
113
- included: {
114
- search: host ? `id = ${singleHostId}` : fetchBulkParams(),
115
- },
116
- ...(singleHostId && { hostId: singleHostId }),
117
- ...submitValues,
118
- };
72
+ const payload = buildSnapshotPayload(
73
+ values,
74
+ snapshotMode,
75
+ host,
76
+ fetchBulkParams
77
+ );
119
78
  await onSubmit(payload, actions);
120
79
  } catch (error) {
121
80
  if (actions.setStatus) {
@@ -143,33 +102,40 @@ const SnapshotForm = ({
143
102
  ouiaId="snapshot-form-card"
144
103
  >
145
104
  <CardBody>
146
- <PfForm onSubmit={formikSubmit} ouiaId="snapshot-form">
147
- <TextField
105
+ <PfForm onSubmit={formikSubmit}>
106
+ <SnapshotFormField
148
107
  name="name"
149
108
  type="text"
150
109
  required
151
110
  label={__('Name')}
152
111
  ouiaId="snapshot-name-field"
153
- inputClassName="pf-v5-u-w-90"
154
112
  />
155
113
 
156
- <TextField
114
+ <SnapshotFormField
157
115
  name="description"
158
116
  type="textarea"
159
117
  label={__('Description')}
160
118
  ouiaId="snapshot-description-field"
161
- inputClassName="pf-v5-u-w-90"
162
119
  />
163
120
 
164
121
  <FormGroup
165
122
  label={__('Snapshot Mode')}
166
123
  fieldId="snapshot-mode-select"
167
- labelHelp={{
168
- content: __(
169
- "Select Snapshot Mode between 'Disk only' (default) or mutually exclusive options, 'Memory' (includes RAM) and 'Quiesce'."
170
- ),
171
- 'aria-label': __('Snapshot mode help'),
172
- }}
124
+ labelIcon={
125
+ <Popover
126
+ bodyContent={__(
127
+ "Select Snapshot Mode between 'Disk only' (default) or mutually exclusive options, 'Memory' (includes RAM) and 'Quiesce'."
128
+ )}
129
+ >
130
+ <Button
131
+ variant="plain"
132
+ aria-label={__('Snapshot mode help')}
133
+ ouiaId="snapshot-mode-help-button"
134
+ >
135
+ <HelpIcon />
136
+ </Button>
137
+ </Popover>
138
+ }
173
139
  >
174
140
  <div className="pf-v5-u-mt-sm">
175
141
  <Select
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Field } from 'formik';
4
+ import {
5
+ FormGroup,
6
+ FormHelperText,
7
+ HelperText,
8
+ HelperTextItem,
9
+ TextArea,
10
+ TextInput,
11
+ } from '@patternfly/react-core';
12
+
13
+ const SnapshotFormField = ({ name, label, type, required, ouiaId }) => (
14
+ <Field name={name}>
15
+ {({ field, form }) => {
16
+ const error = form.touched[name] && form.errors[name];
17
+ const Input = type === 'textarea' ? TextArea : TextInput;
18
+ return (
19
+ <FormGroup
20
+ label={label}
21
+ isRequired={required}
22
+ fieldId={`snapshot-form-${name}`}
23
+ >
24
+ <Input
25
+ id={`snapshot-form-${name}`}
26
+ name={field.name}
27
+ value={field.value || ''}
28
+ onChange={field.onChange}
29
+ onBlur={field.onBlur}
30
+ validated={error ? 'error' : 'default'}
31
+ className="pf-v5-u-w-90"
32
+ {...(type === 'textarea'
33
+ ? { resizeOrientation: 'vertical' }
34
+ : { type, ouiaId })}
35
+ />
36
+ {error && (
37
+ <FormHelperText>
38
+ <HelperText>
39
+ <HelperTextItem variant="error">{error}</HelperTextItem>
40
+ </HelperText>
41
+ </FormHelperText>
42
+ )}
43
+ </FormGroup>
44
+ );
45
+ }}
46
+ </Field>
47
+ );
48
+
49
+ SnapshotFormField.propTypes = {
50
+ name: PropTypes.string.isRequired,
51
+ label: PropTypes.string.isRequired,
52
+ type: PropTypes.string,
53
+ required: PropTypes.bool,
54
+ ouiaId: PropTypes.string.isRequired,
55
+ };
56
+
57
+ SnapshotFormField.defaultProps = {
58
+ type: 'text',
59
+ required: false,
60
+ };
61
+
62
+ export default SnapshotFormField;
@@ -0,0 +1,64 @@
1
+ import * as Yup from 'yup';
2
+
3
+ import { translate as __ } from 'foremanReact/common/I18n';
4
+
5
+ const MAX_SNAPSHOT_NAME_LENGTH = 80;
6
+ const LIMITED_MAX_SNAPSHOT_NAME_LENGTH = 40;
7
+
8
+ export const buildValidationSchema = capabilities => {
9
+ let nameValidation = Yup.string().max(MAX_SNAPSHOT_NAME_LENGTH, 'Too Long!');
10
+ if (capabilities.limitSnapshotNameFormat)
11
+ nameValidation = nameValidation
12
+ .min(2, 'Too Short!')
13
+ .matches(
14
+ /^[A-z]\w+$/,
15
+ __(
16
+ 'Name must contain at least 2 characters starting with alphabet. Valid characters are A-Z a-z 0-9 _'
17
+ )
18
+ )
19
+ .max(LIMITED_MAX_SNAPSHOT_NAME_LENGTH, 'Too Long!');
20
+
21
+ return Yup.object().shape({
22
+ name: nameValidation.required('is required'),
23
+ description: Yup.string(),
24
+ includeRam: Yup.bool(),
25
+ useQuiesce: Yup.bool(),
26
+ snapshotMode: Yup.string(),
27
+ });
28
+ };
29
+
30
+ export const buildSnapshotPayload = (
31
+ values,
32
+ snapshotMode,
33
+ host,
34
+ fetchBulkParams
35
+ ) => {
36
+ if (snapshotMode === 'quiesce') {
37
+ values.useQuiesce = true;
38
+ values.includeRam = false;
39
+ } else if (snapshotMode === 'include_ram') {
40
+ values.includeRam = true;
41
+ values.useQuiesce = false;
42
+ }
43
+
44
+ let mode = 'full';
45
+ if (values.includeRam) {
46
+ mode = 'include_ram';
47
+ } else if (values.useQuiesce) {
48
+ mode = 'quiesce';
49
+ }
50
+
51
+ const singleHostId = host?.id;
52
+
53
+ return {
54
+ included: {
55
+ search: host ? `id = ${singleHostId}` : fetchBulkParams(),
56
+ },
57
+ ...(singleHostId && { hostId: singleHostId }),
58
+ mode,
59
+ snapshot: {
60
+ name: values.name,
61
+ description: values.description || '',
62
+ },
63
+ };
64
+ };
@@ -1,30 +1,78 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
1
+ import React from 'react';
2
+ import { render, screen, waitFor } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
2
4
 
3
5
  import SnapshotForm from '../SnapshotForm';
4
6
 
5
- const fetchBulkParams = () => null;
6
-
7
- const fixtures = {
8
- render: { hostId: 42, onSubmit: () => null, fetchBulkParams },
9
- 'render with limitSnapshotNameFormat capability': {
10
- hostId: 42,
11
- onSubmit: () => null,
12
- fetchBulkParams,
13
- capabilities: { limitSnapshotNameFormat: true },
14
- },
15
- 'render with optional Props': {
16
- hostId: 42,
17
- onSubmit: () => null,
18
- fetchBulkParams,
19
- initialValues: {
20
- name: 'Snapshot1',
21
- description: 'Hello World',
22
- includeRam: true,
23
- },
24
- },
25
- };
7
+ const fetchBulkParams = () => 'bulk search';
8
+ const baseProps = { hostId: 42, onSubmit: jest.fn(), fetchBulkParams };
26
9
 
27
10
  describe('SnapshotForm', () => {
28
- describe('rendering', () =>
29
- testComponentSnapshotsWithFixtures(SnapshotForm, fixtures));
11
+ beforeEach(() => jest.clearAllMocks());
12
+
13
+ it('renders the form fields', () => {
14
+ render(<SnapshotForm {...baseProps} />);
15
+ expect(screen.getAllByRole('textbox')).toHaveLength(2);
16
+ expect(screen.getAllByRole('textbox')[1]).toBeInTheDocument();
17
+ expect(screen.getByText('Select snapshot mode')).toBeInTheDocument();
18
+ });
19
+
20
+ it('renders with initial values', () => {
21
+ render(
22
+ <SnapshotForm
23
+ {...baseProps}
24
+ initialValues={{
25
+ name: 'Snapshot1',
26
+ description: 'Hello World',
27
+ includeRam: true,
28
+ }}
29
+ />
30
+ );
31
+ expect(screen.getAllByRole('textbox')[0]).toHaveValue('Snapshot1');
32
+ expect(screen.getAllByRole('textbox')[1]).toHaveValue('Hello World');
33
+ });
34
+
35
+ it('validates the name with limitSnapshotNameFormat capability', async () => {
36
+ render(
37
+ <SnapshotForm
38
+ {...baseProps}
39
+ capabilities={{ limitSnapshotNameFormat: true }}
40
+ />
41
+ );
42
+ const input = screen.getAllByRole('textbox')[0];
43
+ userEvent.type(input, '1');
44
+ userEvent.tab();
45
+ expect(
46
+ await screen.findByText(
47
+ /Name must contain at least 2 characters|Too Short/
48
+ )
49
+ ).toBeInTheDocument();
50
+ });
51
+
52
+ it('submits a single host snapshot', async () => {
53
+ const onSubmit = jest.fn();
54
+ const setModalClosed = jest.fn();
55
+ render(
56
+ <SnapshotForm
57
+ {...baseProps}
58
+ host={{ id: 42, name: 'deep.thought' }}
59
+ onSubmit={onSubmit}
60
+ setModalClosed={setModalClosed}
61
+ initialValues={{
62
+ name: 'Snap',
63
+ description: 'desc',
64
+ includeRam: false,
65
+ }}
66
+ />
67
+ );
68
+ userEvent.click(screen.getByRole('button', { name: /submit|create/i }));
69
+ await waitFor(() => expect(onSubmit).toHaveBeenCalled());
70
+ expect(onSubmit.mock.calls[0][0]).toMatchObject({
71
+ mode: 'full',
72
+ hostId: 42,
73
+ included: { search: 'id = 42' },
74
+ snapshot: { name: 'Snap', description: 'desc' },
75
+ });
76
+ await waitFor(() => expect(setModalClosed).toHaveBeenCalled());
77
+ });
30
78
  });
@@ -53,6 +53,7 @@ const SnapshotFormModal = ({
53
53
  onClose={setModalClosed}
54
54
  onEscapePress={setModalClosed}
55
55
  header={header}
56
+ aria-label={__('Create snapshot')}
56
57
  ouiaId="snapshot-form-modal"
57
58
  >
58
59
  {hasSelection && (
@@ -1,13 +1,8 @@
1
- import {
2
- testComponentSnapshotsWithFixtures,
3
- // shallowRenderComponentWithFixtures,
4
- } from 'react-redux-test-utils';
5
- // import configureStore from 'redux-mock-store';
1
+ import React from 'react';
2
+ import { render, screen } from '@testing-library/react';
6
3
 
7
4
  import SnapshotFormModal from '../SnapshotFormModal';
8
5
 
9
- // const mockStore = configureStore([]);
10
-
11
6
  const setModalClosed = () => null;
12
7
  const fetchBulkParams = () => null;
13
8
  const fixtures = {
@@ -16,10 +11,42 @@ const fixtures = {
16
11
  host: { id: 42, name: 'deep.thought' },
17
12
  setModalClosed,
18
13
  fetchBulkParams,
14
+ onSubmit: () => null,
19
15
  },
20
16
  };
21
17
 
22
18
  describe('SnapshotFormModal', () => {
23
- describe('renders', () =>
24
- testComponentSnapshotsWithFixtures(SnapshotFormModal, fixtures));
19
+ it('renders the modal with the host count', () => {
20
+ render(<SnapshotFormModal {...fixtures.normal} />);
21
+ expect(screen.getByText('Create snapshot')).toBeInTheDocument();
22
+ expect(
23
+ screen.getByText('1 host is selected for snapshot creation')
24
+ ).toBeInTheDocument();
25
+ });
26
+
27
+ it('renders nothing when closed', () => {
28
+ render(<SnapshotFormModal {...fixtures.normal} isOpen={false} />);
29
+ expect(screen.queryByText('Create snapshot')).not.toBeInTheDocument();
30
+ });
31
+
32
+ it('renders plural count for multiple hosts', () => {
33
+ render(
34
+ <SnapshotFormModal
35
+ {...fixtures.normal}
36
+ host={null}
37
+ selectedHostsCount={3}
38
+ selectedHosts={[{ id: 1, name: 'a' }]}
39
+ />
40
+ );
41
+ expect(
42
+ screen.getByText('3 hosts are selected for snapshot creation')
43
+ ).toBeInTheDocument();
44
+ });
45
+
46
+ it('hides the form without selection', () => {
47
+ render(<SnapshotFormModal {...fixtures.normal} host={null} />);
48
+ expect(
49
+ screen.queryByText(/selected for snapshot creation/)
50
+ ).not.toBeInTheDocument();
51
+ });
25
52
  });