@centreon/ui 26.12.1 → 26.12.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.
- package/package.json +6 -3
- package/public/mockServiceWorker.js +31 -8
- package/src/Dashboard/Dashboard.browser.test.tsx +107 -0
- package/src/Form/Form.browser.test.tsx +445 -0
- package/src/Form/Inputs/ExclusiveCheckboxGroup.browser.test.tsx +304 -0
- package/src/Form/Inputs/SegmentedButtons.browser.test.tsx +113 -0
- 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,74 +0,0 @@
|
|
|
1
|
-
import dayjs from 'dayjs';
|
|
2
|
-
import 'dayjs/locale/en';
|
|
3
|
-
|
|
4
|
-
import { Switch } from '@mui/material';
|
|
5
|
-
|
|
6
|
-
import { userAtom } from '@centreon/ui-context';
|
|
7
|
-
|
|
8
|
-
import localizedFormatPlugin from 'dayjs/plugin/localizedFormat';
|
|
9
|
-
import timezonePlugin from 'dayjs/plugin/timezone';
|
|
10
|
-
import utcPlugin from 'dayjs/plugin/utc';
|
|
11
|
-
import { createStore, Provider } from 'jotai';
|
|
12
|
-
|
|
13
|
-
import TimePeriod from './index';
|
|
14
|
-
import { retrievedUser } from './mockedData';
|
|
15
|
-
|
|
16
|
-
dayjs.extend(timezonePlugin);
|
|
17
|
-
dayjs.extend(utcPlugin);
|
|
18
|
-
dayjs.extend(localizedFormatPlugin);
|
|
19
|
-
|
|
20
|
-
const data = [
|
|
21
|
-
{
|
|
22
|
-
locale: 'en_US',
|
|
23
|
-
resolution: { height: 590, width: 500 },
|
|
24
|
-
timezone: 'Europe/Paris'
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
locale: 'en_US',
|
|
28
|
-
resolution: { height: 590, width: 200 },
|
|
29
|
-
timezone: 'Europe/Paris'
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
locale: 'en_US',
|
|
33
|
-
resolution: { height: 590, width: 1024 },
|
|
34
|
-
timezone: 'Europe/Paris'
|
|
35
|
-
}
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
data.forEach((item) => {
|
|
39
|
-
describe('Time period', () => {
|
|
40
|
-
const { height, width } = item.resolution;
|
|
41
|
-
beforeEach(() => {
|
|
42
|
-
cy.viewport(width, height);
|
|
43
|
-
|
|
44
|
-
const store = createStore();
|
|
45
|
-
|
|
46
|
-
store.set(userAtom, {
|
|
47
|
-
...retrievedUser,
|
|
48
|
-
locale: 'en_US',
|
|
49
|
-
timezone: 'Europe/Paris'
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
cy.mount({
|
|
53
|
-
Component: (
|
|
54
|
-
<Provider store={store}>
|
|
55
|
-
<TimePeriod renderExternalComponent={<Switch />} />
|
|
56
|
-
</Provider>
|
|
57
|
-
)
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it(`displays correctly the dates design when screen resolution is ${width}px`, () => {
|
|
62
|
-
cy.contains('1 day').should('be.visible');
|
|
63
|
-
cy.contains('7 days').should('be.visible');
|
|
64
|
-
cy.contains('31 days').should('be.visible');
|
|
65
|
-
cy.contains('From').should('be.visible');
|
|
66
|
-
cy.contains('To').should('be.visible');
|
|
67
|
-
|
|
68
|
-
cy.makeSnapshotWithCustomResolution({
|
|
69
|
-
resolution: { height, width },
|
|
70
|
-
title: `${width}px`
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
});
|
|
@@ -1,488 +0,0 @@
|
|
|
1
|
-
import { useLocaleDateTimeFormat } from '@centreon/ui';
|
|
2
|
-
import { ListingVariant, userAtom } from '@centreon/ui-context';
|
|
3
|
-
|
|
4
|
-
import { renderHook } from '@testing-library/react';
|
|
5
|
-
import dayjs from 'dayjs';
|
|
6
|
-
import localizedFormatPlugin from 'dayjs/plugin/localizedFormat';
|
|
7
|
-
import timezonePlugin from 'dayjs/plugin/timezone';
|
|
8
|
-
import utcPlugin from 'dayjs/plugin/utc';
|
|
9
|
-
import { createStore, Provider } from 'jotai';
|
|
10
|
-
import { equals } from 'ramda';
|
|
11
|
-
|
|
12
|
-
import DateTimePickerInput from './DateTimePickerInput';
|
|
13
|
-
import { CustomTimePeriodProperty } from './models';
|
|
14
|
-
|
|
15
|
-
dayjs.extend(timezonePlugin);
|
|
16
|
-
dayjs.extend(utcPlugin);
|
|
17
|
-
dayjs.extend(localizedFormatPlugin);
|
|
18
|
-
|
|
19
|
-
const retrievedUser = {
|
|
20
|
-
alias: 'Admin alias',
|
|
21
|
-
default_page: '/monitoring/resources',
|
|
22
|
-
is_export_button_enabled: true,
|
|
23
|
-
isExportButtonEnabled: true,
|
|
24
|
-
locale: 'fr_FR.UTF8',
|
|
25
|
-
name: 'Admin',
|
|
26
|
-
use_deprecated_pages: false,
|
|
27
|
-
user_interface_density: ListingVariant.compact
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const numberDaysInWeek = 7;
|
|
31
|
-
|
|
32
|
-
const days = [
|
|
33
|
-
'Sunday',
|
|
34
|
-
'Monday',
|
|
35
|
-
'Tuesday',
|
|
36
|
-
'Wednesday',
|
|
37
|
-
'Thursday',
|
|
38
|
-
'Friday',
|
|
39
|
-
'Saturday'
|
|
40
|
-
];
|
|
41
|
-
|
|
42
|
-
const months2023 = [
|
|
43
|
-
{
|
|
44
|
-
January: {
|
|
45
|
-
date: '2023-01-01T12:59:41.041Z',
|
|
46
|
-
firstDay: { day: days[0], indexDayInRowWeek: 0, value: 1 },
|
|
47
|
-
lastDay: { day: days[2], indexDayInRowWeek: 2, value: 31 },
|
|
48
|
-
numberWeeks: 5
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
February: {
|
|
53
|
-
date: '2023-02-01T12:59:41.041Z',
|
|
54
|
-
firstDay: { day: days[3], indexDayInRowWeek: 3, value: 1 },
|
|
55
|
-
lastDay: { day: days[2], indexDayInRowWeek: 2, value: 28 },
|
|
56
|
-
numberWeeks: 5
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
March: {
|
|
61
|
-
date: '2023-03-01T12:59:41.041Z',
|
|
62
|
-
firstDay: { day: days[3], indexDayInRowWeek: 3, value: 1 },
|
|
63
|
-
lastDay: { day: days[5], indexDayInRowWeek: 5, value: 31 },
|
|
64
|
-
numberWeeks: 5
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
April: {
|
|
69
|
-
date: '2023-04-01T12:59:41.041Z',
|
|
70
|
-
firstDay: { day: days[6], indexDayInRowWeek: 6, value: 1 },
|
|
71
|
-
lastDay: { day: days[0], indexDayInRowWeek: 0, value: 30 },
|
|
72
|
-
numberWeeks: 6
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
May: {
|
|
77
|
-
date: '2023-05-01T12:59:41.041Z',
|
|
78
|
-
firstDay: { day: days[1], indexDayInRowWeek: 1, value: 1 },
|
|
79
|
-
lastDay: { day: days[3], indexDayInRowWeek: 3, value: 31 },
|
|
80
|
-
numberWeeks: 5
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
June: {
|
|
85
|
-
date: '2023-06-01T12:59:41.041Z',
|
|
86
|
-
firstDay: { day: days[4], indexDayInRowWeek: 4, value: 1 },
|
|
87
|
-
lastDay: { day: days[5], indexDayInRowWeek: 5, value: 30 },
|
|
88
|
-
numberWeeks: 5
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
July: {
|
|
93
|
-
date: '2023-07-01T12:59:41.041Z',
|
|
94
|
-
firstDay: { day: days[6], indexDayInRowWeek: 6, value: 1 },
|
|
95
|
-
lastDay: { day: days[1], indexDayInRowWeek: 1, value: 31 },
|
|
96
|
-
numberWeeks: 6
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
August: {
|
|
101
|
-
date: '2023-08-01T12:59:41.041Z',
|
|
102
|
-
firstDay: { day: days[2], indexDayInRowWeek: 2, value: 1 },
|
|
103
|
-
lastDay: { day: days[4], indexDayInRowWeek: 4, value: 31 },
|
|
104
|
-
numberWeeks: 5
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
September: {
|
|
109
|
-
date: '2023-09-01T12:59:41.041Z',
|
|
110
|
-
firstDay: { day: days[5], indexDayInRowWeek: 5, value: 1 },
|
|
111
|
-
lastDay: { day: days[6], indexDayInRowWeek: 6, value: 30 },
|
|
112
|
-
numberWeeks: 5
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
October: {
|
|
117
|
-
date: '2023-10-01T12:59:41.041Z',
|
|
118
|
-
firstDay: { day: days[0], indexDayInRowWeek: 0, value: 1 },
|
|
119
|
-
lastDay: { day: days[2], indexDayInRowWeek: 2, value: 31 },
|
|
120
|
-
numberWeeks: 5
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
November: {
|
|
125
|
-
date: '2023-11-01T12:59:41.041Z',
|
|
126
|
-
firstDay: { day: days[3], indexDayInRowWeek: 3, value: 1 },
|
|
127
|
-
lastDay: { day: days[4], indexDayInRowWeek: 4, value: 30 },
|
|
128
|
-
numberWeeks: 5
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
December: {
|
|
133
|
-
date: '2023-12-01T12:59:41.041Z',
|
|
134
|
-
firstDay: { day: days[5], indexDayInRowWeek: 5, value: 1 },
|
|
135
|
-
lastDay: { day: days[0], indexDayInRowWeek: 0, value: 31 },
|
|
136
|
-
numberWeeks: 6
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
];
|
|
140
|
-
|
|
141
|
-
const month2023Reverse = [
|
|
142
|
-
{
|
|
143
|
-
December: {
|
|
144
|
-
date: '2023-12-01T12:59:41.041Z',
|
|
145
|
-
firstDay: { day: days[5], indexDayInRowWeek: 5, value: 1 },
|
|
146
|
-
lastDay: { day: days[0], indexDayInRowWeek: 0, value: 31 },
|
|
147
|
-
numberWeeks: 6
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
November: {
|
|
152
|
-
date: '2023-11-01T12:59:41.041Z',
|
|
153
|
-
firstDay: { day: days[3], indexDayInRowWeek: 3, value: 1 },
|
|
154
|
-
lastDay: { day: days[4], indexDayInRowWeek: 4, value: 30 },
|
|
155
|
-
numberWeeks: 5
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
October: {
|
|
160
|
-
date: '2023-10-01T12:59:41.041Z',
|
|
161
|
-
firstDay: { day: days[0], indexDayInRowWeek: 0, value: 1 },
|
|
162
|
-
lastDay: { day: days[2], indexDayInRowWeek: 2, value: 31 },
|
|
163
|
-
numberWeeks: 5
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
September: {
|
|
168
|
-
date: '2023-09-01T12:59:41.041Z',
|
|
169
|
-
firstDay: { day: days[5], indexDayInRowWeek: 5, value: 1 },
|
|
170
|
-
lastDay: { day: days[6], indexDayInRowWeek: 6, value: 30 },
|
|
171
|
-
numberWeeks: 5
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
August: {
|
|
176
|
-
date: '2023-08-01T12:59:41.041Z',
|
|
177
|
-
firstDay: { day: days[2], indexDayInRowWeek: 2, value: 1 },
|
|
178
|
-
lastDay: { day: days[4], indexDayInRowWeek: 4, value: 31 },
|
|
179
|
-
numberWeeks: 5
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
July: {
|
|
184
|
-
date: '2023-07-01T12:59:41.041Z',
|
|
185
|
-
firstDay: { day: days[6], indexDayInRowWeek: 6, value: 1 },
|
|
186
|
-
lastDay: { day: days[1], indexDayInRowWeek: 1, value: 31 },
|
|
187
|
-
numberWeeks: 6
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
June: {
|
|
192
|
-
date: '2023-06-01T12:59:41.041Z',
|
|
193
|
-
firstDay: { day: days[4], indexDayInRowWeek: 4, value: 1 },
|
|
194
|
-
lastDay: { day: days[5], indexDayInRowWeek: 5, value: 30 },
|
|
195
|
-
numberWeeks: 5
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
May: {
|
|
200
|
-
date: '2023-05-01T12:59:41.041Z',
|
|
201
|
-
firstDay: { day: days[1], indexDayInRowWeek: 1, value: 1 },
|
|
202
|
-
lastDay: { day: days[3], indexDayInRowWeek: 3, value: 31 },
|
|
203
|
-
numberWeeks: 5
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
April: {
|
|
208
|
-
date: '2023-04-01T12:59:41.041Z',
|
|
209
|
-
firstDay: { day: days[6], indexDayInRowWeek: 6, value: 1 },
|
|
210
|
-
lastDay: { day: days[0], indexDayInRowWeek: 0, value: 30 },
|
|
211
|
-
numberWeeks: 6
|
|
212
|
-
}
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
March: {
|
|
216
|
-
date: '2023-03-01T12:59:41.041Z',
|
|
217
|
-
firstDay: { day: days[3], indexDayInRowWeek: 3, value: 1 },
|
|
218
|
-
lastDay: { day: days[5], indexDayInRowWeek: 5, value: 31 },
|
|
219
|
-
numberWeeks: 5
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
February: {
|
|
224
|
-
date: '2023-02-01T12:59:41.041Z',
|
|
225
|
-
firstDay: { day: days[3], indexDayInRowWeek: 3, value: 1 },
|
|
226
|
-
lastDay: { day: days[2], indexDayInRowWeek: 2, value: 28 },
|
|
227
|
-
numberWeeks: 5
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
January: {
|
|
232
|
-
date: '2023-01-01T12:59:41.041Z',
|
|
233
|
-
firstDay: { day: days[0], indexDayInRowWeek: 0, value: 1 },
|
|
234
|
-
lastDay: { day: days[2], indexDayInRowWeek: 2, value: 31 },
|
|
235
|
-
numberWeeks: 5
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
];
|
|
239
|
-
|
|
240
|
-
const testData = [
|
|
241
|
-
{
|
|
242
|
-
button: 'Next month',
|
|
243
|
-
data: months2023,
|
|
244
|
-
initialDate: '2023-01-01T12:59:41.041Z',
|
|
245
|
-
timezone: 'Europe/Paris'
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
button: 'Previous month',
|
|
249
|
-
data: month2023Reverse,
|
|
250
|
-
initialDate: '2023-12-01T12:59:41.041Z',
|
|
251
|
-
timezone: 'Europe/Paris'
|
|
252
|
-
}
|
|
253
|
-
];
|
|
254
|
-
|
|
255
|
-
enum ButtonCalendar {
|
|
256
|
-
NMONTH = 'Next month',
|
|
257
|
-
PMONTH = 'Previous month'
|
|
258
|
-
}
|
|
259
|
-
interface GetPreviousNextMonth {
|
|
260
|
-
currentMonth: string;
|
|
261
|
-
labelButton: string;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
const getNextMonth = ({
|
|
265
|
-
currentMonth,
|
|
266
|
-
labelButton
|
|
267
|
-
}: GetPreviousNextMonth): Cypress.Chainable | null => {
|
|
268
|
-
if (equals(currentMonth, 'December')) {
|
|
269
|
-
return null;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
return cy.get(`[aria-label="${labelButton}"]`).click();
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
const getPreviousMonth = ({
|
|
276
|
-
currentMonth,
|
|
277
|
-
labelButton
|
|
278
|
-
}: GetPreviousNextMonth): Cypress.Chainable | null => {
|
|
279
|
-
if (equals(currentMonth, 'January')) {
|
|
280
|
-
return null;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
return cy.get(`[aria-label="${labelButton}"]`).click();
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
const checkIfDuplicateExists = (arr: Array<unknown>): boolean => {
|
|
287
|
-
return new Set(arr).size !== arr.length;
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
testData.forEach((item) => {
|
|
291
|
-
describe(`DateTimePicker ${item.button}`, () => {
|
|
292
|
-
beforeEach(() => {
|
|
293
|
-
cy.viewport('macbook-13');
|
|
294
|
-
|
|
295
|
-
const store = createStore();
|
|
296
|
-
store.set(userAtom, {
|
|
297
|
-
...retrievedUser,
|
|
298
|
-
locale: 'en_US',
|
|
299
|
-
timezone: item.timezone
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
cy.mount({
|
|
303
|
-
Component: (
|
|
304
|
-
<Provider store={store}>
|
|
305
|
-
<DateTimePickerInput
|
|
306
|
-
changeDate={cy.stub()}
|
|
307
|
-
date={new Date(item.initialDate)}
|
|
308
|
-
property={CustomTimePeriodProperty.start}
|
|
309
|
-
/>
|
|
310
|
-
</Provider>
|
|
311
|
-
)
|
|
312
|
-
});
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
it(`displays the correct number of days for the current month when the ${item.button} button is clicked`, () => {
|
|
316
|
-
cy.get('button').click();
|
|
317
|
-
item.data.forEach((element) => {
|
|
318
|
-
const { lastDay } = Object.values(element)[0];
|
|
319
|
-
|
|
320
|
-
cy.get('[role="rowgroup"]').children().as('listWeeks');
|
|
321
|
-
cy.get('@listWeeks').children('button').as('days');
|
|
322
|
-
cy.get('@days').should('have.length', lastDay.value);
|
|
323
|
-
|
|
324
|
-
const currentMonth = Object.keys(element)[0];
|
|
325
|
-
|
|
326
|
-
if (equals(item.button, ButtonCalendar.PMONTH)) {
|
|
327
|
-
getPreviousMonth({ currentMonth, labelButton: item.button });
|
|
328
|
-
} else {
|
|
329
|
-
getNextMonth({ currentMonth, labelButton: item.button });
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
it(`does not duplicate days in any of the month in the year when the ${item.button} button is clicked`, () => {
|
|
335
|
-
cy.get('button').click();
|
|
336
|
-
item.data.forEach((element) => {
|
|
337
|
-
const daysInCurrentMonth: Array<string> = [];
|
|
338
|
-
cy.get('[role="rowgroup"]').first().children().as('listWeeks');
|
|
339
|
-
cy.get('@listWeeks').children('button').as('days');
|
|
340
|
-
|
|
341
|
-
cy.get('@days')
|
|
342
|
-
.each((day) => daysInCurrentMonth.push(day.text()))
|
|
343
|
-
.as('currentDays');
|
|
344
|
-
|
|
345
|
-
cy.get('@currentDays').then(() => {
|
|
346
|
-
const isDuplicateExist = checkIfDuplicateExists(daysInCurrentMonth);
|
|
347
|
-
|
|
348
|
-
return expect(isDuplicateExist).to.be.false;
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
const currentMonth = Object.keys(element)[0];
|
|
352
|
-
if (equals(item.button, ButtonCalendar.PMONTH)) {
|
|
353
|
-
getPreviousMonth({ currentMonth, labelButton: item.button });
|
|
354
|
-
} else {
|
|
355
|
-
getNextMonth({ currentMonth, labelButton: item.button });
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
it(`displays the first day as the start of the week when the ${item.button} button is clicked`, () => {
|
|
361
|
-
cy.get('button').click();
|
|
362
|
-
|
|
363
|
-
item.data.forEach((element) => {
|
|
364
|
-
const { firstDay, numberWeeks } = Object.values(element)[0];
|
|
365
|
-
|
|
366
|
-
cy.get('[role="rowgroup"]').children().as('listWeeks');
|
|
367
|
-
|
|
368
|
-
cy.get('@listWeeks').should('have.length', numberWeeks);
|
|
369
|
-
cy.get('@listWeeks').eq(0).as('firstWeek');
|
|
370
|
-
cy.get('@firstWeek').children().as('listDaysInFirstWeek');
|
|
371
|
-
|
|
372
|
-
cy.get('@listDaysInFirstWeek').should('have.length', numberDaysInWeek);
|
|
373
|
-
cy.get('@listDaysInFirstWeek')
|
|
374
|
-
.eq(firstDay.indexDayInRowWeek)
|
|
375
|
-
.as('firstDayInWeek');
|
|
376
|
-
cy.get('@firstDayInWeek').contains(firstDay.value);
|
|
377
|
-
|
|
378
|
-
const currentMonth = Object.keys(element)[0];
|
|
379
|
-
if (equals(item.button, ButtonCalendar.PMONTH)) {
|
|
380
|
-
getPreviousMonth({ currentMonth, labelButton: item.button });
|
|
381
|
-
} else {
|
|
382
|
-
getNextMonth({ currentMonth, labelButton: item.button });
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
it(`displays the last day as the end of the week when the ${item.button} button is clicked`, () => {
|
|
388
|
-
cy.get('button').click();
|
|
389
|
-
|
|
390
|
-
item.data.forEach((element) => {
|
|
391
|
-
const { lastDay, numberWeeks } = Object.values(element)[0];
|
|
392
|
-
|
|
393
|
-
cy.get('[role="rowgroup"]').children().as('listWeeks');
|
|
394
|
-
|
|
395
|
-
cy.get('@listWeeks').should('have.length', numberWeeks);
|
|
396
|
-
|
|
397
|
-
cy.get('@listWeeks')
|
|
398
|
-
.eq(numberWeeks - 1)
|
|
399
|
-
.as('lastWeek');
|
|
400
|
-
|
|
401
|
-
cy.get('@lastWeek').children().as('listDaysInLastWeek');
|
|
402
|
-
cy.get('@listDaysInLastWeek').should('have.length', numberDaysInWeek);
|
|
403
|
-
|
|
404
|
-
cy.get('@listDaysInLastWeek')
|
|
405
|
-
.eq(lastDay.indexDayInRowWeek)
|
|
406
|
-
.as('lastDayInWeek');
|
|
407
|
-
cy.get('@lastDayInWeek').contains(lastDay.value);
|
|
408
|
-
const currentMonth = Object.keys(element)[0];
|
|
409
|
-
if (equals(item.button, ButtonCalendar.PMONTH)) {
|
|
410
|
-
getPreviousMonth({ currentMonth, labelButton: item.button });
|
|
411
|
-
} else {
|
|
412
|
-
getNextMonth({ currentMonth, labelButton: item.button });
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
it(`displays the month and the year in the calendar's header when the ${item.button} button is clicked`, () => {
|
|
418
|
-
cy.get('button').click();
|
|
419
|
-
const { result } = renderHook(() => useLocaleDateTimeFormat());
|
|
420
|
-
|
|
421
|
-
item.data.forEach((element) => {
|
|
422
|
-
const { date } = Object.values(element)[0];
|
|
423
|
-
|
|
424
|
-
const { format } = result.current;
|
|
425
|
-
const monthAndYear = format({
|
|
426
|
-
date: dayjs(date).tz(item.timezone),
|
|
427
|
-
formatString: 'MMMM YYYY'
|
|
428
|
-
});
|
|
429
|
-
cy.contains(monthAndYear);
|
|
430
|
-
const currentMonth = Object.keys(element)[0];
|
|
431
|
-
if (equals(item.button, ButtonCalendar.PMONTH)) {
|
|
432
|
-
getPreviousMonth({ currentMonth, labelButton: item.button });
|
|
433
|
-
} else {
|
|
434
|
-
getNextMonth({ currentMonth, labelButton: item.button });
|
|
435
|
-
}
|
|
436
|
-
});
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
it(`displays the correct day name on calendar's header when the ${item.button} button is clicked`, () => {
|
|
440
|
-
cy.get('button').click();
|
|
441
|
-
const { result } = renderHook(() => useLocaleDateTimeFormat());
|
|
442
|
-
|
|
443
|
-
item.data.forEach((element) => {
|
|
444
|
-
const { date } = Object.values(element)[0];
|
|
445
|
-
const dateByTimeZone = dayjs(date).tz(item.timezone);
|
|
446
|
-
const firstDay = dateByTimeZone.isUTC()
|
|
447
|
-
? dateByTimeZone.utc().startOf('month').startOf('week')
|
|
448
|
-
: dateByTimeZone.startOf('month').startOf('week');
|
|
449
|
-
|
|
450
|
-
const { format } = result.current;
|
|
451
|
-
const daysArray = [0, 1, 2, 3, 4, 5, 6].map((diff) =>
|
|
452
|
-
format({
|
|
453
|
-
date: firstDay.add(diff, 'day'),
|
|
454
|
-
formatString: 'dd'
|
|
455
|
-
})
|
|
456
|
-
);
|
|
457
|
-
daysArray.forEach((day) => {
|
|
458
|
-
cy.contains(day.toUpperCase());
|
|
459
|
-
});
|
|
460
|
-
const currentMonth = Object.keys(element)[0];
|
|
461
|
-
if (equals(item.button, ButtonCalendar.PMONTH)) {
|
|
462
|
-
getPreviousMonth({ currentMonth, labelButton: item.button });
|
|
463
|
-
} else {
|
|
464
|
-
getNextMonth({ currentMonth, labelButton: item.button });
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
it(`displays the calendar for the timezone ${item.timezone} when the ${item.button} button is clicked`, () => {
|
|
470
|
-
cy.get('button').click();
|
|
471
|
-
|
|
472
|
-
item.data.forEach((element) => {
|
|
473
|
-
const currentMonth = Object.keys(element)[0];
|
|
474
|
-
if (equals(item.button, ButtonCalendar.PMONTH)) {
|
|
475
|
-
getPreviousMonth({ currentMonth, labelButton: item.button });
|
|
476
|
-
} else {
|
|
477
|
-
getNextMonth({ currentMonth, labelButton: item.button });
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
cy.makeSnapshot(
|
|
481
|
-
`calendar-${item.timezone}-${
|
|
482
|
-
Object.keys(element)[0]
|
|
483
|
-
}-when-clicking-on-${item.button}`
|
|
484
|
-
);
|
|
485
|
-
});
|
|
486
|
-
});
|
|
487
|
-
});
|
|
488
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import FluidTypography from '.';
|
|
2
|
-
|
|
3
|
-
const initialize = ({ width, min, max, pref }): void => {
|
|
4
|
-
cy.viewport(width, 590);
|
|
5
|
-
|
|
6
|
-
cy.mount({
|
|
7
|
-
Component: (
|
|
8
|
-
<FluidTypography max={max} min={min} pref={pref} text="Unreachable" />
|
|
9
|
-
)
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
describe('FluidTypography', () => {
|
|
14
|
-
[500, 300, 150].forEach((width) => {
|
|
15
|
-
Object.entries({ max: '80px', min: '30px', pref: 10 }).forEach(
|
|
16
|
-
([key, value]) => {
|
|
17
|
-
it(`displays the text when the viewport is ${width}px and the ${key} is ${value}`, () => {
|
|
18
|
-
initialize({ [key]: value, width });
|
|
19
|
-
|
|
20
|
-
cy.contains('Unreachable').should('be.visible');
|
|
21
|
-
|
|
22
|
-
cy.matchImageSnapshot();
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import SnackbarProvider from '../../Snackbar/SnackbarProvider';
|
|
2
|
-
import TestQueryProvider from '../TestQueryProvider';
|
|
3
|
-
import useMutationQuery, { Method } from '.';
|
|
4
|
-
|
|
5
|
-
const TestComponent = (props) => {
|
|
6
|
-
const mutation = useMutationQuery({
|
|
7
|
-
...props,
|
|
8
|
-
getEndpoint: () => '/endpoint'
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<button
|
|
13
|
-
onClick={() =>
|
|
14
|
-
mutation.mutateAsync({ payload: { a: 'a', b: 2, c: ['arr', 'ay'] } })
|
|
15
|
-
}
|
|
16
|
-
type="button"
|
|
17
|
-
>
|
|
18
|
-
Send
|
|
19
|
-
</button>
|
|
20
|
-
);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const initialize = ({ mutationProps, isError = false }) => {
|
|
24
|
-
cy.interceptAPIRequest({
|
|
25
|
-
alias: 'mutateEndpoint',
|
|
26
|
-
method: mutationProps.method,
|
|
27
|
-
path: './api/latest/endpoint',
|
|
28
|
-
response: isError
|
|
29
|
-
? {
|
|
30
|
-
message: 'custom error message'
|
|
31
|
-
}
|
|
32
|
-
: undefined,
|
|
33
|
-
statusCode: isError ? 400 : 204
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
cy.mount({
|
|
37
|
-
Component: (
|
|
38
|
-
<SnackbarProvider>
|
|
39
|
-
<TestQueryProvider>
|
|
40
|
-
<TestComponent {...mutationProps} />
|
|
41
|
-
</TestQueryProvider>
|
|
42
|
-
</SnackbarProvider>
|
|
43
|
-
)
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
describe('useMutationQuery', () => {
|
|
48
|
-
it('sends data to an endpoint', () => {
|
|
49
|
-
initialize({
|
|
50
|
-
mutationProps: {
|
|
51
|
-
getEndpoint: () => '/endpoint',
|
|
52
|
-
method: Method.POST
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
cy.get('button').click();
|
|
57
|
-
|
|
58
|
-
cy.waitForRequest('@mutateEndpoint').then(({ request }) => {
|
|
59
|
-
expect(request.method).to.equal('POST');
|
|
60
|
-
expect(request.body).to.deep.equal({ a: 'a', b: 2, c: ['arr', 'ay'] });
|
|
61
|
-
expect(request.headers.get('content-type')).to.equal('application/json');
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("shows an error from the API via the Snackbar and inside the browser's console when posting data to an endpoint", () => {
|
|
66
|
-
initialize({
|
|
67
|
-
isError: true,
|
|
68
|
-
mutationProps: {
|
|
69
|
-
getEndpoint: () => '/endpoint',
|
|
70
|
-
method: Method.POST
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
cy.get('button').click();
|
|
75
|
-
|
|
76
|
-
cy.contains('custom error message').should('be.visible');
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('does not show any message via the Snackbar when the httpCodesBypassErrorSnackbar is passed when posting data to an API', () => {
|
|
80
|
-
initialize({
|
|
81
|
-
isError: true,
|
|
82
|
-
mutationProps: {
|
|
83
|
-
getEndpoint: () => '/endpoint',
|
|
84
|
-
httpCodesBypassErrorSnackbar: [400],
|
|
85
|
-
method: Method.POST
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
cy.get('button').click();
|
|
90
|
-
|
|
91
|
-
cy.contains('custom error message').should('not.exist');
|
|
92
|
-
});
|
|
93
|
-
});
|