@centreon/ui 26.12.1 → 26.12.3
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/package.json +6 -3
- package/public/mockServiceWorker.js +31 -8
- package/src/Dashboard/Dashboard.browser.test.tsx +107 -0
- package/src/Form/CollapsibleGroup.tsx +6 -33
- package/src/Form/Form.browser.test.tsx +553 -0
- package/src/Form/Inputs/ExclusiveCheckboxGroup.browser.test.tsx +304 -0
- package/src/Form/Inputs/Grid.tsx +1 -2
- package/src/Form/Inputs/SegmentedButtons.browser.test.tsx +113 -0
- package/src/Form/Inputs/index.tsx +10 -52
- package/src/InputField/Number/Number.browser.test.tsx +109 -0
- package/src/InputField/Select/Autocomplete/Connected/Multi/MultiConnectedAutocompleteField.browser.test.tsx +250 -0
- package/src/Listing/Listing.browser.test.tsx +476 -0
- package/src/Module/Module.browser.test.tsx +145 -0
- package/src/Pagination/Pagination.browser.test.tsx +184 -0
- package/src/RichTextEditor/RichTextEditor.browser.test.tsx +567 -0
- package/src/RichTextEditor/plugins/FloatingLinkEditorPlugin.tsx +3 -1
- package/src/TimePeriods/ResolutionTimePeriod.browser.test.tsx +143 -0
- package/src/TimePeriods/TimePeriods.browser.test.tsx +468 -0
- package/src/Typography/FluidTypography/FluidTypography.browser.test.tsx +54 -0
- package/src/api/useMutationQuery/useMutationQuery.browser.test.tsx +154 -0
- package/src/components/CollapsibleItem/CollapsibleItem.browser.test.tsx +120 -0
- package/src/components/CopyCommand/CopyCommand.browser.test.tsx +287 -0
- package/src/components/CrudPage/CrudPage.browser.test.tsx +659 -0
- package/src/components/DataTable/DataTable.browser.test.tsx +257 -0
- package/src/components/Form/AccessRights/AccessRights.browser.test.tsx +527 -0
- package/src/components/ItemComposition/ItemComposition.browser.test.tsx +172 -0
- package/src/components/Layout/PageLayout.browser.test.tsx +114 -0
- package/src/components/Modal/ConfirmationModal/ConfirmationModal.browser.test.tsx +237 -0
- package/src/components/SortableEntriesList/SortableEntriesList.browser.test.tsx +981 -0
- package/src/components/Tabs/Tabs.browser.test.tsx +115 -0
- package/src/utils/useFullscreen/Fullscreen.browser.test.tsx +176 -0
- package/src/utils/useLocale/useLocale.browser.test.tsx +49 -0
- package/src/utils/useLocaleTimezoneDate/{LocaleTimezoneDate.cypress.spec.tsx → LocaleTimezoneDate.browser.test.tsx} +24 -11
- package/src/Dashboard/Dashboard.cypress.spec.tsx +0 -71
- package/src/Form/Form.cypress.spec.tsx +0 -306
- package/src/Form/Inputs/ExclusiveCheckboxGroup.cypress.spec.tsx +0 -236
- package/src/Form/Inputs/SegmentedButtons.cypress.spec.tsx +0 -101
- package/src/InputField/Number/Number.cypress.spec.tsx +0 -89
- package/src/InputField/Select/Autocomplete/Connected/Multi/MultiConnectedAutocompleteField.cypress.spec.tsx +0 -182
- package/src/Listing/Listing.cypress.spec.tsx +0 -349
- package/src/Module/Module.cypress.spec.tsx +0 -127
- package/src/Pagination/Pagination.cypress.spec.tsx +0 -140
- package/src/RichTextEditor/RichTextEditor.cypress.spec.tsx +0 -408
- package/src/TimePeriods/ResolutionTimePeriod.cypress.spec.tsx +0 -74
- package/src/TimePeriods/TimePeriods.cypress.spec.tsx +0 -488
- package/src/Typography/FluidTypography/FluidTypography.cypress.spec.tsx +0 -27
- package/src/api/useMutationQuery/useMutationQuery.cypress.spec.tsx +0 -93
- package/src/components/CollapsibleItem/CollapsibleItem.cypress.spec.tsx +0 -76
- package/src/components/CopyCommand/CopyCommand.cypress.spec.tsx +0 -167
- package/src/components/CrudPage/CrudPage.cypress.spec.tsx +0 -561
- package/src/components/DataTable/DataTable.cypress.spec.tsx +0 -174
- package/src/components/Form/AccessRights/AccessRights.cypress.spec.tsx +0 -376
- package/src/components/ItemComposition/ItemComposition.cypress.spec.tsx +0 -112
- package/src/components/Layout/PageLayout.cypress.spec.tsx +0 -64
- package/src/components/Modal/ConfirmationModal/ConfirmationModal.cypress.spec.tsx +0 -171
- package/src/components/SortableEntriesList/SortableEntriesList.cypress.spec.tsx +0 -792
- package/src/components/Tabs/Tabs.cypress.spec.tsx +0 -69
- package/src/utils/useFullscreen/Fullscreen.cypress.spec.tsx +0 -130
- 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,349 +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 CheckboxColumn = ({ row }: Props): JSX.Element => {
|
|
19
|
-
const [checked, setChecked] = useState(false);
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<input
|
|
23
|
-
aria-label={`Toggle ${row.name}`}
|
|
24
|
-
checked={checked}
|
|
25
|
-
onChange={(event) => setChecked(event.target.checked)}
|
|
26
|
-
type="checkbox"
|
|
27
|
-
/>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const LargeText = (): JSX.Element => (
|
|
32
|
-
<Typography sx={{ whiteSpace: 'normal' }}>
|
|
33
|
-
This is a large text that fills the content
|
|
34
|
-
</Typography>
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const tenElements = new Array(10).fill(0);
|
|
38
|
-
|
|
39
|
-
const generateSubItems = (): Array<unknown> => {
|
|
40
|
-
return tenElements.map((_, subIndex) => ({
|
|
41
|
-
active: false,
|
|
42
|
-
description: `Sub item ${subIndex * 10} description`,
|
|
43
|
-
disableCheckbox: false,
|
|
44
|
-
disableRow: false,
|
|
45
|
-
id: subIndex * 10,
|
|
46
|
-
name: `Sub Item ${subIndex * 10}`,
|
|
47
|
-
selected: false
|
|
48
|
-
}));
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const listingWithSubItems = tenElements.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 listingWithSubItems3Rows = Array(3)
|
|
63
|
-
.fill(0)
|
|
64
|
-
.map((_, index) => ({
|
|
65
|
-
active: false,
|
|
66
|
-
description: `Entity ${index}`,
|
|
67
|
-
disableCheckbox: false,
|
|
68
|
-
disableRow: false,
|
|
69
|
-
id: index,
|
|
70
|
-
name: `E${index}`,
|
|
71
|
-
selected: false,
|
|
72
|
-
subItems: index % 2 === 0 ? generateSubItems() : undefined
|
|
73
|
-
}));
|
|
74
|
-
|
|
75
|
-
const defaultColumn = [
|
|
76
|
-
{
|
|
77
|
-
getFormattedString: ({ name }): string => name,
|
|
78
|
-
id: 'name',
|
|
79
|
-
label: 'Name',
|
|
80
|
-
type: ColumnType.string
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
getFormattedString: ({ description }): string => description,
|
|
84
|
-
id: 'description',
|
|
85
|
-
label: 'Description',
|
|
86
|
-
type: ColumnType.string
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
Component: LargeText,
|
|
90
|
-
id: '#',
|
|
91
|
-
label: 'Custom',
|
|
92
|
-
type: ColumnType.component,
|
|
93
|
-
width: '100px'
|
|
94
|
-
}
|
|
95
|
-
];
|
|
96
|
-
|
|
97
|
-
const columnsWithSubItems = [
|
|
98
|
-
{
|
|
99
|
-
getFormattedString: ({ name }): string => name,
|
|
100
|
-
id: 'name',
|
|
101
|
-
label: 'Name',
|
|
102
|
-
type: ColumnType.string
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
getFormattedString: ({ description }): string => description,
|
|
106
|
-
id: 'description',
|
|
107
|
-
label: 'Description',
|
|
108
|
-
type: ColumnType.string
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
Component: ButtonColumn,
|
|
112
|
-
displaySubItemsCaret: true,
|
|
113
|
-
id: '#',
|
|
114
|
-
label: 'Custom',
|
|
115
|
-
type: ColumnType.component,
|
|
116
|
-
width: '350px'
|
|
117
|
-
}
|
|
118
|
-
];
|
|
119
|
-
|
|
120
|
-
const expandedItems = [0, 8];
|
|
121
|
-
|
|
122
|
-
const mountListingResponsive = (listingVariant: ListingVariant): void => {
|
|
123
|
-
cy.viewport('macbook-13');
|
|
124
|
-
|
|
125
|
-
cy.mount({
|
|
126
|
-
Component: (
|
|
127
|
-
<div style={{ height: '100vh' }}>
|
|
128
|
-
<Listing
|
|
129
|
-
columns={defaultColumn}
|
|
130
|
-
currentPage={1}
|
|
131
|
-
isResponsive
|
|
132
|
-
limit={10}
|
|
133
|
-
listingVariant={listingVariant}
|
|
134
|
-
rows={listingWithSubItems}
|
|
135
|
-
totalRows={10}
|
|
136
|
-
/>
|
|
137
|
-
</div>
|
|
138
|
-
)
|
|
139
|
-
});
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
interface TestComponentProps {
|
|
143
|
-
canCheckSubItems?: boolean;
|
|
144
|
-
isSmallListing?: boolean;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const TestComponent = ({
|
|
148
|
-
isSmallListing = false,
|
|
149
|
-
canCheckSubItems = false
|
|
150
|
-
}: TestComponentProps): JSX.Element => {
|
|
151
|
-
const [selectedRows, setSelectedRows] = useState([]);
|
|
152
|
-
|
|
153
|
-
return (
|
|
154
|
-
<Listing
|
|
155
|
-
checkable
|
|
156
|
-
columns={columnsWithSubItems}
|
|
157
|
-
currentPage={1}
|
|
158
|
-
limit={10}
|
|
159
|
-
onSelectRows={setSelectedRows}
|
|
160
|
-
rows={isSmallListing ? listingWithSubItems3Rows : listingWithSubItems}
|
|
161
|
-
selectedRows={selectedRows}
|
|
162
|
-
subItems={{
|
|
163
|
-
canCheckSubItems,
|
|
164
|
-
enable: true,
|
|
165
|
-
getRowProperty: () => 'subItems',
|
|
166
|
-
labelCollapse: 'Collapse',
|
|
167
|
-
labelExpand: 'Expand'
|
|
168
|
-
}}
|
|
169
|
-
totalRows={10}
|
|
170
|
-
/>
|
|
171
|
-
);
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const mountListingForSubItems = ({
|
|
175
|
-
isSmallListing = false,
|
|
176
|
-
canCheckSubItems = false
|
|
177
|
-
}: TestComponentProps): void => {
|
|
178
|
-
cy.viewport('macbook-13');
|
|
179
|
-
|
|
180
|
-
cy.mount({
|
|
181
|
-
Component: (
|
|
182
|
-
<div style={{ height: '100vh' }}>
|
|
183
|
-
<TestComponent
|
|
184
|
-
canCheckSubItems={canCheckSubItems}
|
|
185
|
-
isSmallListing={isSmallListing}
|
|
186
|
-
/>
|
|
187
|
-
</div>
|
|
188
|
-
)
|
|
189
|
-
});
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
describe('Listing', () => {
|
|
193
|
-
describe('Sub items', () => {
|
|
194
|
-
it('expands the row when the corresponding icon is clicked', () => {
|
|
195
|
-
mountListingForSubItems({});
|
|
196
|
-
|
|
197
|
-
cy.contains('E0').should('be.visible');
|
|
198
|
-
|
|
199
|
-
expandedItems.forEach((index) => {
|
|
200
|
-
const subItems = generateSubItems(index);
|
|
201
|
-
|
|
202
|
-
cy.findByLabelText(`Expand ${index}`).click();
|
|
203
|
-
|
|
204
|
-
cy.findByLabelText(`Collapse ${index}`).should('exist');
|
|
205
|
-
|
|
206
|
-
subItems.forEach(({ name, description }) => {
|
|
207
|
-
cy.contains(name).should('exist');
|
|
208
|
-
cy.contains(description).should('exist');
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
cy.findByLabelText(`Collapse ${index}`).click();
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
cy.makeSnapshot();
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
it('collapses the row when the corresponding icon is clicked', () => {
|
|
218
|
-
mountListingForSubItems({});
|
|
219
|
-
|
|
220
|
-
cy.findByLabelText('Expand 0').click();
|
|
221
|
-
|
|
222
|
-
cy.contains('Sub item 10').should('be.visible');
|
|
223
|
-
|
|
224
|
-
cy.findByLabelText('Collapse 0').click();
|
|
225
|
-
|
|
226
|
-
cy.contains('Sub item 10').should('not.exist');
|
|
227
|
-
|
|
228
|
-
cy.makeSnapshot();
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
it('displays only one row as hovered when mutilple rows are expanded and a sub item row is hovered', () => {
|
|
232
|
-
mountListingForSubItems({ isSmallListing: true });
|
|
233
|
-
|
|
234
|
-
cy.findByLabelText('Expand 2').click();
|
|
235
|
-
cy.findByLabelText('Expand 0').click();
|
|
236
|
-
|
|
237
|
-
cy.findByLabelText('Collapse 0').should('be.visible');
|
|
238
|
-
cy.findByLabelText('Collapse 2').should('be.visible');
|
|
239
|
-
|
|
240
|
-
cy.contains('Sub Item 0').realHover();
|
|
241
|
-
|
|
242
|
-
cy.get('[data-is-hovered="true"]').should('have.length', 1);
|
|
243
|
-
cy.get('[data-is-hovered="true"]').contains('Sub Item 0').should('exist');
|
|
244
|
-
|
|
245
|
-
cy.findByLabelText('Collapse 0').click();
|
|
246
|
-
cy.findByLabelText('Collapse 2').click();
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
it('selects displayed rows when a row is selected and another row is selected with the shift key', () => {
|
|
250
|
-
mountListingForSubItems({ canCheckSubItems: true, isSmallListing: true });
|
|
251
|
-
|
|
252
|
-
cy.findByLabelText('Expand 2').click();
|
|
253
|
-
|
|
254
|
-
cy.findByLabelText('Collapse 2').should('be.visible');
|
|
255
|
-
|
|
256
|
-
cy.findAllByLabelText('Select row 2').eq(0).click();
|
|
257
|
-
cy.get('body').type('{shift}', { release: false });
|
|
258
|
-
cy.findByLabelText('Select row 50').eq(0).click();
|
|
259
|
-
|
|
260
|
-
cy.findAllByLabelText('Select row 2').eq(0).should('be.checked');
|
|
261
|
-
cy.findByLabelText('Select row 10').should('be.checked');
|
|
262
|
-
cy.findByLabelText('Select row 20').should('be.checked');
|
|
263
|
-
cy.findByLabelText('Select row 30').should('be.checked');
|
|
264
|
-
cy.findByLabelText('Select row 40').should('be.checked');
|
|
265
|
-
|
|
266
|
-
cy.findByLabelText('Collapse 2').click();
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
it('selects displayed rows when the corresponding checkbox is clicked', () => {
|
|
270
|
-
mountListingForSubItems({ canCheckSubItems: true, isSmallListing: true });
|
|
271
|
-
|
|
272
|
-
cy.findByLabelText('Expand 2').click();
|
|
273
|
-
|
|
274
|
-
cy.findByLabelText('Collapse 2').should('be.visible');
|
|
275
|
-
|
|
276
|
-
cy.findAllByLabelText('Select all').eq(0).click();
|
|
277
|
-
|
|
278
|
-
cy.findAllByLabelText('Select row 2').eq(0).should('be.checked');
|
|
279
|
-
tenElements.forEach((_, index) => {
|
|
280
|
-
if (index === 0) {
|
|
281
|
-
cy.findAllByLabelText('Select row 0').eq(1).should('be.checked');
|
|
282
|
-
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
cy.findByLabelText(`Select row ${index * 10}`).should('be.checked');
|
|
286
|
-
});
|
|
287
|
-
cy.findByLabelText('Select row 1').should('be.checked');
|
|
288
|
-
cy.findByLabelText('Select row 2').should('be.checked');
|
|
289
|
-
|
|
290
|
-
cy.findByLabelText('Collapse 2').click();
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
it('displays the last column on several lines in compact mode when the isResponsive prop is set', () => {
|
|
295
|
-
mountListingResponsive(ListingVariant.compact);
|
|
296
|
-
|
|
297
|
-
cy.get('.MuiTable-root').should(
|
|
298
|
-
'have.css',
|
|
299
|
-
'grid-template-rows',
|
|
300
|
-
'30px 85px 85px 85px 85px 85px 85px 85px 85px 85px 85px'
|
|
301
|
-
);
|
|
302
|
-
|
|
303
|
-
cy.makeSnapshot();
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
it('displays the last column on several lines in extended mode when the isResponsive prop is set', () => {
|
|
307
|
-
mountListingResponsive(ListingVariant.extended);
|
|
308
|
-
|
|
309
|
-
cy.get('.MuiTable-root').should(
|
|
310
|
-
'have.css',
|
|
311
|
-
'grid-template-rows',
|
|
312
|
-
'38px 85px 85px 85px 85px 85px 85px 85px 85px 85px 85px'
|
|
313
|
-
);
|
|
314
|
-
|
|
315
|
-
cy.makeSnapshot();
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
it('toggles a checkbox in a clickable column without clicking the row', () => {
|
|
319
|
-
const onRowClick = cy.stub().as('rowClick');
|
|
320
|
-
|
|
321
|
-
cy.mount({
|
|
322
|
-
Component: (
|
|
323
|
-
<div style={{ height: '100vh' }}>
|
|
324
|
-
<Listing
|
|
325
|
-
columns={[
|
|
326
|
-
{
|
|
327
|
-
Component: CheckboxColumn,
|
|
328
|
-
clickable: true,
|
|
329
|
-
id: 'toggle',
|
|
330
|
-
label: 'Toggle',
|
|
331
|
-
type: ColumnType.component
|
|
332
|
-
}
|
|
333
|
-
]}
|
|
334
|
-
currentPage={1}
|
|
335
|
-
limit={10}
|
|
336
|
-
onRowClick={onRowClick}
|
|
337
|
-
rows={[{ id: 0, name: 'E0' }]}
|
|
338
|
-
totalRows={1}
|
|
339
|
-
/>
|
|
340
|
-
</div>
|
|
341
|
-
)
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
cy.findByLabelText('Toggle E0').click();
|
|
345
|
-
|
|
346
|
-
cy.findByLabelText('Toggle E0').should('be.checked');
|
|
347
|
-
cy.get('@rowClick').should('not.have.been.called');
|
|
348
|
-
});
|
|
349
|
-
});
|