@centreon/js-config 24.4.20 → 24.4.21

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.
@@ -18,15 +18,6 @@ interface MountProps {
18
18
  Component: React.ReactNode;
19
19
  options?: object;
20
20
  }
21
- interface Resolution {
22
- height: number;
23
- width: number;
24
- }
25
-
26
- interface MakeSnapshotWithCustomResolution {
27
- resolution: Resolution;
28
- title: string;
29
- }
30
21
 
31
22
  export enum Method {
32
23
  DELETE = 'DELETE',
@@ -106,32 +97,20 @@ Cypress.Commands.add(
106
97
  }
107
98
  );
108
99
 
109
- interface MoveSortableElementProps {
110
- direction: 'up' | 'down' | 'left' | 'right';
111
- element: Cypress.Chainable<JQuery<HTMLElement>>;
112
- times?: number;
113
- }
114
-
115
- Cypress.Commands.add(
116
- 'moveSortableElement',
117
- ({ element, direction, times = 1 }: MoveSortableElementProps): void => {
118
- const key = `{${direction}arrow}`;
119
-
120
- element.type(' ', {
121
- force: true,
122
- scrollBehavior: false
123
- });
100
+ Cypress.Commands.add('moveSortableElement', ({ element, direction }): void => {
101
+ const key = `{${direction}arrow}`;
124
102
 
125
- Array.from({ length: times }).forEach(() => {
126
- element.eq(-1).type(key, {
127
- scrollBehavior: false
128
- });
129
- });
130
- element.eq(-1).type(' ', {
131
- scrollBehavior: false
132
- });
133
- }
134
- );
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
+ });
135
114
 
136
115
  Cypress.Commands.add(
137
116
  'moveSortableElementUsingAriaLabel',
@@ -158,15 +137,6 @@ Cypress.Commands.add('makeSnapshot', (title?: string) => {
158
137
  cy.matchImageSnapshot(title);
159
138
  });
160
139
 
161
- Cypress.Commands.add(
162
- 'makeSnapshotWithCustomResolution',
163
- ({ title, resolution }: MakeSnapshotWithCustomResolution) => {
164
- const { width, height } = resolution;
165
- cy.viewport(width, height);
166
- cy.matchImageSnapshot(title);
167
- }
168
- );
169
-
170
140
  Cypress.Commands.add('cssDisableMotion', (): void => {
171
141
  Cypress.on('window:before:load', (cyWindow) => {
172
142
  disableMotion(cyWindow);
@@ -178,22 +148,13 @@ declare global {
178
148
  interface Chainable {
179
149
  adjustViewport: () => Cypress.Chainable;
180
150
  cssDisableMotion: () => Cypress.Chainable;
181
- getRequestCalls: (alias) => Cypress.Chainable;
182
151
  interceptAPIRequest: <T extends object>(
183
152
  props: InterceptAPIRequestProps<T>
184
153
  ) => Cypress.Chainable;
185
154
  interceptRequest: (method, path, mock, alias) => Cypress.Chainable;
186
155
  makeSnapshot: (title?: string) => void;
187
- makeSnapshotWithCustomResolution: ({
188
- title,
189
- resolution
190
- }: MakeSnapshotWithCustomResolution) => Cypress.Chainable;
191
156
  mount: ({ Component, options }: MountProps) => Cypress.Chainable;
192
- moveSortableElement: ({
193
- element,
194
- direction,
195
- times
196
- }: MoveSortableElementProps) => void;
157
+ moveSortableElement: ({ element, direction }) => void;
197
158
  moveSortableElementUsingAriaLabel: ({ ariaLabel, direction }) => void;
198
159
  waitForRequest: (alias) => Cypress.Chainable;
199
160
  }
@@ -3,7 +3,6 @@ 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');
7
6
 
8
7
  module.exports = ({
9
8
  webpackConfig,
@@ -26,12 +25,9 @@ module.exports = ({
26
25
  setupNodeEvents: (on, config) => {
27
26
  addMatchImageSnapshotPlugin(on, config);
28
27
 
29
- cypressCodeCoverageTask(on, config);
30
-
31
28
  on('before:browser:launch', (browser, launchOptions) => {
32
29
  if (browser.name === 'chrome' && browser.isHeadless) {
33
30
  launchOptions.args.push('--headless=new');
34
- launchOptions.args.push('--force-color-profile=srgb');
35
31
  }
36
32
 
37
33
  return launchOptions;
@@ -41,17 +37,8 @@ module.exports = ({
41
37
  supportFile: `${mainCypressFolder}/support/component.tsx`
42
38
  },
43
39
  env: {
44
- baseUrl: 'http://localhost:9092',
45
- codeCoverage: {
46
- exclude: [
47
- 'cypress/**/*.*',
48
- 'packages/**',
49
- 'node_modules',
50
- '**/*.js',
51
- '**/*.spec.tsx'
52
- ]
53
- },
54
- ...env
40
+ ...env,
41
+ baseUrl: 'http://localhost:9092'
55
42
  },
56
43
  reporter: 'mochawesome',
57
44
  reporterOptions: {
@@ -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 => {
@@ -582,11 +502,6 @@ declare global {
582
502
  hoverRootMenuItem: (rootItemNumber: number) => Cypress.Chainable;
583
503
  insertDashboard: (dashboard: Dashboard) => Cypress.Chainable;
584
504
  insertDashboardList: (fixtureFile: string) => Cypress.Chainable;
585
- insertDashboardWithWidget: (
586
- dashboard: Dashboard,
587
- patch: PatchDashboardBody
588
- ) => Cypress.Chainable;
589
-
590
505
  loginByTypeOfUser: ({
591
506
  jsonName,
592
507
  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,63 +1,59 @@
1
1
  {
2
- "name": "@centreon/js-config",
3
- "description": "Centreon Frontend shared build configuration",
4
- "version": "24.4.20",
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
- }
2
+ "name": "@centreon/js-config",
3
+ "description": "Centreon Frontend shared build configuration",
4
+ "version": "24.4.21",
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
+ }
63
59
  }
@@ -1,10 +1,10 @@
1
1
  const excludeNodeModulesExceptCentreonUi =
2
- /node_modules(\\|\/)\.pnpm(\\|\/)(?!(@centreon|file\+packages\+ui-context))/;
2
+ /node_modules(\\|\/)\.pnpm(\\|\/)(?!(@centreon))/;
3
3
 
4
4
  module.exports = {
5
5
  cache: false,
6
6
  excludeNodeModulesExceptCentreonUi,
7
- getModuleConfiguration: (jscTransformConfiguration, enableCoverage) => ({
7
+ getModuleConfiguration: (jscTransformConfiguration) => ({
8
8
  rules: [
9
9
  {
10
10
  parser: { system: false },
@@ -17,11 +17,6 @@ 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
- },
25
20
  parser: {
26
21
  syntax: 'typescript',
27
22
  tsx: true
@@ -13,11 +13,10 @@ const {
13
13
  const getBaseConfiguration = ({
14
14
  moduleName,
15
15
  moduleFederationConfig,
16
- jscTransformConfiguration,
17
- enableCoverage
16
+ jscTransformConfiguration
18
17
  }) => ({
19
18
  cache,
20
- module: getModuleConfiguration(jscTransformConfiguration, enableCoverage),
19
+ module: getModuleConfiguration(jscTransformConfiguration),
21
20
  optimization,
22
21
  output: {
23
22
  ...output,
@@ -34,18 +33,19 @@ const getBaseConfiguration = ({
34
33
  shared: [
35
34
  {
36
35
  '@centreon/ui-context': {
37
- requiredVersion: '24.x',
36
+ requiredVersion: '22.10.0',
38
37
  singleton: true
39
38
  }
40
39
  },
41
40
  {
42
41
  jotai: {
43
- requiredVersion: '2.x',
42
+ requiredVersion: '1.x',
44
43
  singleton: true
45
44
  }
46
45
  },
47
46
  {
48
47
  'jotai-suspense': {
48
+ requiredVersion: '0.1.x',
49
49
  singleton: true
50
50
  }
51
51
  },
@@ -1,36 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- const filePath = process.argv[2];
5
-
6
- const { error: logError } = console;
7
-
8
- try {
9
- const outFile = fs.readFileSync(path.resolve(filePath)).toString();
10
- const outFileJson = JSON.parse(outFile);
11
-
12
- const coveragesWithoutNodeModules = Object.entries(outFileJson)
13
- .map(([key, value]) => {
14
- if (key.includes('node_modules')) {
15
- return undefined;
16
- }
17
-
18
- return [key, value];
19
- })
20
- .filter((v) => v);
21
-
22
- const finalOutJson = coveragesWithoutNodeModules.reduce(
23
- (acc, [key, value]) => ({
24
- ...acc,
25
- [key]: value
26
- }),
27
- {}
28
- );
29
-
30
- fs.writeFileSync(
31
- path.resolve(filePath),
32
- JSON.stringify(finalOutJson, null, 2)
33
- );
34
- } catch (error) {
35
- logError(error.message);
36
- }
@@ -1,12 +0,0 @@
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
- }