@centreon/js-config 25.2.3 → 25.3.1

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.
@@ -1,204 +1,204 @@
1
- /* eslint-disable @typescript-eslint/no-namespace */
2
- import React from 'react';
3
-
4
- import { mount } from 'cypress/react18';
5
- import { equals, isNil } from 'ramda';
6
-
7
- import { Box, CssBaseline } from '@mui/material';
8
-
9
- import { ThemeProvider } from '@centreon/ui';
10
-
11
- import '@testing-library/cypress/add-commands';
12
- import 'cypress-msw-interceptor';
13
- import 'cypress-real-events';
14
-
15
- import disableMotion from './disableCssTransitions';
16
-
17
- interface MountProps {
18
- Component: React.ReactNode;
19
- options?: object;
20
- }
21
- interface Resolution {
22
- height: number;
23
- width: number;
24
- }
25
-
26
- interface MakeSnapshotWithCustomResolution {
27
- resolution: Resolution;
28
- title: string;
29
- }
30
-
31
- export enum Method {
32
- DELETE = 'DELETE',
33
- GET = 'GET',
34
- PATCH = 'PATCH',
35
- POST = 'POST',
36
- PUT = 'PUT'
37
- }
38
-
39
- Cypress.Commands.add('mount', ({ Component, options = {} }) => {
40
- const wrapped = (
41
- <ThemeProvider>
42
- <Box
43
- sx={{
44
- backgroundColor: 'background.paper',
45
- height: '100%',
46
- width: '100%'
47
- }}
48
- >
49
- {Component}
50
- </Box>
51
- <CssBaseline />
52
- </ThemeProvider>
53
- );
54
-
55
- return mount(wrapped, options);
56
- });
57
-
58
- interface Query {
59
- name: string;
60
- value: string;
61
- }
62
-
63
- export interface InterceptAPIRequestProps<T> {
64
- alias: string;
65
- delay?: number;
66
- method: Method;
67
- path: string;
68
- query?: Query;
69
- response?: T | Array<T>;
70
- statusCode?: number;
71
- }
72
-
73
- Cypress.Commands.add(
74
- 'interceptAPIRequest',
75
- <T extends object>({
76
- method,
77
- path,
78
- response,
79
- alias,
80
- query,
81
- statusCode = 200,
82
- delay = 500
83
- }: InterceptAPIRequestProps<T>): void => {
84
- cy.interceptRequest(
85
- method,
86
- path.replace('./', '**'),
87
- (req, res, ctx) => {
88
- const getQuery = req?.url?.searchParams?.get(query?.name);
89
-
90
- if (query && equals(query.value, getQuery)) {
91
- return res(
92
- ctx.delay(delay),
93
- ctx.json(response),
94
- ctx.status(statusCode)
95
- );
96
- }
97
- if (!getQuery && isNil(query)) {
98
- return res(
99
- ctx.delay(delay),
100
- ctx.json(response),
101
- ctx.status(statusCode)
102
- );
103
- }
104
-
105
- return null;
106
- },
107
- alias
108
- );
109
- }
110
- );
111
-
112
- interface MoveSortableElementProps {
113
- direction: 'up' | 'down' | 'left' | 'right';
114
- element: Cypress.Chainable<JQuery<HTMLElement>>;
115
- times?: number;
116
- }
117
-
118
- Cypress.Commands.add(
119
- 'moveSortableElement',
120
- ({ element, direction, times = 1 }: MoveSortableElementProps): void => {
121
- const key = `{${direction}arrow}`;
122
-
123
- element.type(' ', {
124
- force: true,
125
- scrollBehavior: false
126
- });
127
-
128
- Array.from({ length: times }).forEach(() => {
129
- element.eq(-1).type(key, {
130
- scrollBehavior: false
131
- });
132
- });
133
- element.eq(-1).type(' ', {
134
- scrollBehavior: false
135
- });
136
- }
137
- );
138
-
139
- Cypress.Commands.add(
140
- 'moveSortableElementUsingAriaLabel',
141
- ({ ariaLabel, direction }): void => {
142
- const key = `{${direction}arrow}`;
143
-
144
- cy.findByLabelText(ariaLabel).type(' ', {
145
- force: true,
146
- scrollBehavior: false
147
- });
148
- cy.findAllByLabelText(ariaLabel).eq(-1).type(key, {
149
- scrollBehavior: false
150
- });
151
- cy.findAllByLabelText(ariaLabel).eq(-1).type(' ', {
152
- scrollBehavior: false
153
- });
154
- }
155
- );
156
-
157
- Cypress.Commands.add('adjustViewport', () => cy.viewport(1280, 590));
158
-
159
- Cypress.Commands.add('makeSnapshot', (title?: string) => {
160
- cy.adjustViewport();
161
- cy.matchImageSnapshot(title);
162
- });
163
-
164
- Cypress.Commands.add(
165
- 'makeSnapshotWithCustomResolution',
166
- ({ title, resolution }: MakeSnapshotWithCustomResolution) => {
167
- const { width, height } = resolution;
168
- cy.viewport(width, height);
169
- cy.matchImageSnapshot(title);
170
- }
171
- );
172
-
173
- Cypress.Commands.add('cssDisableMotion', (): void => {
174
- Cypress.on('window:before:load', (cyWindow) => {
175
- disableMotion(cyWindow);
176
- });
177
- });
178
-
179
- declare global {
180
- namespace Cypress {
181
- interface Chainable {
182
- adjustViewport: () => Cypress.Chainable;
183
- cssDisableMotion: () => Cypress.Chainable;
184
- getRequestCalls: (alias) => Cypress.Chainable;
185
- interceptAPIRequest: <T extends object>(
186
- props: InterceptAPIRequestProps<T>
187
- ) => Cypress.Chainable;
188
- interceptRequest: (method, path, mock, alias) => Cypress.Chainable;
189
- makeSnapshot: (title?: string) => void;
190
- makeSnapshotWithCustomResolution: ({
191
- title,
192
- resolution
193
- }: MakeSnapshotWithCustomResolution) => Cypress.Chainable;
194
- mount: ({ Component, options }: MountProps) => Cypress.Chainable;
195
- moveSortableElement: ({
196
- element,
197
- direction,
198
- times
199
- }: MoveSortableElementProps) => void;
200
- moveSortableElementUsingAriaLabel: ({ ariaLabel, direction }) => void;
201
- waitForRequest: (alias) => Cypress.Chainable;
202
- }
203
- }
204
- }
1
+ /* eslint-disable @typescript-eslint/no-namespace */
2
+ import React from 'react';
3
+
4
+ import { mount } from 'cypress/react18';
5
+ import { equals, isNil } from 'ramda';
6
+
7
+ import { Box, CssBaseline } from '@mui/material';
8
+
9
+ import { ThemeProvider } from '@centreon/ui';
10
+
11
+ import '@testing-library/cypress/add-commands';
12
+ import 'cypress-msw-interceptor';
13
+ import 'cypress-real-events';
14
+
15
+ import disableMotion from './disableCssTransitions';
16
+
17
+ interface MountProps {
18
+ Component: React.ReactNode;
19
+ options?: object;
20
+ }
21
+ interface Resolution {
22
+ height: number;
23
+ width: number;
24
+ }
25
+
26
+ interface MakeSnapshotWithCustomResolution {
27
+ resolution: Resolution;
28
+ title: string;
29
+ }
30
+
31
+ export enum Method {
32
+ DELETE = 'DELETE',
33
+ GET = 'GET',
34
+ PATCH = 'PATCH',
35
+ POST = 'POST',
36
+ PUT = 'PUT'
37
+ }
38
+
39
+ Cypress.Commands.add('mount', ({ Component, options = {} }) => {
40
+ const wrapped = (
41
+ <ThemeProvider>
42
+ <Box
43
+ sx={{
44
+ backgroundColor: 'background.paper',
45
+ height: '100%',
46
+ width: '100%'
47
+ }}
48
+ >
49
+ {Component}
50
+ </Box>
51
+ <CssBaseline />
52
+ </ThemeProvider>
53
+ );
54
+
55
+ return mount(wrapped, options);
56
+ });
57
+
58
+ interface Query {
59
+ name: string;
60
+ value: string;
61
+ }
62
+
63
+ export interface InterceptAPIRequestProps<T> {
64
+ alias: string;
65
+ delay?: number;
66
+ method: Method;
67
+ path: string;
68
+ query?: Query;
69
+ response?: T | Array<T>;
70
+ statusCode?: number;
71
+ }
72
+
73
+ Cypress.Commands.add(
74
+ 'interceptAPIRequest',
75
+ <T extends object>({
76
+ method,
77
+ path,
78
+ response,
79
+ alias,
80
+ query,
81
+ statusCode = 200,
82
+ delay = 500
83
+ }: InterceptAPIRequestProps<T>): void => {
84
+ cy.interceptRequest(
85
+ method,
86
+ path.replace('./', '**'),
87
+ (req, res, ctx) => {
88
+ const getQuery = req?.url?.searchParams?.get(query?.name);
89
+
90
+ if (query && equals(query.value, getQuery)) {
91
+ return res(
92
+ ctx.delay(delay),
93
+ ctx.json(response),
94
+ ctx.status(statusCode)
95
+ );
96
+ }
97
+ if (!getQuery && isNil(query)) {
98
+ return res(
99
+ ctx.delay(delay),
100
+ ctx.json(response),
101
+ ctx.status(statusCode)
102
+ );
103
+ }
104
+
105
+ return null;
106
+ },
107
+ alias
108
+ );
109
+ }
110
+ );
111
+
112
+ interface MoveSortableElementProps {
113
+ direction: 'up' | 'down' | 'left' | 'right';
114
+ element: Cypress.Chainable<JQuery<HTMLElement>>;
115
+ times?: number;
116
+ }
117
+
118
+ Cypress.Commands.add(
119
+ 'moveSortableElement',
120
+ ({ element, direction, times = 1 }: MoveSortableElementProps): void => {
121
+ const key = `{${direction}arrow}`;
122
+
123
+ element.type(' ', {
124
+ force: true,
125
+ scrollBehavior: false
126
+ });
127
+
128
+ Array.from({ length: times }).forEach(() => {
129
+ element.eq(-1).type(key, {
130
+ scrollBehavior: false
131
+ });
132
+ });
133
+ element.eq(-1).type(' ', {
134
+ scrollBehavior: false
135
+ });
136
+ }
137
+ );
138
+
139
+ Cypress.Commands.add(
140
+ 'moveSortableElementUsingAriaLabel',
141
+ ({ ariaLabel, direction }): void => {
142
+ const key = `{${direction}arrow}`;
143
+
144
+ cy.findByLabelText(ariaLabel).type(' ', {
145
+ force: true,
146
+ scrollBehavior: false
147
+ });
148
+ cy.findAllByLabelText(ariaLabel).eq(-1).type(key, {
149
+ scrollBehavior: false
150
+ });
151
+ cy.findAllByLabelText(ariaLabel).eq(-1).type(' ', {
152
+ scrollBehavior: false
153
+ });
154
+ }
155
+ );
156
+
157
+ Cypress.Commands.add('adjustViewport', () => cy.viewport(1280, 590));
158
+
159
+ Cypress.Commands.add('makeSnapshot', (title?: string) => {
160
+ cy.adjustViewport();
161
+ cy.matchImageSnapshot(title);
162
+ });
163
+
164
+ Cypress.Commands.add(
165
+ 'makeSnapshotWithCustomResolution',
166
+ ({ title, resolution }: MakeSnapshotWithCustomResolution) => {
167
+ const { width, height } = resolution;
168
+ cy.viewport(width, height);
169
+ cy.matchImageSnapshot(title);
170
+ }
171
+ );
172
+
173
+ Cypress.Commands.add('cssDisableMotion', (): void => {
174
+ Cypress.on('window:before:load', (cyWindow) => {
175
+ disableMotion(cyWindow);
176
+ });
177
+ });
178
+
179
+ declare global {
180
+ namespace Cypress {
181
+ interface Chainable {
182
+ adjustViewport: () => Cypress.Chainable;
183
+ cssDisableMotion: () => Cypress.Chainable;
184
+ getRequestCalls: (alias) => Cypress.Chainable;
185
+ interceptAPIRequest: <T extends object>(
186
+ props: InterceptAPIRequestProps<T>
187
+ ) => Cypress.Chainable;
188
+ interceptRequest: (method, path, mock, alias) => Cypress.Chainable;
189
+ makeSnapshot: (title?: string) => void;
190
+ makeSnapshotWithCustomResolution: ({
191
+ title,
192
+ resolution
193
+ }: MakeSnapshotWithCustomResolution) => Cypress.Chainable;
194
+ mount: ({ Component, options }: MountProps) => Cypress.Chainable;
195
+ moveSortableElement: ({
196
+ element,
197
+ direction,
198
+ times
199
+ }: MoveSortableElementProps) => void;
200
+ moveSortableElementUsingAriaLabel: ({ ariaLabel, direction }) => void;
201
+ waitForRequest: (alias) => Cypress.Chainable;
202
+ }
203
+ }
204
+ }
@@ -1,76 +1,76 @@
1
- /* eslint-disable @typescript-eslint/no-var-requires */
2
- const { devServer } = require('cypress-rspack-dev-server');
3
- const { defineConfig } = require('cypress');
4
- const {
5
- addMatchImageSnapshotPlugin
6
- } = require('@simonsmith/cypress-image-snapshot/plugin');
7
- const cypressCodeCoverageTask = require('@cypress/code-coverage/task');
8
-
9
- module.exports = ({
10
- rspackConfig,
11
- cypressFolder,
12
- specPattern,
13
- env,
14
- excludeSpecPattern
15
- }) => {
16
- const mainCypressFolder = cypressFolder || 'cypress';
17
-
18
- return defineConfig({
19
- component: {
20
- devServer: (devServerConfig) =>
21
- devServer({
22
- ...devServerConfig,
23
- framework: 'react',
24
- rspackConfig
25
- }),
26
- excludeSpecPattern,
27
- setupNodeEvents: (on, config) => {
28
- addMatchImageSnapshotPlugin(on, config);
29
-
30
- cypressCodeCoverageTask(on, config);
31
- on('task', {
32
- coverageReport: () => {
33
- return null;
34
- }
35
- });
36
-
37
- on('before:browser:launch', (browser, launchOptions) => {
38
- if (browser.name === 'chrome' && browser.isHeadless) {
39
- launchOptions.args.push('--headless=new');
40
- launchOptions.args.push('--force-color-profile=srgb');
41
- launchOptions.args.push('--window-size=1400,1200');
42
- }
43
-
44
- return launchOptions;
45
- });
46
- },
47
- specPattern,
48
- supportFile: `${mainCypressFolder}/support/component.tsx`
49
- },
50
- env: {
51
- baseUrl: 'http://localhost:9092',
52
- codeCoverage: {
53
- exclude: [
54
- 'cypress/**/*.*',
55
- 'packages/**',
56
- 'node_modules',
57
- '**/*.js',
58
- '**/*.spec.tsx'
59
- ]
60
- },
61
- ...env
62
- },
63
- reporter: 'mochawesome',
64
- reporterOptions: {
65
- html: false,
66
- json: true,
67
- overwrite: true,
68
- reportDir: `${mainCypressFolder}/results`,
69
- reportFilename: '[name]-report.json'
70
- },
71
- video: true,
72
- videosFolder: `${mainCypressFolder}/results/videos`,
73
- viewportHeight: 590,
74
- viewportWidth: 1280
75
- });
76
- };
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+ const { devServer } = require('cypress-rspack-dev-server');
3
+ const { defineConfig } = require('cypress');
4
+ const {
5
+ addMatchImageSnapshotPlugin
6
+ } = require('@simonsmith/cypress-image-snapshot/plugin');
7
+ const cypressCodeCoverageTask = require('@cypress/code-coverage/task');
8
+
9
+ module.exports = ({
10
+ rspackConfig,
11
+ cypressFolder,
12
+ specPattern,
13
+ env,
14
+ excludeSpecPattern
15
+ }) => {
16
+ const mainCypressFolder = cypressFolder || 'cypress';
17
+
18
+ return defineConfig({
19
+ component: {
20
+ devServer: (devServerConfig) =>
21
+ devServer({
22
+ ...devServerConfig,
23
+ framework: 'react',
24
+ rspackConfig
25
+ }),
26
+ excludeSpecPattern,
27
+ setupNodeEvents: (on, config) => {
28
+ addMatchImageSnapshotPlugin(on, config);
29
+
30
+ cypressCodeCoverageTask(on, config);
31
+ on('task', {
32
+ coverageReport: () => {
33
+ return null;
34
+ }
35
+ });
36
+
37
+ on('before:browser:launch', (browser, launchOptions) => {
38
+ if (browser.name === 'chrome' && browser.isHeadless) {
39
+ launchOptions.args.push('--headless=new');
40
+ launchOptions.args.push('--force-color-profile=srgb');
41
+ launchOptions.args.push('--window-size=1400,1200');
42
+ }
43
+
44
+ return launchOptions;
45
+ });
46
+ },
47
+ specPattern,
48
+ supportFile: `${mainCypressFolder}/support/component.tsx`
49
+ },
50
+ env: {
51
+ baseUrl: 'http://localhost:9092',
52
+ codeCoverage: {
53
+ exclude: [
54
+ 'cypress/**/*.*',
55
+ 'packages/**',
56
+ 'node_modules',
57
+ '**/*.js',
58
+ '**/*.spec.tsx'
59
+ ]
60
+ },
61
+ ...env
62
+ },
63
+ reporter: 'mochawesome',
64
+ reporterOptions: {
65
+ html: false,
66
+ json: true,
67
+ overwrite: true,
68
+ reportDir: `${mainCypressFolder}/results`,
69
+ reportFilename: '[name]-report.json'
70
+ },
71
+ video: true,
72
+ videosFolder: `${mainCypressFolder}/results/videos`,
73
+ viewportHeight: 590,
74
+ viewportWidth: 1280
75
+ });
76
+ };
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": "25.2.3",
4
+ "version": "25.3.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon-frontend.git"
@@ -49,13 +49,13 @@ const getBaseConfiguration = ({
49
49
  },
50
50
  {
51
51
  react: {
52
- requiredVersion: '18.x',
52
+ requiredVersion: '19.x',
53
53
  singleton: true
54
54
  }
55
55
  },
56
56
  {
57
57
  'react-i18next': {
58
- requiredVersion: '14.x',
58
+ requiredVersion: '15.x',
59
59
  singleton: true
60
60
  }
61
61
  },