@centreon/js-config 23.10.25 → 23.10.26

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.
@@ -136,7 +136,7 @@ declare global {
136
136
  ) => Cypress.Chainable;
137
137
  interceptRequest: (method, path, mock, alias) => Cypress.Chainable;
138
138
  mount: ({ Component, options }: MountProps) => Cypress.Chainable;
139
- moveSortableElement: ({ ariaLabel, direction }) => void;
139
+ moveSortableElement: ({ element, direction }) => void;
140
140
  moveSortableElementUsingAriaLabel: ({ ariaLabel, direction }) => void;
141
141
  waitForRequest: (alias) => Cypress.Chainable;
142
142
  }
@@ -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 {};
@@ -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
 
@@ -109,7 +110,7 @@ Cypress.Commands.add(
109
110
  source,
110
111
  destination
111
112
  }: CopyFromContainerProps,
112
- options
113
+ options?: Partial<Cypress.ExecOptions>
113
114
  ) => {
114
115
  return cy.exec(`docker cp ${name}:${source} "${destination}"`, options);
115
116
  }
@@ -129,7 +130,7 @@ Cypress.Commands.add(
129
130
  source,
130
131
  destination
131
132
  }: CopyToContainerProps,
132
- options
133
+ options?: Partial<Cypress.ExecOptions>
133
134
  ) => {
134
135
  return cy.exec(`docker cp ${source} ${name}:${destination}`, options);
135
136
  }
@@ -159,12 +160,15 @@ Cypress.Commands.add(
159
160
  .visit(`${Cypress.config().baseUrl}`)
160
161
  .wait('@getNavigationList');
161
162
  }
163
+
162
164
  cy.visit(`${Cypress.config().baseUrl}`)
163
165
  .fixture(`users/${jsonName}.json`)
164
166
  .then((credential) => {
165
- cy.getByLabel({ label: 'Alias', tag: 'input' }).type(credential.login);
167
+ cy.getByLabel({ label: 'Alias', tag: 'input' }).type(
168
+ `{selectAll}{backspace}${credential.login}`
169
+ );
166
170
  cy.getByLabel({ label: 'Password', tag: 'input' }).type(
167
- credential.password
171
+ `{selectAll}{backspace}${credential.password}`
168
172
  );
169
173
  })
170
174
  .getByLabel({ label: 'Connect', tag: 'button' })
@@ -407,6 +411,14 @@ interface ShareDashboardToUserProps {
407
411
  userName: string;
408
412
  }
409
413
 
414
+ interface ListingRequestResult {
415
+ body: {
416
+ result: Array<{
417
+ id: number;
418
+ }>;
419
+ };
420
+ }
421
+
410
422
  Cypress.Commands.add(
411
423
  'shareDashboardToUser',
412
424
  ({ dashboardName, userName, role }: ShareDashboardToUserProps): void => {
@@ -419,8 +431,11 @@ Cypress.Commands.add(
419
431
  method: 'GET',
420
432
  url: `/centreon/api/latest/configuration/dashboards?search={"name":"${dashboardName}"}`
421
433
  })
422
- ])
423
- .then(([retrievedUser, retrievedDashboard]) => {
434
+ ]).then(
435
+ ([retrievedUser, retrievedDashboard]: [
436
+ ListingRequestResult,
437
+ ListingRequestResult
438
+ ]) => {
424
439
  const userId = retrievedUser.body.result[0].id;
425
440
  const dashboardId = retrievedDashboard.body.result[0].id;
426
441
 
@@ -432,30 +447,39 @@ Cypress.Commands.add(
432
447
  method: 'POST',
433
448
  url: `/centreon/api/latest/configuration/dashboards/${dashboardId}/access_rights/contacts`
434
449
  });
435
- })
436
- .catch((error) => console.log(error));
450
+ }
451
+ );
437
452
  }
438
453
  );
439
454
 
440
455
  Cypress.Commands.add('getTimeFromHeader', (): Cypress.Chainable => {
441
- return cy.waitUntil(() => {
442
- return cy.get('header div[data-cy="clock"]').then(($time) => {
456
+ return cy
457
+ .get('header div[data-cy="clock"]', { timeout: 10000 })
458
+ .should('be.visible')
459
+ .then(($time) => {
443
460
  const headerTime = $time.children()[1].textContent;
444
461
  if (headerTime?.match(/\d+:\d+/)) {
445
- return headerTime;
462
+ cy.log(`header time is : ${headerTime}`);
463
+
464
+ return cy.wrap(headerTime);
446
465
  }
447
466
 
448
- return false;
467
+ throw new Error(`header time is not displayed`);
449
468
  });
450
- });
451
469
  });
452
470
 
453
471
  declare global {
454
472
  namespace Cypress {
455
473
  interface Chainable {
456
474
  clickSubRootMenuItem: (page: string) => Cypress.Chainable;
457
- copyFromContainer: (props: CopyFromContainerProps) => Cypress.Chainable;
458
- copyToContainer: (props: CopyToContainerProps) => Cypress.Chainable;
475
+ copyFromContainer: (
476
+ props: CopyFromContainerProps,
477
+ options?: Partial<Cypress.ExecOptions>
478
+ ) => Cypress.Chainable;
479
+ copyToContainer: (
480
+ props: CopyToContainerProps,
481
+ options?: Partial<Cypress.ExecOptions>
482
+ ) => Cypress.Chainable;
459
483
  execInContainer: ({
460
484
  command,
461
485
  name
@@ -22,9 +22,7 @@ export default ({
22
22
  dockerName,
23
23
  env
24
24
  }: ConfigurationOptions): Cypress.ConfigOptions => {
25
- const resultsFolder = `${cypressFolder || 'cypress'}/results${
26
- isDevelopment ? '/dev' : ''
27
- }`;
25
+ const resultsFolder = `${cypressFolder || 'cypress'}/results`;
28
26
 
29
27
  const webImageVersion = execSync('git rev-parse --abbrev-ref HEAD')
30
28
  .toString('utf8')
@@ -58,6 +56,7 @@ export default ({
58
56
  retries: 0,
59
57
  screenshotsFolder: `${resultsFolder}/screenshots`,
60
58
  video: true,
59
+ videoCompression: isDevelopment ? 0 : 16,
61
60
  videosFolder: `${resultsFolder}/videos`
62
61
  });
63
62
  };
@@ -50,6 +50,9 @@ export default async (on, config): Promise<void> => {
50
50
  on('file:preprocessor', webpackPreprocessor(options));
51
51
 
52
52
  on('before:browser:launch', (browser = {}, launchOptions) => {
53
+ const width = 1920;
54
+ const height = 1080;
55
+
53
56
  if ((browser as { name }).name === 'chrome') {
54
57
  // flags description : https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md
55
58
  launchOptions.args.push('--disable-gpu');
@@ -58,6 +61,10 @@ export default async (on, config): Promise<void> => {
58
61
  launchOptions.args.push('--hide-scrollbars');
59
62
  launchOptions.args.push('--mute-audio');
60
63
  launchOptions.args.push('--hide-scrollbars');
64
+
65
+ launchOptions.args.push(`--window-size=${width},${height}`);
66
+ // force screen to be non-retina and just use our given resolution
67
+ launchOptions.args.push('--force-device-scale-factor=1');
61
68
  }
62
69
 
63
70
  return launchOptions;
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.25",
4
+ "version": "23.10.26",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon-frontend.git"