@patternfly/react-core 4.236.3 → 4.236.6
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 +30 -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/MenuToggle/MenuToggle.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/Page/Page.d.ts.map +1 -1
- package/dist/esm/components/Page/Page.js +11 -2
- package/dist/esm/components/Page/Page.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/MenuToggle/MenuToggle.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/Page/Page.d.ts.map +1 -1
- package/dist/js/components/Page/Page.js +11 -2
- package/dist/js/components/Page/Page.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 +508 -507
- 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/MenuToggle/MenuToggle.tsx +1 -1
- 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/Page/Page.tsx +11 -2
- 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
|
@@ -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
|
});
|
|
@@ -7,7 +7,7 @@ import { TimePicker, TimePickerProps } from '../TimePicker';
|
|
|
7
7
|
|
|
8
8
|
describe('TimePicker', () => {
|
|
9
9
|
describe('test timepicker onChange method with valid values', () => {
|
|
10
|
-
const testOnChange = ({
|
|
10
|
+
const testOnChange = async ({
|
|
11
11
|
inputProps,
|
|
12
12
|
expects
|
|
13
13
|
}: {
|
|
@@ -15,49 +15,51 @@ describe('TimePicker', () => {
|
|
|
15
15
|
expects: { hour: number; minutes: number; seconds: number };
|
|
16
16
|
}) => {
|
|
17
17
|
const onChange = jest.fn();
|
|
18
|
+
const user = userEvent.setup();
|
|
19
|
+
|
|
18
20
|
render(<TimePicker onChange={onChange} {...inputProps} aria-label="time picker" />);
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
expect(onChange).toHaveBeenCalledWith(inputProps.value, expects.hour, expects.minutes, expects.seconds, true)
|
|
22
|
+
await user.type(screen.getByLabelText('time picker'), String(inputProps.value));
|
|
23
|
+
expect(onChange).toHaveBeenCalledWith(inputProps.value, expects.hour, expects.minutes, expects.seconds, true)
|
|
22
24
|
};
|
|
23
25
|
|
|
24
|
-
test('should return the correct value using the AM/PM pattern - midnight', () => {
|
|
25
|
-
testOnChange({
|
|
26
|
+
test('should return the correct value using the AM/PM pattern - midnight', async () => {
|
|
27
|
+
await testOnChange({
|
|
26
28
|
inputProps: { value: '12:00 AM', is24Hour: false },
|
|
27
29
|
expects: { hour: 0, minutes: 0, seconds: null }
|
|
28
30
|
});
|
|
29
31
|
});
|
|
30
32
|
|
|
31
|
-
test('should return the correct value using the AM/PM pattern - midday', () => {
|
|
32
|
-
testOnChange({
|
|
33
|
+
test('should return the correct value using the AM/PM pattern - midday', async () => {
|
|
34
|
+
await testOnChange({
|
|
33
35
|
inputProps: { value: '12:35 PM', is24Hour: false },
|
|
34
36
|
expects: { hour: 12, minutes: 35, seconds: null }
|
|
35
37
|
});
|
|
36
38
|
});
|
|
37
39
|
|
|
38
|
-
test('should return the correct value using the AM/PM pattern - last minute of the day', () => {
|
|
39
|
-
testOnChange({
|
|
40
|
+
test('should return the correct value using the AM/PM pattern - last minute of the day', async () => {
|
|
41
|
+
await testOnChange({
|
|
40
42
|
inputProps: { value: '11:59 PM', is24Hour: false },
|
|
41
43
|
expects: { hour: 23, minutes: 59, seconds: null }
|
|
42
44
|
});
|
|
43
45
|
});
|
|
44
46
|
|
|
45
|
-
test('should return the correct value using the 24h pattern - midnight', () => {
|
|
46
|
-
testOnChange({
|
|
47
|
+
test('should return the correct value using the 24h pattern - midnight', async () => {
|
|
48
|
+
await testOnChange({
|
|
47
49
|
inputProps: { value: '00:00:00', is24Hour: true, includeSeconds: true },
|
|
48
50
|
expects: { hour: 0, minutes: 0, seconds: 0 }
|
|
49
51
|
});
|
|
50
52
|
});
|
|
51
53
|
|
|
52
|
-
test('should return the correct value using the 24h pattern - midday', () => {
|
|
53
|
-
testOnChange({
|
|
54
|
+
test('should return the correct value using the 24h pattern - midday', async () => {
|
|
55
|
+
await testOnChange({
|
|
54
56
|
inputProps: { value: '12:35', is24Hour: false },
|
|
55
57
|
expects: { hour: 12, minutes: 35, seconds: null }
|
|
56
58
|
});
|
|
57
59
|
});
|
|
58
60
|
|
|
59
|
-
test('should return the correct value using the 24h pattern - last minute of the day', () => {
|
|
60
|
-
testOnChange({
|
|
61
|
+
test('should return the correct value using the 24h pattern - last minute of the day', async () => {
|
|
62
|
+
await testOnChange({
|
|
61
63
|
inputProps: { value: '23:59', is24Hour: true },
|
|
62
64
|
expects: { hour: 23, minutes: 59, seconds: null }
|
|
63
65
|
});
|
|
@@ -75,16 +77,17 @@ describe('TimePicker', () => {
|
|
|
75
77
|
expect(screen.getByLabelText('time picker')).not.toHaveClass('pf-m-error');
|
|
76
78
|
});
|
|
77
79
|
|
|
78
|
-
test('should stay valid after onChange', () => {
|
|
80
|
+
test('should stay valid after onChange', async () => {
|
|
79
81
|
const validateTime = (_time: string) => {
|
|
80
82
|
return true;
|
|
81
83
|
};
|
|
84
|
+
const user = userEvent.setup();
|
|
82
85
|
|
|
83
86
|
render(<TimePicker value="00:00" validateTime={validateTime} aria-label="time picker" />);
|
|
84
87
|
|
|
85
88
|
const input = screen.getByLabelText('time picker');
|
|
86
89
|
|
|
87
|
-
|
|
90
|
+
await user.type(input, '01:00');
|
|
88
91
|
expect(input).not.toHaveClass('pf-m-error');
|
|
89
92
|
});
|
|
90
93
|
|
|
@@ -92,6 +95,7 @@ describe('TimePicker', () => {
|
|
|
92
95
|
const validateTime = (_time: string) => {
|
|
93
96
|
return false;
|
|
94
97
|
};
|
|
98
|
+
const user = userEvent.setup();
|
|
95
99
|
|
|
96
100
|
render(
|
|
97
101
|
<>
|
|
@@ -100,10 +104,10 @@ describe('TimePicker', () => {
|
|
|
100
104
|
</>
|
|
101
105
|
);
|
|
102
106
|
|
|
103
|
-
|
|
107
|
+
await user.type(screen.getByLabelText('time picker'), '01:00');
|
|
104
108
|
expect(screen.queryByText('Invalid time format')).toBeNull();
|
|
105
109
|
|
|
106
|
-
|
|
110
|
+
await user.click(screen.getByText('Other element'));
|
|
107
111
|
expect(screen.getByText('Invalid time format')).toBeInTheDocument();
|
|
108
112
|
});
|
|
109
113
|
});
|
|
@@ -115,21 +119,27 @@ describe('TimePicker', () => {
|
|
|
115
119
|
includeSeconds: true
|
|
116
120
|
};
|
|
117
121
|
|
|
118
|
-
it('should be valid still with a max value of "11:59:59 PM" by default', () => {
|
|
122
|
+
it('should be valid still with a max value of "11:59:59 PM" by default', async () => {
|
|
123
|
+
const user = userEvent.setup();
|
|
124
|
+
|
|
119
125
|
render(<TimePicker {...baseProps} />);
|
|
120
126
|
|
|
121
|
-
|
|
127
|
+
await user.type(screen.getByLabelText(baseProps['aria-label']), '11:59:59 PM');
|
|
122
128
|
expect(screen.queryByText('Invalid time format')).toBeNull();
|
|
123
129
|
});
|
|
124
130
|
|
|
125
|
-
it('should be valid still with a max value of "23:59:59" by default when using 24 hour time', () => {
|
|
131
|
+
it('should be valid still with a max value of "23:59:59" by default when using 24 hour time', async () => {
|
|
132
|
+
const user = userEvent.setup();
|
|
133
|
+
|
|
126
134
|
render(<TimePicker {...baseProps} value="20:00" is24Hour />);
|
|
127
135
|
|
|
128
|
-
|
|
136
|
+
await user.type(screen.getByLabelText(baseProps['aria-label']), '23:59:59');
|
|
129
137
|
expect(screen.queryByText('Invalid time format')).toBeNull();
|
|
130
138
|
});
|
|
131
139
|
|
|
132
|
-
it('should be invalid with a max value of "24:00:00" by default', () => {
|
|
140
|
+
it('should be invalid with a max value of "24:00:00" by default', async () => {
|
|
141
|
+
const user = userEvent.setup();
|
|
142
|
+
|
|
133
143
|
render(
|
|
134
144
|
<>
|
|
135
145
|
<div>Other element</div>
|
|
@@ -137,10 +147,10 @@ describe('TimePicker', () => {
|
|
|
137
147
|
</>
|
|
138
148
|
);
|
|
139
149
|
|
|
140
|
-
|
|
150
|
+
await user.type(screen.getByLabelText(baseProps['aria-label']), '24:00:00');
|
|
141
151
|
expect(screen.queryByText('Invalid time format')).toBeNull();
|
|
142
152
|
|
|
143
|
-
|
|
153
|
+
await user.click(screen.getByText('Other element'));
|
|
144
154
|
expect(screen.getByText('Invalid time format')).toBeInTheDocument();
|
|
145
155
|
});
|
|
146
156
|
});
|
|
@@ -40,12 +40,14 @@ describe('ToggleGroup', () => {
|
|
|
40
40
|
expect(asFragment()).toMatchSnapshot();
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
test('item passes selection and event to onChange handler', () => {
|
|
43
|
+
test('item passes selection and event to onChange handler', async () => {
|
|
44
|
+
const user = userEvent.setup();
|
|
45
|
+
|
|
44
46
|
render(
|
|
45
47
|
<ToggleGroupItem text="test" buttonId="toggleGroupItem" onChange={props.onChange} aria-label="onChange handler" />
|
|
46
48
|
);
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
await user.click(screen.getByRole('button'));
|
|
49
51
|
expect(props.onChange).toHaveBeenCalledWith(true, expect.any(Object));
|
|
50
52
|
});
|
|
51
53
|
|
|
@@ -4,7 +4,7 @@ import styles from '@patternfly/react-styles/css/components/Tooltip/tooltip';
|
|
|
4
4
|
import { css } from '@patternfly/react-styles';
|
|
5
5
|
import { TooltipContent } from './TooltipContent';
|
|
6
6
|
import { TooltipArrow } from './TooltipArrow';
|
|
7
|
-
import {
|
|
7
|
+
import { KeyTypes } from '../../helpers/constants';
|
|
8
8
|
import tooltipMaxWidth from '@patternfly/react-tokens/dist/esm/c_tooltip_MaxWidth';
|
|
9
9
|
import { ReactElement } from 'react';
|
|
10
10
|
import { Popper, getOpacityTransition } from '../../helpers/Popper/Popper';
|
|
@@ -209,13 +209,13 @@ export const Tooltip: React.FunctionComponent<TooltipProps> = ({
|
|
|
209
209
|
|
|
210
210
|
const onDocumentKeyDown = (event: KeyboardEvent) => {
|
|
211
211
|
if (!triggerManually) {
|
|
212
|
-
if (event.
|
|
212
|
+
if (event.key === KeyTypes.Escape && visible) {
|
|
213
213
|
hide();
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
};
|
|
217
217
|
const onTriggerEnter = (event: KeyboardEvent) => {
|
|
218
|
-
if (event.
|
|
218
|
+
if (event.key === KeyTypes.Enter) {
|
|
219
219
|
if (!visible) {
|
|
220
220
|
show();
|
|
221
221
|
} else {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { KeyTypes } from '../../helpers/constants';
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
import styles from '@patternfly/react-styles/css/components/Wizard/wizard';
|
|
5
5
|
import { Modal, ModalVariant } from '../Modal';
|
|
@@ -178,7 +178,7 @@ export class Wizard extends React.Component<WizardProps, WizardState> {
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
private handleKeyClicks = (event: KeyboardEvent): void => {
|
|
181
|
-
if (event.
|
|
181
|
+
if (event.key === KeyTypes.Escape) {
|
|
182
182
|
if (this.state.isNavOpen) {
|
|
183
183
|
this.setState({ isNavOpen: !this.state.isNavOpen });
|
|
184
184
|
} else if (this.props.isOpen) {
|
|
@@ -223,13 +223,14 @@ describe('Wizard', () => {
|
|
|
223
223
|
expect(main).toHaveAttribute('aria-labelledby', 'main-aria-labelledby');
|
|
224
224
|
});
|
|
225
225
|
|
|
226
|
-
test('wiz with onCurrentStepChanged setter', () => {
|
|
226
|
+
test('wiz with onCurrentStepChanged setter', async () => {
|
|
227
227
|
const stepA = { name: 'A', component: <p>Step 1</p> };
|
|
228
228
|
const stepB = { name: 'B', component: <p>Step 2</p> };
|
|
229
229
|
const stepC = { name: 'C', component: <p>Step 3</p> };
|
|
230
230
|
|
|
231
231
|
const steps: WizardStep[] = [ stepA, stepB, stepC ];
|
|
232
232
|
const setter = jest.fn();
|
|
233
|
+
const user = userEvent.setup();
|
|
233
234
|
|
|
234
235
|
render(
|
|
235
236
|
<Wizard
|
|
@@ -239,15 +240,15 @@ describe('Wizard', () => {
|
|
|
239
240
|
/>
|
|
240
241
|
);
|
|
241
242
|
expect(setter).toHaveBeenLastCalledWith(expect.objectContaining(stepA));
|
|
242
|
-
|
|
243
|
+
await user.click(screen.getByText(/next/i));
|
|
243
244
|
expect(setter).toHaveBeenLastCalledWith(expect.objectContaining(stepB));
|
|
244
|
-
|
|
245
|
+
await user.click(screen.getByText(/next/i));
|
|
245
246
|
expect(setter).toHaveBeenLastCalledWith(expect.objectContaining(stepC));
|
|
246
|
-
|
|
247
|
+
await user.click(screen.getByText('A'));
|
|
247
248
|
expect(setter).toHaveBeenLastCalledWith(expect.objectContaining(stepA));
|
|
248
|
-
|
|
249
|
+
await user.click(screen.getByText(/next/i));
|
|
249
250
|
expect(setter).toHaveBeenLastCalledWith(expect.objectContaining(stepB));
|
|
250
|
-
|
|
251
|
+
await user.click(screen.getByText(/back/i));
|
|
251
252
|
expect(setter).toHaveBeenLastCalledWith(expect.objectContaining(stepA));
|
|
252
253
|
});
|
|
253
254
|
});
|
|
@@ -274,14 +275,15 @@ describe('Wizard', () => {
|
|
|
274
275
|
expect(screen.getByRole('button',{ name: "E" })).toBeDisabled();
|
|
275
276
|
});
|
|
276
277
|
|
|
277
|
-
test('wiz skip the step disabled when press the next/back button', () => {
|
|
278
|
+
test('wiz skip the step disabled when press the next/back button', async () => {
|
|
278
279
|
const steps: WizardStep[] = [
|
|
279
280
|
{ name: 'A', component: <p>Step 1</p>},
|
|
280
281
|
{ name: 'B', component: <p>Step 2</p>, isDisabled: true },
|
|
281
282
|
{ name: 'C', component: <p>Step 3</p>},
|
|
282
283
|
|
|
283
284
|
];
|
|
284
|
-
|
|
285
|
+
const user = userEvent.setup();
|
|
286
|
+
|
|
285
287
|
render(
|
|
286
288
|
<Wizard
|
|
287
289
|
navAriaLabel="nav aria-label"
|
|
@@ -290,19 +292,20 @@ describe('Wizard', () => {
|
|
|
290
292
|
/>
|
|
291
293
|
);
|
|
292
294
|
|
|
293
|
-
|
|
295
|
+
await user.click(screen.getByRole('button', { name: 'Next' }));
|
|
294
296
|
expect(screen.getByRole('button',{ name: "C" })).toHaveClass('pf-m-current')
|
|
295
297
|
|
|
296
|
-
|
|
298
|
+
await user.click(screen.getByRole('button', { name: 'Back' }));
|
|
297
299
|
expect(screen.getByRole('button',{ name: "A" })).toHaveClass('pf-m-current')
|
|
298
300
|
});
|
|
299
301
|
|
|
300
|
-
test('wiz skip the step when click on the nav item disabled', () => {
|
|
302
|
+
test('wiz skip the step when click on the nav item disabled', async () => {
|
|
301
303
|
const steps: WizardStep[] = [
|
|
302
304
|
{ name: 'A', component: <p>Step 1</p>},
|
|
303
305
|
{ name: 'B', component: <p>Step 2</p>, isDisabled: true },
|
|
304
306
|
{ name: 'C', component: <p>Step 3</p>}
|
|
305
307
|
];
|
|
308
|
+
const user = userEvent.setup();
|
|
306
309
|
|
|
307
310
|
render(
|
|
308
311
|
<Wizard
|
|
@@ -315,7 +318,7 @@ describe('Wizard', () => {
|
|
|
315
318
|
const navItemButton = screen.getByRole('button',{ name: "B" })
|
|
316
319
|
const navItemButtonSelected = screen.getByRole('button',{ name: "A" })
|
|
317
320
|
|
|
318
|
-
|
|
321
|
+
await user.click(navItemButton);
|
|
319
322
|
|
|
320
323
|
expect(navItemButton).not.toHaveClass('pf-m-current')
|
|
321
324
|
expect(navItemButtonSelected).toHaveClass('pf-m-current')
|
|
@@ -343,7 +346,7 @@ describe('Wizard', () => {
|
|
|
343
346
|
expect(screen.getByRole('button',{ name: "A-2" })).toBeDisabled();
|
|
344
347
|
});
|
|
345
348
|
|
|
346
|
-
test('startAtStep can be used to externally control the current step of the wizard', () => {
|
|
349
|
+
test('startAtStep can be used to externally control the current step of the wizard', async () => {
|
|
347
350
|
const WizardTest = () => {
|
|
348
351
|
const [step, setStep] = React.useState(1);
|
|
349
352
|
|
|
@@ -364,12 +367,13 @@ test('startAtStep can be used to externally control the current step of the wiza
|
|
|
364
367
|
</>
|
|
365
368
|
);
|
|
366
369
|
};
|
|
370
|
+
const user = userEvent.setup();
|
|
367
371
|
|
|
368
372
|
render(<WizardTest />);
|
|
369
373
|
|
|
370
374
|
expect(screen.queryByText('Step 2')).not.toBeInTheDocument();
|
|
371
375
|
|
|
372
|
-
|
|
376
|
+
await user.click(screen.getByRole('button', { name: 'Increment step'}))
|
|
373
377
|
|
|
374
378
|
expect(screen.getByText('Step 2')).toBeVisible();
|
|
375
379
|
});
|
|
@@ -1264,7 +1264,7 @@ class PrimaryDetailCardView extends React.Component {
|
|
|
1264
1264
|
return;
|
|
1265
1265
|
}
|
|
1266
1266
|
|
|
1267
|
-
if ([
|
|
1267
|
+
if (['Enter', ' '].includes(event.key)) {
|
|
1268
1268
|
if (event.currentTarget.id === this.state.activeCard) {
|
|
1269
1269
|
this.setState({
|
|
1270
1270
|
isDrawerExpanded: !this.state.isDrawerExpanded,
|