@centreon/js-config 23.10.66 → 24.4.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 +203 -174
- package/cypress/component/configuration.js +83 -66
- package/cypress/component/enableVisualTesting.ts +21 -21
- package/cypress/component/excludeNodeModulesFromCoverage.js +36 -0
- package/cypress/e2e/commands/configuration.ts +327 -1
- package/cypress/e2e/commands/monitoring.ts +56 -0
- package/cypress/e2e/commands.ts +433 -160
- package/cypress/e2e/configuration.ts +28 -12
- package/cypress/e2e/plugins.ts +31 -4
- package/cypress/e2e/tasks.ts +204 -53
- package/package.json +64 -58
- package/tsconfig/lambda/node20.tsconfig.json +12 -0
- package/webpack/base/index.js +2 -1
package/cypress/e2e/commands.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import 'cypress-wait-until';
|
|
2
4
|
|
|
3
5
|
import './commands/configuration';
|
|
4
6
|
import './commands/monitoring';
|
|
@@ -7,10 +9,53 @@ import installLogsCollector from 'cypress-terminal-report/src/installLogsCollect
|
|
|
7
9
|
|
|
8
10
|
installLogsCollector({ enableExtendedCollector: true });
|
|
9
11
|
|
|
12
|
+
const apiBase = '/centreon/api';
|
|
13
|
+
const apiActionV1 = `${apiBase}/index.php`;
|
|
10
14
|
const apiLoginV2 = '/centreon/authentication/providers/configurations/local';
|
|
11
15
|
|
|
12
16
|
const artifactIllegalCharactersMatcher = /[,\s/|<>*?:"]/g;
|
|
13
17
|
|
|
18
|
+
export enum PatternType {
|
|
19
|
+
contains = '*',
|
|
20
|
+
endsWith = '$',
|
|
21
|
+
equals = '',
|
|
22
|
+
startsWith = '^'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface GetByLabelProps {
|
|
26
|
+
label: string;
|
|
27
|
+
patternType?: PatternType;
|
|
28
|
+
tag?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
Cypress.Commands.add(
|
|
32
|
+
'getByLabel',
|
|
33
|
+
({
|
|
34
|
+
tag = '',
|
|
35
|
+
patternType = PatternType.equals,
|
|
36
|
+
label
|
|
37
|
+
}: GetByLabelProps): Cypress.Chainable => {
|
|
38
|
+
return cy.get(`${tag}[aria-label${patternType}="${label}"]`);
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
interface GetByTestIdProps {
|
|
43
|
+
patternType?: PatternType;
|
|
44
|
+
tag?: string;
|
|
45
|
+
testId: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
Cypress.Commands.add(
|
|
49
|
+
'getByTestId',
|
|
50
|
+
({
|
|
51
|
+
tag = '',
|
|
52
|
+
patternType = PatternType.equals,
|
|
53
|
+
testId
|
|
54
|
+
}: GetByTestIdProps): Cypress.Chainable => {
|
|
55
|
+
return cy.get(`${tag}[data-testid${patternType}="${testId}"]`);
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
|
|
14
59
|
Cypress.Commands.add('getWebVersion', (): Cypress.Chainable => {
|
|
15
60
|
return cy
|
|
16
61
|
.exec(
|
|
@@ -34,6 +79,34 @@ Cypress.Commands.add('getIframeBody', (): Cypress.Chainable => {
|
|
|
34
79
|
.then(cy.wrap);
|
|
35
80
|
});
|
|
36
81
|
|
|
82
|
+
Cypress.Commands.add(
|
|
83
|
+
'waitForElementInIframe',
|
|
84
|
+
(iframeSelector, elementSelector) => {
|
|
85
|
+
cy.waitUntil(
|
|
86
|
+
() =>
|
|
87
|
+
cy.get(iframeSelector).then(($iframe) => {
|
|
88
|
+
const iframeBody = $iframe[0].contentDocument.body;
|
|
89
|
+
if (iframeBody) {
|
|
90
|
+
const $element = Cypress.$(iframeBody).find(elementSelector);
|
|
91
|
+
|
|
92
|
+
return $element.length > 0 && $element.is(':visible');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return false;
|
|
96
|
+
}),
|
|
97
|
+
{
|
|
98
|
+
errorMsg: 'The element is not visible within the iframe',
|
|
99
|
+
interval: 5000,
|
|
100
|
+
timeout: 100000
|
|
101
|
+
}
|
|
102
|
+
).then((isVisible) => {
|
|
103
|
+
if (!isVisible) {
|
|
104
|
+
throw new Error('The element is not visible');
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
|
|
37
110
|
Cypress.Commands.add(
|
|
38
111
|
'hoverRootMenuItem',
|
|
39
112
|
(rootItemNumber: number): Cypress.Chainable => {
|
|
@@ -59,7 +132,7 @@ interface NavigateToProps {
|
|
|
59
132
|
|
|
60
133
|
Cypress.Commands.add(
|
|
61
134
|
'navigateTo',
|
|
62
|
-
({ rootItemNumber, subMenu, page }): void => {
|
|
135
|
+
({ rootItemNumber, subMenu, page }: NavigateToProps): void => {
|
|
63
136
|
if (subMenu) {
|
|
64
137
|
cy.hoverRootMenuItem(rootItemNumber)
|
|
65
138
|
.contains(subMenu)
|
|
@@ -100,6 +173,24 @@ Cypress.Commands.add(
|
|
|
100
173
|
}
|
|
101
174
|
);
|
|
102
175
|
|
|
176
|
+
Cypress.Commands.add('getContainerId', (containerName: string) => {
|
|
177
|
+
cy.log(`Getting container id of ${containerName}`);
|
|
178
|
+
|
|
179
|
+
return cy.task('getContainerId', containerName);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
Cypress.Commands.add('getContainerIpAddress', (containerName: string) => {
|
|
183
|
+
cy.log(`Getting container ip address of ${containerName}`);
|
|
184
|
+
|
|
185
|
+
return cy.task('getContainerIpAddress', containerName);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
Cypress.Commands.add('getContainersLogs', () => {
|
|
189
|
+
cy.log('Getting containers logs');
|
|
190
|
+
|
|
191
|
+
return cy.task('getContainersLogs');
|
|
192
|
+
});
|
|
193
|
+
|
|
103
194
|
interface CopyFromContainerProps {
|
|
104
195
|
destination: string;
|
|
105
196
|
name?: string;
|
|
@@ -108,38 +199,54 @@ interface CopyFromContainerProps {
|
|
|
108
199
|
|
|
109
200
|
Cypress.Commands.add(
|
|
110
201
|
'copyFromContainer',
|
|
111
|
-
(
|
|
112
|
-
{
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
destination
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return cy.exec(`docker cp ${name}:${source} "${destination}"`, options);
|
|
202
|
+
({ name = 'web', source, destination }: CopyFromContainerProps) => {
|
|
203
|
+
cy.log(`Copy content from ${name}:${source} to ${destination}`);
|
|
204
|
+
|
|
205
|
+
return cy.task('copyFromContainer', {
|
|
206
|
+
destination,
|
|
207
|
+
serviceName: name,
|
|
208
|
+
source
|
|
209
|
+
});
|
|
120
210
|
}
|
|
121
211
|
);
|
|
122
212
|
|
|
213
|
+
export enum CopyToContainerContentType {
|
|
214
|
+
Directory = 'directory',
|
|
215
|
+
File = 'file'
|
|
216
|
+
}
|
|
217
|
+
|
|
123
218
|
interface CopyToContainerProps {
|
|
124
219
|
destination: string;
|
|
125
220
|
name?: string;
|
|
126
221
|
source: string;
|
|
222
|
+
type: CopyToContainerContentType;
|
|
127
223
|
}
|
|
128
224
|
|
|
129
225
|
Cypress.Commands.add(
|
|
130
226
|
'copyToContainer',
|
|
131
|
-
(
|
|
132
|
-
{
|
|
133
|
-
|
|
227
|
+
({ name = 'web', source, destination, type }: CopyToContainerProps) => {
|
|
228
|
+
cy.log(`Copy content from ${source} to ${name}:${destination}`);
|
|
229
|
+
|
|
230
|
+
return cy.task('copyToContainer', {
|
|
231
|
+
destination,
|
|
232
|
+
serviceName: name,
|
|
134
233
|
source,
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
options?: Partial<Cypress.ExecOptions>
|
|
138
|
-
) => {
|
|
139
|
-
return cy.exec(`docker cp ${source} ${name}:${destination}`, options);
|
|
234
|
+
type
|
|
235
|
+
});
|
|
140
236
|
}
|
|
141
237
|
);
|
|
142
238
|
|
|
239
|
+
Cypress.Commands.add('loginAsAdminViaApiV2', (): Cypress.Chainable => {
|
|
240
|
+
return cy.request({
|
|
241
|
+
body: {
|
|
242
|
+
login: 'admin',
|
|
243
|
+
password: 'Centreon!2021'
|
|
244
|
+
},
|
|
245
|
+
method: 'POST',
|
|
246
|
+
url: apiLoginV2
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
|
|
143
250
|
interface LoginByTypeOfUserProps {
|
|
144
251
|
jsonName?: string;
|
|
145
252
|
loginViaApi?: boolean;
|
|
@@ -181,11 +288,39 @@ Cypress.Commands.add(
|
|
|
181
288
|
return cy.get('.MuiAlert-message').then(($snackbar) => {
|
|
182
289
|
if ($snackbar.text().includes('Login succeeded')) {
|
|
183
290
|
cy.wait('@getNavigationList');
|
|
291
|
+
cy.get('.MuiAlert-message').should('not.be.visible');
|
|
184
292
|
}
|
|
185
293
|
});
|
|
186
294
|
}
|
|
187
295
|
);
|
|
188
296
|
|
|
297
|
+
Cypress.Commands.add('logout', (): void => {
|
|
298
|
+
cy.getByLabel({ label: 'Profile' }).should('exist').click();
|
|
299
|
+
|
|
300
|
+
cy.intercept({
|
|
301
|
+
method: 'GET',
|
|
302
|
+
times: 1,
|
|
303
|
+
url: '/centreon/api/latest/authentication/logout'
|
|
304
|
+
}).as('logout');
|
|
305
|
+
|
|
306
|
+
cy.contains(/^Logout$/).click();
|
|
307
|
+
|
|
308
|
+
cy.wait('@logout').its('response.statusCode').should('eq', 302);
|
|
309
|
+
|
|
310
|
+
// https://github.com/cypress-io/cypress/issues/25841
|
|
311
|
+
cy.clearAllCookies();
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
Cypress.Commands.add('logoutViaAPI', (): Cypress.Chainable => {
|
|
315
|
+
return cy
|
|
316
|
+
.request({
|
|
317
|
+
method: 'GET',
|
|
318
|
+
url: '/centreon/authentication/logout'
|
|
319
|
+
})
|
|
320
|
+
.visit('/')
|
|
321
|
+
.getByLabel({ label: 'Alias', tag: 'input' });
|
|
322
|
+
});
|
|
323
|
+
|
|
189
324
|
Cypress.Commands.add(
|
|
190
325
|
'visitEmptyPage',
|
|
191
326
|
(): Cypress.Chainable =>
|
|
@@ -197,32 +332,91 @@ Cypress.Commands.add(
|
|
|
197
332
|
.visit('/waiting-page')
|
|
198
333
|
);
|
|
199
334
|
|
|
200
|
-
Cypress.Commands.add('waitForContainerAndSetToken', (): Cypress.Chainable => {
|
|
201
|
-
return cy.setUserTokenApiV1();
|
|
202
|
-
});
|
|
203
|
-
|
|
204
335
|
interface ExecInContainerProps {
|
|
205
|
-
command: string
|
|
336
|
+
command: string | Array<string>;
|
|
206
337
|
name: string;
|
|
207
338
|
}
|
|
208
339
|
|
|
340
|
+
interface ExecInContainerResult {
|
|
341
|
+
exitCode: number;
|
|
342
|
+
output: string;
|
|
343
|
+
}
|
|
344
|
+
|
|
209
345
|
Cypress.Commands.add(
|
|
210
346
|
'execInContainer',
|
|
211
347
|
({ command, name }: ExecInContainerProps): Cypress.Chainable => {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
348
|
+
const commands =
|
|
349
|
+
typeof command === 'string' || command instanceof String
|
|
350
|
+
? [command]
|
|
351
|
+
: command;
|
|
352
|
+
|
|
353
|
+
const results = commands.reduce(
|
|
354
|
+
(acc, runCommand) => {
|
|
355
|
+
cy.task<ExecInContainerResult>(
|
|
356
|
+
'execInContainer',
|
|
357
|
+
{ command: runCommand, name },
|
|
358
|
+
{ timeout: 600000 }
|
|
359
|
+
).then((result) => {
|
|
360
|
+
if (result.exitCode) {
|
|
361
|
+
cy.log(result.output);
|
|
362
|
+
|
|
363
|
+
// output will not be truncated
|
|
364
|
+
throw new Error(`
|
|
365
|
+
Execution of "${runCommand}" failed
|
|
366
|
+
Exit code: ${result.exitCode}
|
|
367
|
+
Output:\n${result.output}`);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
acc.output = `${acc.output}${result.output}`;
|
|
371
|
+
});
|
|
223
372
|
|
|
224
|
-
return
|
|
225
|
-
}
|
|
373
|
+
return acc;
|
|
374
|
+
},
|
|
375
|
+
{ exitCode: 0, output: '' }
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
return cy.wrap(results);
|
|
379
|
+
}
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
interface RequestOnDatabaseProps {
|
|
383
|
+
database: string;
|
|
384
|
+
query: string;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
Cypress.Commands.add(
|
|
388
|
+
'requestOnDatabase',
|
|
389
|
+
({ database, query }: RequestOnDatabaseProps): Cypress.Chainable => {
|
|
390
|
+
return cy.task('requestOnDatabase', { database, query });
|
|
391
|
+
}
|
|
392
|
+
);
|
|
393
|
+
|
|
394
|
+
interface SetUserTokenApiV1Props {
|
|
395
|
+
login?: string;
|
|
396
|
+
password?: string;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
Cypress.Commands.add(
|
|
400
|
+
'setUserTokenApiV1',
|
|
401
|
+
({
|
|
402
|
+
login = 'admin',
|
|
403
|
+
password = 'Centreon!2021'
|
|
404
|
+
}: SetUserTokenApiV1Props = {}): Cypress.Chainable => {
|
|
405
|
+
return cy
|
|
406
|
+
.request({
|
|
407
|
+
body: {
|
|
408
|
+
password,
|
|
409
|
+
username: login
|
|
410
|
+
},
|
|
411
|
+
headers: {
|
|
412
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
413
|
+
},
|
|
414
|
+
method: 'POST',
|
|
415
|
+
url: `${apiActionV1}?action=authenticate`
|
|
416
|
+
})
|
|
417
|
+
.then(({ body }) =>
|
|
418
|
+
window.localStorage.setItem('userTokenApiV1', body.authToken)
|
|
419
|
+
);
|
|
226
420
|
}
|
|
227
421
|
);
|
|
228
422
|
|
|
@@ -232,6 +426,7 @@ interface PortBinding {
|
|
|
232
426
|
}
|
|
233
427
|
|
|
234
428
|
interface StartContainerProps {
|
|
429
|
+
command?: string;
|
|
235
430
|
image: string;
|
|
236
431
|
name: string;
|
|
237
432
|
portBindings: Array<PortBinding>;
|
|
@@ -239,168 +434,212 @@ interface StartContainerProps {
|
|
|
239
434
|
|
|
240
435
|
Cypress.Commands.add(
|
|
241
436
|
'startContainer',
|
|
242
|
-
({
|
|
437
|
+
({
|
|
438
|
+
command,
|
|
439
|
+
name,
|
|
440
|
+
image,
|
|
441
|
+
portBindings
|
|
442
|
+
}: StartContainerProps): Cypress.Chainable => {
|
|
243
443
|
cy.log(`Starting container ${name} from image ${image}`);
|
|
244
444
|
|
|
245
445
|
return cy.task(
|
|
246
446
|
'startContainer',
|
|
247
|
-
{ image, name, portBindings },
|
|
447
|
+
{ command, image, name, portBindings },
|
|
248
448
|
{ timeout: 600000 } // 10 minutes because docker pull can be very slow
|
|
249
449
|
);
|
|
250
450
|
}
|
|
251
451
|
);
|
|
252
452
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
interface StartWebContainerProps {
|
|
261
|
-
name?: string;
|
|
262
|
-
os?: string;
|
|
453
|
+
interface StartContainersProps {
|
|
454
|
+
composeFile?: string;
|
|
455
|
+
databaseImage?: string;
|
|
456
|
+
moduleName?: string;
|
|
457
|
+
openidImage?: string;
|
|
458
|
+
profiles?: Array<string>;
|
|
459
|
+
samlImage?: string;
|
|
263
460
|
useSlim?: boolean;
|
|
264
|
-
|
|
461
|
+
webOs?: string;
|
|
462
|
+
webVersion?: string;
|
|
265
463
|
}
|
|
266
464
|
|
|
267
465
|
Cypress.Commands.add(
|
|
268
|
-
'
|
|
466
|
+
'startContainers',
|
|
269
467
|
({
|
|
270
|
-
|
|
271
|
-
|
|
468
|
+
composeFile,
|
|
469
|
+
databaseImage = Cypress.env('DATABASE_IMAGE'),
|
|
470
|
+
moduleName = 'centreon-web',
|
|
471
|
+
openidImage = `docker.centreon.com/centreon/keycloak:${Cypress.env(
|
|
472
|
+
'OPENID_IMAGE_VERSION'
|
|
473
|
+
)}`,
|
|
474
|
+
profiles = [],
|
|
475
|
+
samlImage = `docker.centreon.com/centreon/keycloak:${Cypress.env(
|
|
476
|
+
'SAML_IMAGE_VERSION'
|
|
477
|
+
)}`,
|
|
272
478
|
useSlim = true,
|
|
273
|
-
|
|
274
|
-
|
|
479
|
+
webOs = Cypress.env('WEB_IMAGE_OS'),
|
|
480
|
+
webVersion = Cypress.env('WEB_IMAGE_VERSION')
|
|
481
|
+
}: StartContainersProps = {}): Cypress.Chainable => {
|
|
482
|
+
cy.log('Starting containers ...');
|
|
483
|
+
|
|
484
|
+
let composeFilePath = composeFile;
|
|
485
|
+
if (!composeFile) {
|
|
486
|
+
const cypressDir = path.dirname(Cypress.config('configFile'));
|
|
487
|
+
composeFilePath = `${cypressDir}/../../../.github/docker/docker-compose.yml`;
|
|
488
|
+
}
|
|
489
|
+
|
|
275
490
|
const slimSuffix = useSlim ? '-slim' : '';
|
|
276
491
|
|
|
277
|
-
const
|
|
492
|
+
const webImage = `docker.centreon.com/centreon/${moduleName}${slimSuffix}-${webOs}:${webVersion}`;
|
|
278
493
|
|
|
279
494
|
return cy
|
|
280
|
-
.
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
495
|
+
.task(
|
|
496
|
+
'startContainers',
|
|
497
|
+
{
|
|
498
|
+
composeFile: composeFilePath,
|
|
499
|
+
databaseImage,
|
|
500
|
+
openidImage,
|
|
501
|
+
profiles,
|
|
502
|
+
samlImage,
|
|
503
|
+
webImage
|
|
504
|
+
},
|
|
505
|
+
{ timeout: 600000 } // 10 minutes because docker pull can be very slow
|
|
506
|
+
)
|
|
285
507
|
.then(() => {
|
|
286
508
|
const baseUrl = 'http://127.0.0.1:4000';
|
|
287
509
|
|
|
288
510
|
Cypress.config('baseUrl', baseUrl);
|
|
289
511
|
|
|
290
|
-
return cy.
|
|
291
|
-
'waitOn',
|
|
292
|
-
`${baseUrl}/centreon/api/latest/platform/installation/status`
|
|
293
|
-
);
|
|
512
|
+
return cy.wrap(null);
|
|
294
513
|
})
|
|
295
514
|
.visit('/') // this is necessary to refresh browser cause baseUrl has changed (flash appears in video)
|
|
296
515
|
.setUserTokenApiV1();
|
|
297
516
|
}
|
|
298
517
|
);
|
|
299
518
|
|
|
300
|
-
interface
|
|
301
|
-
name
|
|
519
|
+
interface StopContainerProps {
|
|
520
|
+
name: string;
|
|
302
521
|
}
|
|
303
522
|
|
|
304
523
|
Cypress.Commands.add(
|
|
305
|
-
'
|
|
306
|
-
({
|
|
307
|
-
|
|
308
|
-
|
|
524
|
+
'stopContainer',
|
|
525
|
+
({ name }: StopContainerProps): Cypress.Chainable => {
|
|
526
|
+
cy.log(`Stopping container ${name}`);
|
|
527
|
+
|
|
528
|
+
return cy.task('stopContainer', { name });
|
|
529
|
+
}
|
|
530
|
+
);
|
|
531
|
+
|
|
532
|
+
Cypress.Commands.add(
|
|
533
|
+
'getLogDirectory',
|
|
534
|
+
(): Cypress.Chainable => {
|
|
309
535
|
const logDirectory = `results/logs/${Cypress.spec.name.replace(
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
536
|
+
artifactIllegalCharactersMatcher,
|
|
537
|
+
'_'
|
|
538
|
+
)}/${Cypress.currentTest.title.replace(
|
|
539
|
+
artifactIllegalCharactersMatcher,
|
|
540
|
+
'_'
|
|
541
|
+
)}`;
|
|
316
542
|
|
|
317
543
|
return cy
|
|
318
|
-
.visitEmptyPage()
|
|
319
544
|
.createDirectory(logDirectory)
|
|
320
|
-
.copyFromContainer({
|
|
321
|
-
destination: `${logDirectory}/broker`,
|
|
322
|
-
name,
|
|
323
|
-
source: '/var/log/centreon-broker'
|
|
324
|
-
})
|
|
325
|
-
.copyFromContainer({
|
|
326
|
-
destination: `${logDirectory}/engine`,
|
|
327
|
-
name,
|
|
328
|
-
source: '/var/log/centreon-engine'
|
|
329
|
-
})
|
|
330
|
-
.copyFromContainer({
|
|
331
|
-
destination: `${logDirectory}/centreon`,
|
|
332
|
-
name,
|
|
333
|
-
source: '/var/log/centreon'
|
|
334
|
-
})
|
|
335
|
-
.copyFromContainer({
|
|
336
|
-
destination: `${logDirectory}/centreon-gorgone`,
|
|
337
|
-
name,
|
|
338
|
-
source: '/var/log/centreon-gorgone'
|
|
339
|
-
})
|
|
340
|
-
.then(() => {
|
|
341
|
-
if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
|
|
342
|
-
return cy.copyFromContainer({
|
|
343
|
-
destination: `${logDirectory}/php`,
|
|
344
|
-
name,
|
|
345
|
-
source: '/var/log/php-fpm'
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
return cy.copyFromContainer(
|
|
350
|
-
{
|
|
351
|
-
destination: `${logDirectory}/php8.1-fpm-centreon-error.log`,
|
|
352
|
-
name,
|
|
353
|
-
source: '/var/log/php8.1-fpm-centreon-error.log'
|
|
354
|
-
},
|
|
355
|
-
{ failOnNonZeroExit: false }
|
|
356
|
-
);
|
|
357
|
-
})
|
|
358
|
-
.then(() => {
|
|
359
|
-
if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
|
|
360
|
-
return cy.copyFromContainer({
|
|
361
|
-
destination: `${logDirectory}/httpd`,
|
|
362
|
-
name,
|
|
363
|
-
source: '/var/log/httpd'
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
return cy.copyFromContainer(
|
|
368
|
-
{
|
|
369
|
-
destination: `${logDirectory}/apache2`,
|
|
370
|
-
name,
|
|
371
|
-
source: '/var/log/apache2'
|
|
372
|
-
},
|
|
373
|
-
{ failOnNonZeroExit: false }
|
|
374
|
-
);
|
|
375
|
-
})
|
|
376
545
|
.exec(`chmod -R 755 "${logDirectory}"`)
|
|
377
|
-
.
|
|
546
|
+
.wrap(logDirectory);
|
|
378
547
|
}
|
|
379
548
|
);
|
|
380
549
|
|
|
381
|
-
interface
|
|
550
|
+
interface CopyWebContainerLogsProps {
|
|
382
551
|
name: string;
|
|
383
552
|
}
|
|
384
553
|
|
|
385
554
|
Cypress.Commands.add(
|
|
386
|
-
'
|
|
387
|
-
({ name }:
|
|
388
|
-
cy.log(`
|
|
555
|
+
'copyWebContainerLogs',
|
|
556
|
+
({ name }: CopyWebContainerLogsProps): Cypress.Chainable => {
|
|
557
|
+
cy.log(`Getting logs from container ${name} ...`);
|
|
558
|
+
|
|
559
|
+
return cy.getLogDirectory().then((logDirectory) => {
|
|
560
|
+
let sourcePhpLogs = '/var/log/php8.1-fpm-centreon-error.log';
|
|
561
|
+
let targetPhpLogs = `${logDirectory}/php8.1-fpm-centreon-error.log`;
|
|
562
|
+
let sourceApacheLogs = '/var/log/apache2';
|
|
563
|
+
let targetApacheLogs = `${logDirectory}/apache2`;
|
|
564
|
+
if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
|
|
565
|
+
sourcePhpLogs = '/var/log/php-fpm';
|
|
566
|
+
targetPhpLogs = `${logDirectory}/php`;
|
|
567
|
+
sourceApacheLogs = '/var/log/httpd';
|
|
568
|
+
targetApacheLogs = `${logDirectory}/httpd`;
|
|
569
|
+
}
|
|
389
570
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
'
|
|
395
|
-
)
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
571
|
+
return cy
|
|
572
|
+
.copyFromContainer({
|
|
573
|
+
destination: `${logDirectory}/broker`,
|
|
574
|
+
name,
|
|
575
|
+
source: '/var/log/centreon-broker'
|
|
576
|
+
})
|
|
577
|
+
.copyFromContainer({
|
|
578
|
+
destination: `${logDirectory}/engine`,
|
|
579
|
+
name,
|
|
580
|
+
source: '/var/log/centreon-engine'
|
|
581
|
+
})
|
|
582
|
+
.copyFromContainer({
|
|
583
|
+
destination: `${logDirectory}/centreon`,
|
|
584
|
+
name,
|
|
585
|
+
source: '/var/log/centreon'
|
|
586
|
+
})
|
|
587
|
+
.copyFromContainer({
|
|
588
|
+
destination: `${logDirectory}/centreon-gorgone`,
|
|
589
|
+
name,
|
|
590
|
+
source: '/var/log/centreon-gorgone'
|
|
591
|
+
})
|
|
592
|
+
.copyFromContainer({
|
|
593
|
+
destination: targetPhpLogs,
|
|
594
|
+
name,
|
|
595
|
+
source: sourcePhpLogs,
|
|
596
|
+
})
|
|
597
|
+
.copyFromContainer({
|
|
598
|
+
destination: targetApacheLogs,
|
|
599
|
+
name,
|
|
600
|
+
source: sourceApacheLogs,
|
|
601
|
+
})
|
|
602
|
+
.exec(`chmod -R 755 "${logDirectory}"`);
|
|
603
|
+
});
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
Cypress.Commands.add('stopContainers', (): Cypress.Chainable => {
|
|
607
|
+
cy.log('Stopping containers ...');
|
|
608
|
+
|
|
609
|
+
const name = 'web';
|
|
610
|
+
|
|
611
|
+
return cy
|
|
612
|
+
.visitEmptyPage()
|
|
613
|
+
.getLogDirectory()
|
|
614
|
+
.then((logDirectory) => {
|
|
615
|
+
return cy
|
|
616
|
+
.getContainersLogs()
|
|
617
|
+
.then((containersLogs: Array<Array<string>>) => {
|
|
618
|
+
if (!containersLogs) {
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
Object.entries(containersLogs).forEach(([containerName, logs]) => {
|
|
623
|
+
cy.writeFile(
|
|
624
|
+
`${logDirectory}/container-${containerName}.log`,
|
|
625
|
+
logs
|
|
626
|
+
);
|
|
627
|
+
});
|
|
628
|
+
})
|
|
629
|
+
.copyWebContainerLogs({ name })
|
|
630
|
+
.exec(`chmod -R 755 "${logDirectory}"`)
|
|
631
|
+
.task(
|
|
632
|
+
'stopContainers',
|
|
633
|
+
{},
|
|
634
|
+
{ timeout: 600000 } // 10 minutes because docker pull can be very slow
|
|
635
|
+
);
|
|
401
636
|
});
|
|
637
|
+
});
|
|
402
638
|
|
|
403
|
-
|
|
639
|
+
Cypress.Commands.add(
|
|
640
|
+
'createDirectory',
|
|
641
|
+
(directoryPath: string): Cypress.Chainable => {
|
|
642
|
+
return cy.task('createDirectory', directoryPath);
|
|
404
643
|
}
|
|
405
644
|
);
|
|
406
645
|
|
|
@@ -545,7 +784,7 @@ Cypress.Commands.add(
|
|
|
545
784
|
|
|
546
785
|
Cypress.Commands.add('getTimeFromHeader', (): Cypress.Chainable => {
|
|
547
786
|
return cy
|
|
548
|
-
.get('header div[data-cy="clock"]', { timeout:
|
|
787
|
+
.get('header div[data-cy="clock"]', { timeout: 20000 })
|
|
549
788
|
.should('be.visible')
|
|
550
789
|
.then(($time) => {
|
|
551
790
|
const headerTime = $time.children()[1].textContent;
|
|
@@ -571,12 +810,27 @@ declare global {
|
|
|
571
810
|
props: CopyToContainerProps,
|
|
572
811
|
options?: Partial<Cypress.ExecOptions>
|
|
573
812
|
) => Cypress.Chainable;
|
|
813
|
+
copyWebContainerLogs: (props: CopyWebContainerLogsProps) => Cypress.Chainable;
|
|
574
814
|
createDirectory: (directoryPath: string) => Cypress.Chainable;
|
|
575
815
|
execInContainer: ({
|
|
576
816
|
command,
|
|
577
817
|
name
|
|
578
818
|
}: ExecInContainerProps) => Cypress.Chainable;
|
|
819
|
+
getByLabel: ({
|
|
820
|
+
patternType,
|
|
821
|
+
tag,
|
|
822
|
+
label
|
|
823
|
+
}: GetByLabelProps) => Cypress.Chainable;
|
|
824
|
+
getByTestId: ({
|
|
825
|
+
patternType,
|
|
826
|
+
tag,
|
|
827
|
+
testId
|
|
828
|
+
}: GetByTestIdProps) => Cypress.Chainable;
|
|
829
|
+
getContainerId: (containerName: string) => Cypress.Chainable;
|
|
830
|
+
getContainerIpAddress: (containerName: string) => Cypress.Chainable;
|
|
831
|
+
getContainersLogs: () => Cypress.Chainable;
|
|
579
832
|
getIframeBody: () => Cypress.Chainable;
|
|
833
|
+
getLogDirectory: () => Cypress.Chainable;
|
|
580
834
|
getTimeFromHeader: () => Cypress.Chainable;
|
|
581
835
|
getWebVersion: () => Cypress.Chainable;
|
|
582
836
|
hoverRootMenuItem: (rootItemNumber: number) => Cypress.Chainable;
|
|
@@ -586,36 +840,55 @@ declare global {
|
|
|
586
840
|
dashboard: Dashboard,
|
|
587
841
|
patch: PatchDashboardBody
|
|
588
842
|
) => Cypress.Chainable;
|
|
589
|
-
|
|
843
|
+
loginAsAdminViaApiV2: () => Cypress.Chainable;
|
|
590
844
|
loginByTypeOfUser: ({
|
|
591
845
|
jsonName,
|
|
592
846
|
loginViaApi
|
|
593
847
|
}: LoginByTypeOfUserProps) => Cypress.Chainable;
|
|
848
|
+
logout: () => void;
|
|
849
|
+
logoutViaAPI: () => Cypress.Chainable;
|
|
594
850
|
moveSortableElement: (direction: string) => Cypress.Chainable;
|
|
595
851
|
navigateTo: ({
|
|
596
852
|
page,
|
|
597
853
|
rootItemNumber,
|
|
598
854
|
subMenu
|
|
599
855
|
}: NavigateToProps) => Cypress.Chainable;
|
|
856
|
+
requestOnDatabase: ({
|
|
857
|
+
database,
|
|
858
|
+
query
|
|
859
|
+
}: RequestOnDatabaseProps) => Cypress.Chainable;
|
|
860
|
+
setUserTokenApiV1: ({
|
|
861
|
+
login,
|
|
862
|
+
password
|
|
863
|
+
}?: SetUserTokenApiV1Props) => Cypress.Chainable;
|
|
600
864
|
shareDashboardToUser: ({
|
|
601
865
|
dashboardName,
|
|
602
866
|
userName,
|
|
603
867
|
role
|
|
604
868
|
}: ShareDashboardToUserProps) => Cypress.Chainable;
|
|
605
869
|
startContainer: ({
|
|
870
|
+
command,
|
|
606
871
|
name,
|
|
607
|
-
image
|
|
872
|
+
image,
|
|
873
|
+
portBindings
|
|
608
874
|
}: StartContainerProps) => Cypress.Chainable;
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
875
|
+
startContainers: ({
|
|
876
|
+
composeFile,
|
|
877
|
+
databaseImage,
|
|
878
|
+
moduleName,
|
|
879
|
+
openidImage,
|
|
880
|
+
profiles,
|
|
612
881
|
useSlim,
|
|
613
|
-
|
|
614
|
-
|
|
882
|
+
webOs,
|
|
883
|
+
webVersion
|
|
884
|
+
}?: StartContainersProps) => Cypress.Chainable;
|
|
885
|
+
waitForElementInIframe: (
|
|
886
|
+
iframeSelector: string,
|
|
887
|
+
elementSelector: string
|
|
888
|
+
) => Cypress.Chainable;
|
|
615
889
|
stopContainer: ({ name }: StopContainerProps) => Cypress.Chainable;
|
|
616
|
-
|
|
890
|
+
stopContainers: () => Cypress.Chainable;
|
|
617
891
|
visitEmptyPage: () => Cypress.Chainable;
|
|
618
|
-
waitForContainerAndSetToken: () => Cypress.Chainable;
|
|
619
892
|
}
|
|
620
893
|
}
|
|
621
894
|
}
|