@centreon/js-config 24.7.0 → 24.7.2
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 +22 -82
- package/cypress/component/configuration.js +16 -35
- package/cypress/component/enableVisualTesting.ts +1 -1
- package/cypress/e2e/commands/configuration.ts +1 -330
- package/cypress/e2e/commands.ts +144 -617
- package/cypress/e2e/configuration.ts +40 -45
- package/cypress/e2e/plugins.ts +114 -53
- package/eslint/base.typescript.eslintrc.js +3 -15
- package/jest/index.js +2 -5
- package/package.json +45 -57
- package/tsconfig/index.json +4 -5
- package/webpack/base/index.js +130 -0
- package/webpack/patch/dev.js +24 -0
- package/{rspack → webpack}/patch/devServer.js +5 -3
- package/webpack/patch/module.js +46 -0
- package/cypress/component/disableCssTransitions.ts +0 -19
- package/cypress/component/excludeNodeModulesFromCoverage.js +0 -36
- package/cypress/e2e/commands/monitoring.ts +0 -117
- package/cypress/e2e/esbuild-preprocessor.ts +0 -26
- package/cypress/e2e/reporter-config.js +0 -13
- package/cypress/e2e/tasks.ts +0 -259
- package/eslint/lambda/typescript.eslintrc.js +0 -48
- package/jest/lambda/typescript.js +0 -49
- package/rspack/base/globalConfig.js +0 -71
- package/rspack/base/index.js +0 -89
- package/rspack/patch/dev.js +0 -12
- package/rspack/patch/module.js +0 -13
- package/rspack/plugins/TransformPreloadScript.js +0 -37
- package/rspack/plugins/WriteRemoteEntryNameToModuleFederation.js +0 -30
- package/tsconfig/lambda/node20.tsconfig.json +0 -12
- package/tsconfig/lambda/tsconfig.json +0 -14
- package/tsconfig.json +0 -21
package/cypress/e2e/commands.ts
CHANGED
|
@@ -1,64 +1,11 @@
|
|
|
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
|
-
import './commands/monitoring';
|
|
7
4
|
|
|
8
|
-
import installLogsCollector from 'cypress-terminal-report/src/installLogsCollector';
|
|
9
|
-
|
|
10
|
-
installLogsCollector({
|
|
11
|
-
commandTimings: 'seconds',
|
|
12
|
-
enableExtendedCollector: true
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const apiBase = '/centreon/api';
|
|
16
|
-
const apiActionV1 = `${apiBase}/index.php`;
|
|
17
5
|
const apiLoginV2 = '/centreon/authentication/providers/configurations/local';
|
|
18
6
|
|
|
19
7
|
const artifactIllegalCharactersMatcher = /[,\s/|<>*?:"]/g;
|
|
20
8
|
|
|
21
|
-
export enum PatternType {
|
|
22
|
-
contains = '*',
|
|
23
|
-
endsWith = '$',
|
|
24
|
-
equals = '',
|
|
25
|
-
startsWith = '^'
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface GetByLabelProps {
|
|
29
|
-
label: string;
|
|
30
|
-
patternType?: PatternType;
|
|
31
|
-
tag?: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
Cypress.Commands.add(
|
|
35
|
-
'getByLabel',
|
|
36
|
-
({
|
|
37
|
-
tag = '',
|
|
38
|
-
patternType = PatternType.equals,
|
|
39
|
-
label
|
|
40
|
-
}: GetByLabelProps): Cypress.Chainable => {
|
|
41
|
-
return cy.get(`${tag}[aria-label${patternType}="${label}"]`);
|
|
42
|
-
}
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
interface GetByTestIdProps {
|
|
46
|
-
patternType?: PatternType;
|
|
47
|
-
tag?: string;
|
|
48
|
-
testId: string;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
Cypress.Commands.add(
|
|
52
|
-
'getByTestId',
|
|
53
|
-
({
|
|
54
|
-
tag = '',
|
|
55
|
-
patternType = PatternType.equals,
|
|
56
|
-
testId
|
|
57
|
-
}: GetByTestIdProps): Cypress.Chainable => {
|
|
58
|
-
return cy.get(`${tag}[data-testid${patternType}="${testId}"]`);
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
|
|
62
9
|
Cypress.Commands.add('getWebVersion', (): Cypress.Chainable => {
|
|
63
10
|
return cy
|
|
64
11
|
.exec(
|
|
@@ -76,7 +23,7 @@ Cypress.Commands.add('getWebVersion', (): Cypress.Chainable => {
|
|
|
76
23
|
|
|
77
24
|
Cypress.Commands.add('getIframeBody', (): Cypress.Chainable => {
|
|
78
25
|
return cy
|
|
79
|
-
.get('iframe#main-content'
|
|
26
|
+
.get('iframe#main-content')
|
|
80
27
|
.its('0.contentDocument.body')
|
|
81
28
|
.should('not.be.empty')
|
|
82
29
|
.then(cy.wrap);
|
|
@@ -92,13 +39,6 @@ Cypress.Commands.add(
|
|
|
92
39
|
}
|
|
93
40
|
);
|
|
94
41
|
|
|
95
|
-
Cypress.Commands.add(
|
|
96
|
-
'clickSubRootMenuItem',
|
|
97
|
-
(page: string): Cypress.Chainable => {
|
|
98
|
-
return cy.get('div[data-cy="collapse"]').eq(1).contains(page).click();
|
|
99
|
-
}
|
|
100
|
-
);
|
|
101
|
-
|
|
102
42
|
interface NavigateToProps {
|
|
103
43
|
page: string;
|
|
104
44
|
rootItemNumber: number;
|
|
@@ -107,17 +47,12 @@ interface NavigateToProps {
|
|
|
107
47
|
|
|
108
48
|
Cypress.Commands.add(
|
|
109
49
|
'navigateTo',
|
|
110
|
-
({ rootItemNumber, subMenu, page }
|
|
50
|
+
({ rootItemNumber, subMenu, page }): void => {
|
|
111
51
|
if (subMenu) {
|
|
112
52
|
cy.hoverRootMenuItem(rootItemNumber)
|
|
113
53
|
.contains(subMenu)
|
|
114
|
-
.trigger('mouseover')
|
|
115
|
-
|
|
116
|
-
.find('div[data-cy="collapse"]')
|
|
117
|
-
.should('be.visible')
|
|
118
|
-
.and('contain', page);
|
|
119
|
-
|
|
120
|
-
cy.clickSubRootMenuItem(page);
|
|
54
|
+
.trigger('mouseover', { force: true });
|
|
55
|
+
cy.contains(page).click({ force: true });
|
|
121
56
|
|
|
122
57
|
return;
|
|
123
58
|
}
|
|
@@ -148,80 +83,34 @@ Cypress.Commands.add(
|
|
|
148
83
|
}
|
|
149
84
|
);
|
|
150
85
|
|
|
151
|
-
Cypress.Commands.add('getContainerId', (containerName: string) => {
|
|
152
|
-
cy.log(`Getting container id of ${containerName}`);
|
|
153
|
-
|
|
154
|
-
return cy.task('getContainerId', containerName);
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
Cypress.Commands.add('getContainerIpAddress', (containerName: string) => {
|
|
158
|
-
cy.log(`Getting container ip address of ${containerName}`);
|
|
159
|
-
|
|
160
|
-
return cy.task('getContainerIpAddress', containerName);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
Cypress.Commands.add('getContainersLogs', () => {
|
|
164
|
-
cy.log('Getting containers logs');
|
|
165
|
-
|
|
166
|
-
return cy.task('getContainersLogs');
|
|
167
|
-
});
|
|
168
|
-
|
|
169
86
|
interface CopyFromContainerProps {
|
|
170
87
|
destination: string;
|
|
171
|
-
name?: string;
|
|
172
88
|
source: string;
|
|
173
89
|
}
|
|
174
90
|
|
|
175
91
|
Cypress.Commands.add(
|
|
176
92
|
'copyFromContainer',
|
|
177
|
-
({
|
|
178
|
-
cy.
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
destination,
|
|
182
|
-
serviceName: name,
|
|
183
|
-
source
|
|
184
|
-
});
|
|
93
|
+
({ source, destination }: CopyFromContainerProps) => {
|
|
94
|
+
return cy.exec(
|
|
95
|
+
`docker cp ${Cypress.env('dockerName')}:${source} "${destination}"`
|
|
96
|
+
);
|
|
185
97
|
}
|
|
186
98
|
);
|
|
187
99
|
|
|
188
|
-
export enum CopyToContainerContentType {
|
|
189
|
-
Directory = 'directory',
|
|
190
|
-
File = 'file'
|
|
191
|
-
}
|
|
192
|
-
|
|
193
100
|
interface CopyToContainerProps {
|
|
194
101
|
destination: string;
|
|
195
|
-
name?: string;
|
|
196
102
|
source: string;
|
|
197
|
-
type: CopyToContainerContentType;
|
|
198
103
|
}
|
|
199
104
|
|
|
200
105
|
Cypress.Commands.add(
|
|
201
106
|
'copyToContainer',
|
|
202
|
-
({
|
|
203
|
-
cy.
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
destination,
|
|
207
|
-
serviceName: name,
|
|
208
|
-
source,
|
|
209
|
-
type
|
|
210
|
-
});
|
|
107
|
+
({ source, destination }: CopyToContainerProps) => {
|
|
108
|
+
return cy.exec(
|
|
109
|
+
`docker cp ${source} ${Cypress.env('dockerName')}:${destination}`
|
|
110
|
+
);
|
|
211
111
|
}
|
|
212
112
|
);
|
|
213
113
|
|
|
214
|
-
Cypress.Commands.add('loginAsAdminViaApiV2', (): Cypress.Chainable => {
|
|
215
|
-
return cy.request({
|
|
216
|
-
body: {
|
|
217
|
-
login: 'admin',
|
|
218
|
-
password: 'Centreon!2021'
|
|
219
|
-
},
|
|
220
|
-
method: 'POST',
|
|
221
|
-
url: apiLoginV2
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
|
|
225
114
|
interface LoginByTypeOfUserProps {
|
|
226
115
|
jsonName?: string;
|
|
227
116
|
loginViaApi?: boolean;
|
|
@@ -229,7 +118,7 @@ interface LoginByTypeOfUserProps {
|
|
|
229
118
|
|
|
230
119
|
Cypress.Commands.add(
|
|
231
120
|
'loginByTypeOfUser',
|
|
232
|
-
({ jsonName
|
|
121
|
+
({ jsonName, loginViaApi }): Cypress.Chainable => {
|
|
233
122
|
if (loginViaApi) {
|
|
234
123
|
return cy
|
|
235
124
|
.fixture(`users/${jsonName}.json`)
|
|
@@ -246,56 +135,27 @@ Cypress.Commands.add(
|
|
|
246
135
|
.visit(`${Cypress.config().baseUrl}`)
|
|
247
136
|
.wait('@getNavigationList');
|
|
248
137
|
}
|
|
249
|
-
|
|
250
138
|
cy.visit(`${Cypress.config().baseUrl}`)
|
|
251
139
|
.fixture(`users/${jsonName}.json`)
|
|
252
140
|
.then((credential) => {
|
|
253
|
-
cy.getByLabel({ label: 'Alias', tag: 'input' }).type(
|
|
254
|
-
`{selectAll}{backspace}${credential.login}`
|
|
255
|
-
);
|
|
141
|
+
cy.getByLabel({ label: 'Alias', tag: 'input' }).type(credential.login);
|
|
256
142
|
cy.getByLabel({ label: 'Password', tag: 'input' }).type(
|
|
257
|
-
|
|
143
|
+
credential.password
|
|
258
144
|
);
|
|
259
145
|
})
|
|
260
146
|
.getByLabel({ label: 'Connect', tag: 'button' })
|
|
261
147
|
.click();
|
|
262
148
|
|
|
263
|
-
return cy
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
149
|
+
return cy
|
|
150
|
+
.get('.SnackbarContent-root > .MuiPaper-root')
|
|
151
|
+
.then(($snackbar) => {
|
|
152
|
+
if ($snackbar.text().includes('Login succeeded')) {
|
|
153
|
+
cy.wait('@getNavigationList');
|
|
154
|
+
}
|
|
155
|
+
});
|
|
269
156
|
}
|
|
270
157
|
);
|
|
271
158
|
|
|
272
|
-
Cypress.Commands.add('logout', (): void => {
|
|
273
|
-
cy.getByLabel({ label: 'Profile' }).should('exist').click();
|
|
274
|
-
|
|
275
|
-
cy.intercept({
|
|
276
|
-
method: 'GET',
|
|
277
|
-
times: 1,
|
|
278
|
-
url: '/centreon/api/latest/authentication/logout'
|
|
279
|
-
}).as('logout');
|
|
280
|
-
|
|
281
|
-
cy.contains(/^Logout$/).click();
|
|
282
|
-
|
|
283
|
-
cy.wait('@logout').its('response.statusCode').should('eq', 302);
|
|
284
|
-
|
|
285
|
-
// https://github.com/cypress-io/cypress/issues/25841
|
|
286
|
-
cy.clearAllCookies();
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
Cypress.Commands.add('logoutViaAPI', (): Cypress.Chainable => {
|
|
290
|
-
return cy
|
|
291
|
-
.request({
|
|
292
|
-
method: 'GET',
|
|
293
|
-
url: '/centreon/authentication/logout'
|
|
294
|
-
})
|
|
295
|
-
.visit('/')
|
|
296
|
-
.getByLabel({ label: 'Alias', tag: 'input' });
|
|
297
|
-
});
|
|
298
|
-
|
|
299
159
|
Cypress.Commands.add(
|
|
300
160
|
'visitEmptyPage',
|
|
301
161
|
(): Cypress.Chainable =>
|
|
@@ -307,91 +167,32 @@ Cypress.Commands.add(
|
|
|
307
167
|
.visit('/waiting-page')
|
|
308
168
|
);
|
|
309
169
|
|
|
170
|
+
Cypress.Commands.add('waitForContainerAndSetToken', (): Cypress.Chainable => {
|
|
171
|
+
return cy.setUserTokenApiV1();
|
|
172
|
+
});
|
|
173
|
+
|
|
310
174
|
interface ExecInContainerProps {
|
|
311
|
-
command: string
|
|
175
|
+
command: string;
|
|
312
176
|
name: string;
|
|
313
177
|
}
|
|
314
178
|
|
|
315
|
-
interface ExecInContainerResult {
|
|
316
|
-
exitCode: number;
|
|
317
|
-
output: string;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
179
|
Cypress.Commands.add(
|
|
321
180
|
'execInContainer',
|
|
322
181
|
({ command, name }: ExecInContainerProps): Cypress.Chainable => {
|
|
323
|
-
const commands =
|
|
324
|
-
typeof command === 'string' || command instanceof String
|
|
325
|
-
? [command]
|
|
326
|
-
: command;
|
|
327
|
-
|
|
328
|
-
const results = commands.reduce(
|
|
329
|
-
(acc, runCommand) => {
|
|
330
|
-
cy.task<ExecInContainerResult>(
|
|
331
|
-
'execInContainer',
|
|
332
|
-
{ command: runCommand, name },
|
|
333
|
-
{ timeout: 600000 }
|
|
334
|
-
).then((result) => {
|
|
335
|
-
if (result.exitCode) {
|
|
336
|
-
cy.log(result.output);
|
|
337
|
-
|
|
338
|
-
// output will not be truncated
|
|
339
|
-
throw new Error(`
|
|
340
|
-
Execution of "${runCommand}" failed
|
|
341
|
-
Exit code: ${result.exitCode}
|
|
342
|
-
Output:\n${result.output}`);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
acc.output = `${acc.output}${result.output}`;
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
return acc;
|
|
349
|
-
},
|
|
350
|
-
{ exitCode: 0, output: '' }
|
|
351
|
-
);
|
|
352
|
-
|
|
353
|
-
return cy.wrap(results);
|
|
354
|
-
}
|
|
355
|
-
);
|
|
356
|
-
|
|
357
|
-
interface RequestOnDatabaseProps {
|
|
358
|
-
database: string;
|
|
359
|
-
query: string;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
Cypress.Commands.add(
|
|
363
|
-
'requestOnDatabase',
|
|
364
|
-
({ database, query }: RequestOnDatabaseProps): Cypress.Chainable => {
|
|
365
|
-
return cy.task('requestOnDatabase', { database, query });
|
|
366
|
-
}
|
|
367
|
-
);
|
|
368
|
-
|
|
369
|
-
interface SetUserTokenApiV1Props {
|
|
370
|
-
login?: string;
|
|
371
|
-
password?: string;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
Cypress.Commands.add(
|
|
375
|
-
'setUserTokenApiV1',
|
|
376
|
-
({
|
|
377
|
-
login = 'admin',
|
|
378
|
-
password = 'Centreon!2021'
|
|
379
|
-
}: SetUserTokenApiV1Props = {}): Cypress.Chainable => {
|
|
380
182
|
return cy
|
|
381
|
-
.
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
);
|
|
183
|
+
.exec(`docker exec -i ${name} ${command}`, { failOnNonZeroExit: false })
|
|
184
|
+
.then((result) => {
|
|
185
|
+
if (result.code) {
|
|
186
|
+
// output will not be truncated
|
|
187
|
+
throw new Error(`
|
|
188
|
+
Execution of "${command}" failed
|
|
189
|
+
Exit code: ${result.code}
|
|
190
|
+
Stdout:\n${result.stdout}
|
|
191
|
+
Stderr:\n${result.stderr}`);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return cy.wrap(result);
|
|
195
|
+
});
|
|
395
196
|
}
|
|
396
197
|
);
|
|
397
198
|
|
|
@@ -401,7 +202,6 @@ interface PortBinding {
|
|
|
401
202
|
}
|
|
402
203
|
|
|
403
204
|
interface StartContainerProps {
|
|
404
|
-
command?: string;
|
|
405
205
|
image: string;
|
|
406
206
|
name: string;
|
|
407
207
|
portBindings: Array<PortBinding>;
|
|
@@ -409,447 +209,174 @@ interface StartContainerProps {
|
|
|
409
209
|
|
|
410
210
|
Cypress.Commands.add(
|
|
411
211
|
'startContainer',
|
|
412
|
-
({
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
212
|
+
({ name, image, portBindings }: StartContainerProps): Cypress.Chainable => {
|
|
213
|
+
return cy
|
|
214
|
+
.exec('docker image list --format "{{.Repository}}:{{.Tag}}"')
|
|
215
|
+
.then(({ stdout }) => {
|
|
216
|
+
if (
|
|
217
|
+
stdout.match(
|
|
218
|
+
new RegExp(
|
|
219
|
+
`^${image.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')}`,
|
|
220
|
+
'm'
|
|
221
|
+
)
|
|
222
|
+
)
|
|
223
|
+
) {
|
|
224
|
+
cy.log(`Local docker image found : ${image}`);
|
|
225
|
+
|
|
226
|
+
return cy.wrap(image);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
cy.log(`Pulling remote docker image : ${image}`);
|
|
230
|
+
|
|
231
|
+
return cy.exec(`docker pull ${image}`).then(() => cy.wrap(image));
|
|
232
|
+
})
|
|
233
|
+
.then((imageName) =>
|
|
234
|
+
cy.task('startContainer', { image: imageName, name, portBindings })
|
|
235
|
+
);
|
|
425
236
|
}
|
|
426
237
|
);
|
|
427
238
|
|
|
428
|
-
interface
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
moduleName?: string;
|
|
432
|
-
openidImage?: string;
|
|
433
|
-
profiles?: Array<string>;
|
|
434
|
-
samlImage?: string;
|
|
239
|
+
interface StartWebContainerProps {
|
|
240
|
+
name?: string;
|
|
241
|
+
os?: string;
|
|
435
242
|
useSlim?: boolean;
|
|
436
|
-
|
|
437
|
-
webVersion?: string;
|
|
243
|
+
version?: string;
|
|
438
244
|
}
|
|
439
245
|
|
|
440
246
|
Cypress.Commands.add(
|
|
441
|
-
'
|
|
247
|
+
'startWebContainer',
|
|
442
248
|
({
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
moduleName = 'centreon-web',
|
|
446
|
-
openidImage = `docker.centreon.com/centreon/keycloak:${Cypress.env(
|
|
447
|
-
'OPENID_IMAGE_VERSION'
|
|
448
|
-
)}`,
|
|
449
|
-
profiles = [],
|
|
450
|
-
samlImage = `docker.centreon.com/centreon/keycloak:${Cypress.env(
|
|
451
|
-
'SAML_IMAGE_VERSION'
|
|
452
|
-
)}`,
|
|
249
|
+
name = Cypress.env('dockerName'),
|
|
250
|
+
os = 'alma9',
|
|
453
251
|
useSlim = true,
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
}: StartContainersProps = {}): Cypress.Chainable => {
|
|
457
|
-
cy.log('Starting containers ...');
|
|
458
|
-
|
|
459
|
-
let composeFilePath = composeFile;
|
|
460
|
-
if (!composeFile) {
|
|
461
|
-
const cypressDir = path.dirname(Cypress.config('configFile'));
|
|
462
|
-
composeFilePath = `${cypressDir}/../../../.github/docker/docker-compose.yml`;
|
|
463
|
-
}
|
|
464
|
-
|
|
252
|
+
version = Cypress.env('WEB_IMAGE_VERSION')
|
|
253
|
+
}: StartWebContainerProps = {}): Cypress.Chainable => {
|
|
465
254
|
const slimSuffix = useSlim ? '-slim' : '';
|
|
466
255
|
|
|
467
|
-
const
|
|
256
|
+
const image = `docker.centreon.com/centreon/centreon-web${slimSuffix}-${os}:${version}`;
|
|
468
257
|
|
|
469
258
|
return cy
|
|
470
|
-
.
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
openidImage,
|
|
476
|
-
profiles,
|
|
477
|
-
samlImage,
|
|
478
|
-
webImage
|
|
479
|
-
},
|
|
480
|
-
{ timeout: 600000 } // 10 minutes because docker pull can be very slow
|
|
481
|
-
)
|
|
259
|
+
.startContainer({
|
|
260
|
+
image,
|
|
261
|
+
name,
|
|
262
|
+
portBindings: [{ destination: 4000, source: 80 }]
|
|
263
|
+
})
|
|
482
264
|
.then(() => {
|
|
483
|
-
const baseUrl = 'http://
|
|
265
|
+
const baseUrl = 'http://0.0.0.0:4000';
|
|
484
266
|
|
|
485
267
|
Cypress.config('baseUrl', baseUrl);
|
|
486
268
|
|
|
487
|
-
return cy.
|
|
269
|
+
return cy.exec(
|
|
270
|
+
`npx wait-on ${baseUrl}/centreon/api/latest/platform/installation/status`
|
|
271
|
+
);
|
|
488
272
|
})
|
|
489
273
|
.visit('/') // this is necessary to refresh browser cause baseUrl has changed (flash appears in video)
|
|
490
274
|
.setUserTokenApiV1();
|
|
491
275
|
}
|
|
492
276
|
);
|
|
493
277
|
|
|
494
|
-
interface
|
|
495
|
-
name
|
|
278
|
+
interface StopWebContainerProps {
|
|
279
|
+
name?: string;
|
|
496
280
|
}
|
|
497
281
|
|
|
498
282
|
Cypress.Commands.add(
|
|
499
|
-
'
|
|
500
|
-
({
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
const logDirectory = `results/logs/${Cypress.spec.name.replace(
|
|
511
|
-
artifactIllegalCharactersMatcher,
|
|
512
|
-
'_'
|
|
513
|
-
)}/${Cypress.currentTest.title.replace(
|
|
514
|
-
artifactIllegalCharactersMatcher,
|
|
515
|
-
'_'
|
|
516
|
-
)}`;
|
|
517
|
-
|
|
518
|
-
const name = 'web';
|
|
519
|
-
|
|
520
|
-
return cy
|
|
521
|
-
.visitEmptyPage()
|
|
522
|
-
.createDirectory(logDirectory)
|
|
523
|
-
.getContainersLogs()
|
|
524
|
-
.then((containersLogs: Array<Array<string>>) => {
|
|
525
|
-
if (!containersLogs) {
|
|
526
|
-
return;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
Object.entries(containersLogs).forEach(([containerName, logs]) => {
|
|
530
|
-
cy.writeFile(
|
|
531
|
-
`results/logs/${Cypress.spec.name.replace(
|
|
532
|
-
artifactIllegalCharactersMatcher,
|
|
533
|
-
'_'
|
|
534
|
-
)}/${Cypress.currentTest.title.replace(
|
|
535
|
-
artifactIllegalCharactersMatcher,
|
|
536
|
-
'_'
|
|
537
|
-
)}/container-${containerName}.log`,
|
|
538
|
-
logs
|
|
539
|
-
);
|
|
540
|
-
});
|
|
541
|
-
})
|
|
542
|
-
.copyFromContainer({
|
|
543
|
-
destination: `${logDirectory}/broker`,
|
|
544
|
-
name,
|
|
545
|
-
source: '/var/log/centreon-broker'
|
|
546
|
-
})
|
|
547
|
-
.copyFromContainer({
|
|
548
|
-
destination: `${logDirectory}/engine`,
|
|
549
|
-
name,
|
|
550
|
-
source: '/var/log/centreon-engine'
|
|
551
|
-
})
|
|
552
|
-
.copyFromContainer({
|
|
553
|
-
destination: `${logDirectory}/centreon`,
|
|
554
|
-
name,
|
|
555
|
-
source: '/var/log/centreon'
|
|
556
|
-
})
|
|
557
|
-
.copyFromContainer({
|
|
558
|
-
destination: `${logDirectory}/centreon-gorgone`,
|
|
559
|
-
name,
|
|
560
|
-
source: '/var/log/centreon-gorgone'
|
|
561
|
-
})
|
|
562
|
-
.then(() => {
|
|
563
|
-
if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
|
|
564
|
-
return cy.copyFromContainer({
|
|
565
|
-
destination: `${logDirectory}/php`,
|
|
566
|
-
name,
|
|
567
|
-
source: '/var/log/php-fpm'
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
return cy.copyFromContainer(
|
|
572
|
-
{
|
|
573
|
-
destination: `${logDirectory}/php8.1-fpm-centreon-error.log`,
|
|
574
|
-
name,
|
|
575
|
-
source: '/var/log/php8.1-fpm-centreon-error.log'
|
|
576
|
-
},
|
|
577
|
-
{ failOnNonZeroExit: false }
|
|
578
|
-
);
|
|
579
|
-
})
|
|
580
|
-
.then(() => {
|
|
581
|
-
if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
|
|
582
|
-
return cy.copyFromContainer({
|
|
583
|
-
destination: `${logDirectory}/httpd`,
|
|
584
|
-
name,
|
|
585
|
-
source: '/var/log/httpd'
|
|
586
|
-
});
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
return cy.copyFromContainer(
|
|
590
|
-
{
|
|
591
|
-
destination: `${logDirectory}/apache2`,
|
|
592
|
-
name,
|
|
593
|
-
source: '/var/log/apache2'
|
|
594
|
-
},
|
|
595
|
-
{ failOnNonZeroExit: false }
|
|
596
|
-
);
|
|
597
|
-
})
|
|
598
|
-
.exec(`chmod -R 755 "${logDirectory}"`)
|
|
599
|
-
.task(
|
|
600
|
-
'stopContainers',
|
|
601
|
-
{},
|
|
602
|
-
{ timeout: 600000 } // 10 minutes because docker pull can be very slow
|
|
603
|
-
);
|
|
604
|
-
});
|
|
283
|
+
'stopWebContainer',
|
|
284
|
+
({
|
|
285
|
+
name = Cypress.env('dockerName')
|
|
286
|
+
}: StopWebContainerProps = {}): Cypress.Chainable => {
|
|
287
|
+
const logDirectory = `cypress/results/logs/${Cypress.spec.name.replace(
|
|
288
|
+
artifactIllegalCharactersMatcher,
|
|
289
|
+
'_'
|
|
290
|
+
)}/${Cypress.currentTest.title.replace(
|
|
291
|
+
artifactIllegalCharactersMatcher,
|
|
292
|
+
'_'
|
|
293
|
+
)}`;
|
|
605
294
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
295
|
+
return cy
|
|
296
|
+
.visitEmptyPage()
|
|
297
|
+
.exec(`mkdir -p "${logDirectory}"`)
|
|
298
|
+
.copyFromContainer({
|
|
299
|
+
destination: `${logDirectory}/broker`,
|
|
300
|
+
source: '/var/log/centreon-broker'
|
|
301
|
+
})
|
|
302
|
+
.copyFromContainer({
|
|
303
|
+
destination: `${logDirectory}/engine`,
|
|
304
|
+
source: '/var/log/centreon-engine'
|
|
305
|
+
})
|
|
306
|
+
.execInContainer({
|
|
307
|
+
command: `bash -e <<EOF
|
|
308
|
+
chmod 777 /var/log/centreon/centreon-web.log > /dev/null 2>&1 || :
|
|
309
|
+
EOF`,
|
|
310
|
+
name
|
|
311
|
+
})
|
|
312
|
+
.copyFromContainer({
|
|
313
|
+
destination: `${logDirectory}/centreon`,
|
|
314
|
+
source: '/var/log/centreon'
|
|
315
|
+
})
|
|
316
|
+
.stopContainer({ name });
|
|
610
317
|
}
|
|
611
318
|
);
|
|
612
319
|
|
|
613
|
-
interface
|
|
614
|
-
description?: string;
|
|
320
|
+
interface StopContainerProps {
|
|
615
321
|
name: string;
|
|
616
322
|
}
|
|
617
323
|
|
|
618
324
|
Cypress.Commands.add(
|
|
619
|
-
'
|
|
620
|
-
(
|
|
621
|
-
|
|
622
|
-
cy.
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
325
|
+
'stopContainer',
|
|
326
|
+
({ name }: StopContainerProps): Cypress.Chainable => {
|
|
327
|
+
cy.exec(`docker logs ${name}`).then(({ stdout }) => {
|
|
328
|
+
cy.writeFile(
|
|
329
|
+
`cypress/results/logs/${Cypress.spec.name.replace(
|
|
330
|
+
artifactIllegalCharactersMatcher,
|
|
331
|
+
'_'
|
|
332
|
+
)}/${Cypress.currentTest.title.replace(
|
|
333
|
+
artifactIllegalCharactersMatcher,
|
|
334
|
+
'_'
|
|
335
|
+
)}/container-${name}.log`,
|
|
336
|
+
stdout
|
|
628
337
|
);
|
|
629
338
|
});
|
|
630
|
-
}
|
|
631
|
-
);
|
|
632
|
-
|
|
633
|
-
Cypress.Commands.add(
|
|
634
|
-
'insertDashboard',
|
|
635
|
-
(dashboardBody: Dashboard): Cypress.Chainable => {
|
|
636
|
-
return cy.request({
|
|
637
|
-
body: {
|
|
638
|
-
...dashboardBody
|
|
639
|
-
},
|
|
640
|
-
method: 'POST',
|
|
641
|
-
url: '/centreon/api/latest/configuration/dashboards'
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
);
|
|
645
339
|
|
|
646
|
-
|
|
647
|
-
'insertDashboardWithWidget',
|
|
648
|
-
(dashboardBody, patchBody) => {
|
|
649
|
-
cy.request({
|
|
650
|
-
body: {
|
|
651
|
-
...dashboardBody
|
|
652
|
-
},
|
|
653
|
-
method: 'POST',
|
|
654
|
-
url: '/centreon/api/latest/configuration/dashboards'
|
|
655
|
-
}).then((response) => {
|
|
656
|
-
const dashboardId = response.body.id;
|
|
657
|
-
cy.waitUntil(
|
|
658
|
-
() => {
|
|
659
|
-
return cy
|
|
660
|
-
.request({
|
|
661
|
-
method: 'GET',
|
|
662
|
-
url: `/centreon/api/latest/configuration/dashboards/${dashboardId}`
|
|
663
|
-
})
|
|
664
|
-
.then((getResponse) => {
|
|
665
|
-
return getResponse.body && getResponse.body.id === dashboardId;
|
|
666
|
-
});
|
|
667
|
-
},
|
|
668
|
-
{
|
|
669
|
-
timeout: 10000
|
|
670
|
-
}
|
|
671
|
-
);
|
|
672
|
-
cy.request({
|
|
673
|
-
body: patchBody,
|
|
674
|
-
method: 'PATCH',
|
|
675
|
-
url: `/centreon/api/latest/configuration/dashboards/${dashboardId}`
|
|
676
|
-
});
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
);
|
|
680
|
-
|
|
681
|
-
interface ShareDashboardToUserProps {
|
|
682
|
-
dashboardName: string;
|
|
683
|
-
role: string;
|
|
684
|
-
userName: string;
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
interface ListingRequestResult {
|
|
688
|
-
body: {
|
|
689
|
-
result: Array<{
|
|
690
|
-
id: number;
|
|
691
|
-
}>;
|
|
692
|
-
};
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
interface PatchDashboardBody {
|
|
696
|
-
panels: Array<{
|
|
697
|
-
layout: {
|
|
698
|
-
height: number;
|
|
699
|
-
min_height: number;
|
|
700
|
-
min_width: number;
|
|
701
|
-
width: number;
|
|
702
|
-
x: number;
|
|
703
|
-
y: number;
|
|
704
|
-
};
|
|
705
|
-
name: string;
|
|
706
|
-
widget_settings: {
|
|
707
|
-
options: {
|
|
708
|
-
description: {
|
|
709
|
-
content: string;
|
|
710
|
-
enabled: boolean;
|
|
711
|
-
};
|
|
712
|
-
name: string;
|
|
713
|
-
};
|
|
714
|
-
};
|
|
715
|
-
widget_type: string;
|
|
716
|
-
}>;
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
Cypress.Commands.add(
|
|
720
|
-
'shareDashboardToUser',
|
|
721
|
-
({ dashboardName, userName, role }: ShareDashboardToUserProps): void => {
|
|
722
|
-
Promise.all([
|
|
723
|
-
cy.request({
|
|
724
|
-
method: 'GET',
|
|
725
|
-
url: `/centreon/api/latest/configuration/users?search={"name":"${userName}"}`
|
|
726
|
-
}),
|
|
727
|
-
cy.request({
|
|
728
|
-
method: 'GET',
|
|
729
|
-
url: `/centreon/api/latest/configuration/dashboards?search={"name":"${dashboardName}"}`
|
|
730
|
-
})
|
|
731
|
-
]).then(
|
|
732
|
-
([retrievedUser, retrievedDashboard]: [
|
|
733
|
-
ListingRequestResult,
|
|
734
|
-
ListingRequestResult
|
|
735
|
-
]) => {
|
|
736
|
-
const userId = retrievedUser.body.result[0].id;
|
|
737
|
-
const dashboardId = retrievedDashboard.body.result[0].id;
|
|
738
|
-
|
|
739
|
-
cy.request({
|
|
740
|
-
body: {
|
|
741
|
-
id: userId,
|
|
742
|
-
role: `${role}`
|
|
743
|
-
},
|
|
744
|
-
method: 'POST',
|
|
745
|
-
url: `/centreon/api/latest/configuration/dashboards/${dashboardId}/access_rights/contacts`
|
|
746
|
-
});
|
|
747
|
-
}
|
|
748
|
-
);
|
|
340
|
+
return cy.task('stopContainer', { name });
|
|
749
341
|
}
|
|
750
342
|
);
|
|
751
343
|
|
|
752
|
-
Cypress.Commands.add('getTimeFromHeader', (): Cypress.Chainable => {
|
|
753
|
-
return cy
|
|
754
|
-
.get('header div[data-cy="clock"]', { timeout: 20000 })
|
|
755
|
-
.should('be.visible')
|
|
756
|
-
.then(($time) => {
|
|
757
|
-
const headerTime = $time.children()[1].textContent;
|
|
758
|
-
if (headerTime?.match(/\d+:\d+/)) {
|
|
759
|
-
cy.log(`header time is : ${headerTime}`);
|
|
760
|
-
|
|
761
|
-
return cy.wrap(headerTime);
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
throw new Error(`header time is not displayed`);
|
|
765
|
-
});
|
|
766
|
-
});
|
|
767
|
-
|
|
768
344
|
declare global {
|
|
769
345
|
namespace Cypress {
|
|
770
346
|
interface Chainable {
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
props: CopyFromContainerProps,
|
|
774
|
-
options?: Partial<Cypress.ExecOptions>
|
|
775
|
-
) => Cypress.Chainable;
|
|
776
|
-
copyToContainer: (
|
|
777
|
-
props: CopyToContainerProps,
|
|
778
|
-
options?: Partial<Cypress.ExecOptions>
|
|
779
|
-
) => Cypress.Chainable;
|
|
780
|
-
createDirectory: (directoryPath: string) => Cypress.Chainable;
|
|
347
|
+
copyFromContainer: (props: CopyFromContainerProps) => Cypress.Chainable;
|
|
348
|
+
copyToContainer: (props: CopyToContainerProps) => Cypress.Chainable;
|
|
781
349
|
execInContainer: ({
|
|
782
350
|
command,
|
|
783
351
|
name
|
|
784
352
|
}: ExecInContainerProps) => Cypress.Chainable;
|
|
785
|
-
getByLabel: ({
|
|
786
|
-
patternType,
|
|
787
|
-
tag,
|
|
788
|
-
label
|
|
789
|
-
}: GetByLabelProps) => Cypress.Chainable;
|
|
790
|
-
getByTestId: ({
|
|
791
|
-
patternType,
|
|
792
|
-
tag,
|
|
793
|
-
testId
|
|
794
|
-
}: GetByTestIdProps) => Cypress.Chainable;
|
|
795
|
-
getContainerId: (containerName: string) => Cypress.Chainable;
|
|
796
|
-
getContainerIpAddress: (containerName: string) => Cypress.Chainable;
|
|
797
|
-
getContainersLogs: () => Cypress.Chainable;
|
|
798
353
|
getIframeBody: () => Cypress.Chainable;
|
|
799
|
-
getTimeFromHeader: () => Cypress.Chainable;
|
|
800
354
|
getWebVersion: () => Cypress.Chainable;
|
|
801
355
|
hoverRootMenuItem: (rootItemNumber: number) => Cypress.Chainable;
|
|
802
|
-
insertDashboard: (dashboard: Dashboard) => Cypress.Chainable;
|
|
803
|
-
insertDashboardList: (fixtureFile: string) => Cypress.Chainable;
|
|
804
|
-
insertDashboardWithWidget: (
|
|
805
|
-
dashboard: Dashboard,
|
|
806
|
-
patch: PatchDashboardBody
|
|
807
|
-
) => Cypress.Chainable;
|
|
808
|
-
loginAsAdminViaApiV2: () => Cypress.Chainable;
|
|
809
356
|
loginByTypeOfUser: ({
|
|
810
|
-
jsonName,
|
|
811
|
-
loginViaApi
|
|
357
|
+
jsonName = 'admin',
|
|
358
|
+
loginViaApi = false
|
|
812
359
|
}: LoginByTypeOfUserProps) => Cypress.Chainable;
|
|
813
|
-
logout: () => void;
|
|
814
|
-
logoutViaAPI: () => Cypress.Chainable;
|
|
815
360
|
moveSortableElement: (direction: string) => Cypress.Chainable;
|
|
816
361
|
navigateTo: ({
|
|
817
362
|
page,
|
|
818
363
|
rootItemNumber,
|
|
819
364
|
subMenu
|
|
820
365
|
}: NavigateToProps) => Cypress.Chainable;
|
|
821
|
-
requestOnDatabase: ({
|
|
822
|
-
database,
|
|
823
|
-
query
|
|
824
|
-
}: RequestOnDatabaseProps) => Cypress.Chainable;
|
|
825
|
-
setUserTokenApiV1: ({
|
|
826
|
-
login,
|
|
827
|
-
password
|
|
828
|
-
}?: SetUserTokenApiV1Props) => Cypress.Chainable;
|
|
829
|
-
shareDashboardToUser: ({
|
|
830
|
-
dashboardName,
|
|
831
|
-
userName,
|
|
832
|
-
role
|
|
833
|
-
}: ShareDashboardToUserProps) => Cypress.Chainable;
|
|
834
366
|
startContainer: ({
|
|
835
|
-
command,
|
|
836
367
|
name,
|
|
837
|
-
image
|
|
838
|
-
portBindings
|
|
368
|
+
image
|
|
839
369
|
}: StartContainerProps) => Cypress.Chainable;
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
moduleName,
|
|
844
|
-
openidImage,
|
|
845
|
-
profiles,
|
|
370
|
+
startWebContainer: ({
|
|
371
|
+
name,
|
|
372
|
+
os,
|
|
846
373
|
useSlim,
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
}?: StartContainersProps) => Cypress.Chainable;
|
|
374
|
+
version
|
|
375
|
+
}?: StartWebContainerProps) => Cypress.Chainable;
|
|
850
376
|
stopContainer: ({ name }: StopContainerProps) => Cypress.Chainable;
|
|
851
|
-
|
|
377
|
+
stopWebContainer: ({ name }?: StopWebContainerProps) => Cypress.Chainable;
|
|
852
378
|
visitEmptyPage: () => Cypress.Chainable;
|
|
379
|
+
waitForContainerAndSetToken: () => Cypress.Chainable;
|
|
853
380
|
}
|
|
854
381
|
}
|
|
855
382
|
}
|