@centreon/js-config 23.10.1-increase-timeout-docker-pull.0 → 23.10.1-lambda-node18-jsconfig.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.
@@ -11,6 +11,8 @@ import { ThemeProvider } from '@centreon/ui';
11
11
  import '@testing-library/cypress/add-commands';
12
12
  import 'cypress-msw-interceptor';
13
13
 
14
+ import disableMotion from './disableCssTransitions';
15
+
14
16
  interface MountProps {
15
17
  Component: React.ReactNode;
16
18
  options?: object;
@@ -94,20 +96,32 @@ Cypress.Commands.add(
94
96
  }
95
97
  );
96
98
 
97
- Cypress.Commands.add('moveSortableElement', ({ element, direction }): void => {
98
- const key = `{${direction}arrow}`;
99
+ interface MoveSortableElementProps {
100
+ direction: 'up' | 'down' | 'left' | 'right';
101
+ element: Cypress.Chainable<JQuery<HTMLElement>>;
102
+ times?: number;
103
+ }
99
104
 
100
- element.type(' ', {
101
- force: true,
102
- scrollBehavior: false
103
- });
104
- element.eq(-1).type(key, {
105
- scrollBehavior: false
106
- });
107
- element.eq(-1).type(' ', {
108
- scrollBehavior: false
109
- });
110
- });
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
+ );
111
125
 
112
126
  Cypress.Commands.add(
113
127
  'moveSortableElementUsingAriaLabel',
@@ -132,16 +146,27 @@ Cypress.Commands.add('makeSnapshot', (title?: string) => {
132
146
  cy.matchImageSnapshot(title);
133
147
  });
134
148
 
149
+ Cypress.Commands.add('cssDisableMotion', (): void => {
150
+ Cypress.on('window:before:load', (cyWindow) => {
151
+ disableMotion(cyWindow);
152
+ });
153
+ });
154
+
135
155
  declare global {
136
156
  namespace Cypress {
137
157
  interface Chainable {
158
+ cssDisableMotion: () => Cypress.Chainable;
138
159
  interceptAPIRequest: <T extends object>(
139
160
  props: InterceptAPIRequestProps<T>
140
161
  ) => Cypress.Chainable;
141
162
  interceptRequest: (method, path, mock, alias) => Cypress.Chainable;
142
163
  makeSnapshot: (title?: string) => void;
143
164
  mount: ({ Component, options }: MountProps) => Cypress.Chainable;
144
- moveSortableElement: ({ element, direction }) => void;
165
+ moveSortableElement: ({
166
+ element,
167
+ direction,
168
+ times
169
+ }: MoveSortableElementProps) => void;
145
170
  moveSortableElementUsingAriaLabel: ({ ariaLabel, direction }) => void;
146
171
  waitForRequest: (alias) => Cypress.Chainable;
147
172
  }
@@ -0,0 +1,19 @@
1
+ const disableMotion = (win): void => {
2
+ const injectedStyleEl = win.document.getElementById('__cy_disable_motion__');
3
+ if (injectedStyleEl) {
4
+ return;
5
+ }
6
+ win.document.head.insertAdjacentHTML(
7
+ 'beforeend',
8
+ `
9
+ <style id="__cy_disable_motion__">
10
+ /* Disable CSS transitions. */
11
+ *, *::before, *::after { -webkit-transition: none !important; -moz-transition: none !important; -o-transition: none !important; -ms-transition: none !important; transition: none !important; }
12
+ /* Disable CSS animations. */
13
+ *, *::before, *::after { -webkit-animation: none !important; -moz-animation: none !important; -o-animation: none !important; -ms-animation: none !important; animation: none !important; }
14
+ </style>
15
+ `.trim()
16
+ );
17
+ };
18
+
19
+ export default disableMotion;
@@ -5,7 +5,7 @@ import './commands/monitoring';
5
5
 
6
6
  import installLogsCollector from 'cypress-terminal-report/src/installLogsCollector';
7
7
 
8
- installLogsCollector();
8
+ installLogsCollector({ enableExtendedCollector: true });
9
9
 
10
10
  const apiLoginV2 = '/centreon/authentication/providers/configurations/local';
11
11
 
@@ -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
 
@@ -211,7 +209,20 @@ interface ExecInContainerProps {
211
209
  Cypress.Commands.add(
212
210
  'execInContainer',
213
211
  ({ command, name }: ExecInContainerProps): Cypress.Chainable => {
214
- return cy.exec(`docker exec -i ${name} ${command}`);
212
+ return cy
213
+ .exec(`docker exec -i ${name} ${command}`, { failOnNonZeroExit: false })
214
+ .then((result) => {
215
+ if (result.code) {
216
+ // output will not be truncated
217
+ throw new Error(`
218
+ Execution of "${command}" failed
219
+ Exit code: ${result.code}
220
+ Stdout:\n${result.stdout}
221
+ Stderr:\n${result.stderr}`);
222
+ }
223
+
224
+ return cy.wrap(result);
225
+ });
215
226
  }
216
227
  );
217
228
 
@@ -229,6 +240,8 @@ interface StartContainerProps {
229
240
  Cypress.Commands.add(
230
241
  'startContainer',
231
242
  ({ name, image, portBindings }: StartContainerProps): Cypress.Chainable => {
243
+ cy.log(`Starting container ${name} from image ${image}`);
244
+
232
245
  return cy.task(
233
246
  'startContainer',
234
247
  { image, name, portBindings },
@@ -293,7 +306,7 @@ Cypress.Commands.add(
293
306
  ({
294
307
  name = Cypress.env('dockerName')
295
308
  }: StopWebContainerProps = {}): Cypress.Chainable => {
296
- const logDirectory = `cypress/results/logs/${Cypress.spec.name.replace(
309
+ const logDirectory = `results/logs/${Cypress.spec.name.replace(
297
310
  artifactIllegalCharactersMatcher,
298
311
  '_'
299
312
  )}/${Cypress.currentTest.title.replace(
@@ -349,6 +362,8 @@ interface StopContainerProps {
349
362
  Cypress.Commands.add(
350
363
  'stopContainer',
351
364
  ({ name }: StopContainerProps): Cypress.Chainable => {
365
+ cy.log(`Stopping container ${name}`);
366
+
352
367
  cy.exec(`docker logs ${name}`).then(({ stdout }) => {
353
368
  cy.writeFile(
354
369
  `cypress/results/logs/${Cypress.spec.name.replace(
@@ -399,6 +414,41 @@ Cypress.Commands.add(
399
414
  }
400
415
  );
401
416
 
417
+ Cypress.Commands.add(
418
+ 'insertDashboardWithWidget',
419
+ (dashboardBody, patchBody) => {
420
+ cy.request({
421
+ body: {
422
+ ...dashboardBody
423
+ },
424
+ method: 'POST',
425
+ url: '/centreon/api/latest/configuration/dashboards'
426
+ }).then((response) => {
427
+ const dashboardId = response.body.id;
428
+ cy.waitUntil(
429
+ () => {
430
+ return cy
431
+ .request({
432
+ method: 'GET',
433
+ url: `/centreon/api/latest/configuration/dashboards/${dashboardId}`
434
+ })
435
+ .then((getResponse) => {
436
+ return getResponse.body && getResponse.body.id === dashboardId;
437
+ });
438
+ },
439
+ {
440
+ timeout: 10000
441
+ }
442
+ );
443
+ cy.request({
444
+ body: patchBody,
445
+ method: 'PATCH',
446
+ url: `/centreon/api/latest/configuration/dashboards/${dashboardId}`
447
+ });
448
+ });
449
+ }
450
+ );
451
+
402
452
  interface ShareDashboardToUserProps {
403
453
  dashboardName: string;
404
454
  role: string;
@@ -413,6 +463,30 @@ interface ListingRequestResult {
413
463
  };
414
464
  }
415
465
 
466
+ interface PatchDashboardBody {
467
+ panels: Array<{
468
+ layout: {
469
+ height: number;
470
+ min_height: number;
471
+ min_width: number;
472
+ width: number;
473
+ x: number;
474
+ y: number;
475
+ };
476
+ name: string;
477
+ widget_settings: {
478
+ options: {
479
+ description: {
480
+ content: string;
481
+ enabled: boolean;
482
+ };
483
+ name: string;
484
+ };
485
+ };
486
+ widget_type: string;
487
+ }>;
488
+ }
489
+
416
490
  Cypress.Commands.add(
417
491
  'shareDashboardToUser',
418
492
  ({ dashboardName, userName, role }: ShareDashboardToUserProps): void => {
@@ -485,6 +559,11 @@ declare global {
485
559
  hoverRootMenuItem: (rootItemNumber: number) => Cypress.Chainable;
486
560
  insertDashboard: (dashboard: Dashboard) => Cypress.Chainable;
487
561
  insertDashboardList: (fixtureFile: string) => Cypress.Chainable;
562
+ insertDashboardWithWidget: (
563
+ dashboard: Dashboard,
564
+ patch: PatchDashboardBody
565
+ ) => Cypress.Chainable;
566
+
488
567
  loginByTypeOfUser: ({
489
568
  jsonName,
490
569
  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,9 +25,14 @@ export default ({
23
25
  cypressFolder,
24
26
  isDevelopment,
25
27
  dockerName,
26
- env
28
+ env,
29
+ envFile
27
30
  }: ConfigurationOptions): Cypress.ConfigOptions => {
28
- const resultsFolder = `${cypressFolder || 'cypress'}/results`;
31
+ if (envFile) {
32
+ configDotenv({ path: envFile });
33
+ }
34
+
35
+ const resultsFolder = `${cypressFolder || '.'}/results`;
29
36
 
30
37
  const webImageVersion = execSync('git rev-parse --abbrev-ref HEAD')
31
38
  .toString('utf8')
@@ -36,6 +43,7 @@ export default ({
36
43
  defaultCommandTimeout: 6000,
37
44
  e2e: {
38
45
  excludeSpecPattern: ['*.js', '*.ts', '*.md'],
46
+ fixturesFolder: 'fixtures',
39
47
  reporter: require.resolve('cypress-multi-reporters'),
40
48
  reporterOptions: {
41
49
  configFile: `${__dirname}/reporter-config.js`
@@ -47,11 +55,12 @@ export default ({
47
55
 
48
56
  return plugins(on, config);
49
57
  },
50
- specPattern
58
+ specPattern,
59
+ supportFile: 'support/e2e.{js,jsx,ts,tsx}'
51
60
  },
52
61
  env: {
53
62
  ...env,
54
- OPENID_IMAGE_VERSION: '23.04',
63
+ OPENID_IMAGE_VERSION: process.env.MAJOR || '24.04',
55
64
  WEB_IMAGE_OS: 'alma9',
56
65
  WEB_IMAGE_VERSION: webImageVersion,
57
66
  dockerName: dockerName || 'centreon-dev'
@@ -4,7 +4,7 @@ module.exports = {
4
4
  html: false,
5
5
  json: true,
6
6
  overwrite: true,
7
- reportDir: 'cypress/results/reports',
7
+ reportDir: 'results/reports',
8
8
  reportFilename: '[name]-report.json'
9
9
  },
10
10
  reporterEnabled: `mochawesome,${require.resolve(
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,60 @@
1
1
  {
2
- "name": "@centreon/js-config",
3
- "description": "Centreon Frontend shared build configuration",
4
- "version": "23.10.1-increase-timeout-docker-pull.0",
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": "^18.0.6",
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.2",
52
- "@types/dockerode": "^3.3.19",
53
- "cypress-multi-reporters": "^1.6.3",
54
- "cypress-terminal-report": "^5.3.6",
55
- "dockerode": "^3.3.5",
56
- "esbuild": "^0.19.3",
57
- "mochawesome": "^7.1.3"
58
- }
2
+ "name": "@centreon/js-config",
3
+ "description": "Centreon Frontend shared build configuration",
4
+ "version": "23.10.1-lambda-node18-jsconfig.0",
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/node18": "^18.2.2",
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
+ "dotenv": "^16.3.1",
57
+ "esbuild": "^0.19.5",
58
+ "mochawesome": "^7.1.3"
59
+ }
59
60
  }
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": "@tsconfig/node18/tsconfig.json",
3
+ "compilerOptions": {
4
+ "sourceMap": true,
5
+ "allowJs": true,
6
+ "strictNullChecks": false,
7
+ "declaration": false,
8
+ "esModuleInterop": true,
9
+ "strict": true,
10
+ "types": [
11
+ "@types/jest",
12
+ "node"
13
+ ]
14
+ }
15
+ }
@@ -1,5 +1,5 @@
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,
@@ -18,30 +18,32 @@ 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': {
32
- requiredVersion: '22.10.0',
33
36
  singleton: true
34
37
  }
35
38
  },
36
39
  {
37
40
  jotai: {
38
- requiredVersion: '1.x',
41
+ requiredVersion: '2.x',
39
42
  singleton: true
40
43
  }
41
44
  },
42
45
  {
43
46
  'jotai-suspense': {
44
- requiredVersion: '0.1.x',
45
47
  singleton: true
46
48
  }
47
49
  },
@@ -75,10 +77,10 @@ const getBaseConfiguration = ({
75
77
  ].filter(Boolean),
76
78
  resolve: {
77
79
  alias: {
78
- react: path.resolve('./node_modules/react'),
79
80
  '@centreon/ui/fonts': path.resolve(
80
81
  './node_modules/@centreon/ui/public/fonts'
81
- )
82
+ ),
83
+ react: path.resolve('./node_modules/react')
82
84
  },
83
85
  extensions: ['.js', '.jsx', '.ts', '.tsx']
84
86
  }