@centreon/js-config 23.10.1-update-oidc-tests.1 → 23.10.1-wait-on-task.1
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 +7 -28
- package/cypress/e2e/plugins.ts +30 -37
- package/package.json +5 -3
- 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
|
|
|
@@ -281,8 +259,9 @@ Cypress.Commands.add(
|
|
|
281
259
|
|
|
282
260
|
Cypress.config('baseUrl', baseUrl);
|
|
283
261
|
|
|
284
|
-
return cy.
|
|
285
|
-
|
|
262
|
+
return cy.task(
|
|
263
|
+
'waitOn',
|
|
264
|
+
`${baseUrl}/centreon/api/latest/platform/installation/status`
|
|
286
265
|
);
|
|
287
266
|
})
|
|
288
267
|
.visit('/') // this is necessary to refresh browser cause baseUrl has changed (flash appears in video)
|
|
@@ -491,8 +470,8 @@ declare global {
|
|
|
491
470
|
insertDashboard: (dashboard: Dashboard) => Cypress.Chainable;
|
|
492
471
|
insertDashboardList: (fixtureFile: string) => Cypress.Chainable;
|
|
493
472
|
loginByTypeOfUser: ({
|
|
494
|
-
jsonName
|
|
495
|
-
loginViaApi
|
|
473
|
+
jsonName,
|
|
474
|
+
loginViaApi
|
|
496
475
|
}: LoginByTypeOfUserProps) => Cypress.Chainable;
|
|
497
476
|
moveSortableElement: (direction: string) => Cypress.Chainable;
|
|
498
477
|
navigateTo: ({
|
package/cypress/e2e/plugins.ts
CHANGED
|
@@ -3,51 +3,24 @@
|
|
|
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
|
-
import
|
|
10
|
+
import createBundler from '@bahmutov/cypress-esbuild-preprocessor';
|
|
11
|
+
import createEsbuildPlugin from '@badeball/cypress-cucumber-preprocessor/esbuild';
|
|
9
12
|
|
|
10
13
|
const docker = new Docker();
|
|
11
14
|
|
|
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
15
|
export default async (on, config): Promise<void> => {
|
|
43
16
|
await addCucumberPreprocessorPlugin(on, config);
|
|
44
17
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
18
|
+
on(
|
|
19
|
+
'file:preprocessor',
|
|
20
|
+
createBundler({
|
|
21
|
+
plugins: [createEsbuildPlugin(config)]
|
|
22
|
+
})
|
|
23
|
+
);
|
|
51
24
|
|
|
52
25
|
on('before:browser:launch', (browser = {}, launchOptions) => {
|
|
53
26
|
const width = 1920;
|
|
@@ -91,6 +64,21 @@ export default async (on, config): Promise<void> => {
|
|
|
91
64
|
name,
|
|
92
65
|
portBindings = []
|
|
93
66
|
}: StartContainerProps) => {
|
|
67
|
+
const imageList = execSync(
|
|
68
|
+
'docker image list --format "{{.Repository}}:{{.Tag}}"'
|
|
69
|
+
).toString('utf8');
|
|
70
|
+
|
|
71
|
+
if (
|
|
72
|
+
!imageList.match(
|
|
73
|
+
new RegExp(
|
|
74
|
+
`^${image.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')}`,
|
|
75
|
+
'm'
|
|
76
|
+
)
|
|
77
|
+
)
|
|
78
|
+
) {
|
|
79
|
+
execSync(`docker pull ${image}`);
|
|
80
|
+
}
|
|
81
|
+
|
|
94
82
|
const webContainers = await docker.listContainers({
|
|
95
83
|
all: true,
|
|
96
84
|
filters: { name: [name] }
|
|
@@ -136,6 +124,11 @@ export default async (on, config): Promise<void> => {
|
|
|
136
124
|
await container.kill();
|
|
137
125
|
await container.remove();
|
|
138
126
|
|
|
127
|
+
return null;
|
|
128
|
+
},
|
|
129
|
+
waitOn: async (url: string) => {
|
|
130
|
+
execSync(`npx wait-on ${url}`);
|
|
131
|
+
|
|
139
132
|
return null;
|
|
140
133
|
}
|
|
141
134
|
});
|
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.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/centreon/centreon-frontend.git"
|
|
@@ -16,9 +16,11 @@
|
|
|
16
16
|
"url": "https://github.com/centreon/centreon-frontend/issues"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@badeball/cypress-cucumber-preprocessor": "^
|
|
19
|
+
"@badeball/cypress-cucumber-preprocessor": "^18.0.5",
|
|
20
|
+
"@bahmutov/cypress-esbuild-preprocessor": "^2.2.0",
|
|
20
21
|
"@tsconfig/node16": "^1.0.4",
|
|
21
|
-
"@types/
|
|
22
|
+
"@types/cypress-cucumber-preprocessor": "^4.0.2",
|
|
23
|
+
"@types/dockerode": "^3.3.19",
|
|
22
24
|
"dockerode": "^3.3.5",
|
|
23
25
|
"eslint": "^8.17.0",
|
|
24
26
|
"eslint-config-airbnb": "19.0.4",
|