@patternfly/react-core 4.236.2 → 4.236.5
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 +27 -0
- package/dist/esm/components/AboutModal/AboutModal.js +2 -2
- package/dist/esm/components/AboutModal/AboutModal.js.map +1 -1
- package/dist/esm/components/Alert/Alert.d.ts +2 -0
- package/dist/esm/components/Alert/Alert.d.ts.map +1 -1
- package/dist/esm/components/Alert/Alert.js +2 -2
- package/dist/esm/components/Alert/Alert.js.map +1 -1
- package/dist/esm/components/AlertGroup/AlertGroupInline.d.ts.map +1 -1
- package/dist/esm/components/AlertGroup/AlertGroupInline.js +4 -1
- package/dist/esm/components/AlertGroup/AlertGroupInline.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/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/Tabs/OverflowTab.d.ts.map +1 -1
- package/dist/esm/components/Tabs/OverflowTab.js +1 -1
- package/dist/esm/components/Tabs/OverflowTab.js.map +1 -1
- package/dist/esm/components/Tabs/TabButton.d.ts.map +1 -1
- package/dist/esm/components/Tabs/TabButton.js +1 -1
- package/dist/esm/components/Tabs/TabButton.js.map +1 -1
- package/dist/esm/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/esm/components/Tabs/Tabs.js +2 -2
- package/dist/esm/components/Tabs/Tabs.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/Alert/Alert.d.ts +2 -0
- package/dist/js/components/Alert/Alert.d.ts.map +1 -1
- package/dist/js/components/Alert/Alert.js +2 -2
- package/dist/js/components/Alert/Alert.js.map +1 -1
- package/dist/js/components/AlertGroup/AlertGroupInline.d.ts.map +1 -1
- package/dist/js/components/AlertGroup/AlertGroupInline.js +4 -1
- package/dist/js/components/AlertGroup/AlertGroupInline.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/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/Tabs/OverflowTab.d.ts.map +1 -1
- package/dist/js/components/Tabs/OverflowTab.js +1 -1
- package/dist/js/components/Tabs/OverflowTab.js.map +1 -1
- package/dist/js/components/Tabs/TabButton.d.ts.map +1 -1
- package/dist/js/components/Tabs/TabButton.js +1 -1
- package/dist/js/components/Tabs/TabButton.js.map +1 -1
- package/dist/js/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/js/components/Tabs/Tabs.js +2 -2
- package/dist/js/components/Tabs/Tabs.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 +40 -39
- 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/Alert.tsx +4 -0
- package/src/components/Alert/__tests__/Alert.test.tsx +3 -2
- package/src/components/AlertGroup/AlertGroupInline.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/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/OverflowTab.tsx +1 -0
- package/src/components/Tabs/TabButton.tsx +6 -1
- package/src/components/Tabs/Tabs.tsx +2 -0
- package/src/components/Tabs/__tests__/OverflowTab.test.tsx +42 -23
- package/src/components/Tabs/__tests__/__snapshots__/OverflowTab.test.tsx.snap +1 -0
- package/src/components/Tabs/__tests__/__snapshots__/Tab.test.tsx.snap +1 -0
- package/src/components/Tabs/__tests__/__snapshots__/TabButton.test.tsx.snap +1 -0
- package/src/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap +67 -0
- 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
|
@@ -4,6 +4,7 @@ import { render, screen } from '@testing-library/react';
|
|
|
4
4
|
import userEvent from '@testing-library/user-event';
|
|
5
5
|
|
|
6
6
|
import { Pagination, PaginationVariant } from '../index';
|
|
7
|
+
import { KeyTypes } from '../../../helpers';
|
|
7
8
|
|
|
8
9
|
describe('Pagination', () => {
|
|
9
10
|
describe('component render', () => {
|
|
@@ -117,166 +118,204 @@ describe('Pagination', () => {
|
|
|
117
118
|
describe('onSetPage', () => {
|
|
118
119
|
const onSetPage = jest.fn();
|
|
119
120
|
|
|
120
|
-
test('should call first', () => {
|
|
121
|
+
test('should call first', async () => {
|
|
122
|
+
const user = userEvent.setup();
|
|
123
|
+
|
|
121
124
|
render(<Pagination onSetPage={onSetPage} itemCount={40} page={2} />);
|
|
122
125
|
|
|
123
|
-
|
|
126
|
+
await user.click(screen.getByRole('button', { name: 'Go to first page' }));
|
|
124
127
|
expect(onSetPage).toHaveBeenCalled();
|
|
125
128
|
});
|
|
126
129
|
|
|
127
|
-
test('should call previous', () => {
|
|
130
|
+
test('should call previous', async () => {
|
|
131
|
+
const user = userEvent.setup();
|
|
132
|
+
|
|
128
133
|
render(<Pagination onSetPage={onSetPage} itemCount={40} page={3} />);
|
|
129
134
|
|
|
130
|
-
|
|
135
|
+
await user.click(screen.getByRole('button', { name: 'Go to previous page' }));
|
|
131
136
|
expect(onSetPage).toHaveBeenCalled();
|
|
132
137
|
});
|
|
133
138
|
|
|
134
|
-
test('should call next', () => {
|
|
139
|
+
test('should call next', async () => {
|
|
140
|
+
const user = userEvent.setup();
|
|
141
|
+
|
|
135
142
|
render(<Pagination onSetPage={onSetPage} itemCount={40} />);
|
|
136
143
|
|
|
137
|
-
|
|
144
|
+
await user.click(screen.getByRole('button', { name: 'Go to next page' }));
|
|
138
145
|
expect(onSetPage).toHaveBeenCalled();
|
|
139
146
|
});
|
|
140
147
|
|
|
141
|
-
test('should call last', () => {
|
|
148
|
+
test('should call last', async () => {
|
|
149
|
+
const user = userEvent.setup();
|
|
150
|
+
|
|
142
151
|
render(<Pagination onSetPage={onSetPage} itemCount={40} />);
|
|
143
152
|
|
|
144
|
-
|
|
153
|
+
await user.click(screen.getByRole('button', { name: 'Go to last page' }));
|
|
145
154
|
expect(onSetPage).toHaveBeenCalled();
|
|
146
155
|
});
|
|
147
156
|
|
|
148
|
-
test('should call input', () => {
|
|
157
|
+
test('should call input', async () => {
|
|
158
|
+
const user = userEvent.setup();
|
|
159
|
+
|
|
149
160
|
render(<Pagination onSetPage={onSetPage} itemCount={40} />);
|
|
150
161
|
|
|
151
162
|
const input = screen.getByLabelText('Current page');
|
|
152
|
-
|
|
153
|
-
|
|
163
|
+
await user.type(input, '1');
|
|
164
|
+
await user.type(input, `{${KeyTypes.Enter}}`);
|
|
154
165
|
|
|
155
166
|
expect(onSetPage).toHaveBeenCalled();
|
|
156
167
|
});
|
|
157
168
|
|
|
158
|
-
test('should call input wrong value', () => {
|
|
169
|
+
test('should call input wrong value', async () => {
|
|
170
|
+
const user = userEvent.setup();
|
|
171
|
+
|
|
159
172
|
render(<Pagination onSetPage={onSetPage} itemCount={40} />);
|
|
160
173
|
|
|
161
174
|
const input = screen.getByLabelText('Current page');
|
|
162
|
-
|
|
163
|
-
|
|
175
|
+
await user.type(input, 'a');
|
|
176
|
+
await user.type(input, `{${KeyTypes.Enter}}`);
|
|
164
177
|
|
|
165
178
|
expect(onSetPage).toHaveBeenCalled();
|
|
166
179
|
});
|
|
167
180
|
|
|
168
|
-
test('should call input huge page number', () => {
|
|
181
|
+
test('should call input huge page number', async () => {
|
|
182
|
+
const user = userEvent.setup();
|
|
183
|
+
|
|
169
184
|
render(<Pagination onSetPage={onSetPage} itemCount={40} />);
|
|
170
185
|
|
|
171
186
|
const input = screen.getByLabelText('Current page');
|
|
172
|
-
|
|
173
|
-
|
|
187
|
+
await user.type(input, '10');
|
|
188
|
+
await user.type(input, `{${KeyTypes.Enter}}`);
|
|
174
189
|
|
|
175
190
|
expect(onSetPage).toHaveBeenCalled();
|
|
176
191
|
});
|
|
177
192
|
|
|
178
|
-
test('should call input small page number', () => {
|
|
193
|
+
test('should call input small page number', async () => {
|
|
194
|
+
const user = userEvent.setup();
|
|
195
|
+
|
|
179
196
|
render(<Pagination onSetPage={onSetPage} itemCount={40} />);
|
|
180
197
|
|
|
181
198
|
const input = screen.getByLabelText('Current page');
|
|
182
|
-
|
|
183
|
-
|
|
199
|
+
await user.type(input, '-10');
|
|
200
|
+
await user.type(input, `{${KeyTypes.Enter}}`);
|
|
184
201
|
|
|
185
202
|
expect(onSetPage).toHaveBeenCalled();
|
|
186
203
|
});
|
|
187
204
|
|
|
188
|
-
test('should NOT call', () => {
|
|
205
|
+
test('should NOT call', async () => {
|
|
206
|
+
const user = userEvent.setup();
|
|
207
|
+
|
|
189
208
|
render(<Pagination itemCount={40} />);
|
|
190
209
|
|
|
191
|
-
|
|
210
|
+
await user.click(screen.getByRole('button', { name: 'Go to last page' }));
|
|
192
211
|
expect(onSetPage).not.toHaveBeenCalled();
|
|
193
212
|
});
|
|
194
213
|
});
|
|
195
214
|
|
|
196
215
|
describe('onFirst', () => {
|
|
197
216
|
const onFirst = jest.fn();
|
|
198
|
-
test('should call', () => {
|
|
217
|
+
test('should call', async () => {
|
|
218
|
+
const user = userEvent.setup();
|
|
219
|
+
|
|
199
220
|
render(<Pagination onFirstClick={onFirst} itemCount={40} page={2} />);
|
|
200
221
|
|
|
201
|
-
|
|
222
|
+
await user.click(screen.getByRole('button', { name: 'Go to first page' }));
|
|
202
223
|
expect(onFirst).toHaveBeenCalled();
|
|
203
224
|
});
|
|
204
225
|
|
|
205
|
-
test('should NOT call', () => {
|
|
226
|
+
test('should NOT call', async () => {
|
|
227
|
+
const user = userEvent.setup();
|
|
228
|
+
|
|
206
229
|
render(<Pagination itemCount={40} page={2} />);
|
|
207
230
|
|
|
208
|
-
|
|
231
|
+
await user.click(screen.getByRole('button', { name: 'Go to first page' }));
|
|
209
232
|
expect(onFirst).not.toHaveBeenCalled();
|
|
210
233
|
});
|
|
211
234
|
});
|
|
212
235
|
|
|
213
236
|
describe('onLast', () => {
|
|
214
237
|
const onLast = jest.fn();
|
|
215
|
-
test('should call', () => {
|
|
238
|
+
test('should call', async () => {
|
|
239
|
+
const user = userEvent.setup();
|
|
240
|
+
|
|
216
241
|
render(<Pagination onLastClick={onLast} itemCount={40} />);
|
|
217
242
|
|
|
218
|
-
|
|
243
|
+
await user.click(screen.getByRole('button', { name: 'Go to last page' }));
|
|
219
244
|
expect(onLast).toHaveBeenCalled();
|
|
220
245
|
});
|
|
221
246
|
|
|
222
|
-
test('should NOT call', () => {
|
|
247
|
+
test('should NOT call', async () => {
|
|
248
|
+
const user = userEvent.setup();
|
|
249
|
+
|
|
223
250
|
render(<Pagination itemCount={40} />);
|
|
224
251
|
|
|
225
|
-
|
|
252
|
+
await user.click(screen.getByRole('button', { name: 'Go to last page' }));
|
|
226
253
|
expect(onLast).not.toHaveBeenCalled();
|
|
227
254
|
});
|
|
228
255
|
});
|
|
229
256
|
|
|
230
257
|
describe('onPrevious', () => {
|
|
231
258
|
const onPrevious = jest.fn();
|
|
232
|
-
test('should call', () => {
|
|
259
|
+
test('should call', async () => {
|
|
260
|
+
const user = userEvent.setup();
|
|
261
|
+
|
|
233
262
|
render(<Pagination onPreviousClick={onPrevious} itemCount={40} page={3} />);
|
|
234
263
|
|
|
235
|
-
|
|
264
|
+
await user.click(screen.getByRole('button', { name: 'Go to previous page' }));
|
|
236
265
|
expect(onPrevious).toHaveBeenCalled();
|
|
237
266
|
});
|
|
238
267
|
|
|
239
|
-
test('should NOT call', () => {
|
|
268
|
+
test('should NOT call', async () => {
|
|
269
|
+
const user = userEvent.setup();
|
|
270
|
+
|
|
240
271
|
render(<Pagination itemCount={40} />);
|
|
241
272
|
|
|
242
|
-
|
|
273
|
+
await user.click(screen.getByRole('button', { name: 'Go to previous page' }));
|
|
243
274
|
expect(onPrevious).not.toHaveBeenCalled();
|
|
244
275
|
});
|
|
245
276
|
});
|
|
246
277
|
|
|
247
278
|
describe('onNext', () => {
|
|
248
279
|
const onNext = jest.fn();
|
|
249
|
-
test('should call', () => {
|
|
280
|
+
test('should call', async () => {
|
|
281
|
+
const user = userEvent.setup();
|
|
282
|
+
|
|
250
283
|
render(<Pagination onNextClick={onNext} itemCount={40} />);
|
|
251
284
|
|
|
252
|
-
|
|
285
|
+
await user.click(screen.getByRole('button', { name: 'Go to next page' }));
|
|
253
286
|
expect(onNext).toHaveBeenCalled();
|
|
254
287
|
});
|
|
255
288
|
|
|
256
|
-
test('should NOT call', () => {
|
|
289
|
+
test('should NOT call', async () => {
|
|
290
|
+
const user = userEvent.setup();
|
|
291
|
+
|
|
257
292
|
render(<Pagination itemCount={40} />);
|
|
258
293
|
|
|
259
|
-
|
|
294
|
+
await user.click(screen.getByRole('button', { name: 'Go to previous page' }));
|
|
260
295
|
expect(onNext).not.toHaveBeenCalled();
|
|
261
296
|
});
|
|
262
297
|
});
|
|
263
298
|
|
|
264
299
|
describe('onPerPage', () => {
|
|
265
300
|
const onPerPage = jest.fn();
|
|
266
|
-
test('should call', () => {
|
|
301
|
+
test('should call', async () => {
|
|
302
|
+
const user = userEvent.setup();
|
|
303
|
+
|
|
267
304
|
render(<Pagination onPerPageSelect={onPerPage} itemCount={40} />);
|
|
268
305
|
|
|
269
|
-
|
|
270
|
-
|
|
306
|
+
await user.click(screen.getByRole('button', { name: 'Items per page' }));
|
|
307
|
+
await user.click(screen.getByText('20 per page'));
|
|
271
308
|
|
|
272
309
|
expect(onPerPage).toHaveBeenCalled();
|
|
273
310
|
});
|
|
274
311
|
|
|
275
|
-
test('should NOT call', () => {
|
|
312
|
+
test('should NOT call', async () => {
|
|
313
|
+
const user = userEvent.setup();
|
|
314
|
+
|
|
276
315
|
render(<Pagination itemCount={40} />);
|
|
277
316
|
|
|
278
|
-
|
|
279
|
-
|
|
317
|
+
await user.click(screen.getByRole('button', { name: 'Items per page' }));
|
|
318
|
+
await user.click(screen.getByText('20 per page'));
|
|
280
319
|
|
|
281
320
|
expect(onPerPage).not.toHaveBeenCalled();
|
|
282
321
|
});
|
|
@@ -73,10 +73,12 @@ describe('Radio', () => {
|
|
|
73
73
|
expect(asFragment()).toMatchSnapshot();
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
test('Radio passes value and event to onChange handler', () => {
|
|
76
|
+
test('Radio passes value and event to onChange handler', async () => {
|
|
77
|
+
const user = userEvent.setup();
|
|
78
|
+
|
|
77
79
|
render(<Radio id="check" {...props} aria-label="check" name="check" />);
|
|
78
80
|
|
|
79
|
-
|
|
81
|
+
await user.click(screen.getByRole('radio'));
|
|
80
82
|
expect(props.onChange).toHaveBeenCalledWith(true, expect.any(Object));
|
|
81
83
|
});
|
|
82
84
|
|
|
@@ -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
|
|
|
@@ -26,7 +26,12 @@ export const TabButton: React.FunctionComponent<TabButtonProps> = ({
|
|
|
26
26
|
const Component = (props.href ? 'a' : 'button') as any;
|
|
27
27
|
|
|
28
28
|
return (
|
|
29
|
-
<Component
|
|
29
|
+
<Component
|
|
30
|
+
{...(!props.href && { type: 'button' })}
|
|
31
|
+
ref={parentInnerRef}
|
|
32
|
+
{...getOUIAProps(TabButton.displayName, ouiaId, ouiaSafe)}
|
|
33
|
+
{...props}
|
|
34
|
+
>
|
|
30
35
|
{children}
|
|
31
36
|
</Component>
|
|
32
37
|
);
|