@centreon/js-config 23.10.1-MON-21452-remove-force-true.1 → 23.10.1-MON-integrate-cypress-code-coverage.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.
- package/cypress/component/commands.tsx +31 -15
- package/cypress/component/configuration.js +7 -1
- package/cypress/e2e/commands.ts +5 -7
- package/cypress/e2e/configuration.ts +2 -9
- package/jest/index.js +0 -1
- package/package.json +1 -2
- package/webpack/base/globalConfig.js +7 -2
- package/webpack/base/index.js +6 -7
|
@@ -94,20 +94,32 @@ Cypress.Commands.add(
|
|
|
94
94
|
}
|
|
95
95
|
);
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
97
|
+
interface MoveSortableElementProps {
|
|
98
|
+
direction: 'up' | 'down' | 'left' | 'right';
|
|
99
|
+
element: Cypress.Chainable<JQuery<HTMLElement>>;
|
|
100
|
+
times?: number;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
Cypress.Commands.add(
|
|
104
|
+
'moveSortableElement',
|
|
105
|
+
({ element, direction, times = 1 }: MoveSortableElementProps): void => {
|
|
106
|
+
const key = `{${direction}arrow}`;
|
|
107
|
+
|
|
108
|
+
element.type(' ', {
|
|
109
|
+
force: true,
|
|
110
|
+
scrollBehavior: false
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
Array.from({ length: times }).forEach(() => {
|
|
114
|
+
element.eq(-1).type(key, {
|
|
115
|
+
scrollBehavior: false
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
element.eq(-1).type(' ', {
|
|
119
|
+
scrollBehavior: false
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
);
|
|
111
123
|
|
|
112
124
|
Cypress.Commands.add(
|
|
113
125
|
'moveSortableElementUsingAriaLabel',
|
|
@@ -141,7 +153,11 @@ declare global {
|
|
|
141
153
|
interceptRequest: (method, path, mock, alias) => Cypress.Chainable;
|
|
142
154
|
makeSnapshot: (title?: string) => void;
|
|
143
155
|
mount: ({ Component, options }: MountProps) => Cypress.Chainable;
|
|
144
|
-
moveSortableElement: ({
|
|
156
|
+
moveSortableElement: ({
|
|
157
|
+
element,
|
|
158
|
+
direction,
|
|
159
|
+
times
|
|
160
|
+
}: MoveSortableElementProps) => void;
|
|
145
161
|
moveSortableElementUsingAriaLabel: ({ ariaLabel, direction }) => void;
|
|
146
162
|
waitForRequest: (alias) => Cypress.Chainable;
|
|
147
163
|
}
|
|
@@ -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');
|
|
@@ -38,7 +41,10 @@ module.exports = ({
|
|
|
38
41
|
},
|
|
39
42
|
env: {
|
|
40
43
|
...env,
|
|
41
|
-
baseUrl: 'http://localhost:9092'
|
|
44
|
+
baseUrl: 'http://localhost:9092',
|
|
45
|
+
codeCoverage: {
|
|
46
|
+
exclude: ['cypress/**/*.*', 'packages/**', 'node_modules', '**/*.js']
|
|
47
|
+
}
|
|
42
48
|
},
|
|
43
49
|
reporter: 'mochawesome',
|
|
44
50
|
reporterOptions: {
|
package/cypress/e2e/commands.ts
CHANGED
|
@@ -178,13 +178,11 @@ Cypress.Commands.add(
|
|
|
178
178
|
.getByLabel({ label: 'Connect', tag: 'button' })
|
|
179
179
|
.click();
|
|
180
180
|
|
|
181
|
-
return cy
|
|
182
|
-
.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
|
|
@@ -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 || 'cypress'}/results`;
|
|
36
29
|
|
|
37
30
|
const webImageVersion = execSync('git rev-parse --abbrev-ref HEAD')
|
|
@@ -58,7 +51,7 @@ export default ({
|
|
|
58
51
|
},
|
|
59
52
|
env: {
|
|
60
53
|
...env,
|
|
61
|
-
OPENID_IMAGE_VERSION:
|
|
54
|
+
OPENID_IMAGE_VERSION: '23.04',
|
|
62
55
|
WEB_IMAGE_OS: 'alma9',
|
|
63
56
|
WEB_IMAGE_VERSION: webImageVersion,
|
|
64
57
|
dockerName: dockerName || 'centreon-dev'
|
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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/js-config",
|
|
3
3
|
"description": "Centreon Frontend shared build configuration",
|
|
4
|
-
"version": "23.10.1-MON-
|
|
4
|
+
"version": "23.10.1-MON-integrate-cypress-code-coverage.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/centreon/centreon-frontend.git"
|
|
@@ -53,7 +53,6 @@
|
|
|
53
53
|
"cypress-multi-reporters": "^1.6.3",
|
|
54
54
|
"cypress-terminal-report": "^5.3.6",
|
|
55
55
|
"dockerode": "^3.3.5",
|
|
56
|
-
"dotenv": "^16.3.1",
|
|
57
56
|
"esbuild": "^0.19.3",
|
|
58
57
|
"mochawesome": "^7.1.3"
|
|
59
58
|
}
|
|
@@ -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
|
package/webpack/base/index.js
CHANGED
|
@@ -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
|
plugins: [
|
|
@@ -29,19 +30,17 @@ const getBaseConfiguration = ({
|
|
|
29
30
|
shared: [
|
|
30
31
|
{
|
|
31
32
|
'@centreon/ui-context': {
|
|
32
|
-
requiredVersion: '22.10.0',
|
|
33
33
|
singleton: true
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
37
|
jotai: {
|
|
38
|
-
requiredVersion: '
|
|
38
|
+
requiredVersion: '2.x',
|
|
39
39
|
singleton: true
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
'jotai-suspense': {
|
|
44
|
-
requiredVersion: '0.1.x',
|
|
45
44
|
singleton: true
|
|
46
45
|
}
|
|
47
46
|
},
|
|
@@ -75,10 +74,10 @@ const getBaseConfiguration = ({
|
|
|
75
74
|
].filter(Boolean),
|
|
76
75
|
resolve: {
|
|
77
76
|
alias: {
|
|
78
|
-
react: path.resolve('./node_modules/react'),
|
|
79
77
|
'@centreon/ui/fonts': path.resolve(
|
|
80
78
|
'./node_modules/@centreon/ui/public/fonts'
|
|
81
|
-
)
|
|
79
|
+
),
|
|
80
|
+
react: path.resolve('./node_modules/react')
|
|
82
81
|
},
|
|
83
82
|
extensions: ['.js', '.jsx', '.ts', '.tsx']
|
|
84
83
|
}
|