@centreon/js-config 24.4.13 → 24.4.15

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.
@@ -96,20 +96,32 @@ Cypress.Commands.add(
96
96
  }
97
97
  );
98
98
 
99
- Cypress.Commands.add('moveSortableElement', ({ element, direction }): void => {
100
- const key = `{${direction}arrow}`;
99
+ interface MoveSortableElementProps {
100
+ direction: 'up' | 'down' | 'left' | 'right';
101
+ element: Cypress.Chainable<JQuery<HTMLElement>>;
102
+ times?: number;
103
+ }
101
104
 
102
- element.type(' ', {
103
- force: true,
104
- scrollBehavior: false
105
- });
106
- element.eq(-1).type(key, {
107
- scrollBehavior: false
108
- });
109
- element.eq(-1).type(' ', {
110
- scrollBehavior: false
111
- });
112
- });
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
+ );
113
125
 
114
126
  Cypress.Commands.add(
115
127
  'moveSortableElementUsingAriaLabel',
@@ -147,13 +159,18 @@ declare global {
147
159
  interface Chainable {
148
160
  adjustViewport: () => Cypress.Chainable;
149
161
  cssDisableMotion: () => Cypress.Chainable;
162
+ getRequestCalls: (alias) => Cypress.Chainable;
150
163
  interceptAPIRequest: <T extends object>(
151
164
  props: InterceptAPIRequestProps<T>
152
165
  ) => Cypress.Chainable;
153
166
  interceptRequest: (method, path, mock, alias) => Cypress.Chainable;
154
167
  makeSnapshot: (title?: string) => void;
155
168
  mount: ({ Component, options }: MountProps) => Cypress.Chainable;
156
- moveSortableElement: ({ element, direction }) => void;
169
+ moveSortableElement: ({
170
+ element,
171
+ direction,
172
+ times
173
+ }: MoveSortableElementProps) => void;
157
174
  moveSortableElementUsingAriaLabel: ({ ariaLabel, direction }) => void;
158
175
  waitForRequest: (alias) => Cypress.Chainable;
159
176
  }
@@ -3,6 +3,7 @@ const { defineConfig } = require('cypress');
3
3
  const {
4
4
  addMatchImageSnapshotPlugin
5
5
  } = require('@simonsmith/cypress-image-snapshot/plugin');
6
+ const cypressCodeCoverageTask = require('@cypress/code-coverage/task');
6
7
 
7
8
  module.exports = ({
8
9
  webpackConfig,
@@ -25,6 +26,8 @@ module.exports = ({
25
26
  setupNodeEvents: (on, config) => {
26
27
  addMatchImageSnapshotPlugin(on, config);
27
28
 
29
+ cypressCodeCoverageTask(on, config);
30
+
28
31
  on('before:browser:launch', (browser, launchOptions) => {
29
32
  if (browser.name === 'chrome' && browser.isHeadless) {
30
33
  launchOptions.args.push('--headless=new');
@@ -37,8 +40,17 @@ module.exports = ({
37
40
  supportFile: `${mainCypressFolder}/support/component.tsx`
38
41
  },
39
42
  env: {
40
- ...env,
41
- baseUrl: 'http://localhost:9092'
43
+ baseUrl: 'http://localhost:9092',
44
+ codeCoverage: {
45
+ exclude: [
46
+ 'cypress/**/*.*',
47
+ 'packages/**',
48
+ 'node_modules',
49
+ '**/*.js',
50
+ '**/*.spec.tsx'
51
+ ]
52
+ },
53
+ ...env
42
54
  },
43
55
  reporter: 'mochawesome',
44
56
  reporterOptions: {
@@ -178,13 +178,11 @@ Cypress.Commands.add(
178
178
  .getByLabel({ label: 'Connect', tag: 'button' })
179
179
  .click();
180
180
 
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
- });
181
+ return cy.get('.MuiAlert-message').then(($snackbar) => {
182
+ if ($snackbar.text().includes('Login succeeded')) {
183
+ cy.wait('@getNavigationList');
184
+ }
185
+ });
188
186
  }
189
187
  );
190
188
 
@@ -334,6 +332,11 @@ Cypress.Commands.add(
334
332
  name,
335
333
  source: '/var/log/centreon'
336
334
  })
335
+ .copyFromContainer({
336
+ destination: `${logDirectory}/centreon-gorgone`,
337
+ name,
338
+ source: '/var/log/centreon-gorgone'
339
+ })
337
340
  .then(() => {
338
341
  if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
339
342
  return cy.copyFromContainer({
@@ -352,6 +355,24 @@ Cypress.Commands.add(
352
355
  { failOnNonZeroExit: false }
353
356
  );
354
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
+ })
355
376
  .exec(`chmod -R 755 "${logDirectory}"`)
356
377
  .stopContainer({ name });
357
378
  }
@@ -368,7 +389,7 @@ Cypress.Commands.add(
368
389
 
369
390
  cy.exec(`docker logs ${name}`).then(({ stdout }) => {
370
391
  cy.writeFile(
371
- `cypress/results/logs/${Cypress.spec.name.replace(
392
+ `results/logs/${Cypress.spec.name.replace(
372
393
  artifactIllegalCharactersMatcher,
373
394
  '_'
374
395
  )}/${Cypress.currentTest.title.replace(
@@ -416,6 +437,41 @@ Cypress.Commands.add(
416
437
  }
417
438
  );
418
439
 
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
+
419
475
  interface ShareDashboardToUserProps {
420
476
  dashboardName: string;
421
477
  role: string;
@@ -430,6 +486,30 @@ interface ListingRequestResult {
430
486
  };
431
487
  }
432
488
 
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
+
433
513
  Cypress.Commands.add(
434
514
  'shareDashboardToUser',
435
515
  ({ dashboardName, userName, role }: ShareDashboardToUserProps): void => {
@@ -502,6 +582,11 @@ declare global {
502
582
  hoverRootMenuItem: (rootItemNumber: number) => Cypress.Chainable;
503
583
  insertDashboard: (dashboard: Dashboard) => Cypress.Chainable;
504
584
  insertDashboardList: (fixtureFile: string) => Cypress.Chainable;
585
+ insertDashboardWithWidget: (
586
+ dashboard: Dashboard,
587
+ patch: PatchDashboardBody
588
+ ) => Cypress.Chainable;
589
+
505
590
  loginByTypeOfUser: ({
506
591
  jsonName,
507
592
  loginViaApi
@@ -5,6 +5,7 @@ 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';
8
9
 
9
10
  import esbuildPreprocessor from './esbuild-preprocessor';
10
11
  import plugins from './plugins';
@@ -14,6 +15,7 @@ interface ConfigurationOptions {
14
15
  cypressFolder?: string;
15
16
  dockerName?: string;
16
17
  env?: Record<string, unknown>;
18
+ envFile?: string;
17
19
  isDevelopment?: boolean;
18
20
  specPattern: string;
19
21
  }
@@ -23,8 +25,13 @@ export default ({
23
25
  cypressFolder,
24
26
  isDevelopment,
25
27
  dockerName,
26
- env
28
+ env,
29
+ envFile
27
30
  }: ConfigurationOptions): Cypress.ConfigOptions => {
31
+ if (envFile) {
32
+ configDotenv({ path: envFile });
33
+ }
34
+
28
35
  const resultsFolder = `${cypressFolder || '.'}/results`;
29
36
 
30
37
  const webImageVersion = execSync('git rev-parse --abbrev-ref HEAD')
@@ -53,7 +60,7 @@ export default ({
53
60
  },
54
61
  env: {
55
62
  ...env,
56
- OPENID_IMAGE_VERSION: '23.04',
63
+ OPENID_IMAGE_VERSION: process.env.MAJOR || '24.04',
57
64
  WEB_IMAGE_OS: 'alma9',
58
65
  WEB_IMAGE_VERSION: webImageVersion,
59
66
  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.name === 'chrome') {
14
+ if (browser.family === 'chromium') {
15
15
  if (browser.isHeadless) {
16
16
  launchOptions.args.push('--headless=new');
17
17
  }
package/jest/index.js CHANGED
@@ -5,7 +5,6 @@ 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'],
9
8
  testEnvironment: 'jsdom',
10
9
  testPathIgnorePatterns: ['/node_modules/', '!*.cypress.spec.tsx'],
11
10
  transform: {
package/package.json CHANGED
@@ -1,59 +1,63 @@
1
1
  {
2
- "name": "@centreon/js-config",
3
- "description": "Centreon Frontend shared build configuration",
4
- "version": "24.4.13",
5
- "repository": {
6
- "type": "git",
7
- "url": "git+https://github.com/centreon/centreon-frontend.git"
8
- },
9
- "keywords": [
10
- "centreon",
11
- "eslint"
12
- ],
13
- "author": "centreon@centreon.com",
14
- "license": "GPL-2.0",
15
- "bugs": {
16
- "url": "https://github.com/centreon/centreon-frontend/issues"
17
- },
18
- "devDependencies": {
19
- "@tsconfig/node16": "^16.1.1",
20
- "eslint": "^8.17.0",
21
- "eslint-config-airbnb": "19.0.4",
22
- "eslint-config-prettier": "^8.5.0",
23
- "eslint-import-resolver-alias": "^1.1.2",
24
- "eslint-import-resolver-typescript": "^3.5.5",
25
- "eslint-plugin-babel": "^5.3.1",
26
- "eslint-plugin-hooks": "^0.4.3",
27
- "eslint-plugin-import": "^2.26.0",
28
- "eslint-plugin-jest": "^26.1.5",
29
- "eslint-plugin-jsx-a11y": "^6.5.1",
30
- "eslint-plugin-node": "^11.1.0",
31
- "eslint-plugin-prefer-arrow-functions": "^3.1.4",
32
- "eslint-plugin-prettier": "^4.0.0",
33
- "eslint-plugin-react": "^7.29.4",
34
- "eslint-plugin-react-hooks": "^4.5.0",
35
- "eslint-plugin-sort-keys-fix": "^1.1.2",
36
- "eslint-plugin-typescript-sort-keys": "^2.1.0"
37
- },
38
- "homepage": "https://github.com/centreon/centreon-frontend#readme",
39
- "files": [
40
- "eslint",
41
- "jest",
42
- "tsconfig",
43
- "webpack",
44
- "cypress"
45
- ],
46
- "dependencies": {
47
- "@badeball/cypress-cucumber-preprocessor": "^19.1.0",
48
- "@bahmutov/cypress-esbuild-preprocessor": "^2.2.0",
49
- "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
50
- "@esbuild-plugins/node-modules-polyfill": "^0.2.2",
51
- "@types/cypress-cucumber-preprocessor": "^4.0.5",
52
- "@types/dockerode": "^3.3.23",
53
- "cypress-multi-reporters": "^1.6.4",
54
- "cypress-terminal-report": "^5.3.9",
55
- "dockerode": "^4.0.0",
56
- "esbuild": "^0.19.5",
57
- "mochawesome": "^7.1.3"
58
- }
2
+ "name": "@centreon/js-config",
3
+ "description": "Centreon Frontend shared build configuration",
4
+ "version": "24.4.15",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/centreon/centreon-frontend.git"
8
+ },
9
+ "keywords": [
10
+ "centreon",
11
+ "eslint"
12
+ ],
13
+ "author": "centreon@centreon.com",
14
+ "license": "GPL-2.0",
15
+ "bugs": {
16
+ "url": "https://github.com/centreon/centreon-frontend/issues"
17
+ },
18
+ "homepage": "https://github.com/centreon/centreon-frontend#readme",
19
+ "files": [
20
+ "eslint",
21
+ "jest",
22
+ "tsconfig",
23
+ "webpack",
24
+ "cypress"
25
+ ],
26
+ "peerDependencies": {
27
+ "prettier": "^3.0.0",
28
+ "eslint": "^8.53.0"
29
+ },
30
+ "dependencies": {
31
+ "@badeball/cypress-cucumber-preprocessor": "^19.1.0",
32
+ "@bahmutov/cypress-esbuild-preprocessor": "^2.2.0",
33
+ "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
34
+ "@esbuild-plugins/node-modules-polyfill": "^0.2.2",
35
+ "@tsconfig/node16": "^16.1.1",
36
+ "@tsconfig/node20": "^20.1.2",
37
+ "@types/cypress-cucumber-preprocessor": "^4.0.5",
38
+ "@types/dockerode": "^3.3.23",
39
+ "cypress-multi-reporters": "^1.6.4",
40
+ "cypress-terminal-report": "^5.3.9",
41
+ "dockerode": "^4.0.0",
42
+ "dotenv": "^16.3.1",
43
+ "esbuild": "^0.19.5",
44
+ "eslint": "^8.53.0",
45
+ "eslint-config-airbnb": "19.0.4",
46
+ "eslint-config-prettier": "^8.5.0",
47
+ "eslint-import-resolver-alias": "^1.1.2",
48
+ "eslint-import-resolver-typescript": "^3.5.5",
49
+ "eslint-plugin-babel": "^5.3.1",
50
+ "eslint-plugin-hooks": "^0.4.3",
51
+ "eslint-plugin-import": "^2.26.0",
52
+ "eslint-plugin-jest": "^26.1.5",
53
+ "eslint-plugin-jsx-a11y": "^6.5.1",
54
+ "eslint-plugin-node": "^11.1.0",
55
+ "eslint-plugin-prefer-arrow-functions": "^3.1.4",
56
+ "eslint-plugin-prettier": "^5.0.0",
57
+ "eslint-plugin-react": "^7.29.4",
58
+ "eslint-plugin-react-hooks": "^4.5.0",
59
+ "eslint-plugin-sort-keys-fix": "^1.1.2",
60
+ "eslint-plugin-typescript-sort-keys": "^2.1.0",
61
+ "mochawesome": "^7.1.3"
62
+ }
59
63
  }
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "@tsconfig/node20/tsconfig.json",
3
+ "compilerOptions": {
4
+ "sourceMap": true,
5
+ "allowJs": true,
6
+ "strictNullChecks": false,
7
+ "declaration": false,
8
+ "esModuleInterop": true,
9
+ "strict": true,
10
+ "types": ["@types/jest", "node"]
11
+ }
12
+ }
@@ -1,10 +1,10 @@
1
1
  const excludeNodeModulesExceptCentreonUi =
2
- /node_modules(\\|\/)\.pnpm(\\|\/)(?!(@centreon))/;
2
+ /node_modules(\\|\/)\.pnpm(\\|\/)(?!(@centreon|file\+packages\+ui-context))/;
3
3
 
4
4
  module.exports = {
5
5
  cache: false,
6
6
  excludeNodeModulesExceptCentreonUi,
7
- getModuleConfiguration: (jscTransformConfiguration) => ({
7
+ getModuleConfiguration: (jscTransformConfiguration, enableCoverage) => ({
8
8
  rules: [
9
9
  {
10
10
  parser: { system: false },
@@ -17,6 +17,11 @@ module.exports = {
17
17
  loader: 'swc-loader',
18
18
  options: {
19
19
  jsc: {
20
+ experimental: {
21
+ plugins: [
22
+ enableCoverage && ['swc-plugin-coverage-instrument', {}]
23
+ ].filter(Boolean)
24
+ },
20
25
  parser: {
21
26
  syntax: 'typescript',
22
27
  tsx: true
@@ -13,10 +13,11 @@ const {
13
13
  const getBaseConfiguration = ({
14
14
  moduleName,
15
15
  moduleFederationConfig,
16
- jscTransformConfiguration
16
+ jscTransformConfiguration,
17
+ enableCoverage
17
18
  }) => ({
18
19
  cache,
19
- module: getModuleConfiguration(jscTransformConfiguration),
20
+ module: getModuleConfiguration(jscTransformConfiguration, enableCoverage),
20
21
  optimization,
21
22
  output: {
22
23
  ...output,
@@ -33,19 +34,18 @@ const getBaseConfiguration = ({
33
34
  shared: [
34
35
  {
35
36
  '@centreon/ui-context': {
36
- requiredVersion: '22.10.0',
37
+ requiredVersion: '24.x',
37
38
  singleton: true
38
39
  }
39
40
  },
40
41
  {
41
42
  jotai: {
42
- requiredVersion: '1.x',
43
+ requiredVersion: '2.x',
43
44
  singleton: true
44
45
  }
45
46
  },
46
47
  {
47
48
  'jotai-suspense': {
48
- requiredVersion: '0.1.x',
49
49
  singleton: true
50
50
  }
51
51
  },