@centreon/js-config 23.10.37 → 23.10.39
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/cypress/component/commands.tsx +11 -6
- package/cypress/component/configuration.js +11 -9
- package/cypress/component/enableVisualTesting.ts +1 -1
- package/cypress/e2e/commands/monitoring.ts +75 -0
- package/cypress/e2e/commands.ts +202 -32
- package/cypress/e2e/configuration.ts +18 -29
- package/cypress/e2e/esbuild-preprocessor.ts +26 -0
- package/cypress/e2e/plugins.ts +21 -119
- package/cypress/e2e/reporter-config.js +13 -0
- package/cypress/e2e/tasks.ts +105 -0
- package/eslint/base.typescript.eslintrc.js +15 -3
- package/eslint/lambda/typescript.eslintrc.js +48 -0
- package/jest/index.js +5 -1
- package/jest/lambda/typescript.js +49 -0
- package/package.json +17 -5
- package/tsconfig/index.json +5 -4
- package/tsconfig/lambda/tsconfig.json +14 -0
- package/webpack/base/globalConfig.js +71 -0
- package/webpack/base/index.js +14 -57
|
@@ -4,7 +4,7 @@ import React from 'react';
|
|
|
4
4
|
import { mount } from 'cypress/react18';
|
|
5
5
|
import { equals, isNil } from 'ramda';
|
|
6
6
|
|
|
7
|
-
import { Box } from '@mui/material';
|
|
7
|
+
import { Box, CssBaseline } from '@mui/material';
|
|
8
8
|
|
|
9
9
|
import { ThemeProvider } from '@centreon/ui';
|
|
10
10
|
|
|
@@ -24,7 +24,7 @@ export enum Method {
|
|
|
24
24
|
PUT = 'PUT'
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
Cypress.Commands.add('mount', ({ Component, options }) => {
|
|
27
|
+
Cypress.Commands.add('mount', ({ Component, options = {} }) => {
|
|
28
28
|
const wrapped = (
|
|
29
29
|
<ThemeProvider>
|
|
30
30
|
<Box
|
|
@@ -36,11 +36,10 @@ Cypress.Commands.add('mount', ({ Component, options }) => {
|
|
|
36
36
|
>
|
|
37
37
|
{Component}
|
|
38
38
|
</Box>
|
|
39
|
+
<CssBaseline />
|
|
39
40
|
</ThemeProvider>
|
|
40
41
|
);
|
|
41
42
|
|
|
42
|
-
document.getElementsByTagName('body')[0].setAttribute('style', 'margin:0px');
|
|
43
|
-
|
|
44
43
|
return mount(wrapped, options);
|
|
45
44
|
});
|
|
46
45
|
|
|
@@ -128,6 +127,11 @@ Cypress.Commands.add(
|
|
|
128
127
|
}
|
|
129
128
|
);
|
|
130
129
|
|
|
130
|
+
Cypress.Commands.add('makeSnapshot', (title?: string) => {
|
|
131
|
+
cy.viewport(1280, 590);
|
|
132
|
+
cy.matchImageSnapshot(title);
|
|
133
|
+
});
|
|
134
|
+
|
|
131
135
|
declare global {
|
|
132
136
|
namespace Cypress {
|
|
133
137
|
interface Chainable {
|
|
@@ -135,8 +139,9 @@ declare global {
|
|
|
135
139
|
props: InterceptAPIRequestProps<T>
|
|
136
140
|
) => Cypress.Chainable;
|
|
137
141
|
interceptRequest: (method, path, mock, alias) => Cypress.Chainable;
|
|
138
|
-
|
|
139
|
-
|
|
142
|
+
makeSnapshot: (title?: string) => void;
|
|
143
|
+
mount: ({ Component, options }: MountProps) => Cypress.Chainable;
|
|
144
|
+
moveSortableElement: ({ element, direction }) => void;
|
|
140
145
|
moveSortableElementUsingAriaLabel: ({ ariaLabel, direction }) => void;
|
|
141
146
|
waitForRequest: (alias) => Cypress.Chainable;
|
|
142
147
|
}
|
|
@@ -4,28 +4,30 @@ const {
|
|
|
4
4
|
addMatchImageSnapshotPlugin
|
|
5
5
|
} = require('@simonsmith/cypress-image-snapshot/plugin');
|
|
6
6
|
|
|
7
|
-
module.exports = ({
|
|
7
|
+
module.exports = ({
|
|
8
|
+
webpackConfig,
|
|
9
|
+
cypressFolder,
|
|
10
|
+
specPattern,
|
|
11
|
+
env,
|
|
12
|
+
useVite = false,
|
|
13
|
+
excludeSpecPattern
|
|
14
|
+
}) => {
|
|
8
15
|
const mainCypressFolder = cypressFolder || 'cypress';
|
|
9
16
|
|
|
10
17
|
return defineConfig({
|
|
11
18
|
component: {
|
|
12
19
|
devServer: {
|
|
13
|
-
bundler: 'webpack',
|
|
20
|
+
bundler: useVite ? 'vite' : 'webpack',
|
|
14
21
|
framework: 'react',
|
|
15
22
|
webpackConfig
|
|
16
23
|
},
|
|
24
|
+
excludeSpecPattern,
|
|
17
25
|
setupNodeEvents: (on, config) => {
|
|
18
26
|
addMatchImageSnapshotPlugin(on, config);
|
|
19
27
|
|
|
20
28
|
on('before:browser:launch', (browser, launchOptions) => {
|
|
21
29
|
if (browser.name === 'chrome' && browser.isHeadless) {
|
|
22
|
-
launchOptions.args
|
|
23
|
-
if (arg === '--headless') {
|
|
24
|
-
return '--headless=new';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return arg;
|
|
28
|
-
});
|
|
30
|
+
launchOptions.args.push('--headless=new');
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
return launchOptions;
|
|
@@ -13,7 +13,7 @@ const enableVisualTesting = (cypressFolder = 'cypress'): void => {
|
|
|
13
13
|
capture: 'viewport',
|
|
14
14
|
customDiffConfig: { threshold: 0.01 },
|
|
15
15
|
customSnapshotsDir: `${cypressFolder}/visual-testing-snapshots`,
|
|
16
|
-
failureThreshold: 0.
|
|
16
|
+
failureThreshold: 0.07,
|
|
17
17
|
failureThresholdType: 'percent'
|
|
18
18
|
});
|
|
19
19
|
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
|
+
|
|
3
|
+
const apiBase = '/centreon/api';
|
|
4
|
+
const apiActionV1 = `${apiBase}/index.php`;
|
|
5
|
+
|
|
6
|
+
const getStatusNumberFromString = (status: string): number => {
|
|
7
|
+
const statuses = {
|
|
8
|
+
critical: '2',
|
|
9
|
+
down: '1',
|
|
10
|
+
ok: '0',
|
|
11
|
+
unknown: '3',
|
|
12
|
+
unreachable: '2',
|
|
13
|
+
up: '0',
|
|
14
|
+
warning: '1'
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
if (status in statuses) {
|
|
18
|
+
return statuses[status];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
throw new Error(`Status ${status} does not exist`);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
interface SubmitResult {
|
|
25
|
+
host: string;
|
|
26
|
+
output: string;
|
|
27
|
+
perfdata?: string | null;
|
|
28
|
+
service?: string | null;
|
|
29
|
+
status: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
Cypress.Commands.add(
|
|
33
|
+
'submitResults',
|
|
34
|
+
(results: Array<SubmitResult>): Cypress.Chainable => {
|
|
35
|
+
results.forEach(
|
|
36
|
+
({ host, output, perfdata = '', service = null, status }) => {
|
|
37
|
+
const timestampNow = Math.floor(Date.now() / 1000) - 15;
|
|
38
|
+
const updatetime = timestampNow.toString();
|
|
39
|
+
|
|
40
|
+
const result = {
|
|
41
|
+
host,
|
|
42
|
+
output,
|
|
43
|
+
perfdata,
|
|
44
|
+
service,
|
|
45
|
+
status: getStatusNumberFromString(status),
|
|
46
|
+
updatetime
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
cy.request({
|
|
50
|
+
body: {
|
|
51
|
+
results: [result]
|
|
52
|
+
},
|
|
53
|
+
headers: {
|
|
54
|
+
'Content-Type': 'application/json',
|
|
55
|
+
'centreon-auth-token': window.localStorage.getItem('userTokenApiV1')
|
|
56
|
+
},
|
|
57
|
+
method: 'POST',
|
|
58
|
+
url: `${apiActionV1}?action=submit&object=centreon_submit_results`
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
return cy.wrap(null);
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
declare global {
|
|
68
|
+
namespace Cypress {
|
|
69
|
+
interface Chainable {
|
|
70
|
+
submitResults: (props: Array<SubmitResult>) => Cypress.Chainable;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export {};
|
package/cypress/e2e/commands.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
2
|
|
|
3
3
|
import './commands/configuration';
|
|
4
|
+
import './commands/monitoring';
|
|
5
|
+
|
|
6
|
+
import installLogsCollector from 'cypress-terminal-report/src/installLogsCollector';
|
|
7
|
+
|
|
8
|
+
installLogsCollector();
|
|
4
9
|
|
|
5
10
|
const apiLoginV2 = '/centreon/authentication/providers/configurations/local';
|
|
6
11
|
|
|
@@ -23,7 +28,7 @@ Cypress.Commands.add('getWebVersion', (): Cypress.Chainable => {
|
|
|
23
28
|
|
|
24
29
|
Cypress.Commands.add('getIframeBody', (): Cypress.Chainable => {
|
|
25
30
|
return cy
|
|
26
|
-
.get('iframe#main-content')
|
|
31
|
+
.get('iframe#main-content', { timeout: 10000 })
|
|
27
32
|
.its('0.contentDocument.body')
|
|
28
33
|
.should('not.be.empty')
|
|
29
34
|
.then(cy.wrap);
|
|
@@ -39,6 +44,13 @@ Cypress.Commands.add(
|
|
|
39
44
|
}
|
|
40
45
|
);
|
|
41
46
|
|
|
47
|
+
Cypress.Commands.add(
|
|
48
|
+
'clickSubRootMenuItem',
|
|
49
|
+
(page: string): Cypress.Chainable => {
|
|
50
|
+
return cy.get('div[data-cy="collapse"]').eq(1).contains(page).click();
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
|
|
42
54
|
interface NavigateToProps {
|
|
43
55
|
page: string;
|
|
44
56
|
rootItemNumber: number;
|
|
@@ -51,8 +63,13 @@ Cypress.Commands.add(
|
|
|
51
63
|
if (subMenu) {
|
|
52
64
|
cy.hoverRootMenuItem(rootItemNumber)
|
|
53
65
|
.contains(subMenu)
|
|
54
|
-
.trigger('mouseover'
|
|
55
|
-
|
|
66
|
+
.trigger('mouseover')
|
|
67
|
+
.get('.MuiCollapse-wrapper')
|
|
68
|
+
.find('div[data-cy="collapse"]')
|
|
69
|
+
.should('be.visible')
|
|
70
|
+
.and('contain', page);
|
|
71
|
+
|
|
72
|
+
cy.clickSubRootMenuItem(page);
|
|
56
73
|
|
|
57
74
|
return;
|
|
58
75
|
}
|
|
@@ -85,29 +102,41 @@ Cypress.Commands.add(
|
|
|
85
102
|
|
|
86
103
|
interface CopyFromContainerProps {
|
|
87
104
|
destination: string;
|
|
105
|
+
name?: string;
|
|
88
106
|
source: string;
|
|
89
107
|
}
|
|
90
108
|
|
|
91
109
|
Cypress.Commands.add(
|
|
92
110
|
'copyFromContainer',
|
|
93
|
-
(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
111
|
+
(
|
|
112
|
+
{
|
|
113
|
+
name = Cypress.env('dockerName'),
|
|
114
|
+
source,
|
|
115
|
+
destination
|
|
116
|
+
}: CopyFromContainerProps,
|
|
117
|
+
options?: Partial<Cypress.ExecOptions>
|
|
118
|
+
) => {
|
|
119
|
+
return cy.exec(`docker cp ${name}:${source} "${destination}"`, options);
|
|
97
120
|
}
|
|
98
121
|
);
|
|
99
122
|
|
|
100
123
|
interface CopyToContainerProps {
|
|
101
124
|
destination: string;
|
|
125
|
+
name?: string;
|
|
102
126
|
source: string;
|
|
103
127
|
}
|
|
104
128
|
|
|
105
129
|
Cypress.Commands.add(
|
|
106
130
|
'copyToContainer',
|
|
107
|
-
(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
131
|
+
(
|
|
132
|
+
{
|
|
133
|
+
name = Cypress.env('dockerName'),
|
|
134
|
+
source,
|
|
135
|
+
destination
|
|
136
|
+
}: CopyToContainerProps,
|
|
137
|
+
options?: Partial<Cypress.ExecOptions>
|
|
138
|
+
) => {
|
|
139
|
+
return cy.exec(`docker cp ${source} ${name}:${destination}`, options);
|
|
111
140
|
}
|
|
112
141
|
);
|
|
113
142
|
|
|
@@ -118,7 +147,7 @@ interface LoginByTypeOfUserProps {
|
|
|
118
147
|
|
|
119
148
|
Cypress.Commands.add(
|
|
120
149
|
'loginByTypeOfUser',
|
|
121
|
-
({ jsonName, loginViaApi }): Cypress.Chainable => {
|
|
150
|
+
({ jsonName = 'admin', loginViaApi = false }): Cypress.Chainable => {
|
|
122
151
|
if (loginViaApi) {
|
|
123
152
|
return cy
|
|
124
153
|
.fixture(`users/${jsonName}.json`)
|
|
@@ -135,12 +164,15 @@ Cypress.Commands.add(
|
|
|
135
164
|
.visit(`${Cypress.config().baseUrl}`)
|
|
136
165
|
.wait('@getNavigationList');
|
|
137
166
|
}
|
|
167
|
+
|
|
138
168
|
cy.visit(`${Cypress.config().baseUrl}`)
|
|
139
169
|
.fixture(`users/${jsonName}.json`)
|
|
140
170
|
.then((credential) => {
|
|
141
|
-
cy.getByLabel({ label: 'Alias', tag: 'input' }).type(
|
|
171
|
+
cy.getByLabel({ label: 'Alias', tag: 'input' }).type(
|
|
172
|
+
`{selectAll}{backspace}${credential.login}`
|
|
173
|
+
);
|
|
142
174
|
cy.getByLabel({ label: 'Password', tag: 'input' }).type(
|
|
143
|
-
credential.password
|
|
175
|
+
`{selectAll}{backspace}${credential.password}`
|
|
144
176
|
);
|
|
145
177
|
})
|
|
146
178
|
.getByLabel({ label: 'Connect', tag: 'button' })
|
|
@@ -197,9 +229,18 @@ interface StartContainerProps {
|
|
|
197
229
|
Cypress.Commands.add(
|
|
198
230
|
'startContainer',
|
|
199
231
|
({ name, image, portBindings }: StartContainerProps): Cypress.Chainable => {
|
|
200
|
-
return cy
|
|
201
|
-
|
|
202
|
-
|
|
232
|
+
return cy.task(
|
|
233
|
+
'startContainer',
|
|
234
|
+
{ image, name, portBindings },
|
|
235
|
+
{ timeout: 600000 } // 10 minutes because docker pull can be very slow
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
Cypress.Commands.add(
|
|
241
|
+
'createDirectory',
|
|
242
|
+
(directoryPath: string): Cypress.Chainable => {
|
|
243
|
+
return cy.task('createDirectory', directoryPath);
|
|
203
244
|
}
|
|
204
245
|
);
|
|
205
246
|
|
|
@@ -214,7 +255,7 @@ Cypress.Commands.add(
|
|
|
214
255
|
'startWebContainer',
|
|
215
256
|
({
|
|
216
257
|
name = Cypress.env('dockerName'),
|
|
217
|
-
os = '
|
|
258
|
+
os = Cypress.env('WEB_IMAGE_OS'),
|
|
218
259
|
useSlim = true,
|
|
219
260
|
version = Cypress.env('WEB_IMAGE_VERSION')
|
|
220
261
|
}: StartWebContainerProps = {}): Cypress.Chainable => {
|
|
@@ -229,12 +270,13 @@ Cypress.Commands.add(
|
|
|
229
270
|
portBindings: [{ destination: 4000, source: 80 }]
|
|
230
271
|
})
|
|
231
272
|
.then(() => {
|
|
232
|
-
const baseUrl = 'http://
|
|
273
|
+
const baseUrl = 'http://127.0.0.1:4000';
|
|
233
274
|
|
|
234
275
|
Cypress.config('baseUrl', baseUrl);
|
|
235
276
|
|
|
236
|
-
return cy.
|
|
237
|
-
|
|
277
|
+
return cy.task(
|
|
278
|
+
'waitOn',
|
|
279
|
+
`${baseUrl}/centreon/api/latest/platform/installation/status`
|
|
238
280
|
);
|
|
239
281
|
})
|
|
240
282
|
.visit('/') // this is necessary to refresh browser cause baseUrl has changed (flash appears in video)
|
|
@@ -261,25 +303,41 @@ Cypress.Commands.add(
|
|
|
261
303
|
|
|
262
304
|
return cy
|
|
263
305
|
.visitEmptyPage()
|
|
264
|
-
.
|
|
306
|
+
.createDirectory(logDirectory)
|
|
265
307
|
.copyFromContainer({
|
|
266
308
|
destination: `${logDirectory}/broker`,
|
|
309
|
+
name,
|
|
267
310
|
source: '/var/log/centreon-broker'
|
|
268
311
|
})
|
|
269
312
|
.copyFromContainer({
|
|
270
313
|
destination: `${logDirectory}/engine`,
|
|
314
|
+
name,
|
|
271
315
|
source: '/var/log/centreon-engine'
|
|
272
316
|
})
|
|
273
|
-
.execInContainer({
|
|
274
|
-
command: `bash -e <<EOF
|
|
275
|
-
chmod 777 /var/log/centreon/centreon-web.log > /dev/null 2>&1 || :
|
|
276
|
-
EOF`,
|
|
277
|
-
name
|
|
278
|
-
})
|
|
279
317
|
.copyFromContainer({
|
|
280
318
|
destination: `${logDirectory}/centreon`,
|
|
319
|
+
name,
|
|
281
320
|
source: '/var/log/centreon'
|
|
282
321
|
})
|
|
322
|
+
.then(() => {
|
|
323
|
+
if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
|
|
324
|
+
return cy.copyFromContainer({
|
|
325
|
+
destination: `${logDirectory}/php`,
|
|
326
|
+
name,
|
|
327
|
+
source: '/var/log/php-fpm'
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return cy.copyFromContainer(
|
|
332
|
+
{
|
|
333
|
+
destination: `${logDirectory}/php8.1-fpm-centreon-error.log`,
|
|
334
|
+
name,
|
|
335
|
+
source: '/var/log/php8.1-fpm-centreon-error.log'
|
|
336
|
+
},
|
|
337
|
+
{ failOnNonZeroExit: false }
|
|
338
|
+
);
|
|
339
|
+
})
|
|
340
|
+
.exec(`chmod -R 755 "${logDirectory}"`)
|
|
283
341
|
.stopContainer({ name });
|
|
284
342
|
}
|
|
285
343
|
);
|
|
@@ -308,21 +366,128 @@ Cypress.Commands.add(
|
|
|
308
366
|
}
|
|
309
367
|
);
|
|
310
368
|
|
|
369
|
+
interface Dashboard {
|
|
370
|
+
description?: string;
|
|
371
|
+
name: string;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
Cypress.Commands.add(
|
|
375
|
+
'insertDashboardList',
|
|
376
|
+
(fixtureFile: string): Cypress.Chainable => {
|
|
377
|
+
return cy.fixture(fixtureFile).then((dashboardList) => {
|
|
378
|
+
cy.wrap(
|
|
379
|
+
Promise.all(
|
|
380
|
+
dashboardList.map((dashboardBody: Dashboard) =>
|
|
381
|
+
cy.insertDashboard({ ...dashboardBody })
|
|
382
|
+
)
|
|
383
|
+
)
|
|
384
|
+
);
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
);
|
|
388
|
+
|
|
389
|
+
Cypress.Commands.add(
|
|
390
|
+
'insertDashboard',
|
|
391
|
+
(dashboardBody: Dashboard): Cypress.Chainable => {
|
|
392
|
+
return cy.request({
|
|
393
|
+
body: {
|
|
394
|
+
...dashboardBody
|
|
395
|
+
},
|
|
396
|
+
method: 'POST',
|
|
397
|
+
url: '/centreon/api/latest/configuration/dashboards'
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
interface ShareDashboardToUserProps {
|
|
403
|
+
dashboardName: string;
|
|
404
|
+
role: string;
|
|
405
|
+
userName: string;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
interface ListingRequestResult {
|
|
409
|
+
body: {
|
|
410
|
+
result: Array<{
|
|
411
|
+
id: number;
|
|
412
|
+
}>;
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
Cypress.Commands.add(
|
|
417
|
+
'shareDashboardToUser',
|
|
418
|
+
({ dashboardName, userName, role }: ShareDashboardToUserProps): void => {
|
|
419
|
+
Promise.all([
|
|
420
|
+
cy.request({
|
|
421
|
+
method: 'GET',
|
|
422
|
+
url: `/centreon/api/latest/configuration/users?search={"name":"${userName}"}`
|
|
423
|
+
}),
|
|
424
|
+
cy.request({
|
|
425
|
+
method: 'GET',
|
|
426
|
+
url: `/centreon/api/latest/configuration/dashboards?search={"name":"${dashboardName}"}`
|
|
427
|
+
})
|
|
428
|
+
]).then(
|
|
429
|
+
([retrievedUser, retrievedDashboard]: [
|
|
430
|
+
ListingRequestResult,
|
|
431
|
+
ListingRequestResult
|
|
432
|
+
]) => {
|
|
433
|
+
const userId = retrievedUser.body.result[0].id;
|
|
434
|
+
const dashboardId = retrievedDashboard.body.result[0].id;
|
|
435
|
+
|
|
436
|
+
cy.request({
|
|
437
|
+
body: {
|
|
438
|
+
id: userId,
|
|
439
|
+
role: `${role}`
|
|
440
|
+
},
|
|
441
|
+
method: 'POST',
|
|
442
|
+
url: `/centreon/api/latest/configuration/dashboards/${dashboardId}/access_rights/contacts`
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
);
|
|
448
|
+
|
|
449
|
+
Cypress.Commands.add('getTimeFromHeader', (): Cypress.Chainable => {
|
|
450
|
+
return cy
|
|
451
|
+
.get('header div[data-cy="clock"]', { timeout: 10000 })
|
|
452
|
+
.should('be.visible')
|
|
453
|
+
.then(($time) => {
|
|
454
|
+
const headerTime = $time.children()[1].textContent;
|
|
455
|
+
if (headerTime?.match(/\d+:\d+/)) {
|
|
456
|
+
cy.log(`header time is : ${headerTime}`);
|
|
457
|
+
|
|
458
|
+
return cy.wrap(headerTime);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
throw new Error(`header time is not displayed`);
|
|
462
|
+
});
|
|
463
|
+
});
|
|
464
|
+
|
|
311
465
|
declare global {
|
|
312
466
|
namespace Cypress {
|
|
313
467
|
interface Chainable {
|
|
314
|
-
|
|
315
|
-
|
|
468
|
+
clickSubRootMenuItem: (page: string) => Cypress.Chainable;
|
|
469
|
+
copyFromContainer: (
|
|
470
|
+
props: CopyFromContainerProps,
|
|
471
|
+
options?: Partial<Cypress.ExecOptions>
|
|
472
|
+
) => Cypress.Chainable;
|
|
473
|
+
copyToContainer: (
|
|
474
|
+
props: CopyToContainerProps,
|
|
475
|
+
options?: Partial<Cypress.ExecOptions>
|
|
476
|
+
) => Cypress.Chainable;
|
|
477
|
+
createDirectory: (directoryPath: string) => Cypress.Chainable;
|
|
316
478
|
execInContainer: ({
|
|
317
479
|
command,
|
|
318
480
|
name
|
|
319
481
|
}: ExecInContainerProps) => Cypress.Chainable;
|
|
320
482
|
getIframeBody: () => Cypress.Chainable;
|
|
483
|
+
getTimeFromHeader: () => Cypress.Chainable;
|
|
321
484
|
getWebVersion: () => Cypress.Chainable;
|
|
322
485
|
hoverRootMenuItem: (rootItemNumber: number) => Cypress.Chainable;
|
|
486
|
+
insertDashboard: (dashboard: Dashboard) => Cypress.Chainable;
|
|
487
|
+
insertDashboardList: (fixtureFile: string) => Cypress.Chainable;
|
|
323
488
|
loginByTypeOfUser: ({
|
|
324
|
-
jsonName
|
|
325
|
-
loginViaApi
|
|
489
|
+
jsonName,
|
|
490
|
+
loginViaApi
|
|
326
491
|
}: LoginByTypeOfUserProps) => Cypress.Chainable;
|
|
327
492
|
moveSortableElement: (direction: string) => Cypress.Chainable;
|
|
328
493
|
navigateTo: ({
|
|
@@ -330,6 +495,11 @@ declare global {
|
|
|
330
495
|
rootItemNumber,
|
|
331
496
|
subMenu
|
|
332
497
|
}: NavigateToProps) => Cypress.Chainable;
|
|
498
|
+
shareDashboardToUser: ({
|
|
499
|
+
dashboardName,
|
|
500
|
+
userName,
|
|
501
|
+
role
|
|
502
|
+
}: ShareDashboardToUserProps) => Cypress.Chainable;
|
|
333
503
|
startContainer: ({
|
|
334
504
|
name,
|
|
335
505
|
image
|
|
@@ -4,8 +4,11 @@
|
|
|
4
4
|
import { execSync } from 'child_process';
|
|
5
5
|
|
|
6
6
|
import { defineConfig } from 'cypress';
|
|
7
|
+
import installLogsPrinter from 'cypress-terminal-report/src/installLogsPrinter';
|
|
7
8
|
|
|
8
|
-
import
|
|
9
|
+
import esbuildPreprocessor from './esbuild-preprocessor';
|
|
10
|
+
import plugins from './plugins';
|
|
11
|
+
import tasks from './tasks';
|
|
9
12
|
|
|
10
13
|
interface ConfigurationOptions {
|
|
11
14
|
cypressFolder?: string;
|
|
@@ -22,9 +25,7 @@ export default ({
|
|
|
22
25
|
dockerName,
|
|
23
26
|
env
|
|
24
27
|
}: ConfigurationOptions): Cypress.ConfigOptions => {
|
|
25
|
-
const resultsFolder = `${cypressFolder || 'cypress'}/results
|
|
26
|
-
isDevelopment ? '/dev' : ''
|
|
27
|
-
}`;
|
|
28
|
+
const resultsFolder = `${cypressFolder || 'cypress'}/results`;
|
|
28
29
|
|
|
29
30
|
const webImageVersion = execSync('git rev-parse --abbrev-ref HEAD')
|
|
30
31
|
.toString('utf8')
|
|
@@ -35,7 +36,17 @@ export default ({
|
|
|
35
36
|
defaultCommandTimeout: 6000,
|
|
36
37
|
e2e: {
|
|
37
38
|
excludeSpecPattern: ['*.js', '*.ts', '*.md'],
|
|
38
|
-
|
|
39
|
+
reporter: require.resolve('cypress-multi-reporters'),
|
|
40
|
+
reporterOptions: {
|
|
41
|
+
configFile: `${__dirname}/reporter-config.js`
|
|
42
|
+
},
|
|
43
|
+
setupNodeEvents: async (on, config) => {
|
|
44
|
+
installLogsPrinter(on);
|
|
45
|
+
await esbuildPreprocessor(on, config);
|
|
46
|
+
tasks(on);
|
|
47
|
+
|
|
48
|
+
return plugins(on, config);
|
|
49
|
+
},
|
|
39
50
|
specPattern
|
|
40
51
|
},
|
|
41
52
|
env: {
|
|
@@ -45,34 +56,12 @@ export default ({
|
|
|
45
56
|
WEB_IMAGE_VERSION: webImageVersion,
|
|
46
57
|
dockerName: dockerName || 'centreon-dev'
|
|
47
58
|
},
|
|
48
|
-
execTimeout:
|
|
49
|
-
reporter: 'mochawesome',
|
|
50
|
-
reporterOptions: {
|
|
51
|
-
html: false,
|
|
52
|
-
json: true,
|
|
53
|
-
overwrite: true,
|
|
54
|
-
reportDir: `${resultsFolder}/reports`,
|
|
55
|
-
reportFilename: '[name]-report.json'
|
|
56
|
-
},
|
|
59
|
+
execTimeout: 60000,
|
|
57
60
|
requestTimeout: 10000,
|
|
58
61
|
retries: 0,
|
|
59
62
|
screenshotsFolder: `${resultsFolder}/screenshots`,
|
|
60
|
-
setupNodeEvents: (on, config) => {
|
|
61
|
-
on('before:browser:launch', (browser, launchOptions) => {
|
|
62
|
-
if (browser.name === 'chrome' && browser.isHeadless) {
|
|
63
|
-
launchOptions.args = launchOptions.args.map((arg) => {
|
|
64
|
-
if (arg === '--headless') {
|
|
65
|
-
return '--headless=new';
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return arg;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return launchOptions;
|
|
73
|
-
});
|
|
74
|
-
},
|
|
75
63
|
video: true,
|
|
64
|
+
videoCompression: 0,
|
|
76
65
|
videosFolder: `${resultsFolder}/videos`
|
|
77
66
|
});
|
|
78
67
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
|
|
2
|
+
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill';
|
|
3
|
+
import { addCucumberPreprocessorPlugin } from '@badeball/cypress-cucumber-preprocessor';
|
|
4
|
+
import createBundler from '@bahmutov/cypress-esbuild-preprocessor';
|
|
5
|
+
import createEsbuildPlugin from '@badeball/cypress-cucumber-preprocessor/esbuild';
|
|
6
|
+
|
|
7
|
+
export default async (
|
|
8
|
+
on: Cypress.PluginEvents,
|
|
9
|
+
config: Cypress.PluginConfigOptions
|
|
10
|
+
): Promise<void> => {
|
|
11
|
+
await addCucumberPreprocessorPlugin(on, config);
|
|
12
|
+
|
|
13
|
+
on(
|
|
14
|
+
'file:preprocessor',
|
|
15
|
+
createBundler({
|
|
16
|
+
plugins: [
|
|
17
|
+
createEsbuildPlugin(config),
|
|
18
|
+
NodeModulesPolyfillPlugin(),
|
|
19
|
+
NodeGlobalsPolyfillPlugin({
|
|
20
|
+
buffer: true,
|
|
21
|
+
process: true
|
|
22
|
+
})
|
|
23
|
+
]
|
|
24
|
+
})
|
|
25
|
+
);
|
|
26
|
+
};
|
package/cypress/e2e/plugins.ts
CHANGED
|
@@ -3,132 +3,34 @@
|
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
4
4
|
/* eslint-disable no-param-reassign */
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
test: /\.ts?$/,
|
|
19
|
-
use: [
|
|
20
|
-
{
|
|
21
|
-
loader: 'swc-loader'
|
|
22
|
-
}
|
|
23
|
-
]
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
test: /\.feature$/,
|
|
27
|
-
use: [
|
|
28
|
-
{
|
|
29
|
-
loader: '@badeball/cypress-cucumber-preprocessor/webpack',
|
|
30
|
-
options: config
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
resolve: {
|
|
37
|
-
extensions: ['.ts', '.js']
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export default async (on, config): Promise<void> => {
|
|
43
|
-
await addCucumberPreprocessorPlugin(on, config);
|
|
6
|
+
export default (
|
|
7
|
+
on: Cypress.PluginEvents,
|
|
8
|
+
config: Cypress.PluginConfigOptions
|
|
9
|
+
): Cypress.PluginConfigOptions => {
|
|
10
|
+
on('before:browser:launch', (browser, launchOptions) => {
|
|
11
|
+
const width = 1920;
|
|
12
|
+
const height = 1080;
|
|
13
|
+
|
|
14
|
+
if (browser.name === 'chrome') {
|
|
15
|
+
if (browser.isHeadless) {
|
|
16
|
+
launchOptions.args.push('--headless=new');
|
|
17
|
+
}
|
|
44
18
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
19
|
+
// flags description : https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md
|
|
20
|
+
launchOptions.args.push('--disable-gpu');
|
|
21
|
+
launchOptions.args.push('--auto-open-devtools-for-tabs');
|
|
22
|
+
launchOptions.args.push('--disable-extensions');
|
|
23
|
+
launchOptions.args.push('--hide-scrollbars');
|
|
24
|
+
launchOptions.args.push('--mute-audio');
|
|
49
25
|
|
|
50
|
-
|
|
26
|
+
launchOptions.args.push(`--window-size=${width},${height}`);
|
|
51
27
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
launchOptions.args.push('--disable-gpu');
|
|
55
|
-
launchOptions.args = launchOptions.args.filter(
|
|
56
|
-
(element) => element !== '--disable-dev-shm-usage'
|
|
57
|
-
);
|
|
28
|
+
// force screen to be non-retina and just use our given resolution
|
|
29
|
+
launchOptions.args.push('--force-device-scale-factor=1');
|
|
58
30
|
}
|
|
59
31
|
|
|
60
32
|
return launchOptions;
|
|
61
33
|
});
|
|
62
34
|
|
|
63
|
-
interface PortBinding {
|
|
64
|
-
destination: number;
|
|
65
|
-
source: number;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
interface StartContainerProps {
|
|
69
|
-
image: string;
|
|
70
|
-
name: string;
|
|
71
|
-
portBindings: Array<PortBinding>;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
interface StopContainerProps {
|
|
75
|
-
name: string;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
on('task', {
|
|
79
|
-
startContainer: async ({
|
|
80
|
-
image,
|
|
81
|
-
name,
|
|
82
|
-
portBindings = []
|
|
83
|
-
}: StartContainerProps) => {
|
|
84
|
-
const webContainers = await docker.listContainers({
|
|
85
|
-
all: true,
|
|
86
|
-
filters: { name: [name] }
|
|
87
|
-
});
|
|
88
|
-
if (webContainers.length) {
|
|
89
|
-
return webContainers[0];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const container = await docker.createContainer({
|
|
93
|
-
AttachStderr: true,
|
|
94
|
-
AttachStdin: false,
|
|
95
|
-
AttachStdout: true,
|
|
96
|
-
ExposedPorts: portBindings.reduce((accumulator, currentValue) => {
|
|
97
|
-
accumulator[`${currentValue.source}/tcp`] = {};
|
|
98
|
-
|
|
99
|
-
return accumulator;
|
|
100
|
-
}, {}),
|
|
101
|
-
HostConfig: {
|
|
102
|
-
PortBindings: portBindings.reduce((accumulator, currentValue) => {
|
|
103
|
-
accumulator[`${currentValue.source}/tcp`] = [
|
|
104
|
-
{
|
|
105
|
-
HostIP: '0.0.0.0',
|
|
106
|
-
HostPort: `${currentValue.destination}`
|
|
107
|
-
}
|
|
108
|
-
];
|
|
109
|
-
|
|
110
|
-
return accumulator;
|
|
111
|
-
}, {})
|
|
112
|
-
},
|
|
113
|
-
Image: image,
|
|
114
|
-
OpenStdin: false,
|
|
115
|
-
StdinOnce: false,
|
|
116
|
-
Tty: true,
|
|
117
|
-
name
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
await container.start();
|
|
121
|
-
|
|
122
|
-
return container;
|
|
123
|
-
},
|
|
124
|
-
stopContainer: async ({ name }: StopContainerProps) => {
|
|
125
|
-
const container = await docker.getContainer(name);
|
|
126
|
-
await container.kill();
|
|
127
|
-
await container.remove();
|
|
128
|
-
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
|
|
133
35
|
return config;
|
|
134
36
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
mochawesomeReporterOptions: {
|
|
3
|
+
consoleReporter: 'none',
|
|
4
|
+
html: false,
|
|
5
|
+
json: true,
|
|
6
|
+
overwrite: true,
|
|
7
|
+
reportDir: 'cypress/results/reports',
|
|
8
|
+
reportFilename: '[name]-report.json'
|
|
9
|
+
},
|
|
10
|
+
reporterEnabled: `mochawesome,${require.resolve(
|
|
11
|
+
'@badeball/cypress-cucumber-preprocessor/pretty-reporter'
|
|
12
|
+
)}`
|
|
13
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import { existsSync, mkdirSync } from 'fs';
|
|
3
|
+
|
|
4
|
+
import Docker from 'dockerode';
|
|
5
|
+
|
|
6
|
+
export default (on: Cypress.PluginEvents): void => {
|
|
7
|
+
const docker = new Docker();
|
|
8
|
+
|
|
9
|
+
interface PortBinding {
|
|
10
|
+
destination: number;
|
|
11
|
+
source: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface StartContainerProps {
|
|
15
|
+
image: string;
|
|
16
|
+
name: string;
|
|
17
|
+
portBindings: Array<PortBinding>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface StopContainerProps {
|
|
21
|
+
name: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
on('task', {
|
|
25
|
+
createDirectory: async (directoryPath: string) => {
|
|
26
|
+
if (!existsSync(directoryPath)) {
|
|
27
|
+
mkdirSync(directoryPath, { recursive: true });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return null;
|
|
31
|
+
},
|
|
32
|
+
startContainer: async ({
|
|
33
|
+
image,
|
|
34
|
+
name,
|
|
35
|
+
portBindings = []
|
|
36
|
+
}: StartContainerProps) => {
|
|
37
|
+
const imageList = execSync(
|
|
38
|
+
'docker image list --format "{{.Repository}}:{{.Tag}}"'
|
|
39
|
+
).toString('utf8');
|
|
40
|
+
|
|
41
|
+
if (
|
|
42
|
+
!imageList.match(
|
|
43
|
+
new RegExp(
|
|
44
|
+
`^${image.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')}`,
|
|
45
|
+
'm'
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
) {
|
|
49
|
+
execSync(`docker pull ${image}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const webContainers = await docker.listContainers({
|
|
53
|
+
all: true,
|
|
54
|
+
filters: { name: [name] }
|
|
55
|
+
});
|
|
56
|
+
if (webContainers.length) {
|
|
57
|
+
return webContainers[0];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const container = await docker.createContainer({
|
|
61
|
+
AttachStderr: true,
|
|
62
|
+
AttachStdin: false,
|
|
63
|
+
AttachStdout: true,
|
|
64
|
+
ExposedPorts: portBindings.reduce((accumulator, currentValue) => {
|
|
65
|
+
accumulator[`${currentValue.source}/tcp`] = {};
|
|
66
|
+
|
|
67
|
+
return accumulator;
|
|
68
|
+
}, {}),
|
|
69
|
+
HostConfig: {
|
|
70
|
+
PortBindings: portBindings.reduce((accumulator, currentValue) => {
|
|
71
|
+
accumulator[`${currentValue.source}/tcp`] = [
|
|
72
|
+
{
|
|
73
|
+
HostIP: '127.0.0.1',
|
|
74
|
+
HostPort: `${currentValue.destination}`
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
return accumulator;
|
|
79
|
+
}, {})
|
|
80
|
+
},
|
|
81
|
+
Image: image,
|
|
82
|
+
OpenStdin: false,
|
|
83
|
+
StdinOnce: false,
|
|
84
|
+
Tty: true,
|
|
85
|
+
name
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
await container.start();
|
|
89
|
+
|
|
90
|
+
return container;
|
|
91
|
+
},
|
|
92
|
+
stopContainer: async ({ name }: StopContainerProps) => {
|
|
93
|
+
const container = await docker.getContainer(name);
|
|
94
|
+
await container.kill();
|
|
95
|
+
await container.remove();
|
|
96
|
+
|
|
97
|
+
return null;
|
|
98
|
+
},
|
|
99
|
+
waitOn: async (url: string) => {
|
|
100
|
+
execSync(`npx wait-on ${url}`);
|
|
101
|
+
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
};
|
|
@@ -21,11 +21,15 @@ module.exports = {
|
|
|
21
21
|
}
|
|
22
22
|
],
|
|
23
23
|
'@typescript-eslint/camelcase': 'off',
|
|
24
|
-
'@typescript-eslint/consistent-type-definitions': [
|
|
24
|
+
'@typescript-eslint/consistent-type-definitions': ['off', 'interface'],
|
|
25
|
+
'@typescript-eslint/explicit-function-return-type': [
|
|
25
26
|
'error',
|
|
26
|
-
|
|
27
|
+
{
|
|
28
|
+
allowExpressions: true,
|
|
29
|
+
allowHigherOrderFunctions: true,
|
|
30
|
+
allowTypedFunctionExpressions: true
|
|
31
|
+
}
|
|
27
32
|
],
|
|
28
|
-
'@typescript-eslint/explicit-function-return-type': ['error'],
|
|
29
33
|
'@typescript-eslint/explicit-member-accessibility': [
|
|
30
34
|
'error',
|
|
31
35
|
{
|
|
@@ -76,13 +80,21 @@ module.exports = {
|
|
|
76
80
|
}
|
|
77
81
|
],
|
|
78
82
|
camelcase: 'off',
|
|
83
|
+
'import/no-cycle': 'off',
|
|
84
|
+
'import/no-named-as-default': 'warn',
|
|
79
85
|
'no-shadow': 'off',
|
|
80
86
|
'no-unused-expressions': 'off'
|
|
81
87
|
},
|
|
82
88
|
settings: {
|
|
89
|
+
'import/parsers': {
|
|
90
|
+
'@typescript-eslint/parser': ['.ts', '.tsx']
|
|
91
|
+
},
|
|
83
92
|
'import/resolver': {
|
|
84
93
|
alias: {
|
|
85
94
|
extensions: ['.ts', '.tsx', '.js', '.jsx']
|
|
95
|
+
},
|
|
96
|
+
typescript: {
|
|
97
|
+
alwaysTryTypes: true
|
|
86
98
|
}
|
|
87
99
|
}
|
|
88
100
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: [ '../node/typescript.eslintrc.js'],
|
|
3
|
+
overrides: [
|
|
4
|
+
{
|
|
5
|
+
files: ["*.spec.js", "*.test.ts", "*.tests.ts"],
|
|
6
|
+
rules: {
|
|
7
|
+
"import/first": 0,
|
|
8
|
+
"import/order": 0,
|
|
9
|
+
"@typescript-eslint/ban-ts-comment": 0,
|
|
10
|
+
"@typescript-eslint/no-explicit-any": 0
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
rules: {
|
|
15
|
+
"import/extensions": ["off"],
|
|
16
|
+
"no-console": "off",
|
|
17
|
+
"no-underscore-dangle": "off",
|
|
18
|
+
"class-methods-use-this": "off",
|
|
19
|
+
"@typescript-eslint/naming-convention": [
|
|
20
|
+
"error",
|
|
21
|
+
{
|
|
22
|
+
format: ["camelCase", "PascalCase", "UPPER_CASE"],
|
|
23
|
+
selector: "variable"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
filter: {
|
|
27
|
+
match: false,
|
|
28
|
+
regex: "(__esModule|.+-.+)"
|
|
29
|
+
},
|
|
30
|
+
format: ["snake_case", "camelCase", "PascalCase", "UPPER_CASE"],
|
|
31
|
+
selector: "property",
|
|
32
|
+
leadingUnderscore: "allow"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
filter: {
|
|
36
|
+
match: false,
|
|
37
|
+
regex: "^_$"
|
|
38
|
+
},
|
|
39
|
+
format: ["snake_case", "camelCase", "PascalCase"],
|
|
40
|
+
selector: "parameter"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"@typescript-eslint/require-array-sort-compare": "error"
|
|
44
|
+
},
|
|
45
|
+
parserOptions: {
|
|
46
|
+
project: ["./tsconfig.json"]
|
|
47
|
+
}
|
|
48
|
+
}
|
package/jest/index.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
moduleNameMapper: {
|
|
3
3
|
'\\.(s?css|png|svg|jpg)$': 'identity-obj-proxy',
|
|
4
|
+
'^.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$':
|
|
5
|
+
'jest-transform-stub',
|
|
4
6
|
'^react($|/.+)': '<rootDir>/node_modules/react$1'
|
|
5
7
|
},
|
|
6
8
|
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
|
|
7
9
|
testEnvironment: 'jsdom',
|
|
8
|
-
testPathIgnorePatterns: ['/node_modules/'],
|
|
10
|
+
testPathIgnorePatterns: ['/node_modules/', '!*.cypress.spec.tsx'],
|
|
9
11
|
transform: {
|
|
12
|
+
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$':
|
|
13
|
+
'jest-transform-stub',
|
|
10
14
|
'^.+\\.[jt]sx?$': [
|
|
11
15
|
'@swc/jest',
|
|
12
16
|
{
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Centreon Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// For a detailed explanation regarding each configuration property, visit:
|
|
18
|
+
// https://jestjs.io/docs/en/configuration.html
|
|
19
|
+
const path = require('path');
|
|
20
|
+
|
|
21
|
+
const rootPath = path.join(__dirname);
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
module.exports = {
|
|
26
|
+
rootDir: rootPath,
|
|
27
|
+
// Automatically clear mock calls and instances between every test
|
|
28
|
+
clearMocks: true,
|
|
29
|
+
// The directory where Jest should output its coverage files
|
|
30
|
+
coverageDirectory: '<rootDir>/coverage',
|
|
31
|
+
// An array of regexp pattern strings used to skip coverage collection
|
|
32
|
+
coveragePathIgnorePatterns: ['\\\\node_modules\\\\', 'tests'],
|
|
33
|
+
|
|
34
|
+
// An array of file extensions your modules use
|
|
35
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
|
36
|
+
|
|
37
|
+
// Automatically reset mock state between every test
|
|
38
|
+
// resetMocks: true,
|
|
39
|
+
|
|
40
|
+
testMatch: ['**/*.(test|tests|spec|specs).+(ts|tsx|js)'],
|
|
41
|
+
|
|
42
|
+
// This option allows the use of a custom results processor
|
|
43
|
+
// testResultsProcessor: 'jest-sonar-reporter',
|
|
44
|
+
|
|
45
|
+
// A map from regular expressions to paths to transformers
|
|
46
|
+
transform: {
|
|
47
|
+
'^.+\\.(ts|tsx)$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.json' }],
|
|
48
|
+
},
|
|
49
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/js-config",
|
|
3
3
|
"description": "Centreon Frontend shared build configuration",
|
|
4
|
-
"version": "23.10.
|
|
4
|
+
"version": "23.10.39",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/centreon/centreon-frontend.git"
|
|
@@ -16,13 +16,12 @@
|
|
|
16
16
|
"url": "https://github.com/centreon/centreon-frontend/issues"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@
|
|
20
|
-
"@types/dockerode": "^3.3.16",
|
|
21
|
-
"dockerode": "^3.3.5",
|
|
19
|
+
"@tsconfig/node16": "^16.1.1",
|
|
22
20
|
"eslint": "^8.17.0",
|
|
23
21
|
"eslint-config-airbnb": "19.0.4",
|
|
24
22
|
"eslint-config-prettier": "^8.5.0",
|
|
25
23
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
24
|
+
"eslint-import-resolver-typescript": "^3.5.5",
|
|
26
25
|
"eslint-plugin-babel": "^5.3.1",
|
|
27
26
|
"eslint-plugin-hooks": "^0.4.3",
|
|
28
27
|
"eslint-plugin-import": "^2.26.0",
|
|
@@ -43,5 +42,18 @@
|
|
|
43
42
|
"tsconfig",
|
|
44
43
|
"webpack",
|
|
45
44
|
"cypress"
|
|
46
|
-
]
|
|
45
|
+
],
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@badeball/cypress-cucumber-preprocessor": "^18.0.6",
|
|
48
|
+
"@bahmutov/cypress-esbuild-preprocessor": "^2.2.0",
|
|
49
|
+
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
|
|
50
|
+
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
|
|
51
|
+
"@types/cypress-cucumber-preprocessor": "^4.0.2",
|
|
52
|
+
"@types/dockerode": "^3.3.19",
|
|
53
|
+
"cypress-multi-reporters": "^1.6.3",
|
|
54
|
+
"cypress-terminal-report": "^5.3.6",
|
|
55
|
+
"dockerode": "^3.3.5",
|
|
56
|
+
"esbuild": "^0.19.3",
|
|
57
|
+
"mochawesome": "^7.1.3"
|
|
58
|
+
}
|
|
47
59
|
}
|
package/tsconfig/index.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"moduleResolution": "node",
|
|
4
3
|
"downlevelIteration": true,
|
|
5
|
-
"module": "
|
|
6
|
-
"
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"target": "es2018",
|
|
7
7
|
"jsx": "react-jsx",
|
|
8
8
|
"strict": true,
|
|
9
9
|
"noImplicitAny": false,
|
|
10
10
|
"skipLibCheck": true,
|
|
11
|
-
"esModuleInterop": true
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"resolveJsonModule": true
|
|
12
13
|
}
|
|
13
14
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const excludeNodeModulesExceptCentreonUi =
|
|
2
|
+
/node_modules(\\|\/)\.pnpm(\\|\/)(?!(@centreon))/;
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
cache: false,
|
|
6
|
+
excludeNodeModulesExceptCentreonUi,
|
|
7
|
+
getModuleConfiguration: (jscTransformConfiguration) => ({
|
|
8
|
+
rules: [
|
|
9
|
+
{
|
|
10
|
+
parser: { system: false },
|
|
11
|
+
test: /\.[cm]?(j|t)sx?$/
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
exclude: [excludeNodeModulesExceptCentreonUi],
|
|
15
|
+
test: /\.[jt]sx?$/,
|
|
16
|
+
use: {
|
|
17
|
+
loader: 'swc-loader',
|
|
18
|
+
options: {
|
|
19
|
+
jsc: {
|
|
20
|
+
parser: {
|
|
21
|
+
syntax: 'typescript',
|
|
22
|
+
tsx: true
|
|
23
|
+
},
|
|
24
|
+
transform: jscTransformConfiguration
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
test: /\.icon.svg$/,
|
|
31
|
+
use: ['@svgr/webpack']
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
exclude: excludeNodeModulesExceptCentreonUi,
|
|
35
|
+
test: /\.(bmp|png|jpg|jpeg|gif|svg)$/,
|
|
36
|
+
use: [
|
|
37
|
+
{
|
|
38
|
+
loader: 'url-loader',
|
|
39
|
+
options: {
|
|
40
|
+
limit: 10000,
|
|
41
|
+
name: '[name].[hash:8].[ext]'
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
generator: {
|
|
48
|
+
filename: '[name][ext]'
|
|
49
|
+
},
|
|
50
|
+
test: /\.(woff|woff2|eot|ttf|otf)$/i,
|
|
51
|
+
type: 'asset/resource'
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
test: /\.css$/i,
|
|
55
|
+
use: ['style-loader', 'css-loader']
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}),
|
|
59
|
+
optimization: {
|
|
60
|
+
splitChunks: {
|
|
61
|
+
chunks: 'all',
|
|
62
|
+
maxSize: 400 * 1024
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
output: {
|
|
66
|
+
chunkFilename: '[name].[chunkhash:8].chunk.js',
|
|
67
|
+
filename: '[name].[chunkhash:8].js',
|
|
68
|
+
libraryTarget: 'umd',
|
|
69
|
+
umdNamedDefine: true
|
|
70
|
+
}
|
|
71
|
+
};
|
package/webpack/base/index.js
CHANGED
|
@@ -3,68 +3,22 @@ const path = require('path');
|
|
|
3
3
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
4
4
|
const { ModuleFederationPlugin } = require('webpack').container;
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const {
|
|
7
|
+
getModuleConfiguration,
|
|
8
|
+
optimization,
|
|
9
|
+
output,
|
|
10
|
+
cache
|
|
11
|
+
} = require('./globalConfig');
|
|
8
12
|
|
|
9
13
|
const getBaseConfiguration = ({
|
|
10
14
|
moduleName,
|
|
11
15
|
moduleFederationConfig,
|
|
12
16
|
jscTransformConfiguration
|
|
13
17
|
}) => ({
|
|
14
|
-
cache
|
|
15
|
-
module:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
parser: { system: false },
|
|
19
|
-
test: /\.[cm]?(j|t)sx?$/
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
exclude: excludeNodeModulesExceptCentreonUi,
|
|
23
|
-
test: /\.[jt]sx?$/,
|
|
24
|
-
use: {
|
|
25
|
-
loader: 'swc-loader',
|
|
26
|
-
options: {
|
|
27
|
-
jsc: {
|
|
28
|
-
parser: {
|
|
29
|
-
syntax: 'typescript',
|
|
30
|
-
tsx: true
|
|
31
|
-
},
|
|
32
|
-
transform: jscTransformConfiguration
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
test: /\.icon.svg$/,
|
|
39
|
-
use: ['@svgr/webpack']
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
exclude: excludeNodeModulesExceptCentreonUi,
|
|
43
|
-
test: /\.(bmp|png|jpg|jpeg|gif|svg)$/,
|
|
44
|
-
use: [
|
|
45
|
-
{
|
|
46
|
-
loader: 'url-loader',
|
|
47
|
-
options: {
|
|
48
|
-
limit: 10000,
|
|
49
|
-
name: '[name].[hash:8].[ext]'
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
]
|
|
53
|
-
}
|
|
54
|
-
]
|
|
55
|
-
},
|
|
56
|
-
optimization: {
|
|
57
|
-
splitChunks: {
|
|
58
|
-
chunks: 'all',
|
|
59
|
-
maxSize: 400 * 1024
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
output: {
|
|
63
|
-
chunkFilename: '[name].[chunkhash:8].chunk.js',
|
|
64
|
-
filename: '[name].[chunkhash:8].js',
|
|
65
|
-
libraryTarget: 'umd',
|
|
66
|
-
umdNamedDefine: true
|
|
67
|
-
},
|
|
18
|
+
cache,
|
|
19
|
+
module: getModuleConfiguration(jscTransformConfiguration),
|
|
20
|
+
optimization,
|
|
21
|
+
output,
|
|
68
22
|
plugins: [
|
|
69
23
|
new CleanWebpackPlugin(),
|
|
70
24
|
moduleName &&
|
|
@@ -121,7 +75,10 @@ const getBaseConfiguration = ({
|
|
|
121
75
|
].filter(Boolean),
|
|
122
76
|
resolve: {
|
|
123
77
|
alias: {
|
|
124
|
-
react: path.resolve('./node_modules/react')
|
|
78
|
+
react: path.resolve('./node_modules/react'),
|
|
79
|
+
'@centreon/ui/fonts': path.resolve(
|
|
80
|
+
'./node_modules/@centreon/ui/public/fonts'
|
|
81
|
+
)
|
|
125
82
|
},
|
|
126
83
|
extensions: ['.js', '.jsx', '.ts', '.tsx']
|
|
127
84
|
}
|