@centreon/js-config 23.4.22-enhance-e2e-update-tests.1 → 23.4.22-enhance-e2e-update-tests.2
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.
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
|
+
|
|
3
|
+
const apiBase = '/centreon/api';
|
|
4
|
+
const apiActionV1 = `${apiBase}/index.php`;
|
|
5
|
+
|
|
6
|
+
interface ActionClapi {
|
|
7
|
+
action: string;
|
|
8
|
+
object?: string;
|
|
9
|
+
values: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface ExecuteActionViaClapiProps {
|
|
13
|
+
bodyContent: ActionClapi;
|
|
14
|
+
method?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
Cypress.Commands.add(
|
|
18
|
+
'executeActionViaClapi',
|
|
19
|
+
({
|
|
20
|
+
bodyContent,
|
|
21
|
+
method = 'POST'
|
|
22
|
+
}: ExecuteActionViaClapiProps): Cypress.Chainable => {
|
|
23
|
+
return cy.request({
|
|
24
|
+
body: bodyContent,
|
|
25
|
+
headers: {
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
'centreon-auth-token': window.localStorage.getItem('userTokenApiV1')
|
|
28
|
+
},
|
|
29
|
+
method,
|
|
30
|
+
url: `${apiActionV1}?action=action&object=centreon_clapi`
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
Cypress.Commands.add(
|
|
36
|
+
'executeCommandsViaClapi',
|
|
37
|
+
(fixtureFile: string): Cypress.Chainable => {
|
|
38
|
+
return cy.fixture(fixtureFile).then((listRequestConfig) => {
|
|
39
|
+
cy.wrap(
|
|
40
|
+
Promise.all(
|
|
41
|
+
listRequestConfig.map((request: ActionClapi) =>
|
|
42
|
+
cy.executeActionViaClapi({ bodyContent: request })
|
|
43
|
+
)
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
interface TimePeriod {
|
|
51
|
+
alias?: string | null;
|
|
52
|
+
friday?: string;
|
|
53
|
+
monday?: string;
|
|
54
|
+
name: string;
|
|
55
|
+
saturday?: string;
|
|
56
|
+
sunday?: string;
|
|
57
|
+
thursday?: string;
|
|
58
|
+
tuesday?: string;
|
|
59
|
+
wednesday?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const defaultDayPeriod = '00:00-24:00';
|
|
63
|
+
|
|
64
|
+
Cypress.Commands.add(
|
|
65
|
+
'addTimePeriod',
|
|
66
|
+
({
|
|
67
|
+
alias = null,
|
|
68
|
+
friday = defaultDayPeriod,
|
|
69
|
+
monday = defaultDayPeriod,
|
|
70
|
+
name,
|
|
71
|
+
saturday = defaultDayPeriod,
|
|
72
|
+
sunday = defaultDayPeriod,
|
|
73
|
+
thursday = defaultDayPeriod,
|
|
74
|
+
tuesday = defaultDayPeriod,
|
|
75
|
+
wednesday = defaultDayPeriod
|
|
76
|
+
}: TimePeriod): Cypress.Chainable => {
|
|
77
|
+
const timePeriodAlias = alias === null ? name : alias;
|
|
78
|
+
|
|
79
|
+
return cy
|
|
80
|
+
.executeActionViaClapi({
|
|
81
|
+
bodyContent: {
|
|
82
|
+
action: 'ADD',
|
|
83
|
+
object: 'TP',
|
|
84
|
+
values: `${name};${timePeriodAlias}`
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
.then(() => {
|
|
88
|
+
const weekDays = {
|
|
89
|
+
friday,
|
|
90
|
+
monday,
|
|
91
|
+
saturday,
|
|
92
|
+
sunday,
|
|
93
|
+
thursday,
|
|
94
|
+
tuesday,
|
|
95
|
+
wednesday
|
|
96
|
+
};
|
|
97
|
+
Object.entries(weekDays).map(([dayName, dayValue]) => {
|
|
98
|
+
return cy.executeActionViaClapi({
|
|
99
|
+
bodyContent: {
|
|
100
|
+
action: 'SETPARAM',
|
|
101
|
+
object: 'TP',
|
|
102
|
+
values: `${name};${dayName};${dayValue}`
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
return cy.wrap(null);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
interface CheckCommand {
|
|
113
|
+
command: string;
|
|
114
|
+
enableShell?: boolean;
|
|
115
|
+
name: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
Cypress.Commands.add(
|
|
119
|
+
'addCheckCommand',
|
|
120
|
+
({ name, enableShell = true, command }: CheckCommand): Cypress.Chainable => {
|
|
121
|
+
const commandEnableShell = enableShell ? 1 : 0;
|
|
122
|
+
|
|
123
|
+
return cy
|
|
124
|
+
.executeActionViaClapi({
|
|
125
|
+
bodyContent: {
|
|
126
|
+
action: 'ADD',
|
|
127
|
+
object: 'CMD',
|
|
128
|
+
values: `${name};check;${command}`
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
.executeActionViaClapi({
|
|
132
|
+
bodyContent: {
|
|
133
|
+
action: 'SETPARAM',
|
|
134
|
+
object: 'CMD',
|
|
135
|
+
values: `${name};enable_shell;${commandEnableShell}`
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
interface Host {
|
|
142
|
+
activeCheckEnabled?: boolean;
|
|
143
|
+
address?: string;
|
|
144
|
+
alias?: string | null;
|
|
145
|
+
checkCommand?: string | null;
|
|
146
|
+
checkPeriod?: string | null;
|
|
147
|
+
maxCheckAttempts?: number | null;
|
|
148
|
+
name: string;
|
|
149
|
+
passiveCheckEnabled?: boolean;
|
|
150
|
+
poller?: string;
|
|
151
|
+
template?: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
Cypress.Commands.add(
|
|
155
|
+
'addHost',
|
|
156
|
+
({
|
|
157
|
+
activeCheckEnabled = true,
|
|
158
|
+
address = '127.0.0.1',
|
|
159
|
+
alias = null,
|
|
160
|
+
checkCommand = null,
|
|
161
|
+
checkPeriod = null,
|
|
162
|
+
maxCheckAttempts = 1,
|
|
163
|
+
name,
|
|
164
|
+
passiveCheckEnabled = true,
|
|
165
|
+
poller = 'Central',
|
|
166
|
+
template = ''
|
|
167
|
+
}: Host): Cypress.Chainable => {
|
|
168
|
+
const hostAlias = alias === null ? name : alias;
|
|
169
|
+
const hostMaxCheckAttempts =
|
|
170
|
+
maxCheckAttempts === null ? '' : maxCheckAttempts;
|
|
171
|
+
const hostActiveCheckEnabled = activeCheckEnabled ? 1 : 0;
|
|
172
|
+
const hostPassiveCheckEnabled = passiveCheckEnabled ? 1 : 0;
|
|
173
|
+
|
|
174
|
+
return cy
|
|
175
|
+
.executeActionViaClapi({
|
|
176
|
+
bodyContent: {
|
|
177
|
+
action: 'ADD',
|
|
178
|
+
object: 'HOST',
|
|
179
|
+
values: `${name};${hostAlias};${address};${template};${poller};`
|
|
180
|
+
}
|
|
181
|
+
})
|
|
182
|
+
.then(() => {
|
|
183
|
+
const hostParams = {
|
|
184
|
+
active_checks_enabled: hostActiveCheckEnabled,
|
|
185
|
+
check_command: checkCommand,
|
|
186
|
+
check_period: checkPeriod,
|
|
187
|
+
max_check_attempts: hostMaxCheckAttempts,
|
|
188
|
+
passive_checks_enabled: hostPassiveCheckEnabled
|
|
189
|
+
};
|
|
190
|
+
Object.entries(hostParams).map(([paramName, paramValue]) => {
|
|
191
|
+
if (paramValue === null) {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return cy.executeActionViaClapi({
|
|
196
|
+
bodyContent: {
|
|
197
|
+
action: 'SETPARAM',
|
|
198
|
+
object: 'HOST',
|
|
199
|
+
values: `${name};${paramName};${paramValue}`
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
return cy.wrap(null);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
interface ServiceTemplate {
|
|
210
|
+
activeCheckEnabled?: boolean;
|
|
211
|
+
checkCommand?: string | null;
|
|
212
|
+
checkPeriod?: string | null;
|
|
213
|
+
description?: string | null;
|
|
214
|
+
maxCheckAttempts?: number | null;
|
|
215
|
+
name: string;
|
|
216
|
+
passiveCheckEnabled?: boolean;
|
|
217
|
+
template?: string;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
Cypress.Commands.add(
|
|
221
|
+
'addServiceTemplate',
|
|
222
|
+
({
|
|
223
|
+
activeCheckEnabled = true,
|
|
224
|
+
checkCommand = null,
|
|
225
|
+
checkPeriod = null,
|
|
226
|
+
description = null,
|
|
227
|
+
maxCheckAttempts = 1,
|
|
228
|
+
name,
|
|
229
|
+
passiveCheckEnabled = true,
|
|
230
|
+
template = ''
|
|
231
|
+
}: ServiceTemplate): Cypress.Chainable => {
|
|
232
|
+
const serviceDescription = description === null ? name : description;
|
|
233
|
+
const serviceMaxCheckAttempts =
|
|
234
|
+
maxCheckAttempts === null ? '' : maxCheckAttempts;
|
|
235
|
+
const serviceActiveCheckEnabled = activeCheckEnabled ? 1 : 0;
|
|
236
|
+
const servicePassiveCheckEnabled = passiveCheckEnabled ? 1 : 0;
|
|
237
|
+
|
|
238
|
+
return cy
|
|
239
|
+
.executeActionViaClapi({
|
|
240
|
+
bodyContent: {
|
|
241
|
+
action: 'ADD',
|
|
242
|
+
object: 'STPL',
|
|
243
|
+
values: `${name};${description};${template}`
|
|
244
|
+
}
|
|
245
|
+
})
|
|
246
|
+
.then(() => {
|
|
247
|
+
const serviceParams = {
|
|
248
|
+
active_checks_enabled: serviceActiveCheckEnabled,
|
|
249
|
+
check_command: checkCommand,
|
|
250
|
+
check_period: checkPeriod,
|
|
251
|
+
description: serviceDescription,
|
|
252
|
+
max_check_attempts: serviceMaxCheckAttempts,
|
|
253
|
+
passive_checks_enabled: servicePassiveCheckEnabled
|
|
254
|
+
};
|
|
255
|
+
Object.entries(serviceParams).map(([paramName, paramValue]) => {
|
|
256
|
+
if (paramValue === null) {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return cy.executeActionViaClapi({
|
|
261
|
+
bodyContent: {
|
|
262
|
+
action: 'SETPARAM',
|
|
263
|
+
object: 'STPL',
|
|
264
|
+
values: `${name};${paramName};${paramValue}`
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
return cy.wrap(null);
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
interface Service extends ServiceTemplate {
|
|
275
|
+
host: string;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
Cypress.Commands.add(
|
|
279
|
+
'addService',
|
|
280
|
+
({
|
|
281
|
+
activeCheckEnabled = true,
|
|
282
|
+
checkCommand = null,
|
|
283
|
+
checkPeriod = null,
|
|
284
|
+
host,
|
|
285
|
+
maxCheckAttempts = 1,
|
|
286
|
+
name,
|
|
287
|
+
passiveCheckEnabled = true,
|
|
288
|
+
template = ''
|
|
289
|
+
}: Service): Cypress.Chainable => {
|
|
290
|
+
const serviceMaxCheckAttempts =
|
|
291
|
+
maxCheckAttempts === null ? '' : maxCheckAttempts;
|
|
292
|
+
const serviceActiveCheckEnabled = activeCheckEnabled ? 1 : 0;
|
|
293
|
+
const servicePassiveCheckEnabled = passiveCheckEnabled ? 1 : 0;
|
|
294
|
+
|
|
295
|
+
return cy
|
|
296
|
+
.executeActionViaClapi({
|
|
297
|
+
bodyContent: {
|
|
298
|
+
action: 'ADD',
|
|
299
|
+
object: 'SERVICE',
|
|
300
|
+
values: `${host};${name};${template}`
|
|
301
|
+
}
|
|
302
|
+
})
|
|
303
|
+
.then(() => {
|
|
304
|
+
const serviceParams = {
|
|
305
|
+
active_checks_enabled: serviceActiveCheckEnabled,
|
|
306
|
+
check_command: checkCommand,
|
|
307
|
+
check_period: checkPeriod,
|
|
308
|
+
max_check_attempts: serviceMaxCheckAttempts,
|
|
309
|
+
passive_checks_enabled: servicePassiveCheckEnabled
|
|
310
|
+
};
|
|
311
|
+
Object.entries(serviceParams).map(([paramName, paramValue]) => {
|
|
312
|
+
if (paramValue === null) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return cy.executeActionViaClapi({
|
|
317
|
+
bodyContent: {
|
|
318
|
+
action: 'SETPARAM',
|
|
319
|
+
object: 'SERVICE',
|
|
320
|
+
values: `${host};${name};${paramName};${paramValue}`
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
return cy.wrap(null);
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
);
|
|
329
|
+
|
|
330
|
+
Cypress.Commands.add(
|
|
331
|
+
'applyPollerConfiguration',
|
|
332
|
+
(pollerName = 'Central'): Cypress.Chainable => {
|
|
333
|
+
return cy.executeActionViaClapi({
|
|
334
|
+
bodyContent: {
|
|
335
|
+
action: 'APPLYCFG',
|
|
336
|
+
values: pollerName
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
);
|
|
341
|
+
|
|
342
|
+
declare global {
|
|
343
|
+
namespace Cypress {
|
|
344
|
+
interface Chainable {
|
|
345
|
+
addCheckCommand: (props: CheckCommand) => Cypress.Chainable;
|
|
346
|
+
addHost: (props: Host) => Cypress.Chainable;
|
|
347
|
+
addService: (props: Service) => Cypress.Chainable;
|
|
348
|
+
addServiceTemplate: (props: ServiceTemplate) => Cypress.Chainable;
|
|
349
|
+
addTimePeriod: (props: TimePeriod) => Cypress.Chainable;
|
|
350
|
+
applyPollerConfiguration: (props?: string) => Cypress.Chainable;
|
|
351
|
+
executeActionViaClapi: (
|
|
352
|
+
props: ExecuteActionViaClapiProps
|
|
353
|
+
) => Cypress.Chainable;
|
|
354
|
+
executeCommandsViaClapi: (fixtureFile: string) => Cypress.Chainable;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export {};
|
package/cypress/e2e/commands.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import './commands/configuration';
|
|
4
|
+
|
|
5
5
|
const apiLoginV2 = '/centreon/authentication/providers/configurations/local';
|
|
6
6
|
|
|
7
7
|
Cypress.Commands.add('getWebVersion', (): Cypress.Chainable => {
|
|
@@ -165,50 +165,6 @@ Cypress.Commands.add(
|
|
|
165
165
|
.visit('/waiting-page')
|
|
166
166
|
);
|
|
167
167
|
|
|
168
|
-
interface ActionClapi {
|
|
169
|
-
action: string;
|
|
170
|
-
object?: string;
|
|
171
|
-
values: string;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
interface ExecuteActionViaClapiProps {
|
|
175
|
-
bodyContent: ActionClapi;
|
|
176
|
-
method?: string;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
Cypress.Commands.add(
|
|
180
|
-
'executeActionViaClapi',
|
|
181
|
-
({
|
|
182
|
-
bodyContent,
|
|
183
|
-
method = 'POST'
|
|
184
|
-
}: ExecuteActionViaClapiProps): Cypress.Chainable => {
|
|
185
|
-
return cy.request({
|
|
186
|
-
body: bodyContent,
|
|
187
|
-
headers: {
|
|
188
|
-
'Content-Type': 'application/json',
|
|
189
|
-
'centreon-auth-token': window.localStorage.getItem('userTokenApiV1')
|
|
190
|
-
},
|
|
191
|
-
method,
|
|
192
|
-
url: `${apiActionV1}?action=action&object=centreon_clapi`
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
Cypress.Commands.add(
|
|
198
|
-
'executeCommandsViaClapi',
|
|
199
|
-
(fixtureFile: string): Cypress.Chainable => {
|
|
200
|
-
return cy.fixture(fixtureFile).then((listRequestConfig) => {
|
|
201
|
-
cy.wrap(
|
|
202
|
-
Promise.all(
|
|
203
|
-
listRequestConfig.map((request: ActionClapi) =>
|
|
204
|
-
cy.executeActionViaClapi({ bodyContent: request })
|
|
205
|
-
)
|
|
206
|
-
)
|
|
207
|
-
);
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
);
|
|
211
|
-
|
|
212
168
|
Cypress.Commands.add('waitForContainerAndSetToken', (): Cypress.Chainable => {
|
|
213
169
|
return cy.setUserTokenApiV1();
|
|
214
170
|
});
|
|
@@ -348,10 +304,6 @@ declare global {
|
|
|
348
304
|
command,
|
|
349
305
|
name
|
|
350
306
|
}: ExecInContainerProps) => Cypress.Chainable;
|
|
351
|
-
executeActionViaClapi: (
|
|
352
|
-
props: ExecuteActionViaClapiProps
|
|
353
|
-
) => Cypress.Chainable;
|
|
354
|
-
executeCommandsViaClapi: (fixtureFile: string) => Cypress.Chainable;
|
|
355
307
|
getIframeBody: () => Cypress.Chainable;
|
|
356
308
|
getWebVersion: () => Cypress.Chainable;
|
|
357
309
|
hoverRootMenuItem: (rootItemNumber: number) => Cypress.Chainable;
|
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.4.22-enhance-e2e-update-tests.
|
|
4
|
+
"version": "23.4.22-enhance-e2e-update-tests.2",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/centreon/centreon-frontend.git"
|