@centreon/ui 26.10.8 → 26.10.10

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 (77) hide show
  1. package/package.json +6 -3
  2. package/public/mockServiceWorker.js +31 -8
  3. package/src/Dashboard/Dashboard.browser.test.tsx +107 -0
  4. package/src/Form/CollapsibleGroup.tsx +6 -33
  5. package/src/Form/Form.browser.test.tsx +553 -0
  6. package/src/Form/Form.stories.tsx +102 -1
  7. package/src/Form/Form.tsx +4 -3
  8. package/src/Form/Inputs/ExclusiveCheckboxGroup.browser.test.tsx +304 -0
  9. package/src/Form/Inputs/Grid.browser.test.tsx +186 -0
  10. package/src/Form/Inputs/Grid.tsx +59 -12
  11. package/src/Form/Inputs/PasswordInput.browser.test.tsx +80 -0
  12. package/src/Form/Inputs/SegmentedButtons.browser.test.tsx +197 -0
  13. package/src/Form/Inputs/SegmentedButtons.tsx +38 -29
  14. package/src/Form/Inputs/Text.tsx +13 -1
  15. package/src/Form/Inputs/index.tsx +10 -52
  16. package/src/Form/Inputs/models.ts +6 -0
  17. package/src/Form/Section/FormSection.browser.test.tsx +174 -0
  18. package/src/Form/Section/FormSection.tsx +20 -6
  19. package/src/Form/Section/navigateToSection.ts +26 -8
  20. package/src/Form/Section/useActiveSection.ts +213 -0
  21. package/src/InputField/Number/Number.browser.test.tsx +109 -0
  22. package/src/InputField/Select/Autocomplete/Connected/Multi/MultiConnectedAutocompleteField.browser.test.tsx +250 -0
  23. package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +37 -0
  24. package/src/InputField/Select/Autocomplete/Connected/index.tsx +56 -45
  25. package/src/Listing/Cell/DataCell.tsx +0 -2
  26. package/src/Listing/Listing.browser.test.tsx +476 -0
  27. package/src/Module/Module.browser.test.tsx +145 -0
  28. package/src/Pagination/Pagination.browser.test.tsx +184 -0
  29. package/src/RichTextEditor/RichTextEditor.browser.test.tsx +567 -0
  30. package/src/RichTextEditor/plugins/FloatingLinkEditorPlugin.tsx +3 -1
  31. package/src/TimePeriods/ResolutionTimePeriod.browser.test.tsx +143 -0
  32. package/src/TimePeriods/TimePeriods.browser.test.tsx +468 -0
  33. package/src/Typography/FluidTypography/FluidTypography.browser.test.tsx +54 -0
  34. package/src/api/useMutationQuery/useMutationQuery.browser.test.tsx +154 -0
  35. package/src/components/CollapsibleItem/CollapsibleItem.browser.test.tsx +120 -0
  36. package/src/components/CopyCommand/CopyCommand.browser.test.tsx +287 -0
  37. package/src/components/CrudPage/CrudPage.browser.test.tsx +659 -0
  38. package/src/components/DataTable/DataTable.browser.test.tsx +257 -0
  39. package/src/components/Form/AccessRights/AccessRights.browser.test.tsx +527 -0
  40. package/src/components/Header/PageHeader/PageHeader.stories.tsx +9 -0
  41. package/src/components/Header/PageHeader/PageHeaderMain.tsx +4 -2
  42. package/src/components/Header/PageHeader/PageHeaderTitle.tsx +61 -18
  43. package/src/components/ItemComposition/ItemComposition.browser.test.tsx +172 -0
  44. package/src/components/Layout/PageLayout.browser.test.tsx +114 -0
  45. package/src/components/Modal/ConfirmationModal/ConfirmationModal.browser.test.tsx +237 -0
  46. package/src/components/SortableEntriesList/SortableEntriesList.browser.test.tsx +981 -0
  47. package/src/components/Tabs/Tabs.browser.test.tsx +115 -0
  48. package/src/components/Tabs/Tabs.tsx +7 -1
  49. package/src/utils/useFullscreen/Fullscreen.browser.test.tsx +176 -0
  50. package/src/utils/useLocale/useLocale.browser.test.tsx +49 -0
  51. package/src/utils/useLocaleTimezoneDate/{LocaleTimezoneDate.cypress.spec.tsx → LocaleTimezoneDate.browser.test.tsx} +24 -11
  52. package/src/Dashboard/Dashboard.cypress.spec.tsx +0 -71
  53. package/src/Form/Form.cypress.spec.tsx +0 -306
  54. package/src/Form/Inputs/ExclusiveCheckboxGroup.cypress.spec.tsx +0 -236
  55. package/src/Form/Inputs/SegmentedButtons.cypress.spec.tsx +0 -101
  56. package/src/InputField/Number/Number.cypress.spec.tsx +0 -89
  57. package/src/InputField/Select/Autocomplete/Connected/Multi/MultiConnectedAutocompleteField.cypress.spec.tsx +0 -182
  58. package/src/Listing/Listing.cypress.spec.tsx +0 -304
  59. package/src/Module/Module.cypress.spec.tsx +0 -127
  60. package/src/Pagination/Pagination.cypress.spec.tsx +0 -140
  61. package/src/RichTextEditor/RichTextEditor.cypress.spec.tsx +0 -408
  62. package/src/TimePeriods/ResolutionTimePeriod.cypress.spec.tsx +0 -74
  63. package/src/TimePeriods/TimePeriods.cypress.spec.tsx +0 -488
  64. package/src/Typography/FluidTypography/FluidTypography.cypress.spec.tsx +0 -27
  65. package/src/api/useMutationQuery/useMutationQuery.cypress.spec.tsx +0 -93
  66. package/src/components/CollapsibleItem/CollapsibleItem.cypress.spec.tsx +0 -76
  67. package/src/components/CopyCommand/CopyCommand.cypress.spec.tsx +0 -167
  68. package/src/components/CrudPage/CrudPage.cypress.spec.tsx +0 -561
  69. package/src/components/DataTable/DataTable.cypress.spec.tsx +0 -174
  70. package/src/components/Form/AccessRights/AccessRights.cypress.spec.tsx +0 -376
  71. package/src/components/ItemComposition/ItemComposition.cypress.spec.tsx +0 -112
  72. package/src/components/Layout/PageLayout.cypress.spec.tsx +0 -64
  73. package/src/components/Modal/ConfirmationModal/ConfirmationModal.cypress.spec.tsx +0 -171
  74. package/src/components/SortableEntriesList/SortableEntriesList.cypress.spec.tsx +0 -792
  75. package/src/components/Tabs/Tabs.cypress.spec.tsx +0 -69
  76. package/src/utils/useFullscreen/Fullscreen.cypress.spec.tsx +0 -130
  77. package/src/utils/useLocale/useLocale.cypress.spec.tsx +0 -40
@@ -1,89 +0,0 @@
1
- import NumberField, { type NumberProps } from './Number';
2
-
3
- const initialize = (props: NumberProps): void => {
4
- cy.mount({
5
- Component: <NumberField {...props} />
6
- });
7
- };
8
-
9
- describe('Number field', () => {
10
- it('displays the placeholder when the field has no default or fallback values', () => {
11
- initialize({ dataTestId: 'test', onChange: cy.stub() });
12
-
13
- cy.get('input').should('have.value', '');
14
- cy.get('input').should('have.attr', 'placeholder', '0');
15
-
16
- cy.makeSnapshot();
17
- });
18
-
19
- it('displays the fallback value as placeholder when the field as no default value', () => {
20
- initialize({ dataTestId: 'test', fallbackValue: 25, onChange: cy.stub() });
21
-
22
- cy.get('input').should('have.value', '');
23
- cy.get('input').should('have.attr', 'placeholder', '25');
24
-
25
- cy.makeSnapshot();
26
- });
27
-
28
- it('displays the default value as placeholder when the field as default value', () => {
29
- initialize({ dataTestId: 'test', defaultValue: 25, onChange: cy.stub() });
30
-
31
- cy.get('input').should('have.value', '25');
32
-
33
- cy.makeSnapshot();
34
- });
35
-
36
- it('displays the fallback value when the field is cleared out', () => {
37
- initialize({
38
- dataTestId: 'test',
39
- defaultValue: 25,
40
- fallbackValue: 10,
41
- onChange: cy.stub()
42
- });
43
-
44
- cy.get('input').should('have.value', '25');
45
- cy.get('input').clear();
46
- cy.get('input').should('have.value', '');
47
- cy.get('input').should('have.attr', 'placeholder', '10');
48
-
49
- cy.makeSnapshot();
50
- });
51
-
52
- it('displays the field using auto size', () => {
53
- initialize({
54
- autoSize: true,
55
- dataTestId: 'test',
56
- defaultValue: 25,
57
- onChange: cy.stub()
58
- });
59
-
60
- cy.get('input').should('have.value', '25');
61
-
62
- cy.get('input').type('0');
63
-
64
- cy.makeSnapshot();
65
- });
66
-
67
- it('sets the value to the minimum value configured when a value less than the minimum value is typed in the field', () => {
68
- initialize({
69
- dataTestId: 'test',
70
- defaultValue: 25,
71
- onChange: cy.stub(),
72
- textFieldSlotsAndSlotProps: {
73
- slotProps: {
74
- htmlInput: {
75
- min: 2
76
- }
77
- }
78
- }
79
- });
80
-
81
- cy.get('input').should('have.value', '25');
82
-
83
- cy.get('input').clear().type('-1');
84
-
85
- cy.get('input').should('have.value', '2');
86
-
87
- cy.makeSnapshot();
88
- });
89
- });
@@ -1,182 +0,0 @@
1
- import {
2
- Method,
3
- MultiConnectedAutocompleteField,
4
- TestQueryProvider
5
- } from '@centreon/ui';
6
-
7
- import i18next from 'i18next';
8
- import { useState } from 'react';
9
- import { initReactI18next } from 'react-i18next';
10
-
11
- import { labelSelectAll, labelUnSelectAll } from '../../../../translatedLabels';
12
- import { baseEndpoint, getEndpoint, label, placeholder } from './utils';
13
-
14
- const optionOne = 'My Option 1';
15
-
16
- const Component = () => {
17
- const [values, setValues] = useState([]);
18
- return (
19
- <TestQueryProvider>
20
- <div style={{ paddingTop: 20 }}>
21
- <MultiConnectedAutocompleteField
22
- disableSelectAll={false}
23
- field="host.name"
24
- getEndpoint={getEndpoint}
25
- label={label}
26
- onChange={(_, item) => setValues(item)}
27
- placeholder={placeholder}
28
- value={values}
29
- />
30
- </div>
31
- </TestQueryProvider>
32
- );
33
- };
34
-
35
- describe('Multi connected autocomplete', () => {
36
- beforeEach(() => {
37
- i18next.use(initReactI18next).init({
38
- lng: 'en',
39
- resources: {}
40
- });
41
-
42
- cy.fixture('inputField/listOptions').then((optionsData) => {
43
- cy.interceptAPIRequest({
44
- alias: 'getListOptions',
45
- method: Method.GET,
46
- path: `${baseEndpoint}**`,
47
- response: optionsData
48
- });
49
- });
50
-
51
- cy.fixture('inputField/searchedOption').then((optionData) => {
52
- cy.interceptAPIRequest({
53
- alias: 'getSearchedOption',
54
- method: Method.GET,
55
- path: `${baseEndpoint}**`,
56
- query: {
57
- name: 'search',
58
- value: JSON.stringify({
59
- $and: [{ 'host.name': { $lk: `%${optionOne}%` } }]
60
- })
61
- },
62
- response: optionData
63
- });
64
- });
65
-
66
- cy.mount({
67
- Component: <Component />
68
- });
69
- });
70
-
71
- it('displays and hides the list when the user double-clicks on the input', () => {
72
- cy.contains(label).should('be.visible');
73
-
74
- cy.get('[data-testid="Multi Connected Autocomplete"]').as('input');
75
-
76
- cy.get('@input').click();
77
-
78
- cy.waitForRequest('@getListOptions');
79
-
80
- cy.get('@input').invoke('attr', 'placeholder').should('equal', placeholder);
81
-
82
- cy.findByRole('presentation').as('listOptions');
83
-
84
- cy.get('@listOptions').should('be.visible');
85
-
86
- cy.fixture('inputField/listOptions').then((optionsData) => {
87
- cy.get('@listOptions').within(() => {
88
- optionsData.result.forEach((option) => {
89
- cy.contains(option.name);
90
- });
91
- });
92
- });
93
-
94
- cy.makeSnapshot('displays the list when the user clicks on the input');
95
-
96
- cy.get('@input').click();
97
-
98
- cy.get('@listOptions').should('not.exist');
99
-
100
- cy.makeSnapshot('hides the list when the user clicks on the input');
101
- });
102
-
103
- it('displays all options on the list when the user searches for and selects an option', () => {
104
- cy.get('[data-testid="Multi Connected Autocomplete"]').as('input');
105
-
106
- cy.get('@input').click();
107
-
108
- cy.waitForRequest('@getListOptions');
109
-
110
- cy.findByRole('presentation').as('listOptions');
111
-
112
- cy.get('@listOptions').should('be.visible');
113
-
114
- cy.get('@input').type(optionOne);
115
-
116
- cy.waitForRequest('@getSearchedOption');
117
-
118
- cy.fixture('inputField/searchedOption').then(() => {
119
- cy.get('@listOptions').find('li').should('have.length', 6);
120
- });
121
-
122
- cy.get('[type="checkbox"]').eq(0).check();
123
- cy.get('@input')
124
- .parent()
125
- .within(() => {
126
- cy.contains(optionOne).should('be.visible');
127
-
128
- cy.get('[data-testid="CancelIcon"]').should('be.visible');
129
- });
130
-
131
- cy.waitForRequest('@getListOptions');
132
-
133
- cy.fixture('inputField/listOptions').then((optionsData) => {
134
- cy.get('@listOptions')
135
- .find('li')
136
- .should('have.length', optionsData.result.length + 1);
137
-
138
- cy.get('@listOptions').within(() => {
139
- optionsData.result.forEach((option) => {
140
- cy.contains(option.name);
141
- });
142
- });
143
- });
144
- });
145
-
146
- it('checks all options when Select all button is clicked', () => {
147
- cy.get('[data-testid="Multi Connected Autocomplete"]').as('input');
148
-
149
- cy.get('@input').click();
150
-
151
- cy.contains('5 element(s) found');
152
-
153
- cy.waitForRequest('@getListOptions');
154
-
155
- cy.contains(labelSelectAll).click();
156
-
157
- cy.contains(labelUnSelectAll).should('be.visible');
158
-
159
- cy.get('[data-testid="CancelIcon"]').should('have.length', 5);
160
-
161
- cy.makeSnapshot('checks all options when Select all button is clicked');
162
- });
163
-
164
- it('unchecks all options when unSelect all button is clicked', () => {
165
- cy.get('[data-testid="Multi Connected Autocomplete"]').as('input');
166
-
167
- cy.get('@input').click();
168
-
169
- cy.contains('5 element(s) found');
170
-
171
- cy.waitForRequest('@getListOptions');
172
-
173
- cy.contains(labelSelectAll).click();
174
- cy.contains(labelUnSelectAll).click();
175
-
176
- cy.contains(labelSelectAll).should('be.visible');
177
-
178
- cy.get('[data-testid="CancelIcon"]').should('have.length', 0);
179
-
180
- cy.makeSnapshot('unchecks all options when unSelect all button is clicked');
181
- });
182
- });
@@ -1,304 +0,0 @@
1
- import { Button, Typography } from '@mui/material';
2
-
3
- import { ListingVariant } from '@centreon/ui-context';
4
-
5
- import { useState } from 'react';
6
-
7
- import Listing from '.';
8
- import { ColumnType } from './models';
9
-
10
- interface Props {
11
- row: { name: string };
12
- }
13
-
14
- const ButtonColumn = ({ row }: Props): JSX.Element => (
15
- <Button size="small">Click to reveal details about {row.name}</Button>
16
- );
17
-
18
- const LargeText = (): JSX.Element => (
19
- <Typography sx={{ whiteSpace: 'normal' }}>
20
- This is a large text that fills the content
21
- </Typography>
22
- );
23
-
24
- const tenElements = new Array(10).fill(0);
25
-
26
- const generateSubItems = (): Array<unknown> => {
27
- return tenElements.map((_, subIndex) => ({
28
- active: false,
29
- description: `Sub item ${subIndex * 10} description`,
30
- disableCheckbox: false,
31
- disableRow: false,
32
- id: subIndex * 10,
33
- name: `Sub Item ${subIndex * 10}`,
34
- selected: false
35
- }));
36
- };
37
-
38
- const listingWithSubItems = tenElements.map((_, index) => ({
39
- active: false,
40
- description: `Entity ${index}`,
41
- disableCheckbox: false,
42
- disableRow: false,
43
- id: index,
44
- name: `E${index}`,
45
- selected: false,
46
- subItems: index % 2 === 0 ? generateSubItems() : undefined
47
- }));
48
-
49
- const listingWithSubItems3Rows = Array(3)
50
- .fill(0)
51
- .map((_, index) => ({
52
- active: false,
53
- description: `Entity ${index}`,
54
- disableCheckbox: false,
55
- disableRow: false,
56
- id: index,
57
- name: `E${index}`,
58
- selected: false,
59
- subItems: index % 2 === 0 ? generateSubItems() : undefined
60
- }));
61
-
62
- const defaultColumn = [
63
- {
64
- getFormattedString: ({ name }): string => name,
65
- id: 'name',
66
- label: 'Name',
67
- type: ColumnType.string
68
- },
69
- {
70
- getFormattedString: ({ description }): string => description,
71
- id: 'description',
72
- label: 'Description',
73
- type: ColumnType.string
74
- },
75
- {
76
- Component: LargeText,
77
- id: '#',
78
- label: 'Custom',
79
- type: ColumnType.component,
80
- width: '100px'
81
- }
82
- ];
83
-
84
- const columnsWithSubItems = [
85
- {
86
- getFormattedString: ({ name }): string => name,
87
- id: 'name',
88
- label: 'Name',
89
- type: ColumnType.string
90
- },
91
- {
92
- getFormattedString: ({ description }): string => description,
93
- id: 'description',
94
- label: 'Description',
95
- type: ColumnType.string
96
- },
97
- {
98
- Component: ButtonColumn,
99
- displaySubItemsCaret: true,
100
- id: '#',
101
- label: 'Custom',
102
- type: ColumnType.component,
103
- width: '350px'
104
- }
105
- ];
106
-
107
- const expandedItems = [0, 8];
108
-
109
- const mountListingResponsive = (listingVariant: ListingVariant): void => {
110
- cy.viewport('macbook-13');
111
-
112
- cy.mount({
113
- Component: (
114
- <div style={{ height: '100vh' }}>
115
- <Listing
116
- columns={defaultColumn}
117
- currentPage={1}
118
- isResponsive
119
- limit={10}
120
- listingVariant={listingVariant}
121
- rows={listingWithSubItems}
122
- totalRows={10}
123
- />
124
- </div>
125
- )
126
- });
127
- };
128
-
129
- interface TestComponentProps {
130
- canCheckSubItems?: boolean;
131
- isSmallListing?: boolean;
132
- }
133
-
134
- const TestComponent = ({
135
- isSmallListing = false,
136
- canCheckSubItems = false
137
- }: TestComponentProps): JSX.Element => {
138
- const [selectedRows, setSelectedRows] = useState([]);
139
-
140
- return (
141
- <Listing
142
- checkable
143
- columns={columnsWithSubItems}
144
- currentPage={1}
145
- limit={10}
146
- onSelectRows={setSelectedRows}
147
- rows={isSmallListing ? listingWithSubItems3Rows : listingWithSubItems}
148
- selectedRows={selectedRows}
149
- subItems={{
150
- canCheckSubItems,
151
- enable: true,
152
- getRowProperty: () => 'subItems',
153
- labelCollapse: 'Collapse',
154
- labelExpand: 'Expand'
155
- }}
156
- totalRows={10}
157
- />
158
- );
159
- };
160
-
161
- const mountListingForSubItems = ({
162
- isSmallListing = false,
163
- canCheckSubItems = false
164
- }: TestComponentProps): void => {
165
- cy.viewport('macbook-13');
166
-
167
- cy.mount({
168
- Component: (
169
- <div style={{ height: '100vh' }}>
170
- <TestComponent
171
- canCheckSubItems={canCheckSubItems}
172
- isSmallListing={isSmallListing}
173
- />
174
- </div>
175
- )
176
- });
177
- };
178
-
179
- describe('Listing', () => {
180
- describe('Sub items', () => {
181
- it('expands the row when the corresponding icon is clicked', () => {
182
- mountListingForSubItems({});
183
-
184
- cy.contains('E0').should('be.visible');
185
-
186
- expandedItems.forEach((index) => {
187
- const subItems = generateSubItems(index);
188
-
189
- cy.findByLabelText(`Expand ${index}`).click();
190
-
191
- cy.findByLabelText(`Collapse ${index}`).should('exist');
192
-
193
- subItems.forEach(({ name, description }) => {
194
- cy.contains(name).should('exist');
195
- cy.contains(description).should('exist');
196
- });
197
-
198
- cy.findByLabelText(`Collapse ${index}`).click();
199
- });
200
-
201
- cy.makeSnapshot();
202
- });
203
-
204
- it('collapses the row when the corresponding icon is clicked', () => {
205
- mountListingForSubItems({});
206
-
207
- cy.findByLabelText('Expand 0').click();
208
-
209
- cy.contains('Sub item 10').should('be.visible');
210
-
211
- cy.findByLabelText('Collapse 0').click();
212
-
213
- cy.contains('Sub item 10').should('not.exist');
214
-
215
- cy.makeSnapshot();
216
- });
217
-
218
- it('displays only one row as hovered when mutilple rows are expanded and a sub item row is hovered', () => {
219
- mountListingForSubItems({ isSmallListing: true });
220
-
221
- cy.findByLabelText('Expand 2').click();
222
- cy.findByLabelText('Expand 0').click();
223
-
224
- cy.findByLabelText('Collapse 0').should('be.visible');
225
- cy.findByLabelText('Collapse 2').should('be.visible');
226
-
227
- cy.contains('Sub Item 0').realHover();
228
-
229
- cy.get('[data-is-hovered="true"]').should('have.length', 1);
230
- cy.get('[data-is-hovered="true"]').contains('Sub Item 0').should('exist');
231
-
232
- cy.findByLabelText('Collapse 0').click();
233
- cy.findByLabelText('Collapse 2').click();
234
- });
235
-
236
- it('selects displayed rows when a row is selected and another row is selected with the shift key', () => {
237
- mountListingForSubItems({ canCheckSubItems: true, isSmallListing: true });
238
-
239
- cy.findByLabelText('Expand 2').click();
240
-
241
- cy.findByLabelText('Collapse 2').should('be.visible');
242
-
243
- cy.findAllByLabelText('Select row 2').eq(0).click();
244
- cy.get('body').type('{shift}', { release: false });
245
- cy.findByLabelText('Select row 50').eq(0).click();
246
-
247
- cy.findAllByLabelText('Select row 2').eq(0).should('be.checked');
248
- cy.findByLabelText('Select row 10').should('be.checked');
249
- cy.findByLabelText('Select row 20').should('be.checked');
250
- cy.findByLabelText('Select row 30').should('be.checked');
251
- cy.findByLabelText('Select row 40').should('be.checked');
252
-
253
- cy.findByLabelText('Collapse 2').click();
254
- });
255
-
256
- it('selects displayed rows when the corresponding checkbox is clicked', () => {
257
- mountListingForSubItems({ canCheckSubItems: true, isSmallListing: true });
258
-
259
- cy.findByLabelText('Expand 2').click();
260
-
261
- cy.findByLabelText('Collapse 2').should('be.visible');
262
-
263
- cy.findAllByLabelText('Select all').eq(0).click();
264
-
265
- cy.findAllByLabelText('Select row 2').eq(0).should('be.checked');
266
- tenElements.forEach((_, index) => {
267
- if (index === 0) {
268
- cy.findAllByLabelText('Select row 0').eq(1).should('be.checked');
269
-
270
- return;
271
- }
272
- cy.findByLabelText(`Select row ${index * 10}`).should('be.checked');
273
- });
274
- cy.findByLabelText('Select row 1').should('be.checked');
275
- cy.findByLabelText('Select row 2').should('be.checked');
276
-
277
- cy.findByLabelText('Collapse 2').click();
278
- });
279
- });
280
-
281
- it('displays the last column on several lines in compact mode when the isResponsive prop is set', () => {
282
- mountListingResponsive(ListingVariant.compact);
283
-
284
- cy.get('.MuiTable-root').should(
285
- 'have.css',
286
- 'grid-template-rows',
287
- '30px 85px 85px 85px 85px 85px 85px 85px 85px 85px 85px'
288
- );
289
-
290
- cy.makeSnapshot();
291
- });
292
-
293
- it('displays the last column on several lines in extended mode when the isResponsive prop is set', () => {
294
- mountListingResponsive(ListingVariant.extended);
295
-
296
- cy.get('.MuiTable-root').should(
297
- 'have.css',
298
- 'grid-template-rows',
299
- '38px 85px 85px 85px 85px 85px 85px 85px 85px 85px 85px'
300
- );
301
-
302
- cy.makeSnapshot();
303
- });
304
- });
@@ -1,127 +0,0 @@
1
- import { createStore } from 'jotai';
2
-
3
- import { Method } from '..';
4
- import Module from '.';
5
- import LicensedModule from './LicensedModule';
6
-
7
- const initializeModule = (): void => {
8
- cy.mount({
9
- Component: (
10
- <Module seedName="seed" store={createStore()}>
11
- <p>Module</p>
12
- </Module>
13
- )
14
- });
15
- };
16
-
17
- const initializeModuleWithValidLicense = (
18
- isFederatedComponent = false
19
- ): void => {
20
- cy.interceptAPIRequest({
21
- alias: 'getValidLicense',
22
- method: Method.GET,
23
- path: './api/internal.php?object=centreon_license_manager&action=licenseValid&productName=valid',
24
- response: {
25
- success: true
26
- }
27
- });
28
-
29
- cy.mount({
30
- Component: (
31
- <div style={{ height: '100vh' }}>
32
- <LicensedModule
33
- isFederatedComponent={isFederatedComponent}
34
- moduleName="valid"
35
- seedName="seed"
36
- store={createStore()}
37
- >
38
- <p>Module</p>
39
- </LicensedModule>
40
- </div>
41
- )
42
- });
43
- };
44
-
45
- const initializeModuleWithInvalidLicense = (
46
- isFederatedComponent = false
47
- ): void => {
48
- cy.interceptAPIRequest({
49
- alias: 'getInvalidLicense',
50
- method: Method.GET,
51
- path: './api/internal.php?object=centreon_license_manager&action=licenseValid&productName=invalid',
52
- response: {
53
- success: false
54
- }
55
- });
56
-
57
- cy.mount({
58
- Component: (
59
- <div style={{ height: '100vh' }}>
60
- <LicensedModule
61
- isFederatedComponent={isFederatedComponent}
62
- moduleName="invalid"
63
- seedName="seed"
64
- store={createStore()}
65
- >
66
- <p>Module</p>
67
- </LicensedModule>
68
- </div>
69
- )
70
- });
71
- };
72
-
73
- describe('Module', () => {
74
- beforeEach(() => {
75
- initializeModule();
76
- });
77
-
78
- it('displays the content of the module', () => {
79
- cy.contains('Module').should('be.visible');
80
-
81
- cy.makeSnapshot();
82
- });
83
- });
84
-
85
- describe('Valid license module', () => {
86
- it('displays the content of the page when the license is valid license', () => {
87
- initializeModuleWithValidLicense();
88
- cy.waitForRequest('@getValidLicense');
89
-
90
- cy.contains('Module').should('be.visible');
91
-
92
- cy.makeSnapshot();
93
- });
94
-
95
- it('displays the content of the component when the license is valid license', () => {
96
- initializeModuleWithValidLicense(true);
97
-
98
- cy.contains('Module').should('be.visible');
99
-
100
- cy.makeSnapshot();
101
- });
102
- });
103
-
104
- describe('Invalid license module', () => {
105
- it('displays the content of the page when the license is invalid license', () => {
106
- initializeModuleWithInvalidLicense();
107
- cy.waitForRequest('@getInvalidLicense');
108
-
109
- cy.contains('Module').should('not.exist');
110
-
111
- cy.contains('Oops').should('be.visible');
112
- cy.contains('License invalid or expired').should('be.visible');
113
- cy.contains('Please contact your administrator.').should('be.visible');
114
- cy.get('img[alt="License invalid or expired !"]').should('be.visible');
115
- cy.get('img[alt="Centreon Logo"]').should('be.visible');
116
-
117
- cy.makeSnapshot();
118
- });
119
-
120
- it('displays the content of the module when the license is invalid license', () => {
121
- initializeModuleWithInvalidLicense(true);
122
-
123
- cy.contains('Module').should('not.exist');
124
-
125
- cy.makeSnapshot();
126
- });
127
- });