@centreon/js-config 24.4.28 → 24.4.29
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 +17 -58
- package/cypress/component/configuration.js +2 -15
- package/cypress/e2e/commands/configuration.ts +0 -324
- package/cypress/e2e/commands.ts +149 -460
- package/cypress/e2e/configuration.ts +7 -14
- package/cypress/e2e/plugins.ts +1 -1
- package/cypress/e2e/tasks.ts +53 -206
- package/jest/index.js +1 -0
- package/package.json +57 -64
- package/webpack/base/globalConfig.js +2 -7
- package/webpack/base/index.js +6 -6
- package/cypress/component/excludeNodeModulesFromCoverage.js +0 -36
- package/tsconfig/lambda/node20.tsconfig.json +0 -12
package/cypress/e2e/commands.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import 'cypress-wait-until';
|
|
4
2
|
|
|
5
3
|
import './commands/configuration';
|
|
6
4
|
import './commands/monitoring';
|
|
@@ -9,53 +7,10 @@ import installLogsCollector from 'cypress-terminal-report/src/installLogsCollect
|
|
|
9
7
|
|
|
10
8
|
installLogsCollector({ enableExtendedCollector: true });
|
|
11
9
|
|
|
12
|
-
const apiBase = '/centreon/api';
|
|
13
|
-
const apiActionV1 = `${apiBase}/index.php`;
|
|
14
10
|
const apiLoginV2 = '/centreon/authentication/providers/configurations/local';
|
|
15
11
|
|
|
16
12
|
const artifactIllegalCharactersMatcher = /[,\s/|<>*?:"]/g;
|
|
17
13
|
|
|
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
|
-
|
|
59
14
|
Cypress.Commands.add('getWebVersion', (): Cypress.Chainable => {
|
|
60
15
|
return cy
|
|
61
16
|
.exec(
|
|
@@ -104,7 +59,7 @@ interface NavigateToProps {
|
|
|
104
59
|
|
|
105
60
|
Cypress.Commands.add(
|
|
106
61
|
'navigateTo',
|
|
107
|
-
({ rootItemNumber, subMenu, page }
|
|
62
|
+
({ rootItemNumber, subMenu, page }): void => {
|
|
108
63
|
if (subMenu) {
|
|
109
64
|
cy.hoverRootMenuItem(rootItemNumber)
|
|
110
65
|
.contains(subMenu)
|
|
@@ -145,24 +100,6 @@ Cypress.Commands.add(
|
|
|
145
100
|
}
|
|
146
101
|
);
|
|
147
102
|
|
|
148
|
-
Cypress.Commands.add('getContainerId', (containerName: string) => {
|
|
149
|
-
cy.log(`Getting container id of ${containerName}`);
|
|
150
|
-
|
|
151
|
-
return cy.task('getContainerId', containerName);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
Cypress.Commands.add('getContainerIpAddress', (containerName: string) => {
|
|
155
|
-
cy.log(`Getting container ip address of ${containerName}`);
|
|
156
|
-
|
|
157
|
-
return cy.task('getContainerIpAddress', containerName);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
Cypress.Commands.add('getContainersLogs', () => {
|
|
161
|
-
cy.log('Getting containers logs');
|
|
162
|
-
|
|
163
|
-
return cy.task('getContainersLogs');
|
|
164
|
-
});
|
|
165
|
-
|
|
166
103
|
interface CopyFromContainerProps {
|
|
167
104
|
destination: string;
|
|
168
105
|
name?: string;
|
|
@@ -171,54 +108,38 @@ interface CopyFromContainerProps {
|
|
|
171
108
|
|
|
172
109
|
Cypress.Commands.add(
|
|
173
110
|
'copyFromContainer',
|
|
174
|
-
(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
destination
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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);
|
|
182
120
|
}
|
|
183
121
|
);
|
|
184
122
|
|
|
185
|
-
export enum CopyToContainerContentType {
|
|
186
|
-
Directory = 'directory',
|
|
187
|
-
File = 'file'
|
|
188
|
-
}
|
|
189
|
-
|
|
190
123
|
interface CopyToContainerProps {
|
|
191
124
|
destination: string;
|
|
192
125
|
name?: string;
|
|
193
126
|
source: string;
|
|
194
|
-
type: CopyToContainerContentType;
|
|
195
127
|
}
|
|
196
128
|
|
|
197
129
|
Cypress.Commands.add(
|
|
198
130
|
'copyToContainer',
|
|
199
|
-
(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
return cy.task('copyToContainer', {
|
|
203
|
-
destination,
|
|
204
|
-
serviceName: name,
|
|
131
|
+
(
|
|
132
|
+
{
|
|
133
|
+
name = Cypress.env('dockerName'),
|
|
205
134
|
source,
|
|
206
|
-
|
|
207
|
-
}
|
|
135
|
+
destination
|
|
136
|
+
}: CopyToContainerProps,
|
|
137
|
+
options?: Partial<Cypress.ExecOptions>
|
|
138
|
+
) => {
|
|
139
|
+
return cy.exec(`docker cp ${source} ${name}:${destination}`, options);
|
|
208
140
|
}
|
|
209
141
|
);
|
|
210
142
|
|
|
211
|
-
Cypress.Commands.add('loginAsAdminViaApiV2', (): Cypress.Chainable => {
|
|
212
|
-
return cy.request({
|
|
213
|
-
body: {
|
|
214
|
-
login: 'admin',
|
|
215
|
-
password: 'Centreon!2021'
|
|
216
|
-
},
|
|
217
|
-
method: 'POST',
|
|
218
|
-
url: apiLoginV2
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
|
|
222
143
|
interface LoginByTypeOfUserProps {
|
|
223
144
|
jsonName?: string;
|
|
224
145
|
loginViaApi?: boolean;
|
|
@@ -257,41 +178,16 @@ Cypress.Commands.add(
|
|
|
257
178
|
.getByLabel({ label: 'Connect', tag: 'button' })
|
|
258
179
|
.click();
|
|
259
180
|
|
|
260
|
-
return cy
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
181
|
+
return cy
|
|
182
|
+
.get('.SnackbarContent-root > .MuiPaper-root')
|
|
183
|
+
.then(($snackbar) => {
|
|
184
|
+
if ($snackbar.text().includes('Login succeeded')) {
|
|
185
|
+
cy.wait('@getNavigationList');
|
|
186
|
+
}
|
|
187
|
+
});
|
|
265
188
|
}
|
|
266
189
|
);
|
|
267
190
|
|
|
268
|
-
Cypress.Commands.add('logout', (): void => {
|
|
269
|
-
cy.getByLabel({ label: 'Profile' }).should('exist').click();
|
|
270
|
-
|
|
271
|
-
cy.intercept({
|
|
272
|
-
method: 'GET',
|
|
273
|
-
times: 1,
|
|
274
|
-
url: '/centreon/api/latest/authentication/logout'
|
|
275
|
-
}).as('logout');
|
|
276
|
-
|
|
277
|
-
cy.contains(/^Logout$/).click();
|
|
278
|
-
|
|
279
|
-
cy.wait('@logout').its('response.statusCode').should('eq', 302);
|
|
280
|
-
|
|
281
|
-
// https://github.com/cypress-io/cypress/issues/25841
|
|
282
|
-
cy.clearAllCookies();
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
Cypress.Commands.add('logoutViaAPI', (): Cypress.Chainable => {
|
|
286
|
-
return cy
|
|
287
|
-
.request({
|
|
288
|
-
method: 'GET',
|
|
289
|
-
url: '/centreon/authentication/logout'
|
|
290
|
-
})
|
|
291
|
-
.visit('/')
|
|
292
|
-
.getByLabel({ label: 'Alias', tag: 'input' });
|
|
293
|
-
});
|
|
294
|
-
|
|
295
191
|
Cypress.Commands.add(
|
|
296
192
|
'visitEmptyPage',
|
|
297
193
|
(): Cypress.Chainable =>
|
|
@@ -303,91 +199,32 @@ Cypress.Commands.add(
|
|
|
303
199
|
.visit('/waiting-page')
|
|
304
200
|
);
|
|
305
201
|
|
|
202
|
+
Cypress.Commands.add('waitForContainerAndSetToken', (): Cypress.Chainable => {
|
|
203
|
+
return cy.setUserTokenApiV1();
|
|
204
|
+
});
|
|
205
|
+
|
|
306
206
|
interface ExecInContainerProps {
|
|
307
|
-
command: string
|
|
207
|
+
command: string;
|
|
308
208
|
name: string;
|
|
309
209
|
}
|
|
310
210
|
|
|
311
|
-
interface ExecInContainerResult {
|
|
312
|
-
exitCode: number;
|
|
313
|
-
output: string;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
211
|
Cypress.Commands.add(
|
|
317
212
|
'execInContainer',
|
|
318
213
|
({ command, name }: ExecInContainerProps): Cypress.Chainable => {
|
|
319
|
-
const commands =
|
|
320
|
-
typeof command === 'string' || command instanceof String
|
|
321
|
-
? [command]
|
|
322
|
-
: command;
|
|
323
|
-
|
|
324
|
-
const results = commands.reduce(
|
|
325
|
-
(acc, runCommand) => {
|
|
326
|
-
cy.task<ExecInContainerResult>(
|
|
327
|
-
'execInContainer',
|
|
328
|
-
{ command: runCommand, name },
|
|
329
|
-
{ timeout: 600000 }
|
|
330
|
-
).then((result) => {
|
|
331
|
-
if (result.exitCode) {
|
|
332
|
-
cy.log(result.output);
|
|
333
|
-
|
|
334
|
-
// output will not be truncated
|
|
335
|
-
throw new Error(`
|
|
336
|
-
Execution of "${runCommand}" failed
|
|
337
|
-
Exit code: ${result.exitCode}
|
|
338
|
-
Output:\n${result.output}`);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
acc.output = `${acc.output}${result.output}`;
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
return acc;
|
|
345
|
-
},
|
|
346
|
-
{ exitCode: 0, output: '' }
|
|
347
|
-
);
|
|
348
|
-
|
|
349
|
-
return cy.wrap(results);
|
|
350
|
-
}
|
|
351
|
-
);
|
|
352
|
-
|
|
353
|
-
interface RequestOnDatabaseProps {
|
|
354
|
-
database: string;
|
|
355
|
-
query: string;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
Cypress.Commands.add(
|
|
359
|
-
'requestOnDatabase',
|
|
360
|
-
({ database, query }: RequestOnDatabaseProps): Cypress.Chainable => {
|
|
361
|
-
return cy.task('requestOnDatabase', { database, query });
|
|
362
|
-
}
|
|
363
|
-
);
|
|
364
|
-
|
|
365
|
-
interface SetUserTokenApiV1Props {
|
|
366
|
-
login?: string;
|
|
367
|
-
password?: string;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
Cypress.Commands.add(
|
|
371
|
-
'setUserTokenApiV1',
|
|
372
|
-
({
|
|
373
|
-
login = 'admin',
|
|
374
|
-
password = 'Centreon!2021'
|
|
375
|
-
}: SetUserTokenApiV1Props = {}): Cypress.Chainable => {
|
|
376
214
|
return cy
|
|
377
|
-
.
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
);
|
|
215
|
+
.exec(`docker exec -i ${name} ${command}`, { failOnNonZeroExit: false })
|
|
216
|
+
.then((result) => {
|
|
217
|
+
if (result.code) {
|
|
218
|
+
// output will not be truncated
|
|
219
|
+
throw new Error(`
|
|
220
|
+
Execution of "${command}" failed
|
|
221
|
+
Exit code: ${result.code}
|
|
222
|
+
Stdout:\n${result.stdout}
|
|
223
|
+
Stderr:\n${result.stderr}`);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return cy.wrap(result);
|
|
227
|
+
});
|
|
391
228
|
}
|
|
392
229
|
);
|
|
393
230
|
|
|
@@ -397,7 +234,6 @@ interface PortBinding {
|
|
|
397
234
|
}
|
|
398
235
|
|
|
399
236
|
interface StartContainerProps {
|
|
400
|
-
command?: string;
|
|
401
237
|
image: string;
|
|
402
238
|
name: string;
|
|
403
239
|
portBindings: Array<PortBinding>;
|
|
@@ -405,200 +241,145 @@ interface StartContainerProps {
|
|
|
405
241
|
|
|
406
242
|
Cypress.Commands.add(
|
|
407
243
|
'startContainer',
|
|
408
|
-
({
|
|
409
|
-
command,
|
|
410
|
-
name,
|
|
411
|
-
image,
|
|
412
|
-
portBindings
|
|
413
|
-
}: StartContainerProps): Cypress.Chainable => {
|
|
244
|
+
({ name, image, portBindings }: StartContainerProps): Cypress.Chainable => {
|
|
414
245
|
cy.log(`Starting container ${name} from image ${image}`);
|
|
415
246
|
|
|
416
247
|
return cy.task(
|
|
417
248
|
'startContainer',
|
|
418
|
-
{
|
|
249
|
+
{ image, name, portBindings },
|
|
419
250
|
{ timeout: 600000 } // 10 minutes because docker pull can be very slow
|
|
420
251
|
);
|
|
421
252
|
}
|
|
422
253
|
);
|
|
423
254
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
255
|
+
Cypress.Commands.add(
|
|
256
|
+
'createDirectory',
|
|
257
|
+
(directoryPath: string): Cypress.Chainable => {
|
|
258
|
+
return cy.task('createDirectory', directoryPath);
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
interface StartWebContainerProps {
|
|
263
|
+
name?: string;
|
|
264
|
+
os?: string;
|
|
431
265
|
useSlim?: boolean;
|
|
432
|
-
|
|
433
|
-
webVersion?: string;
|
|
266
|
+
version?: string;
|
|
434
267
|
}
|
|
435
268
|
|
|
436
269
|
Cypress.Commands.add(
|
|
437
|
-
'
|
|
270
|
+
'startWebContainer',
|
|
438
271
|
({
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
moduleName = 'centreon-web',
|
|
442
|
-
openidImage = `docker.centreon.com/centreon/keycloak:${Cypress.env(
|
|
443
|
-
'OPENID_IMAGE_VERSION'
|
|
444
|
-
)}`,
|
|
445
|
-
profiles = [],
|
|
446
|
-
samlImage = `docker.centreon.com/centreon/keycloak:${Cypress.env(
|
|
447
|
-
'SAML_IMAGE_VERSION'
|
|
448
|
-
)}`,
|
|
272
|
+
name = Cypress.env('dockerName'),
|
|
273
|
+
os = Cypress.env('WEB_IMAGE_OS'),
|
|
449
274
|
useSlim = true,
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
}: StartContainersProps = {}): Cypress.Chainable => {
|
|
453
|
-
cy.log('Starting containers ...');
|
|
454
|
-
|
|
455
|
-
let composeFilePath = composeFile;
|
|
456
|
-
if (!composeFile) {
|
|
457
|
-
const cypressDir = path.dirname(Cypress.config('configFile'));
|
|
458
|
-
composeFilePath = `${cypressDir}/../../../.github/docker/docker-compose.yml`;
|
|
459
|
-
}
|
|
460
|
-
|
|
275
|
+
version = Cypress.env('WEB_IMAGE_VERSION')
|
|
276
|
+
}: StartWebContainerProps = {}): Cypress.Chainable => {
|
|
461
277
|
const slimSuffix = useSlim ? '-slim' : '';
|
|
462
278
|
|
|
463
|
-
const
|
|
279
|
+
const image = `docker.centreon.com/centreon/centreon-web${slimSuffix}-${os}:${version}`;
|
|
464
280
|
|
|
465
281
|
return cy
|
|
466
|
-
.
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
openidImage,
|
|
472
|
-
profiles,
|
|
473
|
-
samlImage,
|
|
474
|
-
webImage
|
|
475
|
-
},
|
|
476
|
-
{ timeout: 600000 } // 10 minutes because docker pull can be very slow
|
|
477
|
-
)
|
|
282
|
+
.startContainer({
|
|
283
|
+
image,
|
|
284
|
+
name,
|
|
285
|
+
portBindings: [{ destination: 4000, source: 80 }]
|
|
286
|
+
})
|
|
478
287
|
.then(() => {
|
|
479
288
|
const baseUrl = 'http://127.0.0.1:4000';
|
|
480
289
|
|
|
481
290
|
Cypress.config('baseUrl', baseUrl);
|
|
482
291
|
|
|
483
|
-
return cy.
|
|
292
|
+
return cy.task(
|
|
293
|
+
'waitOn',
|
|
294
|
+
`${baseUrl}/centreon/api/latest/platform/installation/status`
|
|
295
|
+
);
|
|
484
296
|
})
|
|
485
297
|
.visit('/') // this is necessary to refresh browser cause baseUrl has changed (flash appears in video)
|
|
486
298
|
.setUserTokenApiV1();
|
|
487
299
|
}
|
|
488
300
|
);
|
|
489
301
|
|
|
490
|
-
interface
|
|
491
|
-
name
|
|
302
|
+
interface StopWebContainerProps {
|
|
303
|
+
name?: string;
|
|
492
304
|
}
|
|
493
305
|
|
|
494
306
|
Cypress.Commands.add(
|
|
495
|
-
'
|
|
496
|
-
({
|
|
497
|
-
|
|
307
|
+
'stopWebContainer',
|
|
308
|
+
({
|
|
309
|
+
name = Cypress.env('dockerName')
|
|
310
|
+
}: StopWebContainerProps = {}): Cypress.Chainable => {
|
|
311
|
+
const logDirectory = `results/logs/${Cypress.spec.name.replace(
|
|
312
|
+
artifactIllegalCharactersMatcher,
|
|
313
|
+
'_'
|
|
314
|
+
)}/${Cypress.currentTest.title.replace(
|
|
315
|
+
artifactIllegalCharactersMatcher,
|
|
316
|
+
'_'
|
|
317
|
+
)}`;
|
|
498
318
|
|
|
499
|
-
return cy
|
|
319
|
+
return cy
|
|
320
|
+
.visitEmptyPage()
|
|
321
|
+
.createDirectory(logDirectory)
|
|
322
|
+
.copyFromContainer({
|
|
323
|
+
destination: `${logDirectory}/broker`,
|
|
324
|
+
name,
|
|
325
|
+
source: '/var/log/centreon-broker'
|
|
326
|
+
})
|
|
327
|
+
.copyFromContainer({
|
|
328
|
+
destination: `${logDirectory}/engine`,
|
|
329
|
+
name,
|
|
330
|
+
source: '/var/log/centreon-engine'
|
|
331
|
+
})
|
|
332
|
+
.copyFromContainer({
|
|
333
|
+
destination: `${logDirectory}/centreon`,
|
|
334
|
+
name,
|
|
335
|
+
source: '/var/log/centreon'
|
|
336
|
+
})
|
|
337
|
+
.then(() => {
|
|
338
|
+
if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
|
|
339
|
+
return cy.copyFromContainer({
|
|
340
|
+
destination: `${logDirectory}/php`,
|
|
341
|
+
name,
|
|
342
|
+
source: '/var/log/php-fpm'
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return cy.copyFromContainer(
|
|
347
|
+
{
|
|
348
|
+
destination: `${logDirectory}/php8.1-fpm-centreon-error.log`,
|
|
349
|
+
name,
|
|
350
|
+
source: '/var/log/php8.1-fpm-centreon-error.log'
|
|
351
|
+
},
|
|
352
|
+
{ failOnNonZeroExit: false }
|
|
353
|
+
);
|
|
354
|
+
})
|
|
355
|
+
.exec(`chmod -R 755 "${logDirectory}"`)
|
|
356
|
+
.stopContainer({ name });
|
|
500
357
|
}
|
|
501
358
|
);
|
|
502
359
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
const logDirectory = `results/logs/${Cypress.spec.name.replace(
|
|
507
|
-
artifactIllegalCharactersMatcher,
|
|
508
|
-
'_'
|
|
509
|
-
)}/${Cypress.currentTest.title.replace(
|
|
510
|
-
artifactIllegalCharactersMatcher,
|
|
511
|
-
'_'
|
|
512
|
-
)}`;
|
|
513
|
-
|
|
514
|
-
const name = 'web';
|
|
515
|
-
|
|
516
|
-
return cy
|
|
517
|
-
.visitEmptyPage()
|
|
518
|
-
.createDirectory(logDirectory)
|
|
519
|
-
.getContainersLogs()
|
|
520
|
-
.then((containersLogs: Array<Array<string>>) => {
|
|
521
|
-
Object.entries(containersLogs).forEach(([containerName, logs]) => {
|
|
522
|
-
cy.writeFile(
|
|
523
|
-
`results/logs/${Cypress.spec.name.replace(
|
|
524
|
-
artifactIllegalCharactersMatcher,
|
|
525
|
-
'_'
|
|
526
|
-
)}/${Cypress.currentTest.title.replace(
|
|
527
|
-
artifactIllegalCharactersMatcher,
|
|
528
|
-
'_'
|
|
529
|
-
)}/container-${containerName}.log`,
|
|
530
|
-
logs
|
|
531
|
-
);
|
|
532
|
-
});
|
|
533
|
-
})
|
|
534
|
-
.copyFromContainer({
|
|
535
|
-
destination: `${logDirectory}/broker`,
|
|
536
|
-
name,
|
|
537
|
-
source: '/var/log/centreon-broker'
|
|
538
|
-
})
|
|
539
|
-
.copyFromContainer({
|
|
540
|
-
destination: `${logDirectory}/engine`,
|
|
541
|
-
name,
|
|
542
|
-
source: '/var/log/centreon-engine'
|
|
543
|
-
})
|
|
544
|
-
.copyFromContainer({
|
|
545
|
-
destination: `${logDirectory}/centreon`,
|
|
546
|
-
name,
|
|
547
|
-
source: '/var/log/centreon'
|
|
548
|
-
})
|
|
549
|
-
.copyFromContainer({
|
|
550
|
-
destination: `${logDirectory}/centreon-gorgone`,
|
|
551
|
-
name,
|
|
552
|
-
source: '/var/log/centreon-gorgone'
|
|
553
|
-
})
|
|
554
|
-
.then(() => {
|
|
555
|
-
if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
|
|
556
|
-
return cy.copyFromContainer({
|
|
557
|
-
destination: `${logDirectory}/php`,
|
|
558
|
-
name,
|
|
559
|
-
source: '/var/log/php-fpm'
|
|
560
|
-
});
|
|
561
|
-
}
|
|
360
|
+
interface StopContainerProps {
|
|
361
|
+
name: string;
|
|
362
|
+
}
|
|
562
363
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
source: '/var/log/php8.1-fpm-centreon-error.log'
|
|
568
|
-
},
|
|
569
|
-
{ failOnNonZeroExit: false }
|
|
570
|
-
);
|
|
571
|
-
})
|
|
572
|
-
.then(() => {
|
|
573
|
-
if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
|
|
574
|
-
return cy.copyFromContainer({
|
|
575
|
-
destination: `${logDirectory}/httpd`,
|
|
576
|
-
name,
|
|
577
|
-
source: '/var/log/httpd'
|
|
578
|
-
});
|
|
579
|
-
}
|
|
364
|
+
Cypress.Commands.add(
|
|
365
|
+
'stopContainer',
|
|
366
|
+
({ name }: StopContainerProps): Cypress.Chainable => {
|
|
367
|
+
cy.log(`Stopping container ${name}`);
|
|
580
368
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
}
|
|
587
|
-
|
|
369
|
+
cy.exec(`docker logs ${name}`).then(({ stdout }) => {
|
|
370
|
+
cy.writeFile(
|
|
371
|
+
`cypress/results/logs/${Cypress.spec.name.replace(
|
|
372
|
+
artifactIllegalCharactersMatcher,
|
|
373
|
+
'_'
|
|
374
|
+
)}/${Cypress.currentTest.title.replace(
|
|
375
|
+
artifactIllegalCharactersMatcher,
|
|
376
|
+
'_'
|
|
377
|
+
)}/container-${name}.log`,
|
|
378
|
+
stdout
|
|
588
379
|
);
|
|
589
|
-
})
|
|
590
|
-
.exec(`chmod -R 755 "${logDirectory}"`)
|
|
591
|
-
.task(
|
|
592
|
-
'stopContainers',
|
|
593
|
-
{},
|
|
594
|
-
{ timeout: 600000 } // 10 minutes because docker pull can be very slow
|
|
595
|
-
);
|
|
596
|
-
});
|
|
380
|
+
});
|
|
597
381
|
|
|
598
|
-
|
|
599
|
-
'createDirectory',
|
|
600
|
-
(directoryPath: string): Cypress.Chainable => {
|
|
601
|
-
return cy.task('createDirectory', directoryPath);
|
|
382
|
+
return cy.task('stopContainer', { name });
|
|
602
383
|
}
|
|
603
384
|
);
|
|
604
385
|
|
|
@@ -635,41 +416,6 @@ Cypress.Commands.add(
|
|
|
635
416
|
}
|
|
636
417
|
);
|
|
637
418
|
|
|
638
|
-
Cypress.Commands.add(
|
|
639
|
-
'insertDashboardWithWidget',
|
|
640
|
-
(dashboardBody, patchBody) => {
|
|
641
|
-
cy.request({
|
|
642
|
-
body: {
|
|
643
|
-
...dashboardBody
|
|
644
|
-
},
|
|
645
|
-
method: 'POST',
|
|
646
|
-
url: '/centreon/api/latest/configuration/dashboards'
|
|
647
|
-
}).then((response) => {
|
|
648
|
-
const dashboardId = response.body.id;
|
|
649
|
-
cy.waitUntil(
|
|
650
|
-
() => {
|
|
651
|
-
return cy
|
|
652
|
-
.request({
|
|
653
|
-
method: 'GET',
|
|
654
|
-
url: `/centreon/api/latest/configuration/dashboards/${dashboardId}`
|
|
655
|
-
})
|
|
656
|
-
.then((getResponse) => {
|
|
657
|
-
return getResponse.body && getResponse.body.id === dashboardId;
|
|
658
|
-
});
|
|
659
|
-
},
|
|
660
|
-
{
|
|
661
|
-
timeout: 10000
|
|
662
|
-
}
|
|
663
|
-
);
|
|
664
|
-
cy.request({
|
|
665
|
-
body: patchBody,
|
|
666
|
-
method: 'PATCH',
|
|
667
|
-
url: `/centreon/api/latest/configuration/dashboards/${dashboardId}`
|
|
668
|
-
});
|
|
669
|
-
});
|
|
670
|
-
}
|
|
671
|
-
);
|
|
672
|
-
|
|
673
419
|
interface ShareDashboardToUserProps {
|
|
674
420
|
dashboardName: string;
|
|
675
421
|
role: string;
|
|
@@ -684,30 +430,6 @@ interface ListingRequestResult {
|
|
|
684
430
|
};
|
|
685
431
|
}
|
|
686
432
|
|
|
687
|
-
interface PatchDashboardBody {
|
|
688
|
-
panels: Array<{
|
|
689
|
-
layout: {
|
|
690
|
-
height: number;
|
|
691
|
-
min_height: number;
|
|
692
|
-
min_width: number;
|
|
693
|
-
width: number;
|
|
694
|
-
x: number;
|
|
695
|
-
y: number;
|
|
696
|
-
};
|
|
697
|
-
name: string;
|
|
698
|
-
widget_settings: {
|
|
699
|
-
options: {
|
|
700
|
-
description: {
|
|
701
|
-
content: string;
|
|
702
|
-
enabled: boolean;
|
|
703
|
-
};
|
|
704
|
-
name: string;
|
|
705
|
-
};
|
|
706
|
-
};
|
|
707
|
-
widget_type: string;
|
|
708
|
-
}>;
|
|
709
|
-
}
|
|
710
|
-
|
|
711
433
|
Cypress.Commands.add(
|
|
712
434
|
'shareDashboardToUser',
|
|
713
435
|
({ dashboardName, userName, role }: ShareDashboardToUserProps): void => {
|
|
@@ -774,74 +496,41 @@ declare global {
|
|
|
774
496
|
command,
|
|
775
497
|
name
|
|
776
498
|
}: ExecInContainerProps) => Cypress.Chainable;
|
|
777
|
-
getByLabel: ({
|
|
778
|
-
patternType,
|
|
779
|
-
tag,
|
|
780
|
-
label
|
|
781
|
-
}: GetByLabelProps) => Cypress.Chainable;
|
|
782
|
-
getByTestId: ({
|
|
783
|
-
patternType,
|
|
784
|
-
tag,
|
|
785
|
-
testId
|
|
786
|
-
}: GetByTestIdProps) => Cypress.Chainable;
|
|
787
|
-
getContainerId: (containerName: string) => Cypress.Chainable;
|
|
788
|
-
getContainerIpAddress: (containerName: string) => Cypress.Chainable;
|
|
789
|
-
getContainersLogs: () => Cypress.Chainable;
|
|
790
499
|
getIframeBody: () => Cypress.Chainable;
|
|
791
500
|
getTimeFromHeader: () => Cypress.Chainable;
|
|
792
501
|
getWebVersion: () => Cypress.Chainable;
|
|
793
502
|
hoverRootMenuItem: (rootItemNumber: number) => Cypress.Chainable;
|
|
794
503
|
insertDashboard: (dashboard: Dashboard) => Cypress.Chainable;
|
|
795
504
|
insertDashboardList: (fixtureFile: string) => Cypress.Chainable;
|
|
796
|
-
insertDashboardWithWidget: (
|
|
797
|
-
dashboard: Dashboard,
|
|
798
|
-
patch: PatchDashboardBody
|
|
799
|
-
) => Cypress.Chainable;
|
|
800
|
-
loginAsAdminViaApiV2: () => Cypress.Chainable;
|
|
801
505
|
loginByTypeOfUser: ({
|
|
802
506
|
jsonName,
|
|
803
507
|
loginViaApi
|
|
804
508
|
}: LoginByTypeOfUserProps) => Cypress.Chainable;
|
|
805
|
-
logout: () => void;
|
|
806
|
-
logoutViaAPI: () => Cypress.Chainable;
|
|
807
509
|
moveSortableElement: (direction: string) => Cypress.Chainable;
|
|
808
510
|
navigateTo: ({
|
|
809
511
|
page,
|
|
810
512
|
rootItemNumber,
|
|
811
513
|
subMenu
|
|
812
514
|
}: NavigateToProps) => Cypress.Chainable;
|
|
813
|
-
requestOnDatabase: ({
|
|
814
|
-
database,
|
|
815
|
-
query
|
|
816
|
-
}: RequestOnDatabaseProps) => Cypress.Chainable;
|
|
817
|
-
setUserTokenApiV1: ({
|
|
818
|
-
login,
|
|
819
|
-
password
|
|
820
|
-
}?: SetUserTokenApiV1Props) => Cypress.Chainable;
|
|
821
515
|
shareDashboardToUser: ({
|
|
822
516
|
dashboardName,
|
|
823
517
|
userName,
|
|
824
518
|
role
|
|
825
519
|
}: ShareDashboardToUserProps) => Cypress.Chainable;
|
|
826
520
|
startContainer: ({
|
|
827
|
-
command,
|
|
828
521
|
name,
|
|
829
|
-
image
|
|
830
|
-
portBindings
|
|
522
|
+
image
|
|
831
523
|
}: StartContainerProps) => Cypress.Chainable;
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
moduleName,
|
|
836
|
-
openidImage,
|
|
837
|
-
profiles,
|
|
524
|
+
startWebContainer: ({
|
|
525
|
+
name,
|
|
526
|
+
os,
|
|
838
527
|
useSlim,
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
}?: StartContainersProps) => Cypress.Chainable;
|
|
528
|
+
version
|
|
529
|
+
}?: StartWebContainerProps) => Cypress.Chainable;
|
|
842
530
|
stopContainer: ({ name }: StopContainerProps) => Cypress.Chainable;
|
|
843
|
-
|
|
531
|
+
stopWebContainer: ({ name }?: StopWebContainerProps) => Cypress.Chainable;
|
|
844
532
|
visitEmptyPage: () => Cypress.Chainable;
|
|
533
|
+
waitForContainerAndSetToken: () => Cypress.Chainable;
|
|
845
534
|
}
|
|
846
535
|
}
|
|
847
536
|
}
|