@openedx/paragon 22.16.0 → 22.16.2

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.
@@ -1,5 +1,5 @@
1
1
  import React, { useContext } from 'react';
2
- import { render, screen } from '@testing-library/react';
2
+ import { render, screen, waitFor } from '@testing-library/react';
3
3
  import userEvent from '@testing-library/user-event';
4
4
  import * as reactTable from 'react-table';
5
5
  import { IntlProvider } from 'react-intl';
@@ -212,7 +212,6 @@ describe('<DataTable />', () => {
212
212
  pageCount: 3,
213
213
  fetchData: jest.fn(),
214
214
  };
215
-
216
215
  render(<DataTableWrapper {...propsWithSelection} />);
217
216
  const filtersButton = screen.getByRole('button', { name: 'Filters' });
218
217
 
@@ -228,6 +227,10 @@ describe('<DataTable />', () => {
228
227
  // A filtered array is returned from the backend,
229
228
  // and the element counter displays its length.
230
229
  expect(selectAllButton).toHaveTextContent('Select all 7');
230
+
231
+ await userEvent.click(selectAllButton);
232
+
233
+ expect(screen.getByText('All 7 selected')).toBeInTheDocument();
231
234
  });
232
235
 
233
236
  describe('[legacy] controlled table selections', () => {
@@ -242,7 +245,7 @@ describe('<DataTable />', () => {
242
245
 
243
246
  const contextValue = JSON.parse(contextDiv.getAttribute('data-contextvalue'));
244
247
  expect(contextValue.controlledTableSelections).toEqual([
245
- { selectedRows: [], isEntireTableSelected: false },
248
+ { selectedRows: [], isEntireTableSelected: false, isSelectAllEnabled: false },
246
249
  null,
247
250
  ]);
248
251
  });
@@ -312,5 +315,98 @@ describe('<DataTable />', () => {
312
315
  expect(mockOnSelectedRowsChange).toHaveBeenCalledTimes(1);
313
316
  expect(mockOnSelectedRowsChange).toHaveBeenCalledWith({});
314
317
  });
318
+ it('Selects all rows across all pages with ControlledSelectionStatus component', async () => {
319
+ const selectColumn = {
320
+ id: 'selection',
321
+ Header: DataTable.ControlledSelectHeader,
322
+ Cell: DataTable.ControlledSelect,
323
+ disableSortBy: true,
324
+ };
325
+ const propsWithSelection = {
326
+ ...props,
327
+ isPaginated: true,
328
+ isSelectable: true,
329
+ manualSelectColumn: selectColumn,
330
+ SelectionStatusComponent: DataTable.ControlledSelectionStatus,
331
+ initialState: {
332
+ pageIndex: 0,
333
+ pageSize: 2,
334
+ selectedRowIds: {
335
+ 1: true,
336
+ },
337
+ },
338
+ };
339
+ render(<DataTableWrapper {...propsWithSelection} />);
340
+ const selectAllButton = screen.getByTestId('test_selection_state_select_all_button');
341
+
342
+ await userEvent.click(selectAllButton);
343
+
344
+ expect(screen.getByText('All 7 selected')).toBeInTheDocument();
345
+ });
346
+
347
+ it('Select all item rows with ControlledSelectionStatus Component', async () => {
348
+ const selectColumn = {
349
+ id: 'selection',
350
+ Header: DataTable.ControlledSelectHeader,
351
+ Cell: DataTable.ControlledSelect,
352
+ disableSortBy: true,
353
+ };
354
+ const propsWithSelection = {
355
+ ...props,
356
+ isPaginated: true,
357
+ isSelectable: true,
358
+ manualSelectColumn: selectColumn,
359
+ SelectionStatusComponent: DataTable.ControlledSelectionStatus,
360
+ initialState: {
361
+ pageIndex: 0,
362
+ pageSize: 10,
363
+ },
364
+ };
365
+ render(<DataTableWrapper {...propsWithSelection} />);
366
+ const selectAllRowsButton = screen.getByTitle('Toggle All Current Page Rows Selected');
367
+
368
+ await userEvent.click(selectAllRowsButton);
369
+
370
+ expect(screen.getByText('All 7 selected')).toBeInTheDocument();
371
+ });
372
+
373
+ it('Select all item rows individually with ControlledSelectionStatus Component', async () => {
374
+ const selectColumn = {
375
+ id: 'selection',
376
+ Header: DataTable.ControlledSelectHeader,
377
+ Cell: DataTable.ControlledSelect,
378
+ disableSortBy: true,
379
+ };
380
+ const propsWithSelection = {
381
+ ...props,
382
+ isPaginated: true,
383
+ isSelectable: true,
384
+ manualSelectColumn: selectColumn,
385
+ SelectionStatusComponent: DataTable.ControlledSelectionStatus,
386
+ initialState: {
387
+ pageIndex: 0,
388
+ pageSize: 4,
389
+ },
390
+ };
391
+ render(<DataTableWrapper {...propsWithSelection} />);
392
+
393
+ const selectAllRows = () => {
394
+ const selectRowsButtons = screen.getAllByTitle('Toggle Row Selected');
395
+ selectRowsButtons.forEach(async (button) => {
396
+ await userEvent.click(button);
397
+ });
398
+ };
399
+ // Select all page 1
400
+ selectAllRows();
401
+
402
+ // Paginate to page 2
403
+ const nextPageButton2 = screen.getByLabelText('Next, Page 2');
404
+ await userEvent.click(nextPageButton2);
405
+
406
+ // Select all page 2
407
+ selectAllRows();
408
+
409
+ await waitFor(() => expect(screen.getByText('All 7 selected')).toBeInTheDocument());
410
+ });
315
411
  });
316
412
  });
@@ -265,8 +265,8 @@ $select-icon-padding: .5625rem !default;
265
265
  }
266
266
 
267
267
  .form-control:focus ~ &,
268
- // select.form-control ~ &,
269
- .form-control.has-value ~ & {
268
+ .form-control.has-value ~ &,
269
+ .form-control:is(:-webkit-autofill, :autofill) ~ & {
270
270
  .pgn__form-control-floating-label-text {
271
271
  background-color: $input-bg;
272
272
  }