@centreon/ui 24.7.1 → 24.7.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.
Files changed (29) hide show
  1. package/package.json +66 -85
  2. package/public/mockServiceWorker.js +1 -1
  3. package/src/Graph/BarChart/BarChart.cypress.spec.tsx +85 -2
  4. package/src/Graph/BarChart/BarStack.tsx +8 -6
  5. package/src/Graph/BarChart/SingleBar.tsx +2 -2
  6. package/src/Graph/LineChart/Icons/Downtime.tsx +1 -1
  7. package/src/Graph/LineChart/helpers/index.ts +3 -0
  8. package/src/Graph/PieChart/PieChart.cypress.spec.tsx +0 -4
  9. package/src/{Home.stories.mdx → Home.mdx} +41 -39
  10. package/src/Image/index.stories.tsx +101 -101
  11. package/src/RichTextEditor/index.stories.tsx +102 -102
  12. package/src/ThemeProvider/index.tsx +5 -4
  13. package/src/TimePeriods/DateTimePickerInput.tsx +1 -1
  14. package/src/Typography/FluidTypography/index.stories.tsx +63 -63
  15. package/src/components/Form/AccessRights/AccessRights.stories.tsx +5 -5
  16. package/test/setupTests.js +1 -0
  17. package/src/Listing/index.test.tsx +0 -234
  18. /package/{public → src}/fonts/roboto-bold-webfont.ttf +0 -0
  19. /package/{public → src}/fonts/roboto-bold-webfont.woff +0 -0
  20. /package/{public → src}/fonts/roboto-bold-webfont.woff2 +0 -0
  21. /package/{public → src}/fonts/roboto-light-webfont.ttf +0 -0
  22. /package/{public → src}/fonts/roboto-light-webfont.woff +0 -0
  23. /package/{public → src}/fonts/roboto-light-webfont.woff2 +0 -0
  24. /package/{public → src}/fonts/roboto-medium-webfont.ttf +0 -0
  25. /package/{public → src}/fonts/roboto-medium-webfont.woff +0 -0
  26. /package/{public → src}/fonts/roboto-medium-webfont.woff2 +0 -0
  27. /package/{public → src}/fonts/roboto-regular-webfont.ttf +0 -0
  28. /package/{public → src}/fonts/roboto-regular-webfont.woff +0 -0
  29. /package/{public → src}/fonts/roboto-regular-webfont.woff2 +0 -0
@@ -1,234 +0,0 @@
1
- import { useState } from 'react';
2
-
3
- import { prop } from 'ramda';
4
-
5
- import { render, fireEvent, within } from '../../test/testRenderer';
6
-
7
- import { ColumnType } from './models';
8
- import { labelAddColumns } from './translatedLabels';
9
-
10
- import Listing from '.';
11
-
12
- describe('Listing', () => {
13
- const getAllCheckboxes = (container): Array<HTMLElement> => {
14
- return container.querySelectorAll('[type = "checkbox"]');
15
- };
16
-
17
- const columns = [
18
- {
19
- getFormattedString: ({ name }): string => name,
20
- id: 'name',
21
- label: 'name',
22
- sortable: true,
23
- type: ColumnType.string
24
- },
25
- {
26
- getFormattedString: ({ description }): string => description,
27
- id: 'description',
28
- label: 'description',
29
- sortField: 'descriptionField',
30
- sortable: true,
31
- type: ColumnType.string
32
- }
33
- ];
34
-
35
- const rows = [
36
- { description: 'first row description', id: 0, name: 'My First Row' },
37
- { description: 'second row description', id: 1, name: 'My Second Row' },
38
- { description: 'third row description', id: 2, name: 'My Third Row' },
39
- { description: 'fourth row description', id: 3, name: 'My Fourth Row' }
40
- ];
41
-
42
- const onSelectRows = jest.fn();
43
- const onSort = jest.fn();
44
-
45
- const oneHundredElements = new Array(100).fill(0);
46
-
47
- const oneHundredTableData = [...oneHundredElements].map((_, index) => ({
48
- active: index % 2 === 0,
49
- description: `Entity ${index}`,
50
- disableCheckbox: index % 4 === 0,
51
- id: index,
52
- name: `E${index}`,
53
- selected: index % 3 === 0
54
- }));
55
-
56
- const PaginationTable = (): JSX.Element => {
57
- const [limit, setLimit] = useState(10);
58
- const [page, setPage] = useState(4);
59
-
60
- return (
61
- <Listing
62
- columns={columns}
63
- currentPage={page}
64
- limit={limit}
65
- rows={oneHundredTableData}
66
- totalRows={oneHundredTableData.length}
67
- onLimitChange={setLimit}
68
- onPaginate={setPage}
69
- onSort={onSort}
70
- />
71
- );
72
- };
73
-
74
- it('selects a row when the corresponding checkbox is clicked', () => {
75
- const { container } = render(
76
- <Listing
77
- checkable
78
- columns={columns}
79
- rows={rows}
80
- onSelectRows={onSelectRows}
81
- />
82
- );
83
-
84
- // The first visible checkbox is the 'select all' one
85
- const firstRowCheckbox = getAllCheckboxes(container)[1];
86
-
87
- fireEvent.click(firstRowCheckbox);
88
-
89
- const firstRow = rows[0];
90
- expect(onSelectRows).toHaveBeenCalledWith([firstRow]);
91
- });
92
-
93
- it('unselects a row when it is currently selected and the corresponding checkbox is clicked', () => {
94
- const firstRow = rows[0];
95
- const selectedRows = [firstRow];
96
-
97
- const { container } = render(
98
- <Listing
99
- checkable
100
- columns={columns}
101
- rows={rows}
102
- selectedRows={selectedRows}
103
- onSelectRows={onSelectRows}
104
- />
105
- );
106
- const firstRowCheckbox = getAllCheckboxes(container)[1];
107
-
108
- fireEvent.click(firstRowCheckbox);
109
-
110
- expect(onSelectRows).toHaveBeenCalledWith([]);
111
- });
112
-
113
- it('selects all rows when the "select all" checkbox is clicked', () => {
114
- const { container } = render(
115
- <Listing
116
- checkable
117
- columns={columns}
118
- rows={rows}
119
- totalRows={4}
120
- onSelectRows={onSelectRows}
121
- />
122
- );
123
-
124
- const selectAllCheckbox = getAllCheckboxes(container)[0];
125
-
126
- fireEvent.click(selectAllCheckbox);
127
-
128
- expect(onSelectRows).toHaveBeenLastCalledWith(rows);
129
- });
130
-
131
- it('unselects all rows when all rows are selected and the "select all" checkbox is clicked', () => {
132
- const { container } = render(
133
- <Listing
134
- checkable
135
- columns={columns}
136
- rows={rows}
137
- selectedRows={rows}
138
- onSelectRows={onSelectRows}
139
- />
140
- );
141
-
142
- const selectAllCheckbox = getAllCheckboxes(container)[0];
143
-
144
- fireEvent.click(selectAllCheckbox);
145
-
146
- expect(onSelectRows).toHaveBeenCalledWith([]);
147
- });
148
-
149
- it('unselects selected rows when some rows are selected and the "select all" checkbox is clicked', () => {
150
- const selectedRows = rows.filter(({ id }) => id % 2 === 0);
151
- const { container } = render(
152
- <Listing
153
- checkable
154
- columns={columns}
155
- rows={rows}
156
- selectedRows={selectedRows}
157
- onSelectRows={onSelectRows}
158
- />
159
- );
160
-
161
- const selectAllCheckbox = getAllCheckboxes(container)[0];
162
-
163
- fireEvent.click(selectAllCheckbox);
164
-
165
- expect(onSelectRows).toHaveBeenCalledWith([]);
166
- });
167
-
168
- it('sorts on on column id when the column header is clicked and sortField is not defined', () => {
169
- const columnWithoutSortField = columns[0];
170
-
171
- const { getByLabelText } = render(
172
- <Listing columns={columns} rows={rows} onSort={onSort} />
173
- );
174
-
175
- fireEvent.click(getByLabelText(`Column ${columnWithoutSortField.label}`));
176
-
177
- expect(onSort).toHaveBeenCalledWith({
178
- sortField: columnWithoutSortField.id,
179
- sortOrder: 'desc'
180
- });
181
- });
182
-
183
- it('sorts on on column sortField when the column header is clicked and sortField is defined', () => {
184
- const columnWithSortField = columns[1];
185
-
186
- const { getByLabelText } = render(
187
- <Listing columns={columns} rows={rows} onSort={onSort} />
188
- );
189
-
190
- fireEvent.click(getByLabelText(`Column ${columnWithSortField.label}`));
191
-
192
- expect(onSort).toHaveBeenCalledWith({
193
- sortField: columnWithSortField.sortField,
194
- sortOrder: 'desc'
195
- });
196
- });
197
-
198
- it('resets the page number to 0 when changing the limit and the current page is different than 0', () => {
199
- const { getByRole, getByText } = render(<PaginationTable />);
200
-
201
- expect(getByText('41-50 of 100'));
202
-
203
- fireEvent.mouseDown(getByText('10'));
204
-
205
- const listbox = within(getByRole('listbox'));
206
-
207
- fireEvent.click(listbox.getByText('90'));
208
-
209
- expect(getByText('1-90 of 100'));
210
- });
211
-
212
- it(`unselects a column when the "selectable" parameter is set and a column is unselected from the corresponding menu`, () => {
213
- const onSelectColumns = jest.fn();
214
-
215
- const { getAllByText, getByLabelText } = render(
216
- <Listing
217
- columnConfiguration={{
218
- selectedColumnIds: columns.map(prop('id')),
219
- sortable: true
220
- }}
221
- columns={columns}
222
- rows={rows}
223
- onSelectColumns={onSelectColumns}
224
- onSort={onSort}
225
- />
226
- );
227
-
228
- fireEvent.click(getByLabelText(labelAddColumns).firstChild as HTMLElement);
229
-
230
- fireEvent.click(getAllByText('description')[1]);
231
-
232
- expect(onSelectColumns).toHaveBeenCalledWith(['name']);
233
- });
234
- });
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes