@patternfly/react-core 4.236.3 → 4.236.4
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.
- package/CHANGELOG.md +8 -0
- package/dist/esm/components/AboutModal/AboutModal.js +2 -2
- package/dist/esm/components/AboutModal/AboutModal.js.map +1 -1
- package/dist/esm/components/ContextSelector/ContextSelector.js +2 -2
- package/dist/esm/components/ContextSelector/ContextSelector.js.map +1 -1
- package/dist/esm/components/ContextSelector/ContextSelectorToggle.d.ts.map +1 -1
- package/dist/esm/components/ContextSelector/ContextSelectorToggle.js +5 -7
- package/dist/esm/components/ContextSelector/ContextSelectorToggle.js.map +1 -1
- package/dist/esm/components/Dropdown/Toggle.d.ts.map +1 -1
- package/dist/esm/components/Dropdown/Toggle.js +2 -3
- package/dist/esm/components/Dropdown/Toggle.js.map +1 -1
- package/dist/esm/components/Modal/Modal.d.ts.map +1 -1
- package/dist/esm/components/Modal/Modal.js +2 -2
- package/dist/esm/components/Modal/Modal.js.map +1 -1
- package/dist/esm/components/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/esm/components/NumberInput/NumberInput.js +3 -3
- package/dist/esm/components/NumberInput/NumberInput.js.map +1 -1
- package/dist/esm/components/OptionsMenu/OptionsMenuToggleWithText.d.ts.map +1 -1
- package/dist/esm/components/OptionsMenu/OptionsMenuToggleWithText.js +2 -3
- package/dist/esm/components/OptionsMenu/OptionsMenuToggleWithText.js.map +1 -1
- package/dist/esm/components/Pagination/Navigation.js +2 -2
- package/dist/esm/components/Pagination/Navigation.js.map +1 -1
- package/dist/esm/components/SearchInput/AdvancedSearchMenu.d.ts.map +1 -1
- package/dist/esm/components/SearchInput/AdvancedSearchMenu.js +2 -3
- package/dist/esm/components/SearchInput/AdvancedSearchMenu.js.map +1 -1
- package/dist/esm/components/Tooltip/Tooltip.js +3 -3
- package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/esm/components/Wizard/Wizard.js +2 -2
- package/dist/esm/components/Wizard/Wizard.js.map +1 -1
- package/dist/js/components/AboutModal/AboutModal.js +1 -1
- package/dist/js/components/AboutModal/AboutModal.js.map +1 -1
- package/dist/js/components/ContextSelector/ContextSelector.js +1 -1
- package/dist/js/components/ContextSelector/ContextSelector.js.map +1 -1
- package/dist/js/components/ContextSelector/ContextSelectorToggle.d.ts.map +1 -1
- package/dist/js/components/ContextSelector/ContextSelectorToggle.js +4 -6
- package/dist/js/components/ContextSelector/ContextSelectorToggle.js.map +1 -1
- package/dist/js/components/Dropdown/Toggle.d.ts.map +1 -1
- package/dist/js/components/Dropdown/Toggle.js +1 -2
- package/dist/js/components/Dropdown/Toggle.js.map +1 -1
- package/dist/js/components/Modal/Modal.d.ts.map +1 -1
- package/dist/js/components/Modal/Modal.js +1 -1
- package/dist/js/components/Modal/Modal.js.map +1 -1
- package/dist/js/components/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/js/components/NumberInput/NumberInput.js +2 -2
- package/dist/js/components/NumberInput/NumberInput.js.map +1 -1
- package/dist/js/components/OptionsMenu/OptionsMenuToggleWithText.d.ts.map +1 -1
- package/dist/js/components/OptionsMenu/OptionsMenuToggleWithText.js +1 -2
- package/dist/js/components/OptionsMenu/OptionsMenuToggleWithText.js.map +1 -1
- package/dist/js/components/Pagination/Navigation.js +1 -1
- package/dist/js/components/Pagination/Navigation.js.map +1 -1
- package/dist/js/components/SearchInput/AdvancedSearchMenu.d.ts.map +1 -1
- package/dist/js/components/SearchInput/AdvancedSearchMenu.js +1 -2
- package/dist/js/components/SearchInput/AdvancedSearchMenu.js.map +1 -1
- package/dist/js/components/Tooltip/Tooltip.js +2 -2
- package/dist/js/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/js/components/Wizard/Wizard.js +1 -1
- package/dist/js/components/Wizard/Wizard.js.map +1 -1
- package/dist/umd/react-core.min.css +156 -155
- package/dist/umd/react-core.min.js +5 -5
- package/package.json +6 -6
- package/src/components/AboutModal/AboutModal.tsx +2 -2
- package/src/components/AboutModal/__tests__/AboutModal.test.tsx +5 -2
- package/src/components/Alert/__tests__/Alert.test.tsx +3 -2
- package/src/components/AlertGroup/__tests__/AlertGroup.test.tsx +6 -4
- package/src/components/Card/examples/CardLegacySelectable.tsx +1 -1
- package/src/components/Checkbox/__tests__/Checkbox.test.tsx +4 -2
- package/src/components/ChipGroup/__tests__/ChipGroup.test.tsx +4 -2
- package/src/components/ClipboardCopy/__tests__/ClipboardCopyButton.test.tsx +4 -2
- package/src/components/ClipboardCopy/__tests__/ClipboardCopyToggle.test.tsx +4 -2
- package/src/components/ContextSelector/ContextSelector.tsx +2 -2
- package/src/components/ContextSelector/ContextSelectorToggle.tsx +5 -9
- package/src/components/ContextSelector/__tests__/ContextSelector.test.tsx +4 -2
- package/src/components/ContextSelector/__tests__/ContextSelectorItem.test.tsx +3 -2
- package/src/components/ContextSelector/__tests__/ContextSelectorToggle.test.tsx +20 -10
- package/src/components/DataList/__tests__/DataList.test.tsx +3 -2
- package/src/components/DataList/__tests__/DataListCheck.test.tsx +3 -2
- package/src/components/Drawer/__tests__/Drawer.test.tsx +6 -3
- package/src/components/Dropdown/Toggle.tsx +2 -3
- package/src/components/Dropdown/__tests__/Dropdown.test.tsx +3 -2
- package/src/components/Dropdown/__tests__/DropdownToggle.test.tsx +6 -4
- package/src/components/Dropdown/__tests__/DropdownToggleAction.test.tsx +3 -2
- package/src/components/Dropdown/__tests__/DropdownToggleCheckbox.test.tsx +4 -2
- package/src/components/ExpandableSection/__tests__/ExpandableSection.test.tsx +3 -2
- package/src/components/Form/__tests__/FormGroup.test.tsx +6 -4
- package/src/components/FormSelect/__tests__/FormSelect.test.tsx +3 -3
- package/src/components/Label/__tests__/Label.test.tsx +4 -2
- package/src/components/LabelGroup/__tests__/LabelGroup.test.tsx +4 -2
- package/src/components/LoginPage/__tests__/LoginForm.test.tsx +9 -6
- package/src/components/Modal/Modal.tsx +2 -2
- package/src/components/Modal/__tests__/Modal.test.tsx +5 -2
- package/src/components/Modal/__tests__/ModalBoxCloseButton.test.tsx +3 -2
- package/src/components/Nav/__tests__/Nav.test.tsx +10 -6
- package/src/components/NumberInput/NumberInput.tsx +3 -3
- package/src/components/NumberInput/__tests__/NumberInput.test.tsx +42 -17
- package/src/components/OptionsMenu/OptionsMenuToggleWithText.tsx +2 -3
- package/src/components/Pagination/Navigation.tsx +2 -2
- package/src/components/Pagination/__tests__/Pagination.test.tsx +83 -44
- package/src/components/Radio/__tests__/Radio.test.tsx +4 -2
- package/src/components/SearchInput/AdvancedSearchMenu.tsx +2 -3
- package/src/components/SearchInput/__tests__/SearchInput.test.tsx +32 -34
- package/src/components/SearchInput/__tests__/__snapshots__/SearchInput.test.tsx.snap +4 -1
- package/src/components/Select/__tests__/Select.test.tsx +17 -9
- package/src/components/Select/__tests__/SelectToggle.test.tsx +14 -8
- package/src/components/SimpleList/__tests__/SimpleList.test.tsx +6 -4
- package/src/components/Switch/__tests__/Switch.test.tsx +4 -2
- package/src/components/Tabs/__tests__/OverflowTab.test.tsx +42 -23
- package/src/components/TextArea/__tests__/TextArea.test.tsx +4 -2
- package/src/components/TextInput/__tests__/TextInput.test.tsx +4 -2
- package/src/components/TextInputGroup/__tests__/TextInputGroupMain.test.tsx +13 -9
- package/src/components/TimePicker/__tests__/TimePicker.test.tsx +36 -26
- package/src/components/ToggleGroup/__tests__/ToggleGroup.test.tsx +4 -2
- package/src/components/Tooltip/Tooltip.tsx +3 -3
- package/src/components/Wizard/Wizard.tsx +2 -2
- package/src/components/Wizard/__tests__/Wizard.test.tsx +18 -14
- package/src/demos/PrimaryDetail.md +1 -1
- package/src/next/components/Wizard/__tests__/Wizard.test.tsx +21 -15
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { Button } from '../Button';
|
|
3
3
|
import { ActionGroup, Form, FormGroup } from '../Form';
|
|
4
4
|
import { TextInput } from '../TextInput';
|
|
5
|
-
import { GenerateId,
|
|
5
|
+
import { GenerateId, KeyTypes } from '../../helpers';
|
|
6
6
|
import { SearchAttribute } from './SearchInput';
|
|
7
7
|
import { Panel, PanelMain, PanelMainBody } from '../Panel';
|
|
8
8
|
import { css } from '@patternfly/react-styles';
|
|
@@ -107,10 +107,9 @@ export const AdvancedSearchMenu: React.FunctionComponent<AdvancedSearchMenuProps
|
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
const onEscPress = (event: KeyboardEvent) => {
|
|
110
|
-
const keyCode = event.keyCode || event.which;
|
|
111
110
|
if (
|
|
112
111
|
isSearchMenuOpen &&
|
|
113
|
-
|
|
112
|
+
event.key === KeyTypes.Escape &&
|
|
114
113
|
parentRef &&
|
|
115
114
|
parentRef.current.contains(event.target as Node)
|
|
116
115
|
) {
|
|
@@ -33,20 +33,22 @@ describe('SearchInput', () => {
|
|
|
33
33
|
expect(screen.getByTestId('test-id').querySelector('.pf-c-badge')).toBeInTheDocument();
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
test('navigable search results', () => {
|
|
36
|
+
test('navigable search results', async () => {
|
|
37
|
+
const user = userEvent.setup();
|
|
38
|
+
|
|
37
39
|
render(<SearchInput {...props} resultsCount="3 / 7" aria-label="simple text input" data-testid="test-id" />);
|
|
38
40
|
|
|
39
41
|
const input = screen.getByTestId('test-id');
|
|
40
42
|
expect(input.querySelector('.pf-c-text-input-group__group')).toBeInTheDocument();
|
|
41
43
|
expect(input.querySelector('.pf-c-badge')).toBeInTheDocument();
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
await user.click(screen.getByRole('button', { name: 'Previous' }));
|
|
44
46
|
expect(props.onPreviousClick).toHaveBeenCalled();
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
await user.click(screen.getByRole('button', { name: 'Next' }));
|
|
47
49
|
expect(props.onNextClick).toHaveBeenCalled();
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
await user.click(screen.getByRole('button', { name: 'Reset' }));
|
|
50
52
|
expect(props.onClear).toHaveBeenCalled();
|
|
51
53
|
});
|
|
52
54
|
|
|
@@ -57,7 +59,9 @@ describe('SearchInput', () => {
|
|
|
57
59
|
expect(screen.queryByRole('button', { name: 'Reset' })).not.toBeInTheDocument();
|
|
58
60
|
});
|
|
59
61
|
|
|
60
|
-
test('advanced search', () => {
|
|
62
|
+
test('advanced search', async () => {
|
|
63
|
+
const user = userEvent.setup();
|
|
64
|
+
|
|
61
65
|
const { asFragment } = render(
|
|
62
66
|
<SearchInput
|
|
63
67
|
attributes={[
|
|
@@ -72,13 +76,15 @@ describe('SearchInput', () => {
|
|
|
72
76
|
/>
|
|
73
77
|
);
|
|
74
78
|
|
|
75
|
-
|
|
79
|
+
await user.click(screen.getByRole('button', { name: 'Search' }));
|
|
76
80
|
|
|
77
81
|
expect(props.onSearch).toHaveBeenCalled();
|
|
78
82
|
expect(asFragment()).toMatchSnapshot();
|
|
79
83
|
});
|
|
80
84
|
|
|
81
|
-
test('advanced search with custom attributes', () => {
|
|
85
|
+
test('advanced search with custom attributes', async () => {
|
|
86
|
+
const user = userEvent.setup();
|
|
87
|
+
|
|
82
88
|
const { asFragment } = render(
|
|
83
89
|
<SearchInput
|
|
84
90
|
data-testid="test-id"
|
|
@@ -101,45 +107,37 @@ describe('SearchInput', () => {
|
|
|
101
107
|
/>
|
|
102
108
|
);
|
|
103
109
|
|
|
104
|
-
|
|
110
|
+
await user.click(screen.getByRole('button', { name: 'Search' }));
|
|
105
111
|
|
|
106
|
-
|
|
112
|
+
await user.click(screen.getByRole('button', { name: 'Open advanced search' }));
|
|
107
113
|
expect(screen.getByTestId('test-id')).toContainElement(screen.getByText('First name'))
|
|
108
114
|
|
|
109
115
|
expect(props.onSearch).toHaveBeenCalled();
|
|
110
116
|
expect(asFragment()).toMatchSnapshot();
|
|
111
117
|
});
|
|
112
118
|
|
|
113
|
-
test('advanced search with custom attributes and appendTo="inline', () => {
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
{ attr: 'test', display: 'test' },
|
|
119
|
-
]}
|
|
120
|
-
appendTo='inline'
|
|
121
|
-
/>
|
|
119
|
+
test('advanced search with custom attributes and appendTo="inline', async () => {
|
|
120
|
+
const user = userEvent.setup();
|
|
121
|
+
|
|
122
|
+
const { container } = render(
|
|
123
|
+
<SearchInput data-testid="test-id" attributes={[{ attr: 'test', display: 'test' }]} appendTo="inline" />
|
|
122
124
|
);
|
|
123
125
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
expect(screen.getByTestId('test-id')).toContainElement(screen.getByText('test'))
|
|
126
|
+
await user.click(screen.getByRole('button', { name: 'Open advanced search' }));
|
|
127
|
+
|
|
128
|
+
expect(screen.getByTestId('test-id')).toContainElement(screen.getByText('test'));
|
|
127
129
|
});
|
|
128
130
|
|
|
129
|
-
test('advanced search with custom attributes and appendTo external DOM element', () => {
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
{ attr: 'test', display: 'test' },
|
|
135
|
-
]}
|
|
136
|
-
appendTo={document.body}
|
|
137
|
-
/>
|
|
131
|
+
test('advanced search with custom attributes and appendTo external DOM element', async () => {
|
|
132
|
+
const user = userEvent.setup();
|
|
133
|
+
|
|
134
|
+
const { container } = render(
|
|
135
|
+
<SearchInput data-testid="test-id" attributes={[{ attr: 'test', display: 'test' }]} appendTo={document.body} />
|
|
138
136
|
);
|
|
139
137
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
expect(screen.getByTestId('test-id')).not.toContainElement(screen.getByText('test'))
|
|
143
|
-
expect(document.body).toContainElement(screen.getByText('test'))
|
|
138
|
+
await user.click(screen.getByRole('button', { name: 'Open advanced search' }));
|
|
139
|
+
|
|
140
|
+
expect(screen.getByTestId('test-id')).not.toContainElement(screen.getByText('test'));
|
|
141
|
+
expect(document.body).toContainElement(screen.getByText('test'));
|
|
144
142
|
});
|
|
145
143
|
});
|
|
@@ -243,7 +243,10 @@ exports[`SearchInput advanced search with custom attributes 1`] = `
|
|
|
243
243
|
</div>
|
|
244
244
|
<span
|
|
245
245
|
class=""
|
|
246
|
-
|
|
246
|
+
data-popper-escaped="true"
|
|
247
|
+
data-popper-placement="bottom-start"
|
|
248
|
+
data-popper-reference-hidden="true"
|
|
249
|
+
style="position: absolute; top: 0px; left: 0px; transform: translate(0px, 0px); width: 0px; z-index: 9999;"
|
|
247
250
|
>
|
|
248
251
|
<div
|
|
249
252
|
class="pf-c-panel pf-m-raised"
|
|
@@ -7,6 +7,7 @@ import { Select } from '../Select';
|
|
|
7
7
|
import { SelectOption, SelectOptionObject } from '../SelectOption';
|
|
8
8
|
import { SelectGroup } from '../SelectGroup';
|
|
9
9
|
import { SelectVariant, SelectDirection } from '../selectConstants';
|
|
10
|
+
import { KeyTypes } from '../../../helpers';
|
|
10
11
|
|
|
11
12
|
class User implements SelectOptionObject {
|
|
12
13
|
private firstName: string;
|
|
@@ -107,7 +108,7 @@ describe('Select', () => {
|
|
|
107
108
|
});
|
|
108
109
|
|
|
109
110
|
describe('custom select filter', () => {
|
|
110
|
-
test('filters properly', () => {
|
|
111
|
+
test('filters properly', async () => {
|
|
111
112
|
const customFilter = (e: React.ChangeEvent<HTMLInputElement>, value: string) => {
|
|
112
113
|
let input: RegExp;
|
|
113
114
|
try {
|
|
@@ -121,6 +122,8 @@ describe('Select', () => {
|
|
|
121
122
|
: selectOptions;
|
|
122
123
|
return typeaheadFilteredChildren;
|
|
123
124
|
};
|
|
125
|
+
const user = userEvent.setup();
|
|
126
|
+
|
|
124
127
|
render(
|
|
125
128
|
<Select
|
|
126
129
|
toggleId="custom-select-filters"
|
|
@@ -136,7 +139,7 @@ describe('Select', () => {
|
|
|
136
139
|
</Select>
|
|
137
140
|
);
|
|
138
141
|
|
|
139
|
-
|
|
142
|
+
await user.type(screen.getByTestId('test-id').querySelector('input'), 'r');
|
|
140
143
|
|
|
141
144
|
expect(screen.getByText('Mr')).toBeInTheDocument();
|
|
142
145
|
expect(screen.getByText('Mrs')).toBeInTheDocument();
|
|
@@ -333,7 +336,9 @@ describe('typeahead select', () => {
|
|
|
333
336
|
expect(asFragment()).toMatchSnapshot();
|
|
334
337
|
});
|
|
335
338
|
|
|
336
|
-
test('test select existing option on a non-creatable select', () => {
|
|
339
|
+
test('test select existing option on a non-creatable select', async () => {
|
|
340
|
+
const user = userEvent.setup();
|
|
341
|
+
|
|
337
342
|
render(
|
|
338
343
|
<Select variant={SelectVariant.typeahead} onToggle={jest.fn()} isOpen ouiaId="test-id">
|
|
339
344
|
{selectOptions}
|
|
@@ -341,8 +346,8 @@ describe('typeahead select', () => {
|
|
|
341
346
|
);
|
|
342
347
|
|
|
343
348
|
const input = screen.getByTestId('test-id').querySelector('input');
|
|
344
|
-
|
|
345
|
-
|
|
349
|
+
await user.type(input, 'Other');
|
|
350
|
+
await user.type(input, `{${KeyTypes.Enter}}`);
|
|
346
351
|
|
|
347
352
|
expect(screen.getByText('Other')).toBeVisible();
|
|
348
353
|
});
|
|
@@ -392,9 +397,10 @@ describe('typeahead multi select', () => {
|
|
|
392
397
|
});
|
|
393
398
|
|
|
394
399
|
describe('API', () => {
|
|
395
|
-
test('click on item', () => {
|
|
400
|
+
test('click on item', async () => {
|
|
396
401
|
const mockToggle = jest.fn();
|
|
397
402
|
const mockSelect = jest.fn();
|
|
403
|
+
const user = userEvent.setup();
|
|
398
404
|
|
|
399
405
|
render(
|
|
400
406
|
<Select variant="single" onToggle={mockToggle} onSelect={mockSelect} isOpen ouiaId="test-id">
|
|
@@ -402,7 +408,7 @@ describe('API', () => {
|
|
|
402
408
|
</Select>
|
|
403
409
|
);
|
|
404
410
|
|
|
405
|
-
|
|
411
|
+
await user.click(screen.getByRole('option', { name: 'Mr' }));
|
|
406
412
|
|
|
407
413
|
expect(mockToggle).not.toHaveBeenCalled();
|
|
408
414
|
expect(mockSelect).toHaveBeenCalled();
|
|
@@ -517,7 +523,9 @@ describe('select with placeholder', () => {
|
|
|
517
523
|
});
|
|
518
524
|
});
|
|
519
525
|
|
|
520
|
-
test('applies focus styling to the create option when reached via keyboard navigation', () => {
|
|
526
|
+
test('applies focus styling to the create option when reached via keyboard navigation', async () => {
|
|
527
|
+
const user = userEvent.setup();
|
|
528
|
+
|
|
521
529
|
render(
|
|
522
530
|
<Select
|
|
523
531
|
variant={SelectVariant.typeahead}
|
|
@@ -530,7 +538,7 @@ test('applies focus styling to the create option when reached via keyboard navig
|
|
|
530
538
|
);
|
|
531
539
|
|
|
532
540
|
const input = screen.getByRole('textbox');
|
|
533
|
-
|
|
541
|
+
await user.type(input, `a{${KeyTypes.ArrowDown}}`);
|
|
534
542
|
|
|
535
543
|
const createOption = screen.getByRole('option', { name: 'Create "a"' });
|
|
536
544
|
|
|
@@ -7,20 +7,24 @@ import { SelectToggle } from '../SelectToggle';
|
|
|
7
7
|
|
|
8
8
|
describe('SelectToggle', () => {
|
|
9
9
|
describe('API', () => {
|
|
10
|
-
test('click on closed', () => {
|
|
10
|
+
test('click on closed', async () => {
|
|
11
11
|
const mockToggle = jest.fn();
|
|
12
|
+
const user = userEvent.setup();
|
|
13
|
+
|
|
12
14
|
render(
|
|
13
15
|
<SelectToggle id="Select Toggle" onToggle={mockToggle} parentRef={{ current: document.createElement('div') }}>
|
|
14
16
|
Select
|
|
15
17
|
</SelectToggle>
|
|
16
18
|
);
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
await user.click(screen.getByRole('button'));
|
|
19
21
|
expect(mockToggle).toHaveBeenCalledWith(true, expect.any(Object));
|
|
20
22
|
});
|
|
21
23
|
|
|
22
|
-
test('click on opened', () => {
|
|
24
|
+
test('click on opened', async () => {
|
|
23
25
|
const mockToggle = jest.fn();
|
|
26
|
+
const user = userEvent.setup();
|
|
27
|
+
|
|
24
28
|
render(
|
|
25
29
|
<SelectToggle
|
|
26
30
|
id="Select Toggle"
|
|
@@ -32,12 +36,13 @@ describe('SelectToggle', () => {
|
|
|
32
36
|
</SelectToggle>
|
|
33
37
|
);
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
await user.click(screen.getByRole('button'));
|
|
36
40
|
expect(mockToggle).toHaveBeenCalledWith(false, expect.any(MouseEvent));
|
|
37
41
|
});
|
|
38
42
|
|
|
39
|
-
test('click on document', () => {
|
|
43
|
+
test('click on document', async () => {
|
|
40
44
|
const mockToggle = jest.fn();
|
|
45
|
+
const user = userEvent.setup();
|
|
41
46
|
|
|
42
47
|
render(
|
|
43
48
|
<SelectToggle
|
|
@@ -50,12 +55,13 @@ describe('SelectToggle', () => {
|
|
|
50
55
|
</SelectToggle>
|
|
51
56
|
);
|
|
52
57
|
|
|
53
|
-
|
|
58
|
+
await user.click(screen.getByText('Select').parentElement);
|
|
54
59
|
expect(mockToggle).toHaveBeenCalledWith(false, expect.any(MouseEvent));
|
|
55
60
|
});
|
|
56
61
|
|
|
57
|
-
test('on click outside has been removed', () => {
|
|
62
|
+
test('on click outside has been removed', async () => {
|
|
58
63
|
const mockToggle = jest.fn();
|
|
64
|
+
const user = userEvent.setup();
|
|
59
65
|
|
|
60
66
|
render(
|
|
61
67
|
<SelectToggle
|
|
@@ -68,7 +74,7 @@ describe('SelectToggle', () => {
|
|
|
68
74
|
</SelectToggle>
|
|
69
75
|
);
|
|
70
76
|
|
|
71
|
-
|
|
77
|
+
await user.click(screen.getByText('Select').parentElement);
|
|
72
78
|
expect(mockToggle).not.toHaveBeenCalled();
|
|
73
79
|
});
|
|
74
80
|
});
|
|
@@ -40,12 +40,13 @@ describe('SimpleList', () => {
|
|
|
40
40
|
expect(asFragment()).toMatchSnapshot();
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
test('onSelect is called when item is selected', () => {
|
|
43
|
+
test('onSelect is called when item is selected', async () => {
|
|
44
44
|
const onSelect = jest.fn();
|
|
45
|
+
const user = userEvent.setup();
|
|
45
46
|
|
|
46
47
|
render(<SimpleList onSelect={onSelect}>{items}</SimpleList>);
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
await user.click(screen.getByText('Item 1'));
|
|
49
50
|
expect(onSelect).toHaveBeenCalled();
|
|
50
51
|
});
|
|
51
52
|
|
|
@@ -54,12 +55,13 @@ describe('SimpleList', () => {
|
|
|
54
55
|
expect(screen.getAllByRole('link').length).toEqual(3);
|
|
55
56
|
});
|
|
56
57
|
|
|
57
|
-
test('onSelect is called when anchor item is selected', () => {
|
|
58
|
+
test('onSelect is called when anchor item is selected', async () => {
|
|
58
59
|
const onSelect = jest.fn();
|
|
60
|
+
const user = userEvent.setup();
|
|
59
61
|
|
|
60
62
|
render(<SimpleList onSelect={onSelect}>{anchors}</SimpleList>);
|
|
61
63
|
|
|
62
|
-
|
|
64
|
+
await user.click(screen.getByText('Item 1'));
|
|
63
65
|
expect(onSelect).toHaveBeenCalled();
|
|
64
66
|
});
|
|
65
67
|
});
|
|
@@ -75,10 +75,12 @@ describe('Switch', () => {
|
|
|
75
75
|
expect(asFragment()).toMatchSnapshot();
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
test('switch passes value and event to onChange handler', () => {
|
|
78
|
+
test('switch passes value and event to onChange handler', async () => {
|
|
79
|
+
const user = userEvent.setup();
|
|
80
|
+
|
|
79
81
|
render(<Switch id="onChange-switch" {...props} aria-label="Switch label" />);
|
|
80
82
|
|
|
81
|
-
|
|
83
|
+
await user.click(screen.getByLabelText('Switch label'));
|
|
82
84
|
expect(props.onChange).toHaveBeenCalledWith(true, expect.any(Object));
|
|
83
85
|
});
|
|
84
86
|
|
|
@@ -106,12 +106,14 @@ test('Renders without pf-m-expanded on the tab element by default', () => {
|
|
|
106
106
|
expect(screen.getByRole('tab')).not.toHaveClass('pf-m-expanded');
|
|
107
107
|
});
|
|
108
108
|
|
|
109
|
-
test('Renders with pf-m-expanded on the tab element once clicked', () => {
|
|
109
|
+
test('Renders with pf-m-expanded on the tab element once clicked', async () => {
|
|
110
|
+
const user = userEvent.setup();
|
|
111
|
+
|
|
110
112
|
render(<OverflowTab />);
|
|
111
113
|
|
|
112
114
|
const overflowTab = screen.getByRole('tab');
|
|
113
115
|
|
|
114
|
-
|
|
116
|
+
await user.click(overflowTab);
|
|
115
117
|
|
|
116
118
|
expect(overflowTab).toHaveClass('pf-m-expanded');
|
|
117
119
|
});
|
|
@@ -156,7 +158,9 @@ test('Does not render tabs passed via overflowingTabs when not expanded', () =>
|
|
|
156
158
|
expect(screen.queryByText('Tab two')).not.toBeInTheDocument();
|
|
157
159
|
});
|
|
158
160
|
|
|
159
|
-
test('Renders tabs passed via overflowingTabs when expanded', () => {
|
|
161
|
+
test('Renders tabs passed via overflowingTabs when expanded', async () => {
|
|
162
|
+
const user = userEvent.setup();
|
|
163
|
+
|
|
160
164
|
render(
|
|
161
165
|
<OverflowTab
|
|
162
166
|
overflowingTabs={[
|
|
@@ -166,13 +170,15 @@ test('Renders tabs passed via overflowingTabs when expanded', () => {
|
|
|
166
170
|
/>
|
|
167
171
|
);
|
|
168
172
|
|
|
169
|
-
|
|
173
|
+
await user.click(screen.getByRole('tab', { name: 'More' }));
|
|
170
174
|
|
|
171
175
|
expect(screen.getByText('Tab one')).toBeVisible();
|
|
172
176
|
expect(screen.getByText('Tab two')).toBeVisible();
|
|
173
177
|
});
|
|
174
178
|
|
|
175
|
-
test('Closes the overflowing tabs menu when a tab is selected', () => {
|
|
179
|
+
test('Closes the overflowing tabs menu when a tab is selected', async () => {
|
|
180
|
+
const user = userEvent.setup();
|
|
181
|
+
|
|
176
182
|
render(
|
|
177
183
|
<TabsContext.Provider value={{ ...tabsContextDefaultProps, localActiveKey: 0 }}>
|
|
178
184
|
<OverflowTab
|
|
@@ -184,15 +190,17 @@ test('Closes the overflowing tabs menu when a tab is selected', () => {
|
|
|
184
190
|
</TabsContext.Provider>
|
|
185
191
|
);
|
|
186
192
|
|
|
187
|
-
|
|
193
|
+
await user.click(screen.getByRole('tab', { name: 'More' }));
|
|
188
194
|
|
|
189
195
|
// rather than actually clicking a menu item here we click the Select button provided via our Menu mock to keep the mocks simpler
|
|
190
|
-
|
|
196
|
+
await user.click(screen.getByRole('button', { name: 'Select' }));
|
|
191
197
|
|
|
192
198
|
expect(screen.queryByText('Tab two')).not.toBeInTheDocument();
|
|
193
199
|
});
|
|
194
200
|
|
|
195
|
-
test('Closes the overflowing tabs menu when the user clicks outside of the menu', () => {
|
|
201
|
+
test('Closes the overflowing tabs menu when the user clicks outside of the menu', async () => {
|
|
202
|
+
const user = userEvent.setup();
|
|
203
|
+
|
|
196
204
|
render(
|
|
197
205
|
<TabsContext.Provider value={{ ...tabsContextDefaultProps, localActiveKey: 0 }}>
|
|
198
206
|
<OverflowTab
|
|
@@ -204,14 +212,15 @@ test('Closes the overflowing tabs menu when the user clicks outside of the menu'
|
|
|
204
212
|
</TabsContext.Provider>
|
|
205
213
|
);
|
|
206
214
|
|
|
207
|
-
|
|
215
|
+
await user.click(screen.getByRole('tab', { name: 'More' }));
|
|
208
216
|
|
|
209
|
-
|
|
217
|
+
await user.click(document.body);
|
|
210
218
|
|
|
211
219
|
expect(screen.queryByText('Tab two')).not.toBeInTheDocument();
|
|
212
220
|
});
|
|
213
221
|
|
|
214
|
-
test('Calls the onTabClick callback provided via context when a tab is clicked', () => {
|
|
222
|
+
test('Calls the onTabClick callback provided via context when a tab is clicked', async () => {
|
|
223
|
+
const user = userEvent.setup();
|
|
215
224
|
const mockHandleTabClick = jest.fn();
|
|
216
225
|
|
|
217
226
|
render(
|
|
@@ -224,10 +233,10 @@ test('Calls the onTabClick callback provided via context when a tab is clicked',
|
|
|
224
233
|
</TabsContext.Provider>
|
|
225
234
|
);
|
|
226
235
|
|
|
227
|
-
|
|
236
|
+
await user.click(screen.getByRole('tab', { name: 'More' }));
|
|
228
237
|
|
|
229
238
|
// rather than actually clicking a menu item here we click the Select button provided via our Menu mock to keep the mocks simpler
|
|
230
|
-
|
|
239
|
+
await user.click(screen.getByRole('button', { name: 'Select' }));
|
|
231
240
|
|
|
232
241
|
expect(mockHandleTabClick).toHaveBeenCalledTimes(1);
|
|
233
242
|
expect(mockHandleTabClick).toHaveBeenCalledWith('mouseEvent', 1, 'fakeRef');
|
|
@@ -325,12 +334,14 @@ test('Renders the tab with aria-expanded set to false by default', () => {
|
|
|
325
334
|
expect(screen.getByRole('tab')).toHaveAttribute('aria-expanded', 'false');
|
|
326
335
|
});
|
|
327
336
|
|
|
328
|
-
test('Renders the tab with aria-expanded set to true when the menu is opened', () => {
|
|
337
|
+
test('Renders the tab with aria-expanded set to true when the menu is opened', async () => {
|
|
338
|
+
const user = userEvent.setup();
|
|
339
|
+
|
|
329
340
|
render(<OverflowTab />);
|
|
330
341
|
|
|
331
342
|
const overflowTab = screen.getByRole('tab');
|
|
332
343
|
|
|
333
|
-
|
|
344
|
+
await user.click(overflowTab);
|
|
334
345
|
|
|
335
346
|
expect(overflowTab).toHaveAttribute('aria-expanded', 'true');
|
|
336
347
|
});
|
|
@@ -342,16 +353,20 @@ test('Passes Popper popperMatchesTriggerWidth set to false', () => {
|
|
|
342
353
|
expect(screen.getByText('Popper matches trigger width: false')).toBeVisible();
|
|
343
354
|
});
|
|
344
355
|
|
|
345
|
-
test('Passes Popper an appendTo value of the presentation element', () => {
|
|
356
|
+
test('Passes Popper an appendTo value of the presentation element', async () => {
|
|
357
|
+
const user = userEvent.setup();
|
|
358
|
+
|
|
346
359
|
render(<OverflowTab />);
|
|
347
360
|
|
|
348
|
-
|
|
361
|
+
await user.click(screen.getByRole('tab'));
|
|
349
362
|
|
|
350
363
|
// This assertion relies on the structure of the Popper mock to verify the correct props are being sent to Popper
|
|
351
364
|
expect(screen.getByText('Append to class name: pf-c-tabs__item pf-m-overflow')).toBeVisible();
|
|
352
365
|
});
|
|
353
366
|
|
|
354
|
-
test('Does not render an overflowing tab as a selected menu item by default', () => {
|
|
367
|
+
test('Does not render an overflowing tab as a selected menu item by default', async () => {
|
|
368
|
+
const user = userEvent.setup();
|
|
369
|
+
|
|
355
370
|
render(
|
|
356
371
|
<TabsContext.Provider value={{ ...tabsContextDefaultProps, localActiveKey: 0 }}>
|
|
357
372
|
<OverflowTab
|
|
@@ -362,13 +377,15 @@ test('Does not render an overflowing tab as a selected menu item by default', ()
|
|
|
362
377
|
</TabsContext.Provider>
|
|
363
378
|
);
|
|
364
379
|
|
|
365
|
-
|
|
380
|
+
await user.click(screen.getByRole('tab'));
|
|
366
381
|
|
|
367
382
|
// This assertion relies on the structure of the Popper mock to verify the correct props are being sent to Popper
|
|
368
383
|
expect(screen.queryByText('Selected: true')).not.toBeInTheDocument();
|
|
369
384
|
});
|
|
370
385
|
|
|
371
|
-
test('Renders an overflowing tab as a selected menu item when its key matches the localActiveKey provided via context', () => {
|
|
386
|
+
test('Renders an overflowing tab as a selected menu item when its key matches the localActiveKey provided via context', async () => {
|
|
387
|
+
const user = userEvent.setup();
|
|
388
|
+
|
|
372
389
|
render(
|
|
373
390
|
<TabsContext.Provider value={{ ...tabsContextDefaultProps, localActiveKey: 1 }}>
|
|
374
391
|
<OverflowTab
|
|
@@ -379,13 +396,15 @@ test('Renders an overflowing tab as a selected menu item when its key matches th
|
|
|
379
396
|
</TabsContext.Provider>
|
|
380
397
|
);
|
|
381
398
|
|
|
382
|
-
|
|
399
|
+
await user.click(screen.getByRole('tab'));
|
|
383
400
|
|
|
384
401
|
// This assertion relies on the structure of the Popper mock to verify the correct props are being sent to Popper
|
|
385
402
|
expect(screen.getByText('Selected: true')).toBeVisible();
|
|
386
403
|
});
|
|
387
404
|
|
|
388
|
-
test('Matches snapshot when expanded', () => {
|
|
405
|
+
test('Matches snapshot when expanded', async () => {
|
|
406
|
+
const user = userEvent.setup();
|
|
407
|
+
|
|
389
408
|
const { asFragment } = render(
|
|
390
409
|
<TabsContext.Provider value={{ ...tabsContextDefaultProps, localActiveKey: 1 }}>
|
|
391
410
|
<OverflowTab
|
|
@@ -397,7 +416,7 @@ test('Matches snapshot when expanded', () => {
|
|
|
397
416
|
</TabsContext.Provider>
|
|
398
417
|
);
|
|
399
418
|
|
|
400
|
-
|
|
419
|
+
await user.click(screen.getByRole('tab'));
|
|
401
420
|
|
|
402
421
|
expect(asFragment()).toMatchSnapshot();
|
|
403
422
|
});
|
|
@@ -12,10 +12,12 @@ const props = {
|
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
describe('TextArea', () => {
|
|
15
|
-
test('textarea input passes value and event to onChange handler', () => {
|
|
15
|
+
test('textarea input passes value and event to onChange handler', async () => {
|
|
16
|
+
const user = userEvent.setup();
|
|
17
|
+
|
|
16
18
|
render(<TextAreaBase {...props} value="" aria-label="test textarea" />);
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
await user.type(screen.getByLabelText('test textarea'), 'a');
|
|
19
21
|
expect(props.onChange).toHaveBeenCalledWith('a', expect.any(Object));
|
|
20
22
|
});
|
|
21
23
|
|
|
@@ -12,10 +12,12 @@ const props = {
|
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
describe('TextInput', () => {
|
|
15
|
-
test('input passes value and event to onChange handler', () => {
|
|
15
|
+
test('input passes value and event to onChange handler', async () => {
|
|
16
|
+
const user = userEvent.setup();
|
|
17
|
+
|
|
16
18
|
render(<TextInputBase {...props} value="" aria-label="test input" />);
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
await user.type(screen.getByLabelText('test input'), 'a');
|
|
19
21
|
expect(props.onChange).toHaveBeenCalledWith('a', expect.any(Object));
|
|
20
22
|
});
|
|
21
23
|
|
|
@@ -241,13 +241,14 @@ describe('TextInputGroupMain', () => {
|
|
|
241
241
|
expect(onChangeMock).not.toHaveBeenCalled();
|
|
242
242
|
});
|
|
243
243
|
|
|
244
|
-
it('calls the onChange callback when the input changes', () => {
|
|
244
|
+
it('calls the onChange callback when the input changes', async () => {
|
|
245
245
|
const onChangeMock = jest.fn();
|
|
246
|
+
const user = userEvent.setup();
|
|
246
247
|
|
|
247
248
|
render(<TextInputGroupMain onChange={onChangeMock}>Test</TextInputGroupMain>);
|
|
248
249
|
|
|
249
250
|
const input = screen.getByRole('textbox');
|
|
250
|
-
|
|
251
|
+
await user.type(input, 'Test');
|
|
251
252
|
|
|
252
253
|
expect(onChangeMock).toHaveBeenCalledTimes(4);
|
|
253
254
|
});
|
|
@@ -260,36 +261,39 @@ describe('TextInputGroupMain', () => {
|
|
|
260
261
|
expect(onFocusMock).not.toHaveBeenCalled();
|
|
261
262
|
});
|
|
262
263
|
|
|
263
|
-
it('calls the onFocus callback when the input is focused', () => {
|
|
264
|
+
it('calls the onFocus callback when the input is focused', async () => {
|
|
264
265
|
const onFocusMock = jest.fn();
|
|
266
|
+
const user = userEvent.setup();
|
|
265
267
|
|
|
266
268
|
render(<TextInputGroupMain onFocus={onFocusMock}>Test</TextInputGroupMain>);
|
|
267
269
|
|
|
268
270
|
const input = screen.getByRole('textbox');
|
|
269
|
-
|
|
271
|
+
await user.click(input);
|
|
270
272
|
|
|
271
273
|
expect(onFocusMock).toHaveBeenCalledTimes(1);
|
|
272
274
|
});
|
|
273
275
|
|
|
274
|
-
it('does not call onBlur callback when the input does not lose focus', () => {
|
|
276
|
+
it('does not call onBlur callback when the input does not lose focus', async () => {
|
|
275
277
|
const onBlurMock = jest.fn();
|
|
278
|
+
const user = userEvent.setup();
|
|
276
279
|
|
|
277
280
|
render(<TextInputGroupMain onBlur={onBlurMock}>Test</TextInputGroupMain>);
|
|
278
281
|
|
|
279
282
|
const input = screen.getByRole('textbox');
|
|
280
|
-
|
|
283
|
+
await user.click(input);
|
|
281
284
|
|
|
282
285
|
expect(onBlurMock).not.toHaveBeenCalled();
|
|
283
286
|
});
|
|
284
287
|
|
|
285
|
-
it('calls the onBlur callback when the input loses focus', () => {
|
|
288
|
+
it('calls the onBlur callback when the input loses focus', async() => {
|
|
286
289
|
const onBlurMock = jest.fn();
|
|
290
|
+
const user = userEvent.setup();
|
|
287
291
|
|
|
288
292
|
render(<TextInputGroupMain onBlur={onBlurMock}>Test</TextInputGroupMain>);
|
|
289
293
|
|
|
290
294
|
const input = screen.getByRole('textbox');
|
|
291
|
-
|
|
292
|
-
|
|
295
|
+
await user.click(input);
|
|
296
|
+
await user.click(document.body);
|
|
293
297
|
|
|
294
298
|
expect(onBlurMock).toHaveBeenCalledTimes(1);
|
|
295
299
|
});
|