@centreon/js-config 23.10.1-remove-cypress-fail-fast.0 → 23.10.1-remove-video-compression.0
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/e2e/commands/monitoring.ts +75 -0
- package/cypress/e2e/commands.ts +109 -37
- package/cypress/e2e/configuration.ts +11 -5
- package/cypress/e2e/esbuild-preprocessor.ts +26 -0
- package/cypress/e2e/plugins.ts +17 -119
- package/cypress/e2e/tasks.ts +97 -0
- package/package.json +9 -4
- package/tsconfig/index.json +2 -2
|
@@ -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
|
}
|
|
@@ -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,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
2
|
|
|
3
3
|
import './commands/configuration';
|
|
4
|
+
import './commands/monitoring';
|
|
4
5
|
|
|
5
6
|
const apiLoginV2 = '/centreon/authentication/providers/configurations/local';
|
|
6
7
|
|
|
@@ -103,12 +104,15 @@ interface CopyFromContainerProps {
|
|
|
103
104
|
|
|
104
105
|
Cypress.Commands.add(
|
|
105
106
|
'copyFromContainer',
|
|
106
|
-
(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
(
|
|
108
|
+
{
|
|
109
|
+
name = Cypress.env('dockerName'),
|
|
110
|
+
source,
|
|
111
|
+
destination
|
|
112
|
+
}: CopyFromContainerProps,
|
|
113
|
+
options?: Partial<Cypress.ExecOptions>
|
|
114
|
+
) => {
|
|
115
|
+
return cy.exec(`docker cp ${name}:${source} "${destination}"`, options);
|
|
112
116
|
}
|
|
113
117
|
);
|
|
114
118
|
|
|
@@ -120,12 +124,15 @@ interface CopyToContainerProps {
|
|
|
120
124
|
|
|
121
125
|
Cypress.Commands.add(
|
|
122
126
|
'copyToContainer',
|
|
123
|
-
(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
(
|
|
128
|
+
{
|
|
129
|
+
name = Cypress.env('dockerName'),
|
|
130
|
+
source,
|
|
131
|
+
destination
|
|
132
|
+
}: CopyToContainerProps,
|
|
133
|
+
options?: Partial<Cypress.ExecOptions>
|
|
134
|
+
) => {
|
|
135
|
+
return cy.exec(`docker cp ${source} ${name}:${destination}`, options);
|
|
129
136
|
}
|
|
130
137
|
);
|
|
131
138
|
|
|
@@ -136,7 +143,7 @@ interface LoginByTypeOfUserProps {
|
|
|
136
143
|
|
|
137
144
|
Cypress.Commands.add(
|
|
138
145
|
'loginByTypeOfUser',
|
|
139
|
-
({ jsonName, loginViaApi }): Cypress.Chainable => {
|
|
146
|
+
({ jsonName = 'admin', loginViaApi = false }): Cypress.Chainable => {
|
|
140
147
|
if (loginViaApi) {
|
|
141
148
|
return cy
|
|
142
149
|
.fixture(`users/${jsonName}.json`)
|
|
@@ -153,12 +160,15 @@ Cypress.Commands.add(
|
|
|
153
160
|
.visit(`${Cypress.config().baseUrl}`)
|
|
154
161
|
.wait('@getNavigationList');
|
|
155
162
|
}
|
|
163
|
+
|
|
156
164
|
cy.visit(`${Cypress.config().baseUrl}`)
|
|
157
165
|
.fixture(`users/${jsonName}.json`)
|
|
158
166
|
.then((credential) => {
|
|
159
|
-
cy.getByLabel({ label: 'Alias', tag: 'input' }).type(
|
|
167
|
+
cy.getByLabel({ label: 'Alias', tag: 'input' }).type(
|
|
168
|
+
`{selectAll}{backspace}${credential.login}`
|
|
169
|
+
);
|
|
160
170
|
cy.getByLabel({ label: 'Password', tag: 'input' }).type(
|
|
161
|
-
credential.password
|
|
171
|
+
`{selectAll}{backspace}${credential.password}`
|
|
162
172
|
);
|
|
163
173
|
})
|
|
164
174
|
.getByLabel({ label: 'Connect', tag: 'button' })
|
|
@@ -215,11 +225,7 @@ interface StartContainerProps {
|
|
|
215
225
|
Cypress.Commands.add(
|
|
216
226
|
'startContainer',
|
|
217
227
|
({ name, image, portBindings }: StartContainerProps): Cypress.Chainable => {
|
|
218
|
-
return cy
|
|
219
|
-
.exec(`docker image inspect ${image} || docker pull ${image}`, {
|
|
220
|
-
timeout: 120000
|
|
221
|
-
})
|
|
222
|
-
.task('startContainer', { image, name, portBindings });
|
|
228
|
+
return cy.task('startContainer', { image, name, portBindings });
|
|
223
229
|
}
|
|
224
230
|
);
|
|
225
231
|
|
|
@@ -249,12 +255,13 @@ Cypress.Commands.add(
|
|
|
249
255
|
portBindings: [{ destination: 4000, source: 80 }]
|
|
250
256
|
})
|
|
251
257
|
.then(() => {
|
|
252
|
-
const baseUrl = 'http://
|
|
258
|
+
const baseUrl = 'http://127.0.0.1:4000';
|
|
253
259
|
|
|
254
260
|
Cypress.config('baseUrl', baseUrl);
|
|
255
261
|
|
|
256
|
-
return cy.
|
|
257
|
-
|
|
262
|
+
return cy.task(
|
|
263
|
+
'waitOn',
|
|
264
|
+
`${baseUrl}/centreon/api/latest/platform/installation/status`
|
|
258
265
|
);
|
|
259
266
|
})
|
|
260
267
|
.visit('/') // this is necessary to refresh browser cause baseUrl has changed (flash appears in video)
|
|
@@ -306,12 +313,16 @@ Cypress.Commands.add(
|
|
|
306
313
|
});
|
|
307
314
|
}
|
|
308
315
|
|
|
309
|
-
return cy.copyFromContainer(
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
316
|
+
return cy.copyFromContainer(
|
|
317
|
+
{
|
|
318
|
+
destination: `${logDirectory}/php8.1-fpm-centreon-error.log`,
|
|
319
|
+
name,
|
|
320
|
+
source: '/var/log/php8.1-fpm-centreon-error.log'
|
|
321
|
+
},
|
|
322
|
+
{ failOnNonZeroExit: false }
|
|
323
|
+
);
|
|
314
324
|
})
|
|
325
|
+
.exec(`chmod -R 755 "${logDirectory}"`)
|
|
315
326
|
.stopContainer({ name });
|
|
316
327
|
}
|
|
317
328
|
);
|
|
@@ -373,25 +384,81 @@ Cypress.Commands.add(
|
|
|
373
384
|
}
|
|
374
385
|
);
|
|
375
386
|
|
|
387
|
+
interface ShareDashboardToUserProps {
|
|
388
|
+
dashboardName: string;
|
|
389
|
+
role: string;
|
|
390
|
+
userName: string;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
interface ListingRequestResult {
|
|
394
|
+
body: {
|
|
395
|
+
result: Array<{
|
|
396
|
+
id: number;
|
|
397
|
+
}>;
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
Cypress.Commands.add(
|
|
402
|
+
'shareDashboardToUser',
|
|
403
|
+
({ dashboardName, userName, role }: ShareDashboardToUserProps): void => {
|
|
404
|
+
Promise.all([
|
|
405
|
+
cy.request({
|
|
406
|
+
method: 'GET',
|
|
407
|
+
url: `/centreon/api/latest/configuration/users?search={"name":"${userName}"}`
|
|
408
|
+
}),
|
|
409
|
+
cy.request({
|
|
410
|
+
method: 'GET',
|
|
411
|
+
url: `/centreon/api/latest/configuration/dashboards?search={"name":"${dashboardName}"}`
|
|
412
|
+
})
|
|
413
|
+
]).then(
|
|
414
|
+
([retrievedUser, retrievedDashboard]: [
|
|
415
|
+
ListingRequestResult,
|
|
416
|
+
ListingRequestResult
|
|
417
|
+
]) => {
|
|
418
|
+
const userId = retrievedUser.body.result[0].id;
|
|
419
|
+
const dashboardId = retrievedDashboard.body.result[0].id;
|
|
420
|
+
|
|
421
|
+
cy.request({
|
|
422
|
+
body: {
|
|
423
|
+
id: userId,
|
|
424
|
+
role: `${role}`
|
|
425
|
+
},
|
|
426
|
+
method: 'POST',
|
|
427
|
+
url: `/centreon/api/latest/configuration/dashboards/${dashboardId}/access_rights/contacts`
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
);
|
|
433
|
+
|
|
376
434
|
Cypress.Commands.add('getTimeFromHeader', (): Cypress.Chainable => {
|
|
377
|
-
return cy
|
|
378
|
-
|
|
435
|
+
return cy
|
|
436
|
+
.get('header div[data-cy="clock"]', { timeout: 10000 })
|
|
437
|
+
.should('be.visible')
|
|
438
|
+
.then(($time) => {
|
|
379
439
|
const headerTime = $time.children()[1].textContent;
|
|
380
440
|
if (headerTime?.match(/\d+:\d+/)) {
|
|
381
|
-
|
|
441
|
+
cy.log(`header time is : ${headerTime}`);
|
|
442
|
+
|
|
443
|
+
return cy.wrap(headerTime);
|
|
382
444
|
}
|
|
383
445
|
|
|
384
|
-
|
|
446
|
+
throw new Error(`header time is not displayed`);
|
|
385
447
|
});
|
|
386
|
-
});
|
|
387
448
|
});
|
|
388
449
|
|
|
389
450
|
declare global {
|
|
390
451
|
namespace Cypress {
|
|
391
452
|
interface Chainable {
|
|
392
453
|
clickSubRootMenuItem: (page: string) => Cypress.Chainable;
|
|
393
|
-
copyFromContainer: (
|
|
394
|
-
|
|
454
|
+
copyFromContainer: (
|
|
455
|
+
props: CopyFromContainerProps,
|
|
456
|
+
options?: Partial<Cypress.ExecOptions>
|
|
457
|
+
) => Cypress.Chainable;
|
|
458
|
+
copyToContainer: (
|
|
459
|
+
props: CopyToContainerProps,
|
|
460
|
+
options?: Partial<Cypress.ExecOptions>
|
|
461
|
+
) => Cypress.Chainable;
|
|
395
462
|
execInContainer: ({
|
|
396
463
|
command,
|
|
397
464
|
name
|
|
@@ -403,8 +470,8 @@ declare global {
|
|
|
403
470
|
insertDashboard: (dashboard: Dashboard) => Cypress.Chainable;
|
|
404
471
|
insertDashboardList: (fixtureFile: string) => Cypress.Chainable;
|
|
405
472
|
loginByTypeOfUser: ({
|
|
406
|
-
jsonName
|
|
407
|
-
loginViaApi
|
|
473
|
+
jsonName,
|
|
474
|
+
loginViaApi
|
|
408
475
|
}: LoginByTypeOfUserProps) => Cypress.Chainable;
|
|
409
476
|
moveSortableElement: (direction: string) => Cypress.Chainable;
|
|
410
477
|
navigateTo: ({
|
|
@@ -412,6 +479,11 @@ declare global {
|
|
|
412
479
|
rootItemNumber,
|
|
413
480
|
subMenu
|
|
414
481
|
}: NavigateToProps) => Cypress.Chainable;
|
|
482
|
+
shareDashboardToUser: ({
|
|
483
|
+
dashboardName,
|
|
484
|
+
userName,
|
|
485
|
+
role
|
|
486
|
+
}: ShareDashboardToUserProps) => Cypress.Chainable;
|
|
415
487
|
startContainer: ({
|
|
416
488
|
name,
|
|
417
489
|
image
|
|
@@ -5,7 +5,9 @@ import { execSync } from 'child_process';
|
|
|
5
5
|
|
|
6
6
|
import { defineConfig } from 'cypress';
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import esbuildPreprocessor from './esbuild-preprocessor';
|
|
9
|
+
import plugins from './plugins';
|
|
10
|
+
import tasks from './tasks';
|
|
9
11
|
|
|
10
12
|
interface ConfigurationOptions {
|
|
11
13
|
cypressFolder?: string;
|
|
@@ -22,9 +24,7 @@ export default ({
|
|
|
22
24
|
dockerName,
|
|
23
25
|
env
|
|
24
26
|
}: ConfigurationOptions): Cypress.ConfigOptions => {
|
|
25
|
-
const resultsFolder = `${cypressFolder || 'cypress'}/results
|
|
26
|
-
isDevelopment ? '/dev' : ''
|
|
27
|
-
}`;
|
|
27
|
+
const resultsFolder = `${cypressFolder || 'cypress'}/results`;
|
|
28
28
|
|
|
29
29
|
const webImageVersion = execSync('git rev-parse --abbrev-ref HEAD')
|
|
30
30
|
.toString('utf8')
|
|
@@ -35,7 +35,12 @@ export default ({
|
|
|
35
35
|
defaultCommandTimeout: 6000,
|
|
36
36
|
e2e: {
|
|
37
37
|
excludeSpecPattern: ['*.js', '*.ts', '*.md'],
|
|
38
|
-
setupNodeEvents,
|
|
38
|
+
setupNodeEvents: async (on, config) => {
|
|
39
|
+
await esbuildPreprocessor(on, config);
|
|
40
|
+
tasks(on);
|
|
41
|
+
|
|
42
|
+
return plugins(on, config);
|
|
43
|
+
},
|
|
39
44
|
specPattern
|
|
40
45
|
},
|
|
41
46
|
env: {
|
|
@@ -58,6 +63,7 @@ export default ({
|
|
|
58
63
|
retries: 0,
|
|
59
64
|
screenshotsFolder: `${resultsFolder}/screenshots`,
|
|
60
65
|
video: true,
|
|
66
|
+
videoCompression: 0,
|
|
61
67
|
videosFolder: `${resultsFolder}/videos`
|
|
62
68
|
});
|
|
63
69
|
};
|
|
@@ -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,30 @@
|
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
4
4
|
/* eslint-disable no-param-reassign */
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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;
|
|
9
13
|
|
|
10
|
-
const docker = new Docker();
|
|
11
|
-
|
|
12
|
-
const getWebpackOptions = (config): object => {
|
|
13
|
-
return {
|
|
14
|
-
module: {
|
|
15
|
-
rules: [
|
|
16
|
-
{
|
|
17
|
-
exclude: [/node_modules/],
|
|
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);
|
|
44
|
-
|
|
45
|
-
const webpackOptions = await getWebpackOptions(config);
|
|
46
|
-
const options = {
|
|
47
|
-
webpackOptions
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
on('file:preprocessor', webpackPreprocessor(options));
|
|
51
|
-
|
|
52
|
-
on('before:browser:launch', (browser = {}, launchOptions) => {
|
|
53
14
|
if ((browser as { name }).name === 'chrome') {
|
|
15
|
+
// flags description : https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md
|
|
54
16
|
launchOptions.args.push('--disable-gpu');
|
|
55
|
-
launchOptions.args
|
|
56
|
-
|
|
57
|
-
);
|
|
17
|
+
launchOptions.args.push('--auto-open-devtools-for-tabs');
|
|
18
|
+
launchOptions.args.push('--disable-extensions');
|
|
19
|
+
launchOptions.args.push('--hide-scrollbars');
|
|
20
|
+
launchOptions.args.push('--mute-audio');
|
|
21
|
+
launchOptions.args.push('--hide-scrollbars');
|
|
22
|
+
|
|
23
|
+
launchOptions.args.push(`--window-size=${width},${height}`);
|
|
24
|
+
// force screen to be non-retina and just use our given resolution
|
|
25
|
+
launchOptions.args.push('--force-device-scale-factor=1');
|
|
58
26
|
}
|
|
59
27
|
|
|
60
28
|
return launchOptions;
|
|
61
29
|
});
|
|
62
30
|
|
|
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
31
|
return config;
|
|
134
32
|
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
|
|
3
|
+
import Docker from 'dockerode';
|
|
4
|
+
|
|
5
|
+
export default (on: Cypress.PluginEvents): void => {
|
|
6
|
+
const docker = new Docker();
|
|
7
|
+
|
|
8
|
+
interface PortBinding {
|
|
9
|
+
destination: number;
|
|
10
|
+
source: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface StartContainerProps {
|
|
14
|
+
image: string;
|
|
15
|
+
name: string;
|
|
16
|
+
portBindings: Array<PortBinding>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface StopContainerProps {
|
|
20
|
+
name: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
on('task', {
|
|
24
|
+
startContainer: async ({
|
|
25
|
+
image,
|
|
26
|
+
name,
|
|
27
|
+
portBindings = []
|
|
28
|
+
}: StartContainerProps) => {
|
|
29
|
+
const imageList = execSync(
|
|
30
|
+
'docker image list --format "{{.Repository}}:{{.Tag}}"'
|
|
31
|
+
).toString('utf8');
|
|
32
|
+
|
|
33
|
+
if (
|
|
34
|
+
!imageList.match(
|
|
35
|
+
new RegExp(
|
|
36
|
+
`^${image.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')}`,
|
|
37
|
+
'm'
|
|
38
|
+
)
|
|
39
|
+
)
|
|
40
|
+
) {
|
|
41
|
+
execSync(`docker pull ${image}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const webContainers = await docker.listContainers({
|
|
45
|
+
all: true,
|
|
46
|
+
filters: { name: [name] }
|
|
47
|
+
});
|
|
48
|
+
if (webContainers.length) {
|
|
49
|
+
return webContainers[0];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const container = await docker.createContainer({
|
|
53
|
+
AttachStderr: true,
|
|
54
|
+
AttachStdin: false,
|
|
55
|
+
AttachStdout: true,
|
|
56
|
+
ExposedPorts: portBindings.reduce((accumulator, currentValue) => {
|
|
57
|
+
accumulator[`${currentValue.source}/tcp`] = {};
|
|
58
|
+
|
|
59
|
+
return accumulator;
|
|
60
|
+
}, {}),
|
|
61
|
+
HostConfig: {
|
|
62
|
+
PortBindings: portBindings.reduce((accumulator, currentValue) => {
|
|
63
|
+
accumulator[`${currentValue.source}/tcp`] = [
|
|
64
|
+
{
|
|
65
|
+
HostIP: '127.0.0.1',
|
|
66
|
+
HostPort: `${currentValue.destination}`
|
|
67
|
+
}
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
return accumulator;
|
|
71
|
+
}, {})
|
|
72
|
+
},
|
|
73
|
+
Image: image,
|
|
74
|
+
OpenStdin: false,
|
|
75
|
+
StdinOnce: false,
|
|
76
|
+
Tty: true,
|
|
77
|
+
name
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
await container.start();
|
|
81
|
+
|
|
82
|
+
return container;
|
|
83
|
+
},
|
|
84
|
+
stopContainer: async ({ name }: StopContainerProps) => {
|
|
85
|
+
const container = await docker.getContainer(name);
|
|
86
|
+
await container.kill();
|
|
87
|
+
await container.remove();
|
|
88
|
+
|
|
89
|
+
return null;
|
|
90
|
+
},
|
|
91
|
+
waitOn: async (url: string) => {
|
|
92
|
+
execSync(`npx wait-on ${url}`);
|
|
93
|
+
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
};
|
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.1-remove-
|
|
4
|
+
"version": "23.10.1-remove-video-compression.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/centreon/centreon-frontend.git"
|
|
@@ -16,10 +16,15 @@
|
|
|
16
16
|
"url": "https://github.com/centreon/centreon-frontend/issues"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@badeball/cypress-cucumber-preprocessor": "^
|
|
20
|
-
"@
|
|
21
|
-
"@
|
|
19
|
+
"@badeball/cypress-cucumber-preprocessor": "^18.0.5",
|
|
20
|
+
"@bahmutov/cypress-esbuild-preprocessor": "^2.2.0",
|
|
21
|
+
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
|
|
22
|
+
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
|
|
23
|
+
"@tsconfig/node16": "^16.1.1",
|
|
24
|
+
"@types/cypress-cucumber-preprocessor": "^4.0.2",
|
|
25
|
+
"@types/dockerode": "^3.3.19",
|
|
22
26
|
"dockerode": "^3.3.5",
|
|
27
|
+
"esbuild": "^0.19.3",
|
|
23
28
|
"eslint": "^8.17.0",
|
|
24
29
|
"eslint-config-airbnb": "19.0.4",
|
|
25
30
|
"eslint-config-prettier": "^8.5.0",
|