@centreon/js-config 24.4.10 → 24.4.12

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.
@@ -4,15 +4,13 @@ import React from 'react';
4
4
  import { mount } from 'cypress/react18';
5
5
  import { equals, isNil } from 'ramda';
6
6
 
7
- import { Box, CssBaseline } from '@mui/material';
7
+ import { Box } from '@mui/material';
8
8
 
9
9
  import { ThemeProvider } from '@centreon/ui';
10
10
 
11
11
  import '@testing-library/cypress/add-commands';
12
12
  import 'cypress-msw-interceptor';
13
13
 
14
- import disableMotion from './disableCssTransitions';
15
-
16
14
  interface MountProps {
17
15
  Component: React.ReactNode;
18
16
  options?: object;
@@ -26,7 +24,7 @@ export enum Method {
26
24
  PUT = 'PUT'
27
25
  }
28
26
 
29
- Cypress.Commands.add('mount', ({ Component, options = {} }) => {
27
+ Cypress.Commands.add('mount', ({ Component, options }) => {
30
28
  const wrapped = (
31
29
  <ThemeProvider>
32
30
  <Box
@@ -38,10 +36,11 @@ Cypress.Commands.add('mount', ({ Component, options = {} }) => {
38
36
  >
39
37
  {Component}
40
38
  </Box>
41
- <CssBaseline />
42
39
  </ThemeProvider>
43
40
  );
44
41
 
42
+ document.getElementsByTagName('body')[0].setAttribute('style', 'margin:0px');
43
+
45
44
  return mount(wrapped, options);
46
45
  });
47
46
 
@@ -96,32 +95,20 @@ Cypress.Commands.add(
96
95
  }
97
96
  );
98
97
 
99
- interface MoveSortableElementProps {
100
- direction: 'up' | 'down' | 'left' | 'right';
101
- element: Cypress.Chainable<JQuery<HTMLElement>>;
102
- times?: number;
103
- }
98
+ Cypress.Commands.add('moveSortableElement', ({ element, direction }): void => {
99
+ const key = `{${direction}arrow}`;
104
100
 
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
- );
101
+ element.type(' ', {
102
+ force: true,
103
+ scrollBehavior: false
104
+ });
105
+ element.eq(-1).type(key, {
106
+ scrollBehavior: false
107
+ });
108
+ element.eq(-1).type(' ', {
109
+ scrollBehavior: false
110
+ });
111
+ });
125
112
 
126
113
  Cypress.Commands.add(
127
114
  'moveSortableElementUsingAriaLabel',
@@ -141,36 +128,15 @@ Cypress.Commands.add(
141
128
  }
142
129
  );
143
130
 
144
- Cypress.Commands.add('adjustViewport', () => cy.viewport(1280, 590));
145
-
146
- Cypress.Commands.add('makeSnapshot', (title?: string) => {
147
- cy.adjustViewport();
148
- cy.matchImageSnapshot(title);
149
- });
150
-
151
- Cypress.Commands.add('cssDisableMotion', (): void => {
152
- Cypress.on('window:before:load', (cyWindow) => {
153
- disableMotion(cyWindow);
154
- });
155
- });
156
-
157
131
  declare global {
158
132
  namespace Cypress {
159
133
  interface Chainable {
160
- adjustViewport: () => Cypress.Chainable;
161
- cssDisableMotion: () => Cypress.Chainable;
162
- getRequestCalls: (alias) => Cypress.Chainable;
163
134
  interceptAPIRequest: <T extends object>(
164
135
  props: InterceptAPIRequestProps<T>
165
136
  ) => Cypress.Chainable;
166
137
  interceptRequest: (method, path, mock, alias) => Cypress.Chainable;
167
- makeSnapshot: (title?: string) => void;
168
- mount: ({ Component, options }: MountProps) => Cypress.Chainable;
169
- moveSortableElement: ({
170
- element,
171
- direction,
172
- times
173
- }: MoveSortableElementProps) => void;
138
+ mount: ({ Component, options = {} }: MountProps) => Cypress.Chainable;
139
+ moveSortableElement: ({ ariaLabel, direction }) => void;
174
140
  moveSortableElementUsingAriaLabel: ({ ariaLabel, direction }) => void;
175
141
  waitForRequest: (alias) => Cypress.Chainable;
176
142
  }
@@ -3,34 +3,29 @@ 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
- module.exports = ({
9
- webpackConfig,
10
- cypressFolder,
11
- specPattern,
12
- env,
13
- useVite = false,
14
- excludeSpecPattern
15
- }) => {
7
+ module.exports = ({ webpackConfig, cypressFolder, specPattern, env }) => {
16
8
  const mainCypressFolder = cypressFolder || 'cypress';
17
9
 
18
10
  return defineConfig({
19
11
  component: {
20
12
  devServer: {
21
- bundler: useVite ? 'vite' : 'webpack',
13
+ bundler: 'webpack',
22
14
  framework: 'react',
23
15
  webpackConfig
24
16
  },
25
- excludeSpecPattern,
26
17
  setupNodeEvents: (on, config) => {
27
18
  addMatchImageSnapshotPlugin(on, config);
28
19
 
29
- cypressCodeCoverageTask(on, config);
30
-
31
20
  on('before:browser:launch', (browser, launchOptions) => {
32
21
  if (browser.name === 'chrome' && browser.isHeadless) {
33
- launchOptions.args.push('--headless=new');
22
+ launchOptions.args = launchOptions.args.map((arg) => {
23
+ if (arg === '--headless') {
24
+ return '--headless=new';
25
+ }
26
+
27
+ return arg;
28
+ });
34
29
  }
35
30
 
36
31
  return launchOptions;
@@ -40,17 +35,8 @@ module.exports = ({
40
35
  supportFile: `${mainCypressFolder}/support/component.tsx`
41
36
  },
42
37
  env: {
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
38
+ ...env,
39
+ baseUrl: 'http://localhost:9092'
54
40
  },
55
41
  reporter: 'mochawesome',
56
42
  reporterOptions: {
@@ -61,8 +47,6 @@ module.exports = ({
61
47
  reportFilename: '[name]-report.json'
62
48
  },
63
49
  video: true,
64
- videosFolder: `${mainCypressFolder}/results/videos`,
65
- viewportHeight: 590,
66
- viewportWidth: 1280
50
+ videosFolder: `${mainCypressFolder}/results/videos`
67
51
  });
68
52
  };
@@ -13,7 +13,7 @@ const enableVisualTesting = (cypressFolder = 'cypress'): void => {
13
13
  capture: 'viewport',
14
14
  customDiffConfig: { threshold: 0.01 },
15
15
  customSnapshotsDir: `${cypressFolder}/visual-testing-snapshots`,
16
- failureThreshold: 0.07,
16
+ failureThreshold: 0.06,
17
17
  failureThresholdType: 'percent'
18
18
  });
19
19
  };
@@ -144,7 +144,6 @@ interface Host {
144
144
  alias?: string | null;
145
145
  checkCommand?: string | null;
146
146
  checkPeriod?: string | null;
147
- hostGroup?: string;
148
147
  maxCheckAttempts?: number | null;
149
148
  name: string;
150
149
  passiveCheckEnabled?: boolean;
@@ -160,7 +159,6 @@ Cypress.Commands.add(
160
159
  alias = null,
161
160
  checkCommand = null,
162
161
  checkPeriod = null,
163
- hostGroup = '',
164
162
  maxCheckAttempts = 1,
165
163
  name,
166
164
  passiveCheckEnabled = true,
@@ -178,7 +176,7 @@ Cypress.Commands.add(
178
176
  bodyContent: {
179
177
  action: 'ADD',
180
178
  object: 'HOST',
181
- values: `${name};${hostAlias};${address};${template};${poller};${hostGroup}`
179
+ values: `${name};${hostAlias};${address};${template};${poller};`
182
180
  }
183
181
  })
184
182
  .then(() => {