@centreon/js-config 23.10.29 → 23.10.31
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 +6 -11
- package/cypress/component/configuration.js +2 -10
- package/cypress/component/enableVisualTesting.ts +1 -1
- package/cypress/e2e/commands.ts +25 -178
- package/cypress/e2e/configuration.ts +4 -3
- package/cypress/e2e/plugins.ts +3 -30
- package/eslint/base.typescript.eslintrc.js +3 -15
- package/jest/index.js +1 -5
- package/package.json +1 -3
- package/tsconfig/index.json +4 -5
- package/webpack/base/index.js +57 -14
- package/cypress/e2e/commands/monitoring.ts +0 -75
- package/eslint/lambda/typescript.eslintrc.js +0 -48
- package/jest/lambda/typescript.js +0 -49
- package/tsconfig/lambda/tsconfig.json +0 -14
- package/webpack/base/globalConfig.js +0 -71
|
@@ -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
|
|
7
|
+
import { Box } 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,10 +36,11 @@ Cypress.Commands.add('mount', ({ Component, options = {} }) => {
|
|
|
36
36
|
>
|
|
37
37
|
{Component}
|
|
38
38
|
</Box>
|
|
39
|
-
<CssBaseline />
|
|
40
39
|
</ThemeProvider>
|
|
41
40
|
);
|
|
42
41
|
|
|
42
|
+
document.getElementsByTagName('body')[0].setAttribute('style', 'margin:0px');
|
|
43
|
+
|
|
43
44
|
return mount(wrapped, options);
|
|
44
45
|
});
|
|
45
46
|
|
|
@@ -127,11 +128,6 @@ Cypress.Commands.add(
|
|
|
127
128
|
}
|
|
128
129
|
);
|
|
129
130
|
|
|
130
|
-
Cypress.Commands.add('makeSnapshot', (title?: string) => {
|
|
131
|
-
cy.viewport(1280, 590);
|
|
132
|
-
cy.matchImageSnapshot(title);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
131
|
declare global {
|
|
136
132
|
namespace Cypress {
|
|
137
133
|
interface Chainable {
|
|
@@ -139,9 +135,8 @@ declare global {
|
|
|
139
135
|
props: InterceptAPIRequestProps<T>
|
|
140
136
|
) => Cypress.Chainable;
|
|
141
137
|
interceptRequest: (method, path, mock, alias) => Cypress.Chainable;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
moveSortableElement: ({ element, direction }) => void;
|
|
138
|
+
mount: ({ Component, options = {} }: MountProps) => Cypress.Chainable;
|
|
139
|
+
moveSortableElement: ({ ariaLabel, direction }) => void;
|
|
145
140
|
moveSortableElementUsingAriaLabel: ({ ariaLabel, direction }) => void;
|
|
146
141
|
waitForRequest: (alias) => Cypress.Chainable;
|
|
147
142
|
}
|
|
@@ -4,24 +4,16 @@ const {
|
|
|
4
4
|
addMatchImageSnapshotPlugin
|
|
5
5
|
} = require('@simonsmith/cypress-image-snapshot/plugin');
|
|
6
6
|
|
|
7
|
-
module.exports = ({
|
|
8
|
-
webpackConfig,
|
|
9
|
-
cypressFolder,
|
|
10
|
-
specPattern,
|
|
11
|
-
env,
|
|
12
|
-
useVite = false,
|
|
13
|
-
excludeSpecPattern
|
|
14
|
-
}) => {
|
|
7
|
+
module.exports = ({ webpackConfig, cypressFolder, specPattern, env }) => {
|
|
15
8
|
const mainCypressFolder = cypressFolder || 'cypress';
|
|
16
9
|
|
|
17
10
|
return defineConfig({
|
|
18
11
|
component: {
|
|
19
12
|
devServer: {
|
|
20
|
-
bundler:
|
|
13
|
+
bundler: 'webpack',
|
|
21
14
|
framework: 'react',
|
|
22
15
|
webpackConfig
|
|
23
16
|
},
|
|
24
|
-
excludeSpecPattern,
|
|
25
17
|
setupNodeEvents: (on, config) => {
|
|
26
18
|
addMatchImageSnapshotPlugin(on, config);
|
|
27
19
|
},
|
|
@@ -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.06,
|
|
17
17
|
failureThresholdType: 'percent'
|
|
18
18
|
});
|
|
19
19
|
};
|
package/cypress/e2e/commands.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
2
|
|
|
3
3
|
import './commands/configuration';
|
|
4
|
-
import './commands/monitoring';
|
|
5
4
|
|
|
6
5
|
const apiLoginV2 = '/centreon/authentication/providers/configurations/local';
|
|
7
6
|
|
|
@@ -24,7 +23,7 @@ Cypress.Commands.add('getWebVersion', (): Cypress.Chainable => {
|
|
|
24
23
|
|
|
25
24
|
Cypress.Commands.add('getIframeBody', (): Cypress.Chainable => {
|
|
26
25
|
return cy
|
|
27
|
-
.get('iframe#main-content'
|
|
26
|
+
.get('iframe#main-content')
|
|
28
27
|
.its('0.contentDocument.body')
|
|
29
28
|
.should('not.be.empty')
|
|
30
29
|
.then(cy.wrap);
|
|
@@ -40,13 +39,6 @@ Cypress.Commands.add(
|
|
|
40
39
|
}
|
|
41
40
|
);
|
|
42
41
|
|
|
43
|
-
Cypress.Commands.add(
|
|
44
|
-
'clickSubRootMenuItem',
|
|
45
|
-
(page: string): Cypress.Chainable => {
|
|
46
|
-
return cy.get('div[data-cy="collapse"]').eq(1).contains(page).click();
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
|
|
50
42
|
interface NavigateToProps {
|
|
51
43
|
page: string;
|
|
52
44
|
rootItemNumber: number;
|
|
@@ -59,13 +51,8 @@ Cypress.Commands.add(
|
|
|
59
51
|
if (subMenu) {
|
|
60
52
|
cy.hoverRootMenuItem(rootItemNumber)
|
|
61
53
|
.contains(subMenu)
|
|
62
|
-
.trigger('mouseover')
|
|
63
|
-
|
|
64
|
-
.find('div[data-cy="collapse"]')
|
|
65
|
-
.should('be.visible')
|
|
66
|
-
.and('contain', page);
|
|
67
|
-
|
|
68
|
-
cy.clickSubRootMenuItem(page);
|
|
54
|
+
.trigger('mouseover', { force: true });
|
|
55
|
+
cy.contains(page).click({ force: true });
|
|
69
56
|
|
|
70
57
|
return;
|
|
71
58
|
}
|
|
@@ -98,41 +85,29 @@ Cypress.Commands.add(
|
|
|
98
85
|
|
|
99
86
|
interface CopyFromContainerProps {
|
|
100
87
|
destination: string;
|
|
101
|
-
name?: string;
|
|
102
88
|
source: string;
|
|
103
89
|
}
|
|
104
90
|
|
|
105
91
|
Cypress.Commands.add(
|
|
106
92
|
'copyFromContainer',
|
|
107
|
-
(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
destination
|
|
112
|
-
}: CopyFromContainerProps,
|
|
113
|
-
options?: Partial<Cypress.ExecOptions>
|
|
114
|
-
) => {
|
|
115
|
-
return cy.exec(`docker cp ${name}:${source} "${destination}"`, options);
|
|
93
|
+
({ source, destination }: CopyFromContainerProps) => {
|
|
94
|
+
return cy.exec(
|
|
95
|
+
`docker cp ${Cypress.env('dockerName')}:${source} "${destination}"`
|
|
96
|
+
);
|
|
116
97
|
}
|
|
117
98
|
);
|
|
118
99
|
|
|
119
100
|
interface CopyToContainerProps {
|
|
120
101
|
destination: string;
|
|
121
|
-
name?: string;
|
|
122
102
|
source: string;
|
|
123
103
|
}
|
|
124
104
|
|
|
125
105
|
Cypress.Commands.add(
|
|
126
106
|
'copyToContainer',
|
|
127
|
-
(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
destination
|
|
132
|
-
}: CopyToContainerProps,
|
|
133
|
-
options?: Partial<Cypress.ExecOptions>
|
|
134
|
-
) => {
|
|
135
|
-
return cy.exec(`docker cp ${source} ${name}:${destination}`, options);
|
|
107
|
+
({ source, destination }: CopyToContainerProps) => {
|
|
108
|
+
return cy.exec(
|
|
109
|
+
`docker cp ${source} ${Cypress.env('dockerName')}:${destination}`
|
|
110
|
+
);
|
|
136
111
|
}
|
|
137
112
|
);
|
|
138
113
|
|
|
@@ -160,15 +135,12 @@ Cypress.Commands.add(
|
|
|
160
135
|
.visit(`${Cypress.config().baseUrl}`)
|
|
161
136
|
.wait('@getNavigationList');
|
|
162
137
|
}
|
|
163
|
-
|
|
164
138
|
cy.visit(`${Cypress.config().baseUrl}`)
|
|
165
139
|
.fixture(`users/${jsonName}.json`)
|
|
166
140
|
.then((credential) => {
|
|
167
|
-
cy.getByLabel({ label: 'Alias', tag: 'input' }).type(
|
|
168
|
-
`{selectAll}{backspace}${credential.login}`
|
|
169
|
-
);
|
|
141
|
+
cy.getByLabel({ label: 'Alias', tag: 'input' }).type(credential.login);
|
|
170
142
|
cy.getByLabel({ label: 'Password', tag: 'input' }).type(
|
|
171
|
-
|
|
143
|
+
credential.password
|
|
172
144
|
);
|
|
173
145
|
})
|
|
174
146
|
.getByLabel({ label: 'Connect', tag: 'button' })
|
|
@@ -225,7 +197,9 @@ interface StartContainerProps {
|
|
|
225
197
|
Cypress.Commands.add(
|
|
226
198
|
'startContainer',
|
|
227
199
|
({ name, image, portBindings }: StartContainerProps): Cypress.Chainable => {
|
|
228
|
-
return cy
|
|
200
|
+
return cy
|
|
201
|
+
.exec(`docker image inspect ${image} || docker pull ${image}`)
|
|
202
|
+
.task('startContainer', { image, name, portBindings });
|
|
229
203
|
}
|
|
230
204
|
);
|
|
231
205
|
|
|
@@ -240,7 +214,7 @@ Cypress.Commands.add(
|
|
|
240
214
|
'startWebContainer',
|
|
241
215
|
({
|
|
242
216
|
name = Cypress.env('dockerName'),
|
|
243
|
-
os =
|
|
217
|
+
os = 'alma9',
|
|
244
218
|
useSlim = true,
|
|
245
219
|
version = Cypress.env('WEB_IMAGE_VERSION')
|
|
246
220
|
}: StartWebContainerProps = {}): Cypress.Chainable => {
|
|
@@ -290,38 +264,22 @@ Cypress.Commands.add(
|
|
|
290
264
|
.exec(`mkdir -p "${logDirectory}"`)
|
|
291
265
|
.copyFromContainer({
|
|
292
266
|
destination: `${logDirectory}/broker`,
|
|
293
|
-
name,
|
|
294
267
|
source: '/var/log/centreon-broker'
|
|
295
268
|
})
|
|
296
269
|
.copyFromContainer({
|
|
297
270
|
destination: `${logDirectory}/engine`,
|
|
298
|
-
name,
|
|
299
271
|
source: '/var/log/centreon-engine'
|
|
300
272
|
})
|
|
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
|
+
})
|
|
301
279
|
.copyFromContainer({
|
|
302
280
|
destination: `${logDirectory}/centreon`,
|
|
303
|
-
name,
|
|
304
281
|
source: '/var/log/centreon'
|
|
305
282
|
})
|
|
306
|
-
.then(() => {
|
|
307
|
-
if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
|
|
308
|
-
return cy.copyFromContainer({
|
|
309
|
-
destination: `${logDirectory}/php`,
|
|
310
|
-
name,
|
|
311
|
-
source: '/var/log/php-fpm'
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
return cy.copyFromContainer(
|
|
316
|
-
{
|
|
317
|
-
destination: `${logDirectory}/php8.1-fpm-centreon-error.log`,
|
|
318
|
-
name,
|
|
319
|
-
source: '/var/log/php8.1-fpm-centreon-error.log'
|
|
320
|
-
},
|
|
321
|
-
{ failOnNonZeroExit: false }
|
|
322
|
-
);
|
|
323
|
-
})
|
|
324
|
-
.exec(`chmod -R 755 "${logDirectory}"`)
|
|
325
283
|
.stopContainer({ name });
|
|
326
284
|
}
|
|
327
285
|
);
|
|
@@ -350,124 +308,18 @@ Cypress.Commands.add(
|
|
|
350
308
|
}
|
|
351
309
|
);
|
|
352
310
|
|
|
353
|
-
interface Dashboard {
|
|
354
|
-
description?: string;
|
|
355
|
-
name: string;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
Cypress.Commands.add(
|
|
359
|
-
'insertDashboardList',
|
|
360
|
-
(fixtureFile: string): Cypress.Chainable => {
|
|
361
|
-
return cy.fixture(fixtureFile).then((dashboardList) => {
|
|
362
|
-
cy.wrap(
|
|
363
|
-
Promise.all(
|
|
364
|
-
dashboardList.map((dashboardBody: Dashboard) =>
|
|
365
|
-
cy.insertDashboard({ ...dashboardBody })
|
|
366
|
-
)
|
|
367
|
-
)
|
|
368
|
-
);
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
);
|
|
372
|
-
|
|
373
|
-
Cypress.Commands.add(
|
|
374
|
-
'insertDashboard',
|
|
375
|
-
(dashboardBody: Dashboard): Cypress.Chainable => {
|
|
376
|
-
return cy.request({
|
|
377
|
-
body: {
|
|
378
|
-
...dashboardBody
|
|
379
|
-
},
|
|
380
|
-
method: 'POST',
|
|
381
|
-
url: '/centreon/api/latest/configuration/dashboards'
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
);
|
|
385
|
-
|
|
386
|
-
interface ShareDashboardToUserProps {
|
|
387
|
-
dashboardName: string;
|
|
388
|
-
role: string;
|
|
389
|
-
userName: string;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
interface ListingRequestResult {
|
|
393
|
-
body: {
|
|
394
|
-
result: Array<{
|
|
395
|
-
id: number;
|
|
396
|
-
}>;
|
|
397
|
-
};
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
Cypress.Commands.add(
|
|
401
|
-
'shareDashboardToUser',
|
|
402
|
-
({ dashboardName, userName, role }: ShareDashboardToUserProps): void => {
|
|
403
|
-
Promise.all([
|
|
404
|
-
cy.request({
|
|
405
|
-
method: 'GET',
|
|
406
|
-
url: `/centreon/api/latest/configuration/users?search={"name":"${userName}"}`
|
|
407
|
-
}),
|
|
408
|
-
cy.request({
|
|
409
|
-
method: 'GET',
|
|
410
|
-
url: `/centreon/api/latest/configuration/dashboards?search={"name":"${dashboardName}"}`
|
|
411
|
-
})
|
|
412
|
-
]).then(
|
|
413
|
-
([retrievedUser, retrievedDashboard]: [
|
|
414
|
-
ListingRequestResult,
|
|
415
|
-
ListingRequestResult
|
|
416
|
-
]) => {
|
|
417
|
-
const userId = retrievedUser.body.result[0].id;
|
|
418
|
-
const dashboardId = retrievedDashboard.body.result[0].id;
|
|
419
|
-
|
|
420
|
-
cy.request({
|
|
421
|
-
body: {
|
|
422
|
-
id: userId,
|
|
423
|
-
role: `${role}`
|
|
424
|
-
},
|
|
425
|
-
method: 'POST',
|
|
426
|
-
url: `/centreon/api/latest/configuration/dashboards/${dashboardId}/access_rights/contacts`
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
);
|
|
430
|
-
}
|
|
431
|
-
);
|
|
432
|
-
|
|
433
|
-
Cypress.Commands.add('getTimeFromHeader', (): Cypress.Chainable => {
|
|
434
|
-
return cy
|
|
435
|
-
.get('header div[data-cy="clock"]', { timeout: 10000 })
|
|
436
|
-
.should('be.visible')
|
|
437
|
-
.then(($time) => {
|
|
438
|
-
const headerTime = $time.children()[1].textContent;
|
|
439
|
-
if (headerTime?.match(/\d+:\d+/)) {
|
|
440
|
-
cy.log(`header time is : ${headerTime}`);
|
|
441
|
-
|
|
442
|
-
return cy.wrap(headerTime);
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
throw new Error(`header time is not displayed`);
|
|
446
|
-
});
|
|
447
|
-
});
|
|
448
|
-
|
|
449
311
|
declare global {
|
|
450
312
|
namespace Cypress {
|
|
451
313
|
interface Chainable {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
props: CopyFromContainerProps,
|
|
455
|
-
options?: Partial<Cypress.ExecOptions>
|
|
456
|
-
) => Cypress.Chainable;
|
|
457
|
-
copyToContainer: (
|
|
458
|
-
props: CopyToContainerProps,
|
|
459
|
-
options?: Partial<Cypress.ExecOptions>
|
|
460
|
-
) => Cypress.Chainable;
|
|
314
|
+
copyFromContainer: (props: CopyFromContainerProps) => Cypress.Chainable;
|
|
315
|
+
copyToContainer: (props: CopyToContainerProps) => Cypress.Chainable;
|
|
461
316
|
execInContainer: ({
|
|
462
317
|
command,
|
|
463
318
|
name
|
|
464
319
|
}: ExecInContainerProps) => Cypress.Chainable;
|
|
465
320
|
getIframeBody: () => Cypress.Chainable;
|
|
466
|
-
getTimeFromHeader: () => Cypress.Chainable;
|
|
467
321
|
getWebVersion: () => Cypress.Chainable;
|
|
468
322
|
hoverRootMenuItem: (rootItemNumber: number) => Cypress.Chainable;
|
|
469
|
-
insertDashboard: (dashboard: Dashboard) => Cypress.Chainable;
|
|
470
|
-
insertDashboardList: (fixtureFile: string) => Cypress.Chainable;
|
|
471
323
|
loginByTypeOfUser: ({
|
|
472
324
|
jsonName = 'admin',
|
|
473
325
|
loginViaApi = false
|
|
@@ -478,11 +330,6 @@ declare global {
|
|
|
478
330
|
rootItemNumber,
|
|
479
331
|
subMenu
|
|
480
332
|
}: NavigateToProps) => Cypress.Chainable;
|
|
481
|
-
shareDashboardToUser: ({
|
|
482
|
-
dashboardName,
|
|
483
|
-
userName,
|
|
484
|
-
role
|
|
485
|
-
}: ShareDashboardToUserProps) => Cypress.Chainable;
|
|
486
333
|
startContainer: ({
|
|
487
334
|
name,
|
|
488
335
|
image
|
|
@@ -22,7 +22,9 @@ export default ({
|
|
|
22
22
|
dockerName,
|
|
23
23
|
env
|
|
24
24
|
}: ConfigurationOptions): Cypress.ConfigOptions => {
|
|
25
|
-
const resultsFolder = `${cypressFolder || 'cypress'}/results
|
|
25
|
+
const resultsFolder = `${cypressFolder || 'cypress'}/results${
|
|
26
|
+
isDevelopment ? '/dev' : ''
|
|
27
|
+
}`;
|
|
26
28
|
|
|
27
29
|
const webImageVersion = execSync('git rev-parse --abbrev-ref HEAD')
|
|
28
30
|
.toString('utf8')
|
|
@@ -43,7 +45,7 @@ export default ({
|
|
|
43
45
|
WEB_IMAGE_VERSION: webImageVersion,
|
|
44
46
|
dockerName: dockerName || 'centreon-dev'
|
|
45
47
|
},
|
|
46
|
-
execTimeout:
|
|
48
|
+
execTimeout: 120000,
|
|
47
49
|
reporter: 'mochawesome',
|
|
48
50
|
reporterOptions: {
|
|
49
51
|
html: false,
|
|
@@ -56,7 +58,6 @@ export default ({
|
|
|
56
58
|
retries: 0,
|
|
57
59
|
screenshotsFolder: `${resultsFolder}/screenshots`,
|
|
58
60
|
video: true,
|
|
59
|
-
videoCompression: isDevelopment ? 0 : 16,
|
|
60
61
|
videosFolder: `${resultsFolder}/videos`
|
|
61
62
|
});
|
|
62
63
|
};
|
package/cypress/e2e/plugins.ts
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
4
4
|
/* eslint-disable no-param-reassign */
|
|
5
5
|
|
|
6
|
-
import { execSync } from 'child_process';
|
|
7
|
-
|
|
8
6
|
import Docker from 'dockerode';
|
|
9
7
|
import { addCucumberPreprocessorPlugin } from '@badeball/cypress-cucumber-preprocessor';
|
|
10
8
|
import webpackPreprocessor from '@cypress/webpack-preprocessor';
|
|
@@ -52,21 +50,11 @@ export default async (on, config): Promise<void> => {
|
|
|
52
50
|
on('file:preprocessor', webpackPreprocessor(options));
|
|
53
51
|
|
|
54
52
|
on('before:browser:launch', (browser = {}, launchOptions) => {
|
|
55
|
-
const width = 1920;
|
|
56
|
-
const height = 1080;
|
|
57
|
-
|
|
58
53
|
if ((browser as { name }).name === 'chrome') {
|
|
59
|
-
// flags description : https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md
|
|
60
54
|
launchOptions.args.push('--disable-gpu');
|
|
61
|
-
launchOptions.args.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
launchOptions.args.push('--mute-audio');
|
|
65
|
-
launchOptions.args.push('--hide-scrollbars');
|
|
66
|
-
|
|
67
|
-
launchOptions.args.push(`--window-size=${width},${height}`);
|
|
68
|
-
// force screen to be non-retina and just use our given resolution
|
|
69
|
-
launchOptions.args.push('--force-device-scale-factor=1');
|
|
55
|
+
launchOptions.args = launchOptions.args.filter(
|
|
56
|
+
(element) => element !== '--disable-dev-shm-usage'
|
|
57
|
+
);
|
|
70
58
|
}
|
|
71
59
|
|
|
72
60
|
return launchOptions;
|
|
@@ -93,21 +81,6 @@ export default async (on, config): Promise<void> => {
|
|
|
93
81
|
name,
|
|
94
82
|
portBindings = []
|
|
95
83
|
}: StartContainerProps) => {
|
|
96
|
-
const imageList = execSync(
|
|
97
|
-
'docker image list --format "{{.Repository}}:{{.Tag}}"'
|
|
98
|
-
).toString('utf8');
|
|
99
|
-
|
|
100
|
-
if (
|
|
101
|
-
!imageList.match(
|
|
102
|
-
new RegExp(
|
|
103
|
-
`^${image.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')}`,
|
|
104
|
-
'm'
|
|
105
|
-
)
|
|
106
|
-
)
|
|
107
|
-
) {
|
|
108
|
-
execSync(`docker pull ${image}`);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
84
|
const webContainers = await docker.listContainers({
|
|
112
85
|
all: true,
|
|
113
86
|
filters: { name: [name] }
|
|
@@ -21,15 +21,11 @@ module.exports = {
|
|
|
21
21
|
}
|
|
22
22
|
],
|
|
23
23
|
'@typescript-eslint/camelcase': 'off',
|
|
24
|
-
'@typescript-eslint/consistent-type-definitions': [
|
|
25
|
-
'@typescript-eslint/explicit-function-return-type': [
|
|
24
|
+
'@typescript-eslint/consistent-type-definitions': [
|
|
26
25
|
'error',
|
|
27
|
-
|
|
28
|
-
allowExpressions: true,
|
|
29
|
-
allowHigherOrderFunctions: true,
|
|
30
|
-
allowTypedFunctionExpressions: true
|
|
31
|
-
}
|
|
26
|
+
'interface'
|
|
32
27
|
],
|
|
28
|
+
'@typescript-eslint/explicit-function-return-type': ['error'],
|
|
33
29
|
'@typescript-eslint/explicit-member-accessibility': [
|
|
34
30
|
'error',
|
|
35
31
|
{
|
|
@@ -80,21 +76,13 @@ module.exports = {
|
|
|
80
76
|
}
|
|
81
77
|
],
|
|
82
78
|
camelcase: 'off',
|
|
83
|
-
'import/no-cycle': 'off',
|
|
84
|
-
'import/no-named-as-default': 'warn',
|
|
85
79
|
'no-shadow': 'off',
|
|
86
80
|
'no-unused-expressions': 'off'
|
|
87
81
|
},
|
|
88
82
|
settings: {
|
|
89
|
-
'import/parsers': {
|
|
90
|
-
'@typescript-eslint/parser': ['.ts', '.tsx']
|
|
91
|
-
},
|
|
92
83
|
'import/resolver': {
|
|
93
84
|
alias: {
|
|
94
85
|
extensions: ['.ts', '.tsx', '.js', '.jsx']
|
|
95
|
-
},
|
|
96
|
-
typescript: {
|
|
97
|
-
alwaysTryTypes: true
|
|
98
86
|
}
|
|
99
87
|
}
|
|
100
88
|
}
|
package/jest/index.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
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',
|
|
6
4
|
'^react($|/.+)': '<rootDir>/node_modules/react$1'
|
|
7
5
|
},
|
|
8
6
|
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
|
|
9
7
|
testEnvironment: 'jsdom',
|
|
10
|
-
testPathIgnorePatterns: ['/node_modules/'
|
|
8
|
+
testPathIgnorePatterns: ['/node_modules/'],
|
|
11
9
|
transform: {
|
|
12
|
-
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$':
|
|
13
|
-
'jest-transform-stub',
|
|
14
10
|
'^.+\\.[jt]sx?$': [
|
|
15
11
|
'@swc/jest',
|
|
16
12
|
{
|
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.31",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/centreon/centreon-frontend.git"
|
|
@@ -17,14 +17,12 @@
|
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@badeball/cypress-cucumber-preprocessor": "^14.0.0",
|
|
20
|
-
"@tsconfig/node16": "^1.0.4",
|
|
21
20
|
"@types/dockerode": "^3.3.16",
|
|
22
21
|
"dockerode": "^3.3.5",
|
|
23
22
|
"eslint": "^8.17.0",
|
|
24
23
|
"eslint-config-airbnb": "19.0.4",
|
|
25
24
|
"eslint-config-prettier": "^8.5.0",
|
|
26
25
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
27
|
-
"eslint-import-resolver-typescript": "^3.5.5",
|
|
28
26
|
"eslint-plugin-babel": "^5.3.1",
|
|
29
27
|
"eslint-plugin-hooks": "^0.4.3",
|
|
30
28
|
"eslint-plugin-import": "^2.26.0",
|
package/tsconfig/index.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"downlevelIteration": true,
|
|
4
|
-
"module": "ESNext",
|
|
5
3
|
"moduleResolution": "node",
|
|
6
|
-
"
|
|
4
|
+
"downlevelIteration": true,
|
|
5
|
+
"module": "es6",
|
|
6
|
+
"target": "es6",
|
|
7
7
|
"jsx": "react-jsx",
|
|
8
8
|
"strict": true,
|
|
9
9
|
"noImplicitAny": false,
|
|
10
10
|
"skipLibCheck": true,
|
|
11
|
-
"esModuleInterop": true
|
|
12
|
-
"resolveJsonModule": true
|
|
11
|
+
"esModuleInterop": true
|
|
13
12
|
}
|
|
14
13
|
}
|
package/webpack/base/index.js
CHANGED
|
@@ -3,22 +3,68 @@ const path = require('path');
|
|
|
3
3
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
4
4
|
const { ModuleFederationPlugin } = require('webpack').container;
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
optimization,
|
|
9
|
-
output,
|
|
10
|
-
cache
|
|
11
|
-
} = require('./globalConfig');
|
|
6
|
+
const excludeNodeModulesExceptCentreonUi =
|
|
7
|
+
/node_modules(\\|\/)\.pnpm(\\|\/)(?!(@centreon))/;
|
|
12
8
|
|
|
13
9
|
const getBaseConfiguration = ({
|
|
14
10
|
moduleName,
|
|
15
11
|
moduleFederationConfig,
|
|
16
12
|
jscTransformConfiguration
|
|
17
13
|
}) => ({
|
|
18
|
-
cache,
|
|
19
|
-
module:
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
cache: false,
|
|
15
|
+
module: {
|
|
16
|
+
rules: [
|
|
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
|
+
},
|
|
22
68
|
plugins: [
|
|
23
69
|
new CleanWebpackPlugin(),
|
|
24
70
|
moduleName &&
|
|
@@ -75,10 +121,7 @@ const getBaseConfiguration = ({
|
|
|
75
121
|
].filter(Boolean),
|
|
76
122
|
resolve: {
|
|
77
123
|
alias: {
|
|
78
|
-
react: path.resolve('./node_modules/react')
|
|
79
|
-
'@centreon/ui/fonts': path.resolve(
|
|
80
|
-
'./node_modules/@centreon/ui/public/fonts'
|
|
81
|
-
)
|
|
124
|
+
react: path.resolve('./node_modules/react')
|
|
82
125
|
},
|
|
83
126
|
extensions: ['.js', '.jsx', '.ts', '.tsx']
|
|
84
127
|
}
|
|
@@ -1,75 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,48 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
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
|
-
};
|