@centreon/js-config 23.10.1-update-oidc-tests.0 → 23.10.1-wait-on-task.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/e2e/commands.ts +9 -28
- package/cypress/e2e/plugins.ts +22 -0
- package/package.json +1 -1
- package/tsconfig/index.json +1 -0
package/cypress/e2e/commands.ts
CHANGED
|
@@ -143,7 +143,7 @@ interface LoginByTypeOfUserProps {
|
|
|
143
143
|
|
|
144
144
|
Cypress.Commands.add(
|
|
145
145
|
'loginByTypeOfUser',
|
|
146
|
-
({ jsonName, loginViaApi }): Cypress.Chainable => {
|
|
146
|
+
({ jsonName = 'admin', loginViaApi = false }): Cypress.Chainable => {
|
|
147
147
|
if (loginViaApi) {
|
|
148
148
|
return cy
|
|
149
149
|
.fixture(`users/${jsonName}.json`)
|
|
@@ -225,29 +225,7 @@ interface StartContainerProps {
|
|
|
225
225
|
Cypress.Commands.add(
|
|
226
226
|
'startContainer',
|
|
227
227
|
({ name, image, portBindings }: StartContainerProps): Cypress.Chainable => {
|
|
228
|
-
return cy
|
|
229
|
-
.exec('docker image list --format "{{.Repository}}:{{.Tag}}"')
|
|
230
|
-
.then(({ stdout }) => {
|
|
231
|
-
if (
|
|
232
|
-
stdout.match(
|
|
233
|
-
new RegExp(
|
|
234
|
-
`^${image.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')}`,
|
|
235
|
-
'm'
|
|
236
|
-
)
|
|
237
|
-
)
|
|
238
|
-
) {
|
|
239
|
-
cy.log(`Local docker image found : ${image}`);
|
|
240
|
-
|
|
241
|
-
return cy.wrap(image);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
cy.log(`Pulling remote docker image : ${image}`);
|
|
245
|
-
|
|
246
|
-
return cy.exec(`docker pull ${image}`).then(() => cy.wrap(image));
|
|
247
|
-
})
|
|
248
|
-
.then((imageName) =>
|
|
249
|
-
cy.task('startContainer', { image: imageName, name, portBindings })
|
|
250
|
-
);
|
|
228
|
+
return cy.task('startContainer', { image, name, portBindings });
|
|
251
229
|
}
|
|
252
230
|
);
|
|
253
231
|
|
|
@@ -270,6 +248,8 @@ Cypress.Commands.add(
|
|
|
270
248
|
|
|
271
249
|
const image = `docker.centreon.com/centreon/centreon-web${slimSuffix}-${os}:${version}`;
|
|
272
250
|
|
|
251
|
+
cy.setUserTokenApiV1();
|
|
252
|
+
|
|
273
253
|
return cy
|
|
274
254
|
.startContainer({
|
|
275
255
|
image,
|
|
@@ -281,8 +261,9 @@ Cypress.Commands.add(
|
|
|
281
261
|
|
|
282
262
|
Cypress.config('baseUrl', baseUrl);
|
|
283
263
|
|
|
284
|
-
return cy.
|
|
285
|
-
|
|
264
|
+
return cy.task(
|
|
265
|
+
'waitOn',
|
|
266
|
+
`${baseUrl}/centreon/api/latest/platform/installation/status`
|
|
286
267
|
);
|
|
287
268
|
})
|
|
288
269
|
.visit('/') // this is necessary to refresh browser cause baseUrl has changed (flash appears in video)
|
|
@@ -491,8 +472,8 @@ declare global {
|
|
|
491
472
|
insertDashboard: (dashboard: Dashboard) => Cypress.Chainable;
|
|
492
473
|
insertDashboardList: (fixtureFile: string) => Cypress.Chainable;
|
|
493
474
|
loginByTypeOfUser: ({
|
|
494
|
-
jsonName
|
|
495
|
-
loginViaApi
|
|
475
|
+
jsonName,
|
|
476
|
+
loginViaApi
|
|
496
477
|
}: LoginByTypeOfUserProps) => Cypress.Chainable;
|
|
497
478
|
moveSortableElement: (direction: string) => Cypress.Chainable;
|
|
498
479
|
navigateTo: ({
|
package/cypress/e2e/plugins.ts
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
4
4
|
/* eslint-disable no-param-reassign */
|
|
5
5
|
|
|
6
|
+
import { execSync } from 'child_process';
|
|
7
|
+
|
|
6
8
|
import Docker from 'dockerode';
|
|
7
9
|
import { addCucumberPreprocessorPlugin } from '@badeball/cypress-cucumber-preprocessor';
|
|
8
10
|
import webpackPreprocessor from '@cypress/webpack-preprocessor';
|
|
@@ -91,6 +93,21 @@ export default async (on, config): Promise<void> => {
|
|
|
91
93
|
name,
|
|
92
94
|
portBindings = []
|
|
93
95
|
}: StartContainerProps) => {
|
|
96
|
+
const imageList = execSync(
|
|
97
|
+
'docker image list --format "{{.Repository}}:{{.Tag}}"'
|
|
98
|
+
).toString('utf8');
|
|
99
|
+
|
|
100
|
+
if (
|
|
101
|
+
!imageList.match(
|
|
102
|
+
new RegExp(
|
|
103
|
+
`^${image.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')}`,
|
|
104
|
+
'm'
|
|
105
|
+
)
|
|
106
|
+
)
|
|
107
|
+
) {
|
|
108
|
+
execSync(`docker pull ${image}`);
|
|
109
|
+
}
|
|
110
|
+
|
|
94
111
|
const webContainers = await docker.listContainers({
|
|
95
112
|
all: true,
|
|
96
113
|
filters: { name: [name] }
|
|
@@ -136,6 +153,11 @@ export default async (on, config): Promise<void> => {
|
|
|
136
153
|
await container.kill();
|
|
137
154
|
await container.remove();
|
|
138
155
|
|
|
156
|
+
return null;
|
|
157
|
+
},
|
|
158
|
+
waitOn: async (url: string) => {
|
|
159
|
+
execSync(`npx wait-on ${url}`);
|
|
160
|
+
|
|
139
161
|
return null;
|
|
140
162
|
}
|
|
141
163
|
});
|
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-
|
|
4
|
+
"version": "23.10.1-wait-on-task.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/centreon/centreon-frontend.git"
|