@patternfly/react-core 4.202.12 → 4.202.15

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 (53) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/esm/components/Drawer/DrawerContent.js +1 -1
  3. package/dist/esm/components/Drawer/DrawerContent.js.map +1 -1
  4. package/dist/esm/components/LoginPage/LoginFooterItem.d.ts.map +1 -1
  5. package/dist/esm/components/LoginPage/LoginFooterItem.js +1 -3
  6. package/dist/esm/components/LoginPage/LoginFooterItem.js.map +1 -1
  7. package/dist/esm/components/TextInput/TextInput.d.ts +1 -0
  8. package/dist/esm/components/TextInput/TextInput.d.ts.map +1 -1
  9. package/dist/esm/components/TextInput/TextInput.js +2 -1
  10. package/dist/esm/components/TextInput/TextInput.js.map +1 -1
  11. package/dist/js/components/Drawer/DrawerContent.js +1 -1
  12. package/dist/js/components/Drawer/DrawerContent.js.map +1 -1
  13. package/dist/js/components/LoginPage/LoginFooterItem.d.ts.map +1 -1
  14. package/dist/js/components/LoginPage/LoginFooterItem.js +1 -3
  15. package/dist/js/components/LoginPage/LoginFooterItem.js.map +1 -1
  16. package/dist/js/components/TextInput/TextInput.d.ts +1 -0
  17. package/dist/js/components/TextInput/TextInput.d.ts.map +1 -1
  18. package/dist/js/components/TextInput/TextInput.js +2 -1
  19. package/dist/js/components/TextInput/TextInput.js.map +1 -1
  20. package/dist/umd/react-core.js +4 -5
  21. package/dist/umd/react-core.min.js +2 -2
  22. package/package.json +6 -6
  23. package/src/components/Drawer/DrawerContent.tsx +1 -1
  24. package/src/components/EmptyState/__tests__/EmptyState.test.tsx +46 -42
  25. package/src/components/EmptyState/__tests__/__snapshots__/EmptyState.test.tsx.snap +5 -130
  26. package/src/components/Form/__tests__/FormGroup.test.tsx +82 -57
  27. package/src/components/Form/__tests__/FormHelperText.test.tsx +42 -28
  28. package/src/components/Form/__tests__/__snapshots__/FormGroup.test.tsx.snap +51 -250
  29. package/src/components/Form/__tests__/__snapshots__/FormHelperText.test.tsx.snap +4 -44
  30. package/src/components/FormSelect/__tests__/FormSelect.test.tsx +131 -122
  31. package/src/components/FormSelect/__tests__/__snapshots__/FormSelect.test.tsx.snap +9 -301
  32. package/src/components/InputGroup/__tests__/InputGroup.test.tsx +17 -41
  33. package/src/components/InputGroup/__tests__/InputGroupText.test.tsx +17 -0
  34. package/src/components/Label/__tests__/Label.test.tsx +127 -68
  35. package/src/components/Label/__tests__/__snapshots__/Label.test.tsx.snap +26 -828
  36. package/src/components/LabelGroup/__tests__/LabelGroup.test.tsx +24 -20
  37. package/src/components/LabelGroup/__tests__/__snapshots__/LabelGroup.test.tsx.snap +10 -12
  38. package/src/components/LoginPage/LoginFooterItem.tsx +0 -2
  39. package/src/components/LoginPage/__tests__/LoginFooterItem.test.tsx +23 -24
  40. package/src/components/LoginPage/__tests__/LoginForm.test.tsx +40 -33
  41. package/src/components/LoginPage/__tests__/LoginMainBody.test.tsx +10 -16
  42. package/src/components/LoginPage/__tests__/LoginMainFooter.test.tsx +11 -17
  43. package/src/components/LoginPage/__tests__/LoginMainFooterBandItem.test.tsx +23 -24
  44. package/src/components/LoginPage/__tests__/LoginMainFooterLinksItem.test.tsx +20 -24
  45. package/src/components/LoginPage/__tests__/LoginMainHeader.test.tsx +14 -20
  46. package/src/components/LoginPage/__tests__/__snapshots__/LoginFooterItem.test.tsx.snap +3 -13
  47. package/src/components/LoginPage/__tests__/__snapshots__/LoginForm.test.tsx.snap +3 -415
  48. package/src/components/LoginPage/__tests__/__snapshots__/LoginMainBody.test.tsx.snap +2 -8
  49. package/src/components/LoginPage/__tests__/__snapshots__/LoginMainFooter.test.tsx.snap +2 -8
  50. package/src/components/LoginPage/__tests__/__snapshots__/LoginMainFooterBandItem.test.tsx.snap +3 -17
  51. package/src/components/LoginPage/__tests__/__snapshots__/LoginMainFooterLinksItem.test.tsx.snap +3 -31
  52. package/src/components/LoginPage/__tests__/__snapshots__/LoginMainHeader.test.tsx.snap +3 -12
  53. package/src/components/TextInput/TextInput.tsx +4 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.202.12",
3
+ "version": "4.202.15",
4
4
  "description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
5
5
  "main": "dist/js/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -34,16 +34,16 @@
34
34
  "generate": "node scripts/copyStyles.js"
35
35
  },
36
36
  "dependencies": {
37
- "@patternfly/react-icons": "^4.53.12",
38
- "@patternfly/react-styles": "^4.52.12",
39
- "@patternfly/react-tokens": "^4.54.12",
37
+ "@patternfly/react-icons": "^4.53.15",
38
+ "@patternfly/react-styles": "^4.52.15",
39
+ "@patternfly/react-tokens": "^4.54.15",
40
40
  "focus-trap": "6.2.2",
41
41
  "react-dropzone": "9.0.0",
42
42
  "tippy.js": "5.1.2",
43
43
  "tslib": "^2.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@patternfly/patternfly": "4.185.0",
46
+ "@patternfly/patternfly": "4.185.1",
47
47
  "@rollup/plugin-commonjs": "^21.0.0",
48
48
  "@rollup/plugin-node-resolve": "^13.0.0",
49
49
  "@rollup/plugin-replace": "^3.0.0",
@@ -60,5 +60,5 @@
60
60
  "react": "^16.8.0 || ^17.0.0",
61
61
  "react-dom": "^16.8.0 || ^17.0.0"
62
62
  },
63
- "gitHead": "fc5d999e50a87f1e2eb6a630b8c810ed720a5e14"
63
+ "gitHead": "af93f798f3d171321a1f2992eebaee672fc95132"
64
64
  }
@@ -37,7 +37,7 @@ export const DrawerContent: React.SFC<DrawerContentProps> = ({
37
37
  >
38
38
  {children}
39
39
  </div>
40
- {React.cloneElement(panelContent as React.ReactElement, { drawerContentRef })}
40
+ {panelContent && React.cloneElement(panelContent as React.ReactElement, { drawerContentRef })}
41
41
  </DrawerMain>
42
42
  );
43
43
  };
@@ -1,6 +1,8 @@
1
- import * as React from 'react';
2
- import { render } from '@testing-library/react';
3
- import { shallow } from 'enzyme';
1
+ import React from 'react';
2
+
3
+ import { render, screen } from '@testing-library/react';
4
+ import "@testing-library/jest-dom";
5
+
4
6
  import AddressBookIcon from '@patternfly/react-icons/dist/esm/icons/address-book-icon';
5
7
  import { EmptyState, EmptyStateVariant } from '../EmptyState';
6
8
  import { EmptyStateBody } from '../EmptyStateBody';
@@ -12,8 +14,8 @@ import { Title, TitleSizes } from '../../Title';
12
14
 
13
15
  describe('EmptyState', () => {
14
16
  test('Main', () => {
15
- const view = render(
16
- <EmptyState>
17
+ render(
18
+ <EmptyState data-testid="empty-state-test-id">
17
19
  <Title headingLevel="h5" size="lg">
18
20
  HTTP Proxies
19
21
  </Title>
@@ -28,58 +30,59 @@ describe('EmptyState', () => {
28
30
  </EmptyStateSecondaryActions>
29
31
  </EmptyState>
30
32
  );
31
- expect(view.container).toMatchSnapshot();
33
+ expect(screen.getByTestId('empty-state-test-id').outerHTML).toMatchSnapshot();
32
34
  });
33
35
 
34
36
  test('Main variant large', () => {
35
- const view = render(
36
- <EmptyState variant={EmptyStateVariant.large}>
37
- <Title headingLevel="h3" size={TitleSizes.md}>EmptyState large</Title>
37
+ render(
38
+ <EmptyState variant={EmptyStateVariant.large} data-testid="empty-state-test-id">
39
+ <Title headingLevel="h3" size={TitleSizes.md}>
40
+ EmptyState large
41
+ </Title>
38
42
  </EmptyState>
39
43
  );
40
- expect(view.container).toMatchSnapshot();
44
+ expect(screen.getByTestId('empty-state-test-id').outerHTML).toMatchSnapshot();
41
45
  });
42
46
 
43
47
  test('Main variant small', () => {
44
- const view = render(
45
- <EmptyState variant={EmptyStateVariant.small}>
46
- <Title headingLevel="h3" size={TitleSizes.md}>EmptyState small</Title>
48
+ render(
49
+ <EmptyState variant={EmptyStateVariant.small} data-testid="empty-state-test-id">
50
+ <Title headingLevel="h3" size={TitleSizes.md}>
51
+ EmptyState small
52
+ </Title>
47
53
  </EmptyState>
48
54
  );
49
- expect(view.container).toMatchSnapshot();
55
+ expect(screen.getByTestId('empty-state-test-id').outerHTML).toMatchSnapshot();
50
56
  });
51
57
 
52
58
  test('Main variant xs', () => {
53
- const view = render(
54
- <EmptyState variant={EmptyStateVariant.xs}>
55
- <Title headingLevel="h3" size={TitleSizes.md}>EmptyState small</Title>
59
+ render(
60
+ <EmptyState variant={EmptyStateVariant.xs} data-testid="empty-state-test-id">
61
+ <Title headingLevel="h3" size={TitleSizes.md}>
62
+ EmptyState small
63
+ </Title>
56
64
  </EmptyState>
57
65
  );
58
- expect(view.container).toMatchSnapshot();
66
+ expect(screen.getByTestId('empty-state-test-id').outerHTML).toMatchSnapshot();
59
67
  });
60
68
 
61
69
  test('Body', () => {
62
- const view = shallow(<EmptyStateBody className="custom-empty-state-body" id="empty-state-1" />);
63
- expect(view.props().className).toBe('pf-c-empty-state__body custom-empty-state-body');
64
- expect(view.props().id).toBe('empty-state-1');
70
+ render(<EmptyStateBody className="custom-empty-state-body" data-testid="body-test-id" />);
71
+ expect(screen.getByTestId('body-test-id')).toHaveClass('custom-empty-state-body pf-c-empty-state__body');
65
72
  });
66
73
 
67
74
  test('Secondary Action', () => {
68
- const view = shallow(<EmptyStateSecondaryActions className="custom-empty-state-secondary" id="empty-state-2" />);
69
- expect(view.props().className).toBe('pf-c-empty-state__secondary custom-empty-state-secondary');
70
- expect(view.props().id).toBe('empty-state-2');
75
+ render(<EmptyStateSecondaryActions className="custom-empty-state-secondary" data-testid="actions-test-id" />);
76
+ expect(screen.getByTestId('actions-test-id')).toHaveClass('custom-empty-state-secondary pf-c-empty-state__secondary');
71
77
  });
72
78
 
73
79
  test('Icon', () => {
74
- const view = shallow(
75
- <EmptyStateIcon icon={AddressBookIcon} className="custom-empty-state-icon" id="empty-state-icon" />
76
- );
77
- expect(view.props().className).toBe('pf-c-empty-state__icon custom-empty-state-icon');
78
- expect(view.props().id).toBe('empty-state-icon');
80
+ render(<EmptyStateIcon icon={AddressBookIcon} data-testid="icon-test-id" />);
81
+ expect(screen.getByTestId('icon-test-id').outerHTML).toContain('pf-c-empty-state__icon');
79
82
  });
80
83
 
81
84
  test('Wrap icon in a div', () => {
82
- const view = shallow(
85
+ const view = render(
83
86
  <EmptyStateIcon
84
87
  variant="container"
85
88
  component={AddressBookIcon}
@@ -87,27 +90,28 @@ describe('EmptyState', () => {
87
90
  id="empty-state-icon"
88
91
  />
89
92
  );
90
- expect(view.find('div').props().className).toBe('pf-c-empty-state__icon custom-empty-state-icon');
91
- expect(view.find('AddressBookIcon').length).toBe(1);
92
- });
93
+
94
+ expect(view.container.querySelector('div')).toHaveClass('pf-c-empty-state__icon custom-empty-state-icon');
95
+ expect(view.container.querySelector('svg')).toBeInTheDocument();
96
+ })
93
97
 
94
98
  test('Primary div', () => {
95
- const view = shallow(
96
- <EmptyStatePrimary className="custom-empty-state-prim-cls" id="empty-state-prim-id">
99
+ render(
100
+ <EmptyStatePrimary data-testid="primary-test-id">
97
101
  <Button variant="link">Link</Button>
98
102
  </EmptyStatePrimary>
99
103
  );
100
- expect(view.props().className).toBe('pf-c-empty-state__primary custom-empty-state-prim-cls');
101
- expect(view.props().id).toBe('empty-state-prim-id');
104
+ expect(screen.getByTestId('primary-test-id').className).toContain('pf-c-empty-state__primary');
102
105
  });
103
106
 
104
107
  test('Full height', () => {
105
- const view = render(
106
- <EmptyState isFullHeight variant={EmptyStateVariant.large}>
107
- <Title headingLevel="h3" size={TitleSizes.md}>EmptyState large</Title>
108
+ render(
109
+ <EmptyState isFullHeight variant={EmptyStateVariant.large} data-testid="empty-state-test-id">
110
+ <Title headingLevel="h3" size={TitleSizes.md}>
111
+ EmptyState large
112
+ </Title>
108
113
  </EmptyState>
109
114
  );
110
- expect(view.container).toMatchSnapshot();
115
+ expect(screen.getByTestId('empty-state-test-id').outerHTML).toMatchSnapshot();
111
116
  });
112
-
113
117
  });
@@ -1,136 +1,11 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`EmptyState Full height 1`] = `
4
- <div>
5
- <div
6
- class="pf-c-empty-state pf-m-lg pf-m-full-height"
7
- >
8
- <div
9
- class="pf-c-empty-state__content"
10
- >
11
- <h3
12
- class="pf-c-title pf-m-md"
13
- data-ouia-component-id="OUIA-Generated-Title-5"
14
- data-ouia-component-type="PF4/Title"
15
- data-ouia-safe="true"
16
- >
17
- EmptyState large
18
- </h3>
19
- </div>
20
- </div>
21
- </div>
22
- `;
3
+ exports[`EmptyState Full height 1`] = `"<div class=\\"pf-c-empty-state pf-m-lg pf-m-full-height\\" data-testid=\\"empty-state-test-id\\"><div class=\\"pf-c-empty-state__content\\"><h3 data-ouia-component-type=\\"PF4/Title\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Title-5\\" class=\\"pf-c-title pf-m-md\\">EmptyState large</h3></div></div>"`;
23
4
 
24
- exports[`EmptyState Main 1`] = `
25
- <div>
26
- <div
27
- class="pf-c-empty-state"
28
- >
29
- <div
30
- class="pf-c-empty-state__content"
31
- >
32
- <h5
33
- class="pf-c-title pf-m-lg"
34
- data-ouia-component-id="OUIA-Generated-Title-1"
35
- data-ouia-component-type="PF4/Title"
36
- data-ouia-safe="true"
37
- >
38
- HTTP Proxies
39
- </h5>
40
- <div
41
- class="pf-c-empty-state__body"
42
- >
43
- Defining HTTP Proxies that exist on your network allows you to perform various actions through those proxies.
44
- </div>
45
- <button
46
- aria-disabled="false"
47
- class="pf-c-button pf-m-primary"
48
- data-ouia-component-id="OUIA-Generated-Button-primary-1"
49
- data-ouia-component-type="PF4/Button"
50
- data-ouia-safe="true"
51
- type="button"
52
- >
53
- New HTTP Proxy
54
- </button>
55
- <div
56
- class="pf-c-empty-state__secondary"
57
- >
58
- <button
59
- aria-disabled="false"
60
- aria-label="learn more action"
61
- class="pf-c-button pf-m-link"
62
- data-ouia-component-id="OUIA-Generated-Button-link-1"
63
- data-ouia-component-type="PF4/Button"
64
- data-ouia-safe="true"
65
- type="button"
66
- >
67
- Learn more about this in the documentation.
68
- </button>
69
- </div>
70
- </div>
71
- </div>
72
- </div>
73
- `;
5
+ exports[`EmptyState Main 1`] = `"<div class=\\"pf-c-empty-state\\" data-testid=\\"empty-state-test-id\\"><div class=\\"pf-c-empty-state__content\\"><h5 data-ouia-component-type=\\"PF4/Title\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Title-1\\" class=\\"pf-c-title pf-m-lg\\">HTTP Proxies</h5><div class=\\"pf-c-empty-state__body\\">Defining HTTP Proxies that exist on your network allows you to perform various actions through those proxies.</div><button aria-disabled=\\"false\\" class=\\"pf-c-button pf-m-primary\\" type=\\"button\\" data-ouia-component-type=\\"PF4/Button\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Button-primary-1\\">New HTTP Proxy</button><div class=\\"pf-c-empty-state__secondary\\"><button aria-disabled=\\"false\\" aria-label=\\"learn more action\\" class=\\"pf-c-button pf-m-link\\" type=\\"button\\" data-ouia-component-type=\\"PF4/Button\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Button-link-1\\">Learn more about this in the documentation.</button></div></div></div>"`;
74
6
 
75
- exports[`EmptyState Main variant large 1`] = `
76
- <div>
77
- <div
78
- class="pf-c-empty-state pf-m-lg"
79
- >
80
- <div
81
- class="pf-c-empty-state__content"
82
- >
83
- <h3
84
- class="pf-c-title pf-m-md"
85
- data-ouia-component-id="OUIA-Generated-Title-2"
86
- data-ouia-component-type="PF4/Title"
87
- data-ouia-safe="true"
88
- >
89
- EmptyState large
90
- </h3>
91
- </div>
92
- </div>
93
- </div>
94
- `;
7
+ exports[`EmptyState Main variant large 1`] = `"<div class=\\"pf-c-empty-state pf-m-lg\\" data-testid=\\"empty-state-test-id\\"><div class=\\"pf-c-empty-state__content\\"><h3 data-ouia-component-type=\\"PF4/Title\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Title-2\\" class=\\"pf-c-title pf-m-md\\">EmptyState large</h3></div></div>"`;
95
8
 
96
- exports[`EmptyState Main variant small 1`] = `
97
- <div>
98
- <div
99
- class="pf-c-empty-state pf-m-sm"
100
- >
101
- <div
102
- class="pf-c-empty-state__content"
103
- >
104
- <h3
105
- class="pf-c-title pf-m-md"
106
- data-ouia-component-id="OUIA-Generated-Title-3"
107
- data-ouia-component-type="PF4/Title"
108
- data-ouia-safe="true"
109
- >
110
- EmptyState small
111
- </h3>
112
- </div>
113
- </div>
114
- </div>
115
- `;
9
+ exports[`EmptyState Main variant small 1`] = `"<div class=\\"pf-c-empty-state pf-m-sm\\" data-testid=\\"empty-state-test-id\\"><div class=\\"pf-c-empty-state__content\\"><h3 data-ouia-component-type=\\"PF4/Title\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Title-3\\" class=\\"pf-c-title pf-m-md\\">EmptyState small</h3></div></div>"`;
116
10
 
117
- exports[`EmptyState Main variant xs 1`] = `
118
- <div>
119
- <div
120
- class="pf-c-empty-state pf-m-xs"
121
- >
122
- <div
123
- class="pf-c-empty-state__content"
124
- >
125
- <h3
126
- class="pf-c-title pf-m-md"
127
- data-ouia-component-id="OUIA-Generated-Title-4"
128
- data-ouia-component-type="PF4/Title"
129
- data-ouia-safe="true"
130
- >
131
- EmptyState small
132
- </h3>
133
- </div>
134
- </div>
135
- </div>
136
- `;
11
+ exports[`EmptyState Main variant xs 1`] = `"<div class=\\"pf-c-empty-state pf-m-xs\\" data-testid=\\"empty-state-test-id\\"><div class=\\"pf-c-empty-state__content\\"><h3 data-ouia-component-type=\\"PF4/Title\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Title-4\\" class=\\"pf-c-title pf-m-md\\">EmptyState small</h3></div></div>"`;
@@ -1,192 +1,217 @@
1
1
  import React from 'react';
2
+
3
+ import { render, screen } from '@testing-library/react';
4
+ import '@testing-library/jest-dom';
5
+
6
+ import { ValidatedOptions } from '../../../helpers/constants';
2
7
  import { FormGroup } from '../FormGroup';
3
8
  import { Form } from '../Form';
4
- import { render } from '@testing-library/react';
5
- import { mount } from 'enzyme';
6
- import { ValidatedOptions } from '../../../helpers/constants';
7
9
 
8
- describe('FormGroup component', () => {
10
+ describe('FormGroup', () => {
9
11
  const returnFunction = () => <div>label</div>;
10
12
 
11
13
  test('should render default form group variant', () => {
12
- const view = render(
14
+ const { asFragment } = render(
13
15
  <FormGroup label="label" fieldId="label-id" helperText="this is helper text">
14
16
  <input id="label-id" />
15
17
  </FormGroup>
16
18
  );
17
- expect(view.container).toMatchSnapshot();
19
+ expect(asFragment()).toMatchSnapshot();
18
20
  });
19
21
 
20
22
  test('should render inline form group variant', () => {
21
- const view = mount(
23
+ render(
22
24
  <FormGroup isInline label="label" fieldId="label-id" helperText="this is helper text">
23
25
  <input id="label-id" />
24
26
  </FormGroup>
25
27
  );
26
- expect(view).toMatchSnapshot();
27
- expect(view.find('.pf-c-form__group-control').prop('className')).toMatch(/pf-m-inline/);
28
+ expect(screen.getByLabelText('label').parentElement).toHaveClass('pf-m-inline');
28
29
  });
29
30
 
30
31
  test('should render no padding-top form group variant', () => {
31
- const view = mount(
32
- <FormGroup hasNoPaddingTop label="label" fieldId="label-id" helperText="this is helper text">
32
+ render(
33
+ <FormGroup
34
+ hasNoPaddingTop
35
+ label="label"
36
+ fieldId="label-id"
37
+ helperText="this is helper text"
38
+ data-testid="form-group-test-id"
39
+ >
33
40
  <input id="label-id" />
34
41
  </FormGroup>
35
42
  );
36
- expect(view.find('.pf-c-form__group-label').prop('className')).toMatch(/no-padding-top/);
43
+ expect(screen.getByTestId('form-group-test-id').firstElementChild).toHaveClass('pf-m-no-padding-top');
37
44
  });
38
45
 
39
46
  test('should render form group variant with required label', () => {
40
- const view = render(
47
+ const { asFragment } = render(
41
48
  <FormGroup label="label" isRequired fieldId="label-id">
42
49
  <input id="label-id" />
43
50
  </FormGroup>
44
51
  );
45
- expect(view.container).toMatchSnapshot();
52
+ expect(asFragment()).toMatchSnapshot();
46
53
  });
47
54
 
48
55
  test('should render form group variant with node label', () => {
49
- const view = render(
56
+ const { asFragment } = render(
50
57
  <FormGroup fieldId="id" label={<h1>Header</h1>}>
51
58
  <input aria-label="input" />
52
59
  </FormGroup>
53
60
  );
54
- expect(view.container).toMatchSnapshot();
61
+ expect(asFragment()).toMatchSnapshot();
55
62
  });
56
63
 
57
64
  test('should render form group with additonal label info', () => {
58
- const view = render(
65
+ const { asFragment } = render(
59
66
  <FormGroup fieldId="id" label={<h1>Header</h1>} labelInfo="more info">
60
67
  <input aria-label="input" />
61
68
  </FormGroup>
62
69
  );
63
- expect(view.container).toMatchSnapshot();
70
+ expect(asFragment()).toMatchSnapshot();
64
71
  });
65
72
 
66
73
  test('should render form group variant with function label', () => {
67
- const view = render(
74
+ render(
68
75
  <FormGroup fieldId="id" label={returnFunction()}>
69
76
  <input aria-label="input" />
70
77
  </FormGroup>
71
78
  );
72
- expect(view.container).toMatchSnapshot();
79
+
80
+ expect(screen.getByText('label')).toBeInTheDocument();
73
81
  });
74
82
 
75
83
  test('should render form group variant with node helperText', () => {
76
- const view = render(
84
+ render(
77
85
  <FormGroup label="Label" fieldId="label-id" helperText={<h1>Header</h1>}>
78
86
  <input id="label-id" />
79
87
  </FormGroup>
80
88
  );
81
- expect(view.container).toMatchSnapshot();
89
+
90
+ expect(screen.getByRole('heading', { name: 'Header' })).toBeInTheDocument();
82
91
  });
83
92
 
84
93
  test('should render form group variant with function helperText', () => {
85
- const view = render(
94
+ render(
86
95
  <FormGroup label="Label" fieldId="label-id" helperText={returnFunction()}>
87
96
  <input id="label-id" />
88
97
  </FormGroup>
89
98
  );
90
- expect(view.container).toMatchSnapshot();
99
+
100
+ expect(screen.getByText('label')).toBeInTheDocument();
91
101
  });
92
102
 
93
103
  test('should render horizontal form group variant', () => {
94
- const view = render(
104
+ const { asFragment } = render(
95
105
  <Form isHorizontal>
96
106
  <FormGroup label="label" fieldId="label-id" helperText="this is helperText">
97
107
  <input id="label-id" />
98
108
  </FormGroup>
99
109
  </Form>
100
110
  );
101
- expect(view.container).toMatchSnapshot();
111
+ expect(asFragment()).toMatchSnapshot();
102
112
  });
103
113
 
104
114
  test('should render stacked horizontal form group variant', () => {
105
- const view = render(
115
+ const { asFragment } = render(
106
116
  <Form isHorizontal>
107
117
  <FormGroup label="label" fieldId="label-id" isStack helperText="this is helperText">
108
118
  <input id="label-id" />
109
119
  </FormGroup>
110
120
  </Form>
111
121
  );
112
- expect(view.container).toMatchSnapshot();
122
+ expect(asFragment()).toMatchSnapshot();
113
123
  });
114
124
 
115
125
  test('should render helper text above input', () => {
116
- const view = render(
126
+ const { asFragment } = render(
117
127
  <Form isHorizontal>
118
128
  <FormGroup label="label" fieldId="label-id" helperText="this is helperText" isHelperTextBeforeField>
119
129
  <input id="label-id" />
120
130
  </FormGroup>
121
131
  </Form>
122
132
  );
123
- expect(view.container).toMatchSnapshot();
133
+ expect(asFragment()).toMatchSnapshot();
124
134
  });
125
135
 
126
136
  test('should render form group variant without label', () => {
127
- const view = render(
137
+ const { asFragment } = render(
128
138
  <FormGroup fieldId="id">
129
139
  <input aria-label="input" />
130
140
  </FormGroup>
131
141
  );
132
- expect(view.container).toMatchSnapshot();
133
- });
134
-
135
- test('should render form group required variant', () => {
136
- const view = render(
137
- <FormGroup isRequired label="label" fieldId="id">
138
- <input id="id" />
139
- </FormGroup>
140
- );
141
- expect(view.container).toMatchSnapshot();
142
+ expect(asFragment()).toMatchSnapshot();
142
143
  });
143
144
 
144
145
  test('should render form group invalid variant', () => {
145
- const view = render(
146
- <FormGroup label="label" fieldId="label-id" validated={'error'} helperTextInvalid="Invalid FormGroup">
146
+ const { asFragment } = render(
147
+ <FormGroup
148
+ label="label"
149
+ fieldId="label-id"
150
+ validated={'error'}
151
+ helperTextInvalid="Invalid FormGroup"
152
+ >
147
153
  <input id="id" />
148
154
  </FormGroup>
149
155
  );
150
- expect(view.container).toMatchSnapshot();
156
+ expect(asFragment()).toMatchSnapshot();
151
157
  });
152
158
 
153
159
  test('should render form group validated success variant', () => {
154
- const view = mount(
155
- <FormGroup label="label" fieldId="label-id" validated={ValidatedOptions.success} helperText="Validated FormGroup">
160
+ const { asFragment } = render(
161
+ <FormGroup
162
+ label="label"
163
+ fieldId="label-id"
164
+ validated={ValidatedOptions.success}
165
+ helperText="Validated FormGroup"
166
+ data-testid="form-group-test-id"
167
+ >
156
168
  <input id="id" />
157
169
  </FormGroup>
158
170
  );
159
- expect(view.find('.pf-c-form__helper-text.pf-m-success').length).toBe(1);
160
- expect(view).toMatchSnapshot();
171
+
172
+ expect(screen.getByTestId('form-group-test-id').querySelector('input + div')).toHaveClass('pf-m-success');
173
+ expect(asFragment()).toMatchSnapshot();
161
174
  });
162
175
 
163
176
  test('should render form group validated error variant', () => {
164
- const view = render(
165
- <FormGroup label="label" fieldId="label-id" validated={ValidatedOptions.error} helperText="Validated FormGroup">
177
+ const { asFragment } = render(
178
+ <FormGroup
179
+ label="label"
180
+ fieldId="label-id"
181
+ validated={ValidatedOptions.error}
182
+ helperText="Validated FormGroup"
183
+ >
166
184
  <input id="id" />
167
185
  </FormGroup>
168
186
  );
169
- expect(view.container).toMatchSnapshot();
187
+ expect(asFragment()).toMatchSnapshot();
170
188
  });
171
189
 
172
190
  test('should render form group validated warning variant', () => {
173
- const view = mount(
174
- <FormGroup label="label" fieldId="label-id" validated={ValidatedOptions.warning} helperText="Validated FormGroup">
191
+ const { asFragment } = render(
192
+ <FormGroup
193
+ label="label"
194
+ fieldId="label-id"
195
+ validated={ValidatedOptions.warning}
196
+ helperText="Validated FormGroup"
197
+ data-testid="form-group-test-id"
198
+ >
175
199
  <input id="id" />
176
200
  </FormGroup>
177
201
  );
178
- expect(view.find('.pf-c-form__helper-text.pf-m-warning').length).toBe(1);
179
- expect(view).toMatchSnapshot();
202
+
203
+ expect(screen.getByTestId('form-group-test-id').querySelector('input + div')).toHaveClass('pf-m-warning');
204
+ expect(asFragment()).toMatchSnapshot();
180
205
  });
181
206
 
182
207
  test('should render correctly when label is not a string with Children = Array', () => {
183
- const view = render(
208
+ const { asFragment } = render(
184
209
  <FormGroup fieldId="id" label={returnFunction()}>
185
210
  <input aria-label="label" />
186
211
  <input id="id" />
187
212
  <input />
188
213
  </FormGroup>
189
214
  );
190
- expect(view.container).toMatchSnapshot();
215
+ expect(asFragment()).toMatchSnapshot();
191
216
  });
192
217
  });