@centreon/js-config 23.10.1-debug-e2e-cookies.24 → 23.10.1-dev-23-10-x.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.
@@ -10,6 +10,7 @@ import { ThemeProvider } from '@centreon/ui';
10
10
 
11
11
  import '@testing-library/cypress/add-commands';
12
12
  import 'cypress-msw-interceptor';
13
+ import 'cypress-real-events';
13
14
 
14
15
  import disableMotion from './disableCssTransitions';
15
16
 
@@ -96,32 +97,20 @@ Cypress.Commands.add(
96
97
  }
97
98
  );
98
99
 
99
- interface MoveSortableElementProps {
100
- direction: 'up' | 'down' | 'left' | 'right';
101
- element: Cypress.Chainable<JQuery<HTMLElement>>;
102
- times?: number;
103
- }
100
+ Cypress.Commands.add('moveSortableElement', ({ element, direction }): void => {
101
+ const key = `{${direction}arrow}`;
104
102
 
105
- Cypress.Commands.add(
106
- 'moveSortableElement',
107
- ({ element, direction, times = 1 }: MoveSortableElementProps): void => {
108
- const key = `{${direction}arrow}`;
109
-
110
- element.type(' ', {
111
- force: true,
112
- scrollBehavior: false
113
- });
114
-
115
- Array.from({ length: times }).forEach(() => {
116
- element.eq(-1).type(key, {
117
- scrollBehavior: false
118
- });
119
- });
120
- element.eq(-1).type(' ', {
121
- scrollBehavior: false
122
- });
123
- }
124
- );
103
+ element.type(' ', {
104
+ force: true,
105
+ scrollBehavior: false
106
+ });
107
+ element.eq(-1).type(key, {
108
+ scrollBehavior: false
109
+ });
110
+ element.eq(-1).type(' ', {
111
+ scrollBehavior: false
112
+ });
113
+ });
125
114
 
126
115
  Cypress.Commands.add(
127
116
  'moveSortableElementUsingAriaLabel',
@@ -141,8 +130,10 @@ Cypress.Commands.add(
141
130
  }
142
131
  );
143
132
 
133
+ Cypress.Commands.add('adjustViewport', () => cy.viewport(1280, 590));
134
+
144
135
  Cypress.Commands.add('makeSnapshot', (title?: string) => {
145
- cy.viewport(1280, 590);
136
+ cy.adjustViewport();
146
137
  cy.matchImageSnapshot(title);
147
138
  });
148
139
 
@@ -155,6 +146,7 @@ Cypress.Commands.add('cssDisableMotion', (): void => {
155
146
  declare global {
156
147
  namespace Cypress {
157
148
  interface Chainable {
149
+ adjustViewport: () => Cypress.Chainable;
158
150
  cssDisableMotion: () => Cypress.Chainable;
159
151
  interceptAPIRequest: <T extends object>(
160
152
  props: InterceptAPIRequestProps<T>
@@ -162,11 +154,7 @@ declare global {
162
154
  interceptRequest: (method, path, mock, alias) => Cypress.Chainable;
163
155
  makeSnapshot: (title?: string) => void;
164
156
  mount: ({ Component, options }: MountProps) => Cypress.Chainable;
165
- moveSortableElement: ({
166
- element,
167
- direction,
168
- times
169
- }: MoveSortableElementProps) => void;
157
+ moveSortableElement: ({ element, direction }) => void;
170
158
  moveSortableElementUsingAriaLabel: ({ ariaLabel, direction }) => void;
171
159
  waitForRequest: (alias) => Cypress.Chainable;
172
160
  }
@@ -49,6 +49,8 @@ module.exports = ({
49
49
  reportFilename: '[name]-report.json'
50
50
  },
51
51
  video: true,
52
- videosFolder: `${mainCypressFolder}/results/videos`
52
+ videosFolder: `${mainCypressFolder}/results/videos`,
53
+ viewportHeight: 590,
54
+ viewportWidth: 1280
53
55
  });
54
56
  };
@@ -144,6 +144,7 @@ interface Host {
144
144
  alias?: string | null;
145
145
  checkCommand?: string | null;
146
146
  checkPeriod?: string | null;
147
+ hostGroup?: string;
147
148
  maxCheckAttempts?: number | null;
148
149
  name: string;
149
150
  passiveCheckEnabled?: boolean;
@@ -159,6 +160,7 @@ Cypress.Commands.add(
159
160
  alias = null,
160
161
  checkCommand = null,
161
162
  checkPeriod = null,
163
+ hostGroup = '',
162
164
  maxCheckAttempts = 1,
163
165
  name,
164
166
  passiveCheckEnabled = true,
@@ -176,7 +178,7 @@ Cypress.Commands.add(
176
178
  bodyContent: {
177
179
  action: 'ADD',
178
180
  object: 'HOST',
179
- values: `${name};${hostAlias};${address};${template};${poller};`
181
+ values: `${name};${hostAlias};${address};${template};${poller};${hostGroup}`
180
182
  }
181
183
  })
182
184
  .then(() => {
@@ -64,10 +64,73 @@ Cypress.Commands.add(
64
64
  }
65
65
  );
66
66
 
67
+ interface ServiceCheck {
68
+ host: string;
69
+ isForced?: boolean;
70
+ service: string;
71
+ }
72
+
73
+ Cypress.Commands.add(
74
+ 'scheduleServiceCheck',
75
+ ({ host, isForced = true, service }: ServiceCheck): Cypress.Chainable => {
76
+ cy.log(`Host: ${host}, Service: ${service}`);
77
+
78
+ let query = `SELECT parent_id, id FROM resources WHERE parent_name = '${host}' AND name = '${service}'`;
79
+
80
+ return cy
81
+ .fetchHostData({
82
+ database: 'centreon_storage',
83
+ query
84
+ })
85
+ .then((rows) => {
86
+ cy.log('Rows:', JSON.stringify(rows));
87
+
88
+ if (!Array.isArray(rows) || rows.length === 0) {
89
+ throw new Error(`Cannot find service ${host} / ${service}`);
90
+ }
91
+
92
+ const hostId = parseInt(rows[0].parent_id, 10);
93
+ const serviceId = parseInt(rows[0].id, 10);
94
+
95
+ cy.log(`Host ID: ${hostId}, Service ID: ${serviceId}`);
96
+
97
+ if (isNaN(hostId) || isNaN(serviceId)) {
98
+ throw new Error(`Invalid IDs: hostId = ${hostId}, serviceId = ${serviceId}`);
99
+ }
100
+
101
+ return cy.request({
102
+ body: {
103
+ check: {
104
+ is_forced: isForced
105
+ },
106
+ resources: [
107
+ {
108
+ id: serviceId,
109
+ parent: {
110
+ id: hostId
111
+ },
112
+ type: 'service'
113
+ }
114
+ ]
115
+ },
116
+ method: 'POST',
117
+ timeout: 30000,
118
+ url: '/centreon/api/latest/monitoring/resources/check'
119
+ }).then((response) => {
120
+ expect(response.status).to.eq(204);
121
+
122
+ return cy.wrap(null);
123
+ });
124
+ });
125
+ }
126
+ );
127
+
128
+
67
129
  declare global {
68
130
  namespace Cypress {
69
131
  interface Chainable {
70
132
  submitResults: (props: Array<SubmitResult>) => Cypress.Chainable;
133
+ scheduleServiceCheck: (serviceCheck) => Cypress.Chainable;
71
134
  }
72
135
  }
73
136
  }
@@ -178,11 +178,13 @@ Cypress.Commands.add(
178
178
  .getByLabel({ label: 'Connect', tag: 'button' })
179
179
  .click();
180
180
 
181
- return cy.get('.MuiAlert-message').then(($snackbar) => {
182
- if ($snackbar.text().includes('Login succeeded')) {
183
- cy.wait('@getNavigationList');
184
- }
185
- });
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
+ });
186
188
  }
187
189
  );
188
190
 
@@ -332,11 +334,6 @@ Cypress.Commands.add(
332
334
  name,
333
335
  source: '/var/log/centreon'
334
336
  })
335
- .copyFromContainer({
336
- destination: `${logDirectory}/centreon-gorgone`,
337
- name,
338
- source: '/var/log/centreon-gorgone'
339
- })
340
337
  .then(() => {
341
338
  if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
342
339
  return cy.copyFromContainer({
@@ -355,24 +352,6 @@ Cypress.Commands.add(
355
352
  { failOnNonZeroExit: false }
356
353
  );
357
354
  })
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
355
  .exec(`chmod -R 755 "${logDirectory}"`)
377
356
  .stopContainer({ name });
378
357
  }
@@ -389,7 +368,7 @@ Cypress.Commands.add(
389
368
 
390
369
  cy.exec(`docker logs ${name}`).then(({ stdout }) => {
391
370
  cy.writeFile(
392
- `results/logs/${Cypress.spec.name.replace(
371
+ `cypress/results/logs/${Cypress.spec.name.replace(
393
372
  artifactIllegalCharactersMatcher,
394
373
  '_'
395
374
  )}/${Cypress.currentTest.title.replace(
@@ -437,41 +416,6 @@ Cypress.Commands.add(
437
416
  }
438
417
  );
439
418
 
440
- Cypress.Commands.add(
441
- 'insertDashboardWithWidget',
442
- (dashboardBody, patchBody) => {
443
- cy.request({
444
- body: {
445
- ...dashboardBody
446
- },
447
- method: 'POST',
448
- url: '/centreon/api/latest/configuration/dashboards'
449
- }).then((response) => {
450
- const dashboardId = response.body.id;
451
- cy.waitUntil(
452
- () => {
453
- return cy
454
- .request({
455
- method: 'GET',
456
- url: `/centreon/api/latest/configuration/dashboards/${dashboardId}`
457
- })
458
- .then((getResponse) => {
459
- return getResponse.body && getResponse.body.id === dashboardId;
460
- });
461
- },
462
- {
463
- timeout: 10000
464
- }
465
- );
466
- cy.request({
467
- body: patchBody,
468
- method: 'PATCH',
469
- url: `/centreon/api/latest/configuration/dashboards/${dashboardId}`
470
- });
471
- });
472
- }
473
- );
474
-
475
419
  interface ShareDashboardToUserProps {
476
420
  dashboardName: string;
477
421
  role: string;
@@ -486,30 +430,6 @@ interface ListingRequestResult {
486
430
  };
487
431
  }
488
432
 
489
- interface PatchDashboardBody {
490
- panels: Array<{
491
- layout: {
492
- height: number;
493
- min_height: number;
494
- min_width: number;
495
- width: number;
496
- x: number;
497
- y: number;
498
- };
499
- name: string;
500
- widget_settings: {
501
- options: {
502
- description: {
503
- content: string;
504
- enabled: boolean;
505
- };
506
- name: string;
507
- };
508
- };
509
- widget_type: string;
510
- }>;
511
- }
512
-
513
433
  Cypress.Commands.add(
514
434
  'shareDashboardToUser',
515
435
  ({ dashboardName, userName, role }: ShareDashboardToUserProps): void => {
@@ -559,10 +479,22 @@ Cypress.Commands.add('getTimeFromHeader', (): Cypress.Chainable => {
559
479
  });
560
480
  });
561
481
 
482
+ Cypress.Commands.add('loginAsAdminViaApiV2', (): Cypress.Chainable => {
483
+ return cy.request({
484
+ body: {
485
+ login: 'admin',
486
+ password: 'Centreon!2021'
487
+ },
488
+ method: 'POST',
489
+ url: apiLoginV2
490
+ });
491
+ });
492
+
562
493
  declare global {
563
494
  namespace Cypress {
564
495
  interface Chainable {
565
496
  clickSubRootMenuItem: (page: string) => Cypress.Chainable;
497
+ loginAsAdminViaApiV2: () => Cypress.Chainable;
566
498
  copyFromContainer: (
567
499
  props: CopyFromContainerProps,
568
500
  options?: Partial<Cypress.ExecOptions>
@@ -582,11 +514,6 @@ declare global {
582
514
  hoverRootMenuItem: (rootItemNumber: number) => Cypress.Chainable;
583
515
  insertDashboard: (dashboard: Dashboard) => Cypress.Chainable;
584
516
  insertDashboardList: (fixtureFile: string) => Cypress.Chainable;
585
- insertDashboardWithWidget: (
586
- dashboard: Dashboard,
587
- patch: PatchDashboardBody
588
- ) => Cypress.Chainable;
589
-
590
517
  loginByTypeOfUser: ({
591
518
  jsonName,
592
519
  loginViaApi
@@ -5,7 +5,6 @@ import { execSync } from 'child_process';
5
5
 
6
6
  import { defineConfig } from 'cypress';
7
7
  import installLogsPrinter from 'cypress-terminal-report/src/installLogsPrinter';
8
- import { config as configDotenv } from 'dotenv';
9
8
 
10
9
  import esbuildPreprocessor from './esbuild-preprocessor';
11
10
  import plugins from './plugins';
@@ -15,7 +14,6 @@ interface ConfigurationOptions {
15
14
  cypressFolder?: string;
16
15
  dockerName?: string;
17
16
  env?: Record<string, unknown>;
18
- envFile?: string;
19
17
  isDevelopment?: boolean;
20
18
  specPattern: string;
21
19
  }
@@ -25,13 +23,8 @@ export default ({
25
23
  cypressFolder,
26
24
  isDevelopment,
27
25
  dockerName,
28
- env,
29
- envFile
26
+ env
30
27
  }: ConfigurationOptions): Cypress.ConfigOptions => {
31
- if (envFile) {
32
- configDotenv({ path: envFile });
33
- }
34
-
35
28
  const resultsFolder = `${cypressFolder || '.'}/results`;
36
29
 
37
30
  const webImageVersion = execSync('git rev-parse --abbrev-ref HEAD')
@@ -60,7 +53,7 @@ export default ({
60
53
  },
61
54
  env: {
62
55
  ...env,
63
- OPENID_IMAGE_VERSION: process.env.MAJOR || '24.04',
56
+ OPENID_IMAGE_VERSION: '23.04',
64
57
  WEB_IMAGE_OS: 'alma9',
65
58
  WEB_IMAGE_VERSION: webImageVersion,
66
59
  dockerName: dockerName || 'centreon-dev'
@@ -11,7 +11,7 @@ export default (
11
11
  const width = 1920;
12
12
  const height = 1080;
13
13
 
14
- if (browser.family === 'chromium') {
14
+ if (browser.name === 'chrome') {
15
15
  if (browser.isHeadless) {
16
16
  launchOptions.args.push('--headless=new');
17
17
  }
package/jest/index.js CHANGED
@@ -5,6 +5,7 @@ module.exports = {
5
5
  'jest-transform-stub',
6
6
  '^react($|/.+)': '<rootDir>/node_modules/react$1'
7
7
  },
8
+ setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
8
9
  testEnvironment: 'jsdom',
9
10
  testPathIgnorePatterns: ['/node_modules/', '!*.cypress.spec.tsx'],
10
11
  transform: {
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-debug-e2e-cookies.24",
4
+ "version": "23.10.1-dev-23-10-x.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon-frontend.git"
@@ -53,7 +53,6 @@
53
53
  "cypress-multi-reporters": "^1.6.4",
54
54
  "cypress-terminal-report": "^5.3.9",
55
55
  "dockerode": "^4.0.0",
56
- "dotenv": "^16.3.1",
57
56
  "esbuild": "^0.19.5",
58
57
  "mochawesome": "^7.1.3"
59
58
  }
@@ -1,5 +1,5 @@
1
1
  const excludeNodeModulesExceptCentreonUi =
2
- /node_modules(\\|\/)\.pnpm(\\|\/)(?!(@centreon|file\+packages\+ui-context))/;
2
+ /node_modules[/\\]\.pnpm[/\\](?!.*node_modules[/\\]@centreon).*/;
3
3
 
4
4
  module.exports = {
5
5
  cache: false,
@@ -18,28 +18,34 @@ const getBaseConfiguration = ({
18
18
  cache,
19
19
  module: getModuleConfiguration(jscTransformConfiguration),
20
20
  optimization,
21
- output,
21
+ output: {
22
+ ...output,
23
+ library: moduleName,
24
+ uniqueName: moduleName
25
+ },
22
26
  plugins: [
23
27
  new CleanWebpackPlugin(),
24
28
  moduleName &&
25
29
  new ModuleFederationPlugin({
26
30
  filename: 'remoteEntry.[chunkhash:8].js',
27
- library: { name: moduleName, type: 'var' },
31
+ library: { name: moduleName, type: 'umd' },
28
32
  name: moduleName,
29
33
  shared: [
30
34
  {
31
35
  '@centreon/ui-context': {
36
+ requiredVersion: '22.10.0',
32
37
  singleton: true
33
38
  }
34
39
  },
35
40
  {
36
41
  jotai: {
37
- requiredVersion: '2.x',
42
+ requiredVersion: '1.x',
38
43
  singleton: true
39
44
  }
40
45
  },
41
46
  {
42
47
  'jotai-suspense': {
48
+ requiredVersion: '0.1.x',
43
49
  singleton: true
44
50
  }
45
51
  },