@centreon/js-config 24.11.7 → 24.11.8
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 +22 -82
- package/cypress/component/configuration.js +16 -39
- package/cypress/component/enableVisualTesting.ts +1 -1
- package/cypress/e2e/commands/configuration.ts +1 -330
- package/cypress/e2e/commands.ts +174 -727
- package/cypress/e2e/configuration.ts +40 -46
- package/cypress/e2e/plugins.ts +114 -52
- package/eslint/base.typescript.eslintrc.js +3 -15
- package/jest/index.js +2 -5
- package/package.json +45 -57
- package/tsconfig/index.json +4 -5
- package/webpack/base/index.js +130 -0
- package/webpack/patch/dev.js +24 -0
- package/{rspack → webpack}/patch/devServer.js +8 -4
- package/webpack/patch/module.js +46 -0
- package/biome/base.json +0 -210
- package/cypress/component/disableCssTransitions.ts +0 -19
- package/cypress/component/excludeNodeModulesFromCoverage.js +0 -36
- package/cypress/e2e/commands/monitoring.ts +0 -225
- package/cypress/e2e/esbuild-preprocessor.ts +0 -26
- package/cypress/e2e/reporter-config.js +0 -13
- package/cypress/e2e/tasks.ts +0 -259
- package/eslint/lambda/typescript.eslintrc.js +0 -48
- package/jest/lambda/typescript.js +0 -49
- package/rspack/base/globalConfig.js +0 -71
- package/rspack/base/index.js +0 -89
- package/rspack/patch/dev.js +0 -12
- package/rspack/patch/module.js +0 -13
- package/rspack/plugins/TransformPreloadScript.js +0 -37
- package/rspack/plugins/WriteRemoteEntryNameToModuleFederation.js +0 -30
- package/tsconfig/lambda/node20.tsconfig.json +0 -12
- package/tsconfig/lambda/tsconfig.json +0 -14
- package/tsconfig.json +0 -21
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const os = require('os');
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
|
4
4
|
|
|
5
5
|
const devServerPort = 9090;
|
|
6
6
|
|
|
@@ -13,13 +13,16 @@ const externalInterface = Object.keys(interfaces).find(
|
|
|
13
13
|
!process.env.IS_STATIC_PORT_FORWARDED
|
|
14
14
|
);
|
|
15
15
|
|
|
16
|
-
const devServerAddress =
|
|
16
|
+
const devServerAddress = externalInterface
|
|
17
|
+
? interfaces[externalInterface][0].address
|
|
18
|
+
: 'localhost';
|
|
17
19
|
|
|
18
20
|
const publicPath = `http://${devServerAddress}:${devServerPort}/static/`;
|
|
19
21
|
|
|
20
|
-
const
|
|
22
|
+
const isServeMode = process.env.WEBPACK_ENV === 'serve';
|
|
23
|
+
const isDevelopmentMode = process.env.WEBPACK_ENV === 'development';
|
|
21
24
|
|
|
22
|
-
const devServerPlugins =
|
|
25
|
+
const devServerPlugins = isServeMode ? [new ReactRefreshWebpackPlugin()] : [];
|
|
23
26
|
|
|
24
27
|
module.exports = {
|
|
25
28
|
devServer: {
|
|
@@ -29,5 +32,6 @@ module.exports = {
|
|
|
29
32
|
},
|
|
30
33
|
devServerPlugins,
|
|
31
34
|
isDevelopmentMode,
|
|
35
|
+
isServeMode,
|
|
32
36
|
publicPath
|
|
33
37
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
3
|
+
|
|
4
|
+
class CentreonModulePlugin {
|
|
5
|
+
constructor(federatedComponentConfiguration) {
|
|
6
|
+
this.federatedComponentConfiguration = federatedComponentConfiguration;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
apply(compiler) {
|
|
10
|
+
compiler.hooks.done.tap('CentreonModulePlugin', (stats) => {
|
|
11
|
+
const newFederatedComponentConfiguration = {
|
|
12
|
+
...this.federatedComponentConfiguration,
|
|
13
|
+
remoteEntry: Object.keys(stats.compilation.assets).find((assetName) =>
|
|
14
|
+
assetName.match(/(^remoteEntry)\S+.js$/),
|
|
15
|
+
),
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
if (!fs.existsSync(compiler.options.output.path)) {
|
|
19
|
+
fs.mkdirSync(compiler.options.output.path, { recursive: true });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
fs.writeFileSync(
|
|
23
|
+
`${compiler.options.output.path}/moduleFederation.json`,
|
|
24
|
+
JSON.stringify(newFederatedComponentConfiguration, null, 2),
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports = ({
|
|
31
|
+
outputPath,
|
|
32
|
+
federatedComponentConfiguration,
|
|
33
|
+
}) => ({
|
|
34
|
+
output: {
|
|
35
|
+
library: '[chunkhash:8]',
|
|
36
|
+
path: outputPath,
|
|
37
|
+
},
|
|
38
|
+
plugins: [
|
|
39
|
+
new CleanWebpackPlugin({
|
|
40
|
+
cleanOnceBeforeBuildPatterns: [`${outputPath}/**/*.js`],
|
|
41
|
+
dangerouslyAllowCleanPatternsOutsideProject: true,
|
|
42
|
+
dry: false,
|
|
43
|
+
}),
|
|
44
|
+
new CentreonModulePlugin(federatedComponentConfiguration),
|
|
45
|
+
],
|
|
46
|
+
});
|
package/biome/base.json
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"formatter": {
|
|
3
|
-
"enabled": true,
|
|
4
|
-
"indentStyle": "space",
|
|
5
|
-
"formatWithErrors": false
|
|
6
|
-
},
|
|
7
|
-
"organizeImports": {
|
|
8
|
-
"enabled": true
|
|
9
|
-
},
|
|
10
|
-
"linter": {
|
|
11
|
-
"enabled": true,
|
|
12
|
-
"rules": {
|
|
13
|
-
"recommended": true,
|
|
14
|
-
"a11y": {
|
|
15
|
-
"noSvgWithoutTitle": "off"
|
|
16
|
-
},
|
|
17
|
-
"complexity": {
|
|
18
|
-
"noBannedTypes": "off",
|
|
19
|
-
"noForEach": "off"
|
|
20
|
-
},
|
|
21
|
-
"correctness": {
|
|
22
|
-
"noUnusedImports": "error",
|
|
23
|
-
"noUnusedVariables": "error",
|
|
24
|
-
"useExhaustiveDependencies": "off",
|
|
25
|
-
"noUnknownUnit": "error",
|
|
26
|
-
"noUnknownProperty": "error",
|
|
27
|
-
"noUnknownFunction": "error",
|
|
28
|
-
"useIsNan": "error"
|
|
29
|
-
},
|
|
30
|
-
"nursery": {
|
|
31
|
-
"noRestrictedImports": {
|
|
32
|
-
"level": "error",
|
|
33
|
-
"options": {
|
|
34
|
-
"paths": {
|
|
35
|
-
"lodash": "Using lodash is not encouraged.",
|
|
36
|
-
"moment": "Using moment is not encouraged."
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"suspicious": {
|
|
42
|
-
"noConsole": "error",
|
|
43
|
-
"useAwait": "error"
|
|
44
|
-
},
|
|
45
|
-
"performance": {
|
|
46
|
-
"noAccumulatingSpread": "off"
|
|
47
|
-
},
|
|
48
|
-
"style": {
|
|
49
|
-
"useLiteralEnumMembers": "off",
|
|
50
|
-
"useImportType": "off",
|
|
51
|
-
"noNamespace": "error",
|
|
52
|
-
"noNamespaceImport": "error",
|
|
53
|
-
"useFragmentSyntax": "error",
|
|
54
|
-
"useFilenamingConvention": {
|
|
55
|
-
"level": "error",
|
|
56
|
-
"options": {
|
|
57
|
-
"strictCase": false,
|
|
58
|
-
"filenameCases": ["camelCase", "PascalCase", "kebab-case"]
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
"useNamingConvention": {
|
|
62
|
-
"level": "error",
|
|
63
|
-
"options": {
|
|
64
|
-
"strictCase": false,
|
|
65
|
-
"conventions": [
|
|
66
|
-
{
|
|
67
|
-
"formats": ["camelCase", "PascalCase"],
|
|
68
|
-
"selector": {
|
|
69
|
-
"kind": "variable"
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
"selector": {
|
|
74
|
-
"kind": "interface"
|
|
75
|
-
},
|
|
76
|
-
"formats": ["PascalCase"]
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
"selector": {
|
|
80
|
-
"kind": "enum"
|
|
81
|
-
},
|
|
82
|
-
"formats": ["PascalCase"]
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
"selector": {
|
|
86
|
-
"kind": "objectLiteralProperty"
|
|
87
|
-
},
|
|
88
|
-
"match": ".*"
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
"match": "_(.*)|([a-zA-Z].*)",
|
|
92
|
-
"selector": {
|
|
93
|
-
"kind": "functionParameter"
|
|
94
|
-
},
|
|
95
|
-
"formats": ["snake_case", "PascalCase", "camelCase"]
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
"match": ".*",
|
|
99
|
-
"formats": [
|
|
100
|
-
"snake_case",
|
|
101
|
-
"camelCase",
|
|
102
|
-
"PascalCase",
|
|
103
|
-
"CONSTANT_CASE"
|
|
104
|
-
]
|
|
105
|
-
}
|
|
106
|
-
]
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
"noRestrictedGlobals": {
|
|
110
|
-
"level": "error",
|
|
111
|
-
"options": {
|
|
112
|
-
"deniedGlobals": [
|
|
113
|
-
"isFinite",
|
|
114
|
-
"isNaN",
|
|
115
|
-
"addEventListener",
|
|
116
|
-
"blur",
|
|
117
|
-
"close",
|
|
118
|
-
"closed",
|
|
119
|
-
"confirm",
|
|
120
|
-
"defaultStatus",
|
|
121
|
-
"defaultstatus",
|
|
122
|
-
"event",
|
|
123
|
-
"external",
|
|
124
|
-
"find",
|
|
125
|
-
"focus",
|
|
126
|
-
"frameElement",
|
|
127
|
-
"frames",
|
|
128
|
-
"history",
|
|
129
|
-
"innerHeight",
|
|
130
|
-
"innerWidth",
|
|
131
|
-
"length",
|
|
132
|
-
"location",
|
|
133
|
-
"locationbar",
|
|
134
|
-
"menubar",
|
|
135
|
-
"moveBy",
|
|
136
|
-
"moveTo",
|
|
137
|
-
"name",
|
|
138
|
-
"onblur",
|
|
139
|
-
"onerror",
|
|
140
|
-
"onfocus",
|
|
141
|
-
"onload",
|
|
142
|
-
"onresize",
|
|
143
|
-
"onunload",
|
|
144
|
-
"open",
|
|
145
|
-
"opener",
|
|
146
|
-
"opera",
|
|
147
|
-
"outerHeight",
|
|
148
|
-
"outerWidth",
|
|
149
|
-
"pageXOffset",
|
|
150
|
-
"pageYOffset",
|
|
151
|
-
"parent",
|
|
152
|
-
"print",
|
|
153
|
-
"removeEventListener",
|
|
154
|
-
"resizeBy",
|
|
155
|
-
"resizeTo",
|
|
156
|
-
"screen",
|
|
157
|
-
"screenLeft",
|
|
158
|
-
"screenTop",
|
|
159
|
-
"screenX",
|
|
160
|
-
"screenY",
|
|
161
|
-
"scroll",
|
|
162
|
-
"scrollbars",
|
|
163
|
-
"scrollBy",
|
|
164
|
-
"scrollTo",
|
|
165
|
-
"scrollX",
|
|
166
|
-
"scrollY",
|
|
167
|
-
"self",
|
|
168
|
-
"status",
|
|
169
|
-
"statusbar",
|
|
170
|
-
"stop",
|
|
171
|
-
"toolbar",
|
|
172
|
-
"top"
|
|
173
|
-
]
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
"javascript": {
|
|
180
|
-
"formatter": {
|
|
181
|
-
"enabled": true,
|
|
182
|
-
"quoteStyle": "single",
|
|
183
|
-
"semicolons": "always",
|
|
184
|
-
"indentStyle": "space",
|
|
185
|
-
"trailingCommas": "none"
|
|
186
|
-
},
|
|
187
|
-
"linter": {
|
|
188
|
-
"enabled": true
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
"json": {
|
|
192
|
-
"parser": {
|
|
193
|
-
"allowComments": true,
|
|
194
|
-
"allowTrailingCommas": false
|
|
195
|
-
},
|
|
196
|
-
"formatter": {
|
|
197
|
-
"enabled": true,
|
|
198
|
-
"indentStyle": "space"
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
"css": {
|
|
202
|
-
"formatter": {
|
|
203
|
-
"enabled": true,
|
|
204
|
-
"indentStyle": "space"
|
|
205
|
-
},
|
|
206
|
-
"linter": {
|
|
207
|
-
"enabled": true
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
@@ -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,36 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
const filePath = process.argv[2];
|
|
5
|
-
|
|
6
|
-
const { error: logError } = console;
|
|
7
|
-
|
|
8
|
-
try {
|
|
9
|
-
const outFile = fs.readFileSync(path.resolve(filePath)).toString();
|
|
10
|
-
const outFileJson = JSON.parse(outFile);
|
|
11
|
-
|
|
12
|
-
const coveragesWithoutNodeModules = Object.entries(outFileJson)
|
|
13
|
-
.map(([key, value]) => {
|
|
14
|
-
if (key.includes('node_modules')) {
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return [key, value];
|
|
19
|
-
})
|
|
20
|
-
.filter((v) => v);
|
|
21
|
-
|
|
22
|
-
const finalOutJson = coveragesWithoutNodeModules.reduce(
|
|
23
|
-
(acc, [key, value]) => ({
|
|
24
|
-
...acc,
|
|
25
|
-
[key]: value
|
|
26
|
-
}),
|
|
27
|
-
{}
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
fs.writeFileSync(
|
|
31
|
-
path.resolve(filePath),
|
|
32
|
-
JSON.stringify(finalOutJson, null, 2)
|
|
33
|
-
);
|
|
34
|
-
} catch (error) {
|
|
35
|
-
logError(error.message);
|
|
36
|
-
}
|
|
@@ -1,225 +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 HostCheck {
|
|
25
|
-
host: string;
|
|
26
|
-
isForced?: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
Cypress.Commands.add(
|
|
30
|
-
'scheduleHostCheck',
|
|
31
|
-
({
|
|
32
|
-
host,
|
|
33
|
-
isForced = true
|
|
34
|
-
}: ServiceCheck): Cypress.Chainable => {
|
|
35
|
-
let query = `SELECT id FROM resources WHERE name = '${host}' AND type = 1`;
|
|
36
|
-
|
|
37
|
-
return cy
|
|
38
|
-
.requestOnDatabase({
|
|
39
|
-
database: 'centreon_storage',
|
|
40
|
-
query
|
|
41
|
-
})
|
|
42
|
-
.then(([rows]) => {
|
|
43
|
-
if (rows.length === 0) {
|
|
44
|
-
throw new Error(`Cannot find host ${host}`);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const hostId = rows[0].id;
|
|
48
|
-
|
|
49
|
-
return cy.request({
|
|
50
|
-
body: {
|
|
51
|
-
check: {
|
|
52
|
-
is_forced: isForced
|
|
53
|
-
},
|
|
54
|
-
resources: [
|
|
55
|
-
{
|
|
56
|
-
id: hostId,
|
|
57
|
-
parent: null,
|
|
58
|
-
type: 'host'
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
},
|
|
62
|
-
method: 'POST',
|
|
63
|
-
timeout: 30000,
|
|
64
|
-
url: '/centreon/api/latest/monitoring/resources/check'
|
|
65
|
-
}).then((response) => {
|
|
66
|
-
expect(response.status).to.eq(204);
|
|
67
|
-
|
|
68
|
-
return cy.wrap(null);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
interface ServiceCheck {
|
|
75
|
-
host: string;
|
|
76
|
-
isForced?: boolean;
|
|
77
|
-
service: string;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
Cypress.Commands.add(
|
|
81
|
-
'scheduleServiceCheck',
|
|
82
|
-
({
|
|
83
|
-
host,
|
|
84
|
-
isForced = true,
|
|
85
|
-
service
|
|
86
|
-
}: ServiceCheck): Cypress.Chainable => {
|
|
87
|
-
let query = `SELECT parent_id, id FROM resources WHERE parent_name = '${host}' AND name = '${service}'`;
|
|
88
|
-
|
|
89
|
-
return cy
|
|
90
|
-
.requestOnDatabase({
|
|
91
|
-
database: 'centreon_storage',
|
|
92
|
-
query
|
|
93
|
-
})
|
|
94
|
-
.then(([rows]) => {
|
|
95
|
-
if (rows.length === 0) {
|
|
96
|
-
throw new Error(`Cannot find service ${host} / ${service}`);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const hostId = rows[0].parent_id;
|
|
100
|
-
const serviceId = rows[0].id;
|
|
101
|
-
|
|
102
|
-
return cy.request({
|
|
103
|
-
body: {
|
|
104
|
-
check: {
|
|
105
|
-
is_forced: isForced
|
|
106
|
-
},
|
|
107
|
-
resources: [
|
|
108
|
-
{
|
|
109
|
-
id: serviceId,
|
|
110
|
-
parent: {
|
|
111
|
-
id: hostId
|
|
112
|
-
},
|
|
113
|
-
type: 'service'
|
|
114
|
-
}
|
|
115
|
-
]
|
|
116
|
-
},
|
|
117
|
-
method: 'POST',
|
|
118
|
-
timeout: 30000,
|
|
119
|
-
url: '/centreon/api/latest/monitoring/resources/check'
|
|
120
|
-
}).then((response) => {
|
|
121
|
-
expect(response.status).to.eq(204);
|
|
122
|
-
|
|
123
|
-
return cy.wrap(null);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
interface SubmitResult {
|
|
131
|
-
host: string;
|
|
132
|
-
output: string;
|
|
133
|
-
perfdata?: string | null;
|
|
134
|
-
service?: string | null;
|
|
135
|
-
status: string;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
Cypress.Commands.add(
|
|
139
|
-
'submitResults',
|
|
140
|
-
(results: Array<SubmitResult>): Cypress.Chainable => {
|
|
141
|
-
results.forEach(
|
|
142
|
-
({ host, output, perfdata = '', service = null, status }) => {
|
|
143
|
-
const timestampNow = Math.floor(Date.now() / 1000) - 15;
|
|
144
|
-
const updatetime = timestampNow.toString();
|
|
145
|
-
|
|
146
|
-
const result = {
|
|
147
|
-
host,
|
|
148
|
-
output,
|
|
149
|
-
perfdata,
|
|
150
|
-
service,
|
|
151
|
-
status: getStatusNumberFromString(status),
|
|
152
|
-
updatetime
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
cy.request({
|
|
156
|
-
body: {
|
|
157
|
-
results: [result]
|
|
158
|
-
},
|
|
159
|
-
headers: {
|
|
160
|
-
'Content-Type': 'application/json',
|
|
161
|
-
'centreon-auth-token': window.localStorage.getItem('userTokenApiV1')
|
|
162
|
-
},
|
|
163
|
-
method: 'POST',
|
|
164
|
-
url: `${apiActionV1}?action=submit&object=centreon_submit_results`
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
return cy.wrap(null);
|
|
170
|
-
}
|
|
171
|
-
);
|
|
172
|
-
|
|
173
|
-
interface Downtime {
|
|
174
|
-
host: string;
|
|
175
|
-
service?: string | null;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
Cypress.Commands.add(
|
|
179
|
-
'waitForDowntime',
|
|
180
|
-
(downtime: Downtime): Cypress.Chainable => {
|
|
181
|
-
cy.log('Checking hosts in database');
|
|
182
|
-
|
|
183
|
-
let query = `SELECT COUNT(d.downtime_id) AS count_downtimes FROM downtimes as d
|
|
184
|
-
INNER JOIN hosts as h ON h.host_id = d.host_id AND h.name = '${downtime.host}'`;
|
|
185
|
-
if (downtime.service) {
|
|
186
|
-
query += ` INNER JOIN services as s ON s.service_id = d.service_id AND s.description = '${downtime.service}'`;
|
|
187
|
-
}
|
|
188
|
-
query += ` WHERE d.started=1`;
|
|
189
|
-
if (!downtime.service) {
|
|
190
|
-
query += ` AND d.service_id = 0`;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
cy.log(query);
|
|
194
|
-
|
|
195
|
-
cy.waitUntil(() => {
|
|
196
|
-
return cy
|
|
197
|
-
.requestOnDatabase({
|
|
198
|
-
database: 'centreon_storage',
|
|
199
|
-
query
|
|
200
|
-
})
|
|
201
|
-
.then(([rows]) => {
|
|
202
|
-
const foundDowntimesCount = rows.length ? rows[0].count_downtimes : 0;
|
|
203
|
-
|
|
204
|
-
cy.log('Downtime count in database', foundDowntimesCount);
|
|
205
|
-
|
|
206
|
-
return cy.wrap(foundDowntimesCount > 0);
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
return cy.wrap(null);
|
|
211
|
-
}
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
declare global {
|
|
215
|
-
namespace Cypress {
|
|
216
|
-
interface Chainable {
|
|
217
|
-
scheduleHostCheck: (hostCheck) => Cypress.Chainable;
|
|
218
|
-
scheduleServiceCheck: (serviceCheck) => Cypress.Chainable;
|
|
219
|
-
submitResults: (props: Array<SubmitResult>) => Cypress.Chainable;
|
|
220
|
-
waitForDowntime: (downtime: Downtime) => Cypress.Chainable;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
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
|
-
};
|