@centreon/js-config 26.1.0 → 26.1.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.
|
@@ -14,16 +14,19 @@ interface ActionClapi {
|
|
|
14
14
|
interface ExecuteActionViaClapiProps {
|
|
15
15
|
bodyContent: ActionClapi;
|
|
16
16
|
method?: string;
|
|
17
|
+
failOnError?: boolean;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
Cypress.Commands.add(
|
|
20
21
|
'executeActionViaClapi',
|
|
21
22
|
({
|
|
22
23
|
bodyContent,
|
|
23
|
-
method = 'POST'
|
|
24
|
+
method = 'POST',
|
|
25
|
+
failOnError = true
|
|
24
26
|
}: ExecuteActionViaClapiProps): Cypress.Chainable => {
|
|
25
27
|
return cy.request({
|
|
26
28
|
body: bodyContent,
|
|
29
|
+
failOnStatusCode: failOnError,
|
|
27
30
|
headers: {
|
|
28
31
|
'Content-Type': 'application/json',
|
|
29
32
|
'centreon-auth-token': window.localStorage.getItem('userTokenApiV1')
|
package/cypress/e2e/commands.ts
CHANGED
|
@@ -74,13 +74,89 @@ Cypress.Commands.add('getWebVersion', (): Cypress.Chainable => {
|
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
Cypress.Commands.add(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
})
|
|
77
|
+
Cypress.Commands.add(
|
|
78
|
+
'getIframeBody',
|
|
79
|
+
(iframeSelector = 'iframe#main-content'): Cypress.Chainable<JQuery<HTMLElement>> => {
|
|
80
|
+
return cy.waitUntil(
|
|
81
|
+
() =>
|
|
82
|
+
cy
|
|
83
|
+
.get<HTMLIFrameElement>(iframeSelector, { log: false })
|
|
84
|
+
.then($iframe => {
|
|
85
|
+
const doc = $iframe[0].contentDocument;
|
|
86
|
+
|
|
87
|
+
return Boolean(
|
|
88
|
+
doc &&
|
|
89
|
+
doc.readyState === 'complete' &&
|
|
90
|
+
doc.body &&
|
|
91
|
+
doc.body.children.length > 0
|
|
92
|
+
);
|
|
93
|
+
}),
|
|
94
|
+
{
|
|
95
|
+
timeout: 20000,
|
|
96
|
+
interval: 200,
|
|
97
|
+
errorMsg: 'Iframe not fully loaded (readyState !== complete)',
|
|
98
|
+
}
|
|
99
|
+
).then(() => {
|
|
100
|
+
return cy
|
|
101
|
+
.get<HTMLIFrameElement>(iframeSelector)
|
|
102
|
+
.then($iframe => {
|
|
103
|
+
const body = $iframe[0].contentDocument!.body;
|
|
104
|
+
return cy.wrap(body);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
Cypress.Commands.add(
|
|
111
|
+
'waitForElementInIframe',
|
|
112
|
+
(iframeSelector, elementSelector) => {
|
|
113
|
+
cy.waitUntil(
|
|
114
|
+
() =>
|
|
115
|
+
cy
|
|
116
|
+
.get(iframeSelector)
|
|
117
|
+
.its('0.contentDocument.body')
|
|
118
|
+
.should('not.be.empty')
|
|
119
|
+
.then(cy.wrap)
|
|
120
|
+
.within(() => {
|
|
121
|
+
const element = Cypress.$(elementSelector);
|
|
122
|
+
|
|
123
|
+
return element.length > 0 && element.is(':visible');
|
|
124
|
+
}),
|
|
125
|
+
{
|
|
126
|
+
errorMsg: 'The element is not visible',
|
|
127
|
+
interval: 5000,
|
|
128
|
+
timeout: 100000
|
|
129
|
+
}
|
|
130
|
+
).then((isVisible) => {
|
|
131
|
+
if (!isVisible) {
|
|
132
|
+
throw new Error('The element is not visible');
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
Cypress.Commands.add(
|
|
139
|
+
'waitForElementToBeVisible',
|
|
140
|
+
(selector, timeout = 50000, interval = 2000) => {
|
|
141
|
+
cy.waitUntil(
|
|
142
|
+
() =>
|
|
143
|
+
cy.get('body').then(($body) => {
|
|
144
|
+
const element = $body.find(selector);
|
|
145
|
+
|
|
146
|
+
return element.length > 0 && element.is(':visible');
|
|
147
|
+
}),
|
|
148
|
+
{
|
|
149
|
+
errorMsg: `The element '${selector}' is not visible`,
|
|
150
|
+
interval,
|
|
151
|
+
timeout
|
|
152
|
+
}
|
|
153
|
+
).then((isVisible) => {
|
|
154
|
+
if (!isVisible) {
|
|
155
|
+
throw new Error(`The element '${selector}' is not visible`);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
);
|
|
84
160
|
|
|
85
161
|
Cypress.Commands.add(
|
|
86
162
|
'hoverRootMenuItem',
|
|
@@ -259,7 +335,7 @@ Cypress.Commands.add(
|
|
|
259
335
|
cy.getByLabel({ label: 'Alias', tag: 'input' }).type(
|
|
260
336
|
`{selectAll}{backspace}${credential.login}`
|
|
261
337
|
);
|
|
262
|
-
cy.
|
|
338
|
+
cy.get('input[type="password"]').type(
|
|
263
339
|
`{selectAll}{backspace}${credential.password}`
|
|
264
340
|
);
|
|
265
341
|
})
|
|
@@ -301,9 +377,14 @@ Cypress.Commands.add('logout', (): void => {
|
|
|
301
377
|
cy.clearAllCookies();
|
|
302
378
|
});
|
|
303
379
|
|
|
304
|
-
|
|
380
|
+
interface LogoutViaAPIProps {
|
|
381
|
+
failOnError?: boolean;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
Cypress.Commands.add('logoutViaAPI', ({ failOnError = true }: LogoutViaAPIProps = {}): Cypress.Chainable => {
|
|
305
385
|
return cy
|
|
306
386
|
.request({
|
|
387
|
+
failOnStatusCode: failOnError,
|
|
307
388
|
method: 'GET',
|
|
308
389
|
url: '/centreon/authentication/logout'
|
|
309
390
|
})
|
|
@@ -488,8 +569,11 @@ Cypress.Commands.add(
|
|
|
488
569
|
|
|
489
570
|
const webImage = `docker.centreon.com/centreon/${moduleName}${slimSuffix}-${webOs}:${webVersion}`;
|
|
490
571
|
|
|
491
|
-
|
|
492
|
-
|
|
572
|
+
const timeout = 1200_000; // 20 minutes because docker pull can be very slow (mainly keycloak)
|
|
573
|
+
const cypressTaskTimeout = Cypress.config('taskTimeout') || 600_000;
|
|
574
|
+
Cypress.config('taskTimeout', timeout);
|
|
575
|
+
|
|
576
|
+
cy.task(
|
|
493
577
|
'startContainers',
|
|
494
578
|
{
|
|
495
579
|
composeFile: composeFilePath,
|
|
@@ -499,7 +583,7 @@ Cypress.Commands.add(
|
|
|
499
583
|
samlImage,
|
|
500
584
|
webImage
|
|
501
585
|
},
|
|
502
|
-
{ timeout
|
|
586
|
+
{ timeout }
|
|
503
587
|
)
|
|
504
588
|
.then(() => {
|
|
505
589
|
const baseUrl = 'http://127.0.0.1:4000';
|
|
@@ -510,6 +594,10 @@ Cypress.Commands.add(
|
|
|
510
594
|
})
|
|
511
595
|
.visit('/') // this is necessary to refresh browser cause baseUrl has changed (flash appears in video)
|
|
512
596
|
.setUserTokenApiV1();
|
|
597
|
+
|
|
598
|
+
Cypress.config('taskTimeout', cypressTaskTimeout);
|
|
599
|
+
|
|
600
|
+
return cy.wrap(null);
|
|
513
601
|
}
|
|
514
602
|
);
|
|
515
603
|
|
|
@@ -923,7 +1011,7 @@ declare global {
|
|
|
923
1011
|
getContainerIpAddress: (containerName: string) => Cypress.Chainable;
|
|
924
1012
|
getContainersLogs: () => Cypress.Chainable;
|
|
925
1013
|
getContainerMappedPort: (containerName: string, containerPort: number) => Cypress.Chainable;
|
|
926
|
-
getIframeBody: () => Cypress.Chainable;
|
|
1014
|
+
getIframeBody: (iframeSelector?: string) => Cypress.Chainable;
|
|
927
1015
|
getLogDirectory: () => Cypress.Chainable;
|
|
928
1016
|
getTimeFromHeader: () => Cypress.Chainable;
|
|
929
1017
|
getWebVersion: () => Cypress.Chainable;
|
|
@@ -949,7 +1037,7 @@ declare global {
|
|
|
949
1037
|
loginViaApi
|
|
950
1038
|
}: LoginByTypeOfUserProps) => Cypress.Chainable;
|
|
951
1039
|
logout: () => void;
|
|
952
|
-
logoutViaAPI: () => Cypress.Chainable;
|
|
1040
|
+
logoutViaAPI: (props?: LogoutViaAPIProps) => Cypress.Chainable;
|
|
953
1041
|
moveSortableElement: (direction: string) => Cypress.Chainable;
|
|
954
1042
|
navigateTo: ({
|
|
955
1043
|
page,
|
|
@@ -988,6 +1076,15 @@ declare global {
|
|
|
988
1076
|
stopContainer: ({ name }: StopContainerProps) => Cypress.Chainable;
|
|
989
1077
|
stopContainers: () => Cypress.Chainable;
|
|
990
1078
|
visitEmptyPage: () => Cypress.Chainable;
|
|
1079
|
+
waitForElementInIframe: (
|
|
1080
|
+
iframeSelector: string,
|
|
1081
|
+
elementSelector: string
|
|
1082
|
+
) => Cypress.Chainable;
|
|
1083
|
+
waitForElementToBeVisible(
|
|
1084
|
+
selector: string,
|
|
1085
|
+
timeout?: number,
|
|
1086
|
+
interval?: number
|
|
1087
|
+
): Cypress.Chainable;
|
|
991
1088
|
}
|
|
992
1089
|
}
|
|
993
1090
|
}
|
package/cypress/e2e/tasks.ts
CHANGED
|
@@ -226,7 +226,7 @@ export default (on: Cypress.PluginEvents): void => {
|
|
|
226
226
|
WEB_IMAGE: webImage,
|
|
227
227
|
})
|
|
228
228
|
.withProfiles(...profiles)
|
|
229
|
-
.withStartupTimeout(
|
|
229
|
+
.withStartupTimeout(900_000) // 15 minutes
|
|
230
230
|
.withWaitStrategy(
|
|
231
231
|
"web-1",
|
|
232
232
|
Wait.forAll([
|
|
@@ -238,9 +238,7 @@ export default (on: Cypress.PluginEvents): void => {
|
|
|
238
238
|
|
|
239
239
|
return null;
|
|
240
240
|
} catch (error) {
|
|
241
|
-
|
|
242
|
-
console.error(error.message);
|
|
243
|
-
}
|
|
241
|
+
console.error(error);
|
|
244
242
|
|
|
245
243
|
throw error;
|
|
246
244
|
}
|
package/package.json
CHANGED