@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.
- package/cypress/component/commands.tsx +19 -53
- package/cypress/component/configuration.js +12 -28
- package/cypress/component/enableVisualTesting.ts +1 -1
- package/cypress/e2e/commands/configuration.ts +1 -3
- package/cypress/e2e/commands.ts +59 -298
- package/cypress/e2e/configuration.ts +32 -30
- package/cypress/e2e/plugins.ts +119 -21
- package/eslint/base.typescript.eslintrc.js +3 -15
- package/jest/index.js +2 -5
- package/package.json +45 -61
- package/tsconfig/index.json +4 -5
- package/webpack/base/index.js +59 -20
- package/cypress/component/disableCssTransitions.ts +0 -19
- package/cypress/e2e/commands/monitoring.ts +0 -75
- package/cypress/e2e/esbuild-preprocessor.ts +0 -26
- package/cypress/e2e/reporter-config.js +0 -13
- package/cypress/e2e/tasks.ts +0 -105
- package/eslint/lambda/typescript.eslintrc.js +0 -48
- package/jest/lambda/typescript.js +0 -49
- package/tsconfig/lambda/node20.tsconfig.json +0 -12
- package/tsconfig/lambda/tsconfig.json +0 -14
- package/webpack/base/globalConfig.js +0 -76
package/cypress/e2e/plugins.ts
CHANGED
|
@@ -3,34 +3,132 @@
|
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
4
4
|
/* eslint-disable no-param-reassign */
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
): Cypress.PluginConfigOptions => {
|
|
10
|
-
on('before:browser:launch', (browser, launchOptions) => {
|
|
11
|
-
const width = 1920;
|
|
12
|
-
const height = 1080;
|
|
13
|
-
|
|
14
|
-
if (browser.family === 'chromium') {
|
|
15
|
-
if (browser.isHeadless) {
|
|
16
|
-
launchOptions.args.push('--headless=new');
|
|
17
|
-
}
|
|
6
|
+
import Docker from 'dockerode';
|
|
7
|
+
import { addCucumberPreprocessorPlugin } from '@badeball/cypress-cucumber-preprocessor';
|
|
8
|
+
import webpackPreprocessor from '@cypress/webpack-preprocessor';
|
|
18
9
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
const docker = new Docker();
|
|
11
|
+
|
|
12
|
+
const getWebpackOptions = (config): object => {
|
|
13
|
+
return {
|
|
14
|
+
module: {
|
|
15
|
+
rules: [
|
|
16
|
+
{
|
|
17
|
+
exclude: [/node_modules/],
|
|
18
|
+
test: /\.ts?$/,
|
|
19
|
+
use: [
|
|
20
|
+
{
|
|
21
|
+
loader: 'swc-loader'
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
test: /\.feature$/,
|
|
27
|
+
use: [
|
|
28
|
+
{
|
|
29
|
+
loader: '@badeball/cypress-cucumber-preprocessor/webpack',
|
|
30
|
+
options: config
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
resolve: {
|
|
37
|
+
extensions: ['.ts', '.js']
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default async (on, config): Promise<void> => {
|
|
43
|
+
await addCucumberPreprocessorPlugin(on, config);
|
|
25
44
|
|
|
26
|
-
|
|
45
|
+
const webpackOptions = await getWebpackOptions(config);
|
|
46
|
+
const options = {
|
|
47
|
+
webpackOptions
|
|
48
|
+
};
|
|
27
49
|
|
|
28
|
-
|
|
29
|
-
|
|
50
|
+
on('file:preprocessor', webpackPreprocessor(options));
|
|
51
|
+
|
|
52
|
+
on('before:browser:launch', (browser = {}, launchOptions) => {
|
|
53
|
+
if ((browser as { name }).name === 'chrome') {
|
|
54
|
+
launchOptions.args.push('--disable-gpu');
|
|
55
|
+
launchOptions.args = launchOptions.args.filter(
|
|
56
|
+
(element) => element !== '--disable-dev-shm-usage'
|
|
57
|
+
);
|
|
30
58
|
}
|
|
31
59
|
|
|
32
60
|
return launchOptions;
|
|
33
61
|
});
|
|
34
62
|
|
|
63
|
+
interface PortBinding {
|
|
64
|
+
destination: number;
|
|
65
|
+
source: number;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface StartContainerProps {
|
|
69
|
+
image: string;
|
|
70
|
+
name: string;
|
|
71
|
+
portBindings: Array<PortBinding>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
interface StopContainerProps {
|
|
75
|
+
name: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
on('task', {
|
|
79
|
+
startContainer: async ({
|
|
80
|
+
image,
|
|
81
|
+
name,
|
|
82
|
+
portBindings = []
|
|
83
|
+
}: StartContainerProps) => {
|
|
84
|
+
const webContainers = await docker.listContainers({
|
|
85
|
+
all: true,
|
|
86
|
+
filters: { name: [name] }
|
|
87
|
+
});
|
|
88
|
+
if (webContainers.length) {
|
|
89
|
+
return webContainers[0];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const container = await docker.createContainer({
|
|
93
|
+
AttachStderr: true,
|
|
94
|
+
AttachStdin: false,
|
|
95
|
+
AttachStdout: true,
|
|
96
|
+
ExposedPorts: portBindings.reduce((accumulator, currentValue) => {
|
|
97
|
+
accumulator[`${currentValue.source}/tcp`] = {};
|
|
98
|
+
|
|
99
|
+
return accumulator;
|
|
100
|
+
}, {}),
|
|
101
|
+
HostConfig: {
|
|
102
|
+
PortBindings: portBindings.reduce((accumulator, currentValue) => {
|
|
103
|
+
accumulator[`${currentValue.source}/tcp`] = [
|
|
104
|
+
{
|
|
105
|
+
HostIP: '0.0.0.0',
|
|
106
|
+
HostPort: `${currentValue.destination}`
|
|
107
|
+
}
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
return accumulator;
|
|
111
|
+
}, {})
|
|
112
|
+
},
|
|
113
|
+
Image: image,
|
|
114
|
+
OpenStdin: false,
|
|
115
|
+
StdinOnce: false,
|
|
116
|
+
Tty: true,
|
|
117
|
+
name
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
await container.start();
|
|
121
|
+
|
|
122
|
+
return container;
|
|
123
|
+
},
|
|
124
|
+
stopContainer: async ({ name }: StopContainerProps) => {
|
|
125
|
+
const container = await docker.getContainer(name);
|
|
126
|
+
await container.kill();
|
|
127
|
+
await container.remove();
|
|
128
|
+
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
35
133
|
return config;
|
|
36
134
|
};
|
|
@@ -21,15 +21,11 @@ module.exports = {
|
|
|
21
21
|
}
|
|
22
22
|
],
|
|
23
23
|
'@typescript-eslint/camelcase': 'off',
|
|
24
|
-
'@typescript-eslint/consistent-type-definitions': [
|
|
25
|
-
'@typescript-eslint/explicit-function-return-type': [
|
|
24
|
+
'@typescript-eslint/consistent-type-definitions': [
|
|
26
25
|
'error',
|
|
27
|
-
|
|
28
|
-
allowExpressions: true,
|
|
29
|
-
allowHigherOrderFunctions: true,
|
|
30
|
-
allowTypedFunctionExpressions: true
|
|
31
|
-
}
|
|
26
|
+
'interface'
|
|
32
27
|
],
|
|
28
|
+
'@typescript-eslint/explicit-function-return-type': ['error'],
|
|
33
29
|
'@typescript-eslint/explicit-member-accessibility': [
|
|
34
30
|
'error',
|
|
35
31
|
{
|
|
@@ -80,21 +76,13 @@ module.exports = {
|
|
|
80
76
|
}
|
|
81
77
|
],
|
|
82
78
|
camelcase: 'off',
|
|
83
|
-
'import/no-cycle': 'off',
|
|
84
|
-
'import/no-named-as-default': 'warn',
|
|
85
79
|
'no-shadow': 'off',
|
|
86
80
|
'no-unused-expressions': 'off'
|
|
87
81
|
},
|
|
88
82
|
settings: {
|
|
89
|
-
'import/parsers': {
|
|
90
|
-
'@typescript-eslint/parser': ['.ts', '.tsx']
|
|
91
|
-
},
|
|
92
83
|
'import/resolver': {
|
|
93
84
|
alias: {
|
|
94
85
|
extensions: ['.ts', '.tsx', '.js', '.jsx']
|
|
95
|
-
},
|
|
96
|
-
typescript: {
|
|
97
|
-
alwaysTryTypes: true
|
|
98
86
|
}
|
|
99
87
|
}
|
|
100
88
|
}
|
package/jest/index.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
moduleNameMapper: {
|
|
3
3
|
'\\.(s?css|png|svg|jpg)$': 'identity-obj-proxy',
|
|
4
|
-
'^.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$':
|
|
5
|
-
'jest-transform-stub',
|
|
6
4
|
'^react($|/.+)': '<rootDir>/node_modules/react$1'
|
|
7
5
|
},
|
|
6
|
+
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
|
|
8
7
|
testEnvironment: 'jsdom',
|
|
9
|
-
testPathIgnorePatterns: ['/node_modules/'
|
|
8
|
+
testPathIgnorePatterns: ['/node_modules/'],
|
|
10
9
|
transform: {
|
|
11
|
-
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$':
|
|
12
|
-
'jest-transform-stub',
|
|
13
10
|
'^.+\\.[jt]sx?$': [
|
|
14
11
|
'@swc/jest',
|
|
15
12
|
{
|
package/package.json
CHANGED
|
@@ -1,63 +1,47 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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.12",
|
|
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
|
+
"@badeball/cypress-cucumber-preprocessor": "^14.0.0",
|
|
20
|
+
"@types/dockerode": "^3.3.16",
|
|
21
|
+
"dockerode": "^3.3.5",
|
|
22
|
+
"eslint": "^8.17.0",
|
|
23
|
+
"eslint-config-airbnb": "19.0.4",
|
|
24
|
+
"eslint-config-prettier": "^8.5.0",
|
|
25
|
+
"eslint-import-resolver-alias": "^1.1.2",
|
|
26
|
+
"eslint-plugin-babel": "^5.3.1",
|
|
27
|
+
"eslint-plugin-hooks": "^0.4.3",
|
|
28
|
+
"eslint-plugin-import": "^2.26.0",
|
|
29
|
+
"eslint-plugin-jest": "^26.1.5",
|
|
30
|
+
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
31
|
+
"eslint-plugin-node": "^11.1.0",
|
|
32
|
+
"eslint-plugin-prefer-arrow-functions": "^3.1.4",
|
|
33
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
34
|
+
"eslint-plugin-react": "^7.29.4",
|
|
35
|
+
"eslint-plugin-react-hooks": "^4.5.0",
|
|
36
|
+
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
37
|
+
"eslint-plugin-typescript-sort-keys": "^2.1.0"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/centreon/centreon-frontend#readme",
|
|
40
|
+
"files": [
|
|
41
|
+
"eslint",
|
|
42
|
+
"jest",
|
|
43
|
+
"tsconfig",
|
|
44
|
+
"webpack",
|
|
45
|
+
"cypress"
|
|
46
|
+
]
|
|
63
47
|
}
|
package/tsconfig/index.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"downlevelIteration": true,
|
|
4
|
-
"module": "ESNext",
|
|
5
3
|
"moduleResolution": "node",
|
|
6
|
-
"
|
|
4
|
+
"downlevelIteration": true,
|
|
5
|
+
"module": "es6",
|
|
6
|
+
"target": "es6",
|
|
7
7
|
"jsx": "react-jsx",
|
|
8
8
|
"strict": true,
|
|
9
9
|
"noImplicitAny": false,
|
|
10
10
|
"skipLibCheck": true,
|
|
11
|
-
"esModuleInterop": true
|
|
12
|
-
"resolveJsonModule": true
|
|
11
|
+
"esModuleInterop": true
|
|
13
12
|
}
|
|
14
13
|
}
|
package/webpack/base/index.js
CHANGED
|
@@ -3,49 +3,91 @@ const path = require('path');
|
|
|
3
3
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
4
4
|
const { ModuleFederationPlugin } = require('webpack').container;
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
optimization,
|
|
9
|
-
output,
|
|
10
|
-
cache
|
|
11
|
-
} = require('./globalConfig');
|
|
6
|
+
const excludeNodeModulesExceptCentreonUi =
|
|
7
|
+
/node_modules(\\|\/)\.pnpm(\\|\/)(?!(@centreon))/;
|
|
12
8
|
|
|
13
9
|
const getBaseConfiguration = ({
|
|
14
10
|
moduleName,
|
|
15
11
|
moduleFederationConfig,
|
|
16
|
-
jscTransformConfiguration
|
|
17
|
-
enableCoverage
|
|
12
|
+
jscTransformConfiguration
|
|
18
13
|
}) => ({
|
|
19
|
-
cache,
|
|
20
|
-
module:
|
|
21
|
-
|
|
14
|
+
cache: false,
|
|
15
|
+
module: {
|
|
16
|
+
rules: [
|
|
17
|
+
{
|
|
18
|
+
parser: { system: false },
|
|
19
|
+
test: /\.[cm]?(j|t)sx?$/
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
exclude: excludeNodeModulesExceptCentreonUi,
|
|
23
|
+
test: /\.[jt]sx?$/,
|
|
24
|
+
use: {
|
|
25
|
+
loader: 'swc-loader',
|
|
26
|
+
options: {
|
|
27
|
+
jsc: {
|
|
28
|
+
parser: {
|
|
29
|
+
syntax: 'typescript',
|
|
30
|
+
tsx: true
|
|
31
|
+
},
|
|
32
|
+
transform: jscTransformConfiguration
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
test: /\.icon.svg$/,
|
|
39
|
+
use: ['@svgr/webpack']
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
exclude: excludeNodeModulesExceptCentreonUi,
|
|
43
|
+
test: /\.(bmp|png|jpg|jpeg|gif|svg)$/,
|
|
44
|
+
use: [
|
|
45
|
+
{
|
|
46
|
+
loader: 'url-loader',
|
|
47
|
+
options: {
|
|
48
|
+
limit: 10000,
|
|
49
|
+
name: '[name].[hash:8].[ext]'
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
optimization: {
|
|
57
|
+
splitChunks: {
|
|
58
|
+
chunks: 'all',
|
|
59
|
+
maxSize: 400 * 1024
|
|
60
|
+
}
|
|
61
|
+
},
|
|
22
62
|
output: {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
63
|
+
chunkFilename: '[name].[chunkhash:8].chunk.js',
|
|
64
|
+
filename: '[name].[chunkhash:8].js',
|
|
65
|
+
libraryTarget: 'umd',
|
|
66
|
+
umdNamedDefine: true
|
|
26
67
|
},
|
|
27
68
|
plugins: [
|
|
28
69
|
new CleanWebpackPlugin(),
|
|
29
70
|
moduleName &&
|
|
30
71
|
new ModuleFederationPlugin({
|
|
31
72
|
filename: 'remoteEntry.[chunkhash:8].js',
|
|
32
|
-
library: { name: moduleName, type: '
|
|
73
|
+
library: { name: moduleName, type: 'var' },
|
|
33
74
|
name: moduleName,
|
|
34
75
|
shared: [
|
|
35
76
|
{
|
|
36
77
|
'@centreon/ui-context': {
|
|
37
|
-
requiredVersion: '
|
|
78
|
+
requiredVersion: '22.10.0',
|
|
38
79
|
singleton: true
|
|
39
80
|
}
|
|
40
81
|
},
|
|
41
82
|
{
|
|
42
83
|
jotai: {
|
|
43
|
-
requiredVersion: '
|
|
84
|
+
requiredVersion: '1.x',
|
|
44
85
|
singleton: true
|
|
45
86
|
}
|
|
46
87
|
},
|
|
47
88
|
{
|
|
48
89
|
'jotai-suspense': {
|
|
90
|
+
requiredVersion: '0.1.x',
|
|
49
91
|
singleton: true
|
|
50
92
|
}
|
|
51
93
|
},
|
|
@@ -79,9 +121,6 @@ const getBaseConfiguration = ({
|
|
|
79
121
|
].filter(Boolean),
|
|
80
122
|
resolve: {
|
|
81
123
|
alias: {
|
|
82
|
-
'@centreon/ui/fonts': path.resolve(
|
|
83
|
-
'./node_modules/@centreon/ui/public/fonts'
|
|
84
|
-
),
|
|
85
124
|
react: path.resolve('./node_modules/react')
|
|
86
125
|
},
|
|
87
126
|
extensions: ['.js', '.jsx', '.ts', '.tsx']
|
|
@@ -1,19 +0,0 @@
|
|
|
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;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
|
-
|
|
3
|
-
const apiBase = '/centreon/api';
|
|
4
|
-
const apiActionV1 = `${apiBase}/index.php`;
|
|
5
|
-
|
|
6
|
-
const getStatusNumberFromString = (status: string): number => {
|
|
7
|
-
const statuses = {
|
|
8
|
-
critical: '2',
|
|
9
|
-
down: '1',
|
|
10
|
-
ok: '0',
|
|
11
|
-
unknown: '3',
|
|
12
|
-
unreachable: '2',
|
|
13
|
-
up: '0',
|
|
14
|
-
warning: '1'
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
if (status in statuses) {
|
|
18
|
-
return statuses[status];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
throw new Error(`Status ${status} does not exist`);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
interface SubmitResult {
|
|
25
|
-
host: string;
|
|
26
|
-
output: string;
|
|
27
|
-
perfdata?: string | null;
|
|
28
|
-
service?: string | null;
|
|
29
|
-
status: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
Cypress.Commands.add(
|
|
33
|
-
'submitResults',
|
|
34
|
-
(results: Array<SubmitResult>): Cypress.Chainable => {
|
|
35
|
-
results.forEach(
|
|
36
|
-
({ host, output, perfdata = '', service = null, status }) => {
|
|
37
|
-
const timestampNow = Math.floor(Date.now() / 1000) - 15;
|
|
38
|
-
const updatetime = timestampNow.toString();
|
|
39
|
-
|
|
40
|
-
const result = {
|
|
41
|
-
host,
|
|
42
|
-
output,
|
|
43
|
-
perfdata,
|
|
44
|
-
service,
|
|
45
|
-
status: getStatusNumberFromString(status),
|
|
46
|
-
updatetime
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
cy.request({
|
|
50
|
-
body: {
|
|
51
|
-
results: [result]
|
|
52
|
-
},
|
|
53
|
-
headers: {
|
|
54
|
-
'Content-Type': 'application/json',
|
|
55
|
-
'centreon-auth-token': window.localStorage.getItem('userTokenApiV1')
|
|
56
|
-
},
|
|
57
|
-
method: 'POST',
|
|
58
|
-
url: `${apiActionV1}?action=submit&object=centreon_submit_results`
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
return cy.wrap(null);
|
|
64
|
-
}
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
declare global {
|
|
68
|
-
namespace Cypress {
|
|
69
|
-
interface Chainable {
|
|
70
|
-
submitResults: (props: Array<SubmitResult>) => Cypress.Chainable;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
|
|
2
|
-
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill';
|
|
3
|
-
import { addCucumberPreprocessorPlugin } from '@badeball/cypress-cucumber-preprocessor';
|
|
4
|
-
import createBundler from '@bahmutov/cypress-esbuild-preprocessor';
|
|
5
|
-
import createEsbuildPlugin from '@badeball/cypress-cucumber-preprocessor/esbuild';
|
|
6
|
-
|
|
7
|
-
export default async (
|
|
8
|
-
on: Cypress.PluginEvents,
|
|
9
|
-
config: Cypress.PluginConfigOptions
|
|
10
|
-
): Promise<void> => {
|
|
11
|
-
await addCucumberPreprocessorPlugin(on, config);
|
|
12
|
-
|
|
13
|
-
on(
|
|
14
|
-
'file:preprocessor',
|
|
15
|
-
createBundler({
|
|
16
|
-
plugins: [
|
|
17
|
-
createEsbuildPlugin(config),
|
|
18
|
-
NodeModulesPolyfillPlugin(),
|
|
19
|
-
NodeGlobalsPolyfillPlugin({
|
|
20
|
-
buffer: true,
|
|
21
|
-
process: true
|
|
22
|
-
})
|
|
23
|
-
]
|
|
24
|
-
})
|
|
25
|
-
);
|
|
26
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
mochawesomeReporterOptions: {
|
|
3
|
-
consoleReporter: 'none',
|
|
4
|
-
html: false,
|
|
5
|
-
json: true,
|
|
6
|
-
overwrite: true,
|
|
7
|
-
reportDir: 'results/reports',
|
|
8
|
-
reportFilename: '[name]-report.json'
|
|
9
|
-
},
|
|
10
|
-
reporterEnabled: `mochawesome,${require.resolve(
|
|
11
|
-
'@badeball/cypress-cucumber-preprocessor/pretty-reporter'
|
|
12
|
-
)}`
|
|
13
|
-
};
|