@patternfly/react-core 4.199.2 → 4.199.3

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 (31) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/umd/react-core.min.css +219 -219
  3. package/package.json +5 -5
  4. package/src/components/AboutModal/__tests__/AboutModal.test.tsx +41 -60
  5. package/src/components/Accordion/__tests__/Accordion.test.tsx +23 -17
  6. package/src/components/Alert/__tests__/Alert.test.tsx +195 -184
  7. package/src/components/Alert/__tests__/Generated/AlertActionCloseButton.test.tsx +19 -17
  8. package/src/components/Alert/__tests__/Generated/__snapshots__/AlertActionCloseButton.test.tsx.snap +26 -4
  9. package/src/components/Alert/__tests__/__snapshots__/Alert.test.tsx.snap +50 -700
  10. package/src/components/AlertGroup/__tests__/AlertGroup.test.tsx +68 -73
  11. package/src/components/AlertGroup/__tests__/__snapshots__/AlertGroup.test.tsx.snap +1 -893
  12. package/src/components/ApplicationLauncher/__tests__/Generated/ApplicationLauncherSeparator.test.tsx +13 -10
  13. package/src/components/ApplicationLauncher/__tests__/Generated/__snapshots__/ApplicationLauncherSeparator.test.tsx.snap +12 -1
  14. package/src/components/Button/__tests__/Button.test.tsx +116 -107
  15. package/src/components/Button/__tests__/__snapshots__/Button.test.tsx.snap +21 -21
  16. package/src/components/Card/__tests__/Card.test.tsx +119 -100
  17. package/src/components/Card/__tests__/CardBody.test.tsx +35 -28
  18. package/src/components/Card/__tests__/CardFooter.test.tsx +28 -24
  19. package/src/components/Card/__tests__/CardHeadMain.test.tsx +19 -14
  20. package/src/components/Card/__tests__/CardHeader.test.tsx +6 -22
  21. package/src/components/Card/__tests__/CardHeaderMain.test.tsx +19 -14
  22. package/src/components/Card/__tests__/CardTitle.test.tsx +25 -0
  23. package/src/components/Card/__tests__/__snapshots__/Card.test.tsx.snap +12 -28
  24. package/src/components/Card/__tests__/__snapshots__/CardBody.test.tsx.snap +2 -4
  25. package/src/components/Card/__tests__/__snapshots__/CardFooter.test.tsx.snap +1 -3
  26. package/src/components/Card/__tests__/__snapshots__/CardHeadMain.test.tsx.snap +1 -11
  27. package/src/components/Card/__tests__/__snapshots__/CardHeader.test.tsx.snap +1 -11
  28. package/src/components/Card/__tests__/__snapshots__/CardHeaderMain.test.tsx.snap +1 -11
  29. package/src/components/Card/__tests__/__snapshots__/CardTitle.test.tsx.snap +3 -0
  30. package/src/components/Checkbox/__tests__/Checkbox.test.tsx +66 -70
  31. package/src/components/Checkbox/__tests__/__snapshots__/Checkbox.test.tsx.snap +9 -204
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
- import { render } from '@testing-library/react';
3
- import { mount } from 'enzyme';
2
+
3
+ import { render, screen } from '@testing-library/react';
4
+ import '@testing-library/jest-dom';
5
+
4
6
  import { Accordion } from '../Accordion';
5
7
  import { AccordionToggle } from '../AccordionToggle';
6
8
  import { AccordionContent } from '../AccordionContent';
@@ -26,31 +28,34 @@ describe('Accordion', () => {
26
28
  });
27
29
 
28
30
  test('It should pass optional aria props', () => {
29
- const view = mount(
31
+ render(
30
32
  <Accordion asDefinitionList>
31
33
  <AccordionToggle aria-label="Toggle details for" aria-labelledby="ex-toggle2 ex-item2" id="ex-toggle2" />
32
34
  </Accordion>
33
35
  );
34
- const button = view.find('button[id="ex-toggle2"]').getElement();
35
- expect(button.props['aria-label']).toBe('Toggle details for');
36
- expect(button.props['aria-labelledby']).toBe('ex-toggle2 ex-item2');
37
- expect(button.props['aria-expanded']).toBe(false);
36
+ const button = screen.getByRole('button');
37
+
38
+ expect(button.getAttribute('aria-label')).toEqual('Toggle details for');
39
+ expect(button.getAttribute('aria-labelledby')).toEqual('ex-toggle2 ex-item2');
40
+ expect(button.getAttribute('aria-expanded')).toEqual('false');
38
41
  });
39
42
 
40
43
  test('Toggle expanded', () => {
41
- const view = mount(
44
+ render(
42
45
  <Accordion asDefinitionList>
43
46
  <AccordionToggle aria-label="Toggle details for" id="ex-toggle2" isExpanded />
44
47
  </Accordion>
45
48
  );
46
- const button = view.find('button[id="ex-toggle2"]').getElement();
47
- expect(button.props['aria-expanded']).toBe(true);
48
- expect(button.props.className).toContain('pf-m-expanded');
49
+ const button = screen.getByRole('button');
50
+
51
+ expect(button.getAttribute('aria-expanded')).toEqual('true');
52
+ expect(button.className).toContain('pf-m-expanded');
49
53
  });
50
54
 
51
- test('Custom containers', () => {
55
+ test('renders content with custom Toggle and Content containers', () => {
52
56
  const container = 'a';
53
- const view = mount(
57
+
58
+ const view = render(
54
59
  <Accordion headingLevel="h2">
55
60
  <AccordionItem>
56
61
  <AccordionToggle id="item-1" component={container}>
@@ -60,8 +65,9 @@ describe('Accordion', () => {
60
65
  </AccordionItem>
61
66
  </Accordion>
62
67
  );
63
- expect(view.find(AccordionToggle).getDOMNode().tagName).toBe(container.toLocaleUpperCase());
64
- expect(view.find(AccordionContent).getDOMNode().tagName).toBe(container.toLocaleUpperCase());
68
+
69
+ expect(screen.getByText('Item One')).toBeInTheDocument();
70
+ expect(screen.getByText('Item One Content')).toBeInTheDocument();
65
71
  });
66
72
 
67
73
  test('Accordion bordered', () => {
@@ -78,7 +84,7 @@ describe('Accordion', () => {
78
84
 
79
85
  test('Accordion display large', () => {
80
86
  const view = render(
81
- <Accordion displaySize='large'>
87
+ <Accordion displaySize="large">
82
88
  <AccordionItem>
83
89
  <AccordionToggle id="item-1">Item One</AccordionToggle>
84
90
  <AccordionContent>Item One Content</AccordionContent>
@@ -96,7 +102,7 @@ describe('Accordion', () => {
96
102
  <AccordionContent isCustomContent>
97
103
  <AccordionExpandedContentBody>Item one content body 1</AccordionExpandedContentBody>
98
104
  <AccordionExpandedContentBody>Item one Content body 2</AccordionExpandedContentBody>
99
- </AccordionContent>
105
+ </AccordionContent>
100
106
  </AccordionItem>
101
107
  </Accordion>
102
108
  );
@@ -1,197 +1,208 @@
1
1
  import * as React from 'react';
2
- import { render } from '@testing-library/react';
3
- import { mount } from 'enzyme';
2
+ import { render, screen } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
4
 
5
5
  import { Alert, AlertVariant } from '../Alert';
6
6
  import { AlertActionLink } from '../AlertActionLink';
7
7
  import { AlertActionCloseButton } from '../AlertActionCloseButton';
8
8
  import { UsersIcon } from '@patternfly/react-icons';
9
9
 
10
- test('default Alert variant is default', () => {
11
- const view = mount(<Alert title="this is a test">Alert testing</Alert>);
12
- expect(
13
- view
14
- .find('Alert')
15
- .childAt(0)
16
- .prop('className')
17
- ).toContain('pf-c-alert');
18
- });
19
-
20
- Object.values(AlertVariant).forEach(variant => {
21
- describe(`Alert - ${variant}`, () => {
22
- test('Description', () => {
23
- const view = render(
24
- <Alert variant={variant} title="">
25
- Some alert
26
- </Alert>
27
- );
28
- expect(view.container).toMatchSnapshot();
29
- });
30
-
31
- test('Title', () => {
32
- const view = render(
33
- <Alert variant={variant} title="Some title">
34
- Some alert
35
- </Alert>
36
- );
37
- expect(view.container).toMatchSnapshot();
38
- });
39
-
40
- test('Heading level', () => {
41
- const view = render(
42
- <Alert variant={variant} title="Some title" titleHeadingLevel="h1">
43
- Some alert
44
- </Alert>
45
- );
46
- expect(view.container).toMatchSnapshot();
47
- });
48
-
49
- test('Action Link', () => {
50
- const view = render(
51
- <Alert variant={variant} actionLinks={[<AlertActionLink key={'action-1'}>test</AlertActionLink>]} title="">
52
- Some alert
53
- </Alert>
54
- );
55
- expect(view.container).toMatchSnapshot();
56
- });
57
-
58
- test('Action Close Button', () => {
59
- const onClose = jest.fn();
60
- const view = mount(
61
- <Alert
62
- variant={variant}
63
- actionClose={<AlertActionCloseButton aria-label="Close" onClose={onClose} />}
64
- title={`Sample ${variant} alert`}
65
- >
66
- Some alert
67
- </Alert>
68
- );
69
- expect(view).toMatchSnapshot();
70
- view.find('button[aria-label="Close"]').simulate('click');
71
- expect(onClose).toHaveBeenCalled();
72
- });
73
-
74
- test('Action and Title', () => {
75
- const view = render(
76
- <Alert variant={variant} actionLinks={[<AlertActionLink key={'action-1'}>test</AlertActionLink>]} title="Some title">
77
- Some alert
78
- </Alert>
79
- );
80
- expect(view.container).toMatchSnapshot();
81
- });
82
-
83
- test('Custom aria label', () => {
84
- const view = render(
85
- <Alert
86
- variant={variant}
87
- aria-label={`Custom aria label for ${variant}`}
88
- actionLinks={[<AlertActionLink key={'action-1'}>test</AlertActionLink>]}
89
- title="Some title"
90
- >
91
- Some alert
92
- </Alert>
93
- );
94
- expect(view.container).toMatchSnapshot();
95
- });
96
-
97
- test('inline variation', () => {
98
- const view = render(
99
- <Alert variant={variant} isInline title="Some title">
100
- Some alert
101
- </Alert>
102
- );
103
- expect(view.container).toMatchSnapshot();
104
- });
105
-
106
- test('expandable variation', () => {
107
- const view = render(
108
- <Alert variant={variant} title="Some title" isExpandable>
109
- <p>Success alert description. This should tell the user more information about the alert.</p>
110
- </Alert>
111
- )
112
- expect(view.container).toMatchSnapshot();
113
- })
114
-
115
- test('expandable variation description hidden', () => {
116
- const wrapper = mount(
117
- <Alert variant={variant} title="Some title" isExpandable>
118
- <p>Success alert description. This should tell the user more information about the alert.</p>
119
- </Alert>
120
- )
121
- const descriptionExists = wrapper.find('.pf-c-alert__description').exists();
122
- expect(descriptionExists).toBeFalsy();
123
- })
124
-
125
- test('Toast alerts match snapsnot', () => {
126
- const view = render(
127
- <Alert isLiveRegion={true} variant={variant} aria-label={`${variant} toast alert`} title="Some title">
128
- Some toast alert
129
- </Alert>
130
- );
131
- expect(view.container).toMatchSnapshot();
132
- });
133
-
134
- test('Toast alerts contain default live region', () => {
135
- const wrapper = mount(
136
- <Alert isLiveRegion={true} variant={variant} aria-label={`${variant} toast alert`} title="Some title">
137
- Some toast alert
138
- </Alert>
139
- );
140
- const liveRegion = wrapper.find({ 'aria-live': 'polite' }).length;
141
- expect(liveRegion).toBe(1);
142
- });
143
-
144
- test('Toast alert live regions are not atomic', () => {
145
- const wrapper = mount(
146
- <Alert isLiveRegion={true} variant={variant} aria-label={`${variant} toast alert`} title="Some title">
147
- Some toast alert
148
- </Alert>
149
- );
150
- expect(wrapper.find('.pf-c-alert').prop('aria-atomic')).toBe('false');
151
- });
152
-
153
- test('Non-toast alerts can have custom live region settings', () => {
154
- const wrapper = mount(
155
- <Alert
156
- aria-live="assertive"
157
- aria-relevant="all"
158
- aria-atomic="true"
159
- variant={variant}
160
- aria-label={`${variant} toast alert`}
161
- title="Some title"
162
- >
163
- Some noisy alert
164
- </Alert>
165
- );
166
- const alert = wrapper.find(Alert);
167
-
168
- expect(alert.prop('aria-live')).toBe('assertive');
169
- expect(alert.prop('aria-relevant')).toBe('all');
170
- expect(alert.prop('aria-atomic')).toBe('true');
171
- });
10
+ describe('Alert', () => {
11
+ test('default Alert variant is default', () => {
12
+ render(<Alert title="this is a test">Alert testing</Alert>);
13
+ expect(screen.getByText('this is a test').className).toContain('pf-c-alert');
14
+ });
172
15
 
173
- test('Custom icon', () => {
174
- const view = render(
175
- <Alert
176
- customIcon={<UsersIcon />}
177
- variant={variant}
178
- aria-label={`${variant} custom icon alert`}
179
- title="custom icon alert title"
180
- >
181
- Some noisy alert
182
- </Alert>
183
- );
184
- expect(view.container).toMatchSnapshot();
16
+ Object.values(AlertVariant).forEach(variant => {
17
+ describe(`Alert - ${variant}`, () => {
18
+ test('Description', () => {
19
+ const view = render(
20
+ <Alert variant={variant} title="">
21
+ Some alert
22
+ </Alert>
23
+ );
24
+ expect(view.container).toMatchSnapshot();
25
+ });
26
+
27
+ test('Title', () => {
28
+ const view = render(
29
+ <Alert variant={variant} title="Some title">
30
+ Some alert
31
+ </Alert>
32
+ );
33
+ expect(view.container).toMatchSnapshot();
34
+ });
35
+
36
+ test('Heading level', () => {
37
+ const view = render(
38
+ <Alert variant={variant} title="Some title" titleHeadingLevel="h1">
39
+ Some alert
40
+ </Alert>
41
+ );
42
+ expect(view.container).toMatchSnapshot();
43
+ });
44
+
45
+ test('Action Link', () => {
46
+ const view = render(
47
+ <Alert variant={variant} actionLinks={[<AlertActionLink key={'action-1'}>test</AlertActionLink>]} title="">
48
+ Some alert
49
+ </Alert>
50
+ );
51
+ expect(view.container).toMatchSnapshot();
52
+ });
53
+
54
+ test('Action Close Button', () => {
55
+ const onClose = jest.fn();
56
+
57
+ render(
58
+ <Alert
59
+ variant={variant}
60
+ actionClose={<AlertActionCloseButton aria-label="Close" onClose={onClose} />}
61
+ title={`Sample ${variant} alert`}
62
+ >
63
+ Some alert
64
+ </Alert>
65
+ );
66
+
67
+ userEvent.click(screen.getByLabelText('Close'));
68
+ expect(onClose).toHaveBeenCalled();
69
+ });
70
+
71
+ test('Action and Title', () => {
72
+ const view = render(
73
+ <Alert
74
+ variant={variant}
75
+ actionLinks={[<AlertActionLink key={'action-1'}>test</AlertActionLink>]}
76
+ title="Some title"
77
+ >
78
+ Some alert
79
+ </Alert>
80
+ );
81
+ expect(view.container).toMatchSnapshot();
82
+ });
83
+
84
+ test('Custom aria label', () => {
85
+ const view = render(
86
+ <Alert
87
+ variant={variant}
88
+ aria-label={`Custom aria label for ${variant}`}
89
+ actionLinks={[<AlertActionLink key={'action-1'}>test</AlertActionLink>]}
90
+ title="Some title"
91
+ >
92
+ Some alert
93
+ </Alert>
94
+ );
95
+ expect(view.container).toMatchSnapshot();
96
+ });
97
+
98
+ test('inline variation', () => {
99
+ const view = render(
100
+ <Alert variant={variant} isInline title="Some title">
101
+ Some alert
102
+ </Alert>
103
+ );
104
+ expect(view.container).toMatchSnapshot();
105
+ });
106
+
107
+ test('expandable variation', () => {
108
+ const view = render(
109
+ <Alert variant={variant} title="Some title" isExpandable>
110
+ <p>Success alert description. This should tell the user more information about the alert.</p>
111
+ </Alert>
112
+ );
113
+ expect(view.container).toMatchSnapshot();
114
+ });
115
+
116
+ test('expandable variation description hidden', () => {
117
+ const description = 'Success alert description.';
118
+
119
+ render(
120
+ <Alert variant={variant} title="Some title" isExpandable>
121
+ <p>{description}</p>
122
+ </Alert>
123
+ );
124
+
125
+ expect(screen.queryByText(description)).toBeNull();
126
+ });
127
+
128
+ test('Toast alerts match snapsnot', () => {
129
+ const view = render(
130
+ <Alert isLiveRegion={true} variant={variant} aria-label={`${variant} toast alert`} title="Some title">
131
+ Some toast alert
132
+ </Alert>
133
+ );
134
+ expect(view.container).toMatchSnapshot();
135
+ });
136
+
137
+ test('Toast alerts contain default live region', () => {
138
+ const ariaLabel = `${variant} toast alert`;
139
+
140
+ render(
141
+ <Alert isLiveRegion={true} variant={variant} aria-label={ariaLabel} title="Some title">
142
+ Some toast alert
143
+ </Alert>
144
+ );
145
+
146
+ expect(screen.getByLabelText(ariaLabel).getAttribute('aria-live')).toEqual('polite');
147
+ });
148
+
149
+ test('Toast alert live regions are not atomic', () => {
150
+ const ariaLabel = `${variant} toast alert`;
151
+
152
+ render(
153
+ <Alert isLiveRegion={true} variant={variant} aria-label={ariaLabel} title="Some title">
154
+ Some toast alert
155
+ </Alert>
156
+ );
157
+
158
+ expect(screen.getByLabelText(ariaLabel).getAttribute('aria-atomic')).toEqual('false');
159
+ });
160
+
161
+ test('Non-toast alerts can have custom live region settings', () => {
162
+ const ariaLabel = `${variant} toast alert`;
163
+
164
+ render(
165
+ <Alert
166
+ aria-live="assertive"
167
+ aria-relevant="all"
168
+ aria-atomic="true"
169
+ variant={variant}
170
+ aria-label={ariaLabel}
171
+ title="Some title"
172
+ >
173
+ Some noisy alert
174
+ </Alert>
175
+ );
176
+ const alert = screen.getByLabelText(ariaLabel);
177
+
178
+ expect(alert.getAttribute('aria-live')).toEqual('assertive');
179
+ expect(alert.getAttribute('aria-relevant')).toEqual('all');
180
+ expect(alert.getAttribute('aria-atomic')).toEqual('true');
181
+ });
182
+
183
+ test('Custom icon', () => {
184
+ const view = render(
185
+ <Alert
186
+ customIcon={<UsersIcon />}
187
+ variant={variant}
188
+ aria-label={`${variant} custom icon alert`}
189
+ title="custom icon alert title"
190
+ >
191
+ Some noisy alert
192
+ </Alert>
193
+ );
194
+ expect(view.container).toMatchSnapshot();
195
+ });
185
196
  });
186
197
  });
187
- });
188
198
 
199
+ test('Alert truncate title', () => {
200
+ render(
201
+ <Alert truncateTitle={1} title="this is a test">
202
+ Alert testing
203
+ </Alert>
204
+ );
189
205
 
190
- test('Alert truncate title', () => {
191
- const view = mount(<Alert truncateTitle={1} title="this is a test">Alert testing</Alert>);
192
- expect(
193
- view
194
- .find('h4')
195
- .prop('className')
196
- ).toContain('pf-m-truncate');
206
+ expect(screen.getByText('this is a test').className).toContain('pf-m-truncate');
207
+ });
197
208
  });
@@ -1,20 +1,22 @@
1
- /**
2
- * This test was generated
3
- */
4
- import * as React from 'react';
5
- import { shallow } from 'enzyme';
1
+ import React from 'react';
2
+
3
+ import { render } from '@testing-library/react';
4
+
6
5
  import { AlertActionCloseButton } from '../../AlertActionCloseButton';
7
- // any missing imports can usually be resolved by adding them here
8
- import {} from '../..';
6
+ import { AlertContext } from '../../AlertContext';
9
7
 
10
- it('AlertActionCloseButton should match snapshot (auto-generated)', () => {
11
- const view = shallow(
12
- <AlertActionCloseButton
13
- className={"''"}
14
- onClose={() => undefined as any}
15
- aria-label={"''"}
16
- variantLabel={'string'}
17
- />
18
- );
19
- expect(view).toMatchSnapshot();
8
+ describe('AlertActionCloseButton', () => {
9
+ it('should match snapshot', () => {
10
+ const view = render(
11
+ <AlertContext.Provider value={{ title: 'test title', variantLabel: 'some label' }}>
12
+ <AlertActionCloseButton
13
+ className=""
14
+ onClose={() => console.log('close clicked')}
15
+ aria-label=""
16
+ variantLabel=""
17
+ />
18
+ </AlertContext.Provider>
19
+ );
20
+ expect(view.container).toMatchSnapshot();
21
+ });
20
22
  });
@@ -1,7 +1,29 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`AlertActionCloseButton should match snapshot (auto-generated) 1`] = `
4
- <ContextConsumer>
5
- <Component />
6
- </ContextConsumer>
3
+ exports[`AlertActionCloseButton should match snapshot 1`] = `
4
+ <div>
5
+ <button
6
+ aria-disabled="false"
7
+ aria-label="Close some label alert: test title"
8
+ class="pf-c-button pf-m-plain"
9
+ data-ouia-component-id="OUIA-Generated-Button-plain-1"
10
+ data-ouia-component-type="PF4/Button"
11
+ data-ouia-safe="true"
12
+ type="button"
13
+ >
14
+ <svg
15
+ aria-hidden="true"
16
+ fill="currentColor"
17
+ height="1em"
18
+ role="img"
19
+ style="vertical-align: -0.125em;"
20
+ viewBox="0 0 352 512"
21
+ width="1em"
22
+ >
23
+ <path
24
+ d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"
25
+ />
26
+ </svg>
27
+ </button>
28
+ </div>
7
29
  `;