@centreon/js-config 26.9.0 → 26.10.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.
@@ -24,16 +24,18 @@ Cypress.Commands.add(
24
24
  method = 'POST',
25
25
  failOnError = true
26
26
  }: ExecuteActionViaClapiProps): Cypress.Chainable => {
27
- return cy.request({
28
- body: bodyContent,
29
- failOnStatusCode: failOnError,
30
- headers: {
31
- 'Content-Type': 'application/json',
32
- 'centreon-auth-token': window.localStorage.getItem('userTokenApiV1')
33
- },
34
- method,
35
- url: `${apiActionV1}?action=action&object=centreon_clapi`
36
- });
27
+ return cy.ensureUserTokenApiV1().then(() =>
28
+ cy.request({
29
+ body: bodyContent,
30
+ failOnStatusCode: failOnError,
31
+ headers: {
32
+ 'Content-Type': 'application/json',
33
+ 'centreon-auth-token': window.localStorage.getItem('userTokenApiV1')
34
+ },
35
+ method,
36
+ url: `${apiActionV1}?action=action&object=centreon_clapi`
37
+ })
38
+ );
37
39
  }
38
40
  );
39
41
 
@@ -150,17 +150,20 @@ Cypress.Commands.add(
150
150
  updatetime
151
151
  };
152
152
 
153
- cy.request({
154
- body: {
155
- results: [result]
156
- },
157
- headers: {
158
- 'Content-Type': 'application/json',
159
- 'centreon-auth-token': window.localStorage.getItem('userTokenApiV1')
160
- },
161
- method: 'POST',
162
- url: `${apiActionV1}?action=submit&object=centreon_submit_results`
163
- });
153
+ cy.ensureUserTokenApiV1().then(() =>
154
+ cy.request({
155
+ body: {
156
+ results: [result]
157
+ },
158
+ headers: {
159
+ 'Content-Type': 'application/json',
160
+ 'centreon-auth-token':
161
+ window.localStorage.getItem('userTokenApiV1')
162
+ },
163
+ method: 'POST',
164
+ url: `${apiActionV1}?action=submit&object=centreon_submit_results`
165
+ })
166
+ );
164
167
  }
165
168
  );
166
169
 
@@ -499,6 +499,16 @@ Cypress.Commands.add(
499
499
  }
500
500
  );
501
501
 
502
+ // The token is set once in the feature's before(), so it is missing when a
503
+ // test is retried: get it again only in that case.
504
+ Cypress.Commands.add('ensureUserTokenApiV1', (): Cypress.Chainable => {
505
+ if (window.localStorage.getItem('userTokenApiV1')) {
506
+ return cy.wrap(null);
507
+ }
508
+
509
+ return cy.setUserTokenApiV1();
510
+ });
511
+
502
512
  interface PortBinding {
503
513
  destination: number;
504
514
  source: number;
@@ -532,6 +542,8 @@ Cypress.Commands.add(
532
542
  interface StartContainersProps {
533
543
  composeFile?: string;
534
544
  databaseImage?: string;
545
+ dbConfiguration?: string;
546
+ dbStorage?: string;
535
547
  moduleName?: string;
536
548
  openidImage?: string;
537
549
  profiles?: Array<string>;
@@ -546,6 +558,8 @@ Cypress.Commands.add(
546
558
  ({
547
559
  composeFile,
548
560
  databaseImage = Cypress.env('DATABASE_IMAGE'),
561
+ dbConfiguration = Cypress.env('MYSQL_DB_CONFIGURATION'),
562
+ dbStorage = Cypress.env('MYSQL_DB_STORAGE'),
549
563
  moduleName = 'centreon-web',
550
564
  openidImage = `ghcr.io/centreon/centreon/keycloak:${Cypress.env(
551
565
  'OPENID_IMAGE_VERSION'
@@ -579,6 +593,8 @@ Cypress.Commands.add(
579
593
  {
580
594
  composeFile: composeFilePath,
581
595
  databaseImage,
596
+ dbConfiguration,
597
+ dbStorage,
582
598
  openidImage,
583
599
  profiles,
584
600
  samlImage,
@@ -994,6 +1010,7 @@ declare global {
994
1010
  ) => Cypress.Chainable;
995
1011
  copyWebContainerLogs: (props: CopyWebContainerLogsProps) => Cypress.Chainable;
996
1012
  createDirectory: (directoryPath: string) => Cypress.Chainable;
1013
+ ensureUserTokenApiV1: () => Cypress.Chainable;
997
1014
  execInContainer: (
998
1015
  props: ExecInContainerProps,
999
1016
  options?: ExecInContainerOptions
@@ -210,6 +210,8 @@ export default (on: Cypress.PluginEvents): void => {
210
210
  startContainers: async ({
211
211
  composeFile,
212
212
  databaseImage,
213
+ dbConfiguration,
214
+ dbStorage,
213
215
  openidImage,
214
216
  profiles,
215
217
  samlImage,
@@ -219,16 +221,24 @@ export default (on: Cypress.PluginEvents): void => {
219
221
  const composeFileDir = path.dirname(composeFile);
220
222
  const composeFileName = path.basename(composeFile);
221
223
 
224
+ const environment: Record<string, string> = {
225
+ MYSQL_IMAGE: databaseImage,
226
+ OPENID_IMAGE: openidImage,
227
+ SAML_IMAGE: samlImage,
228
+ WEB_IMAGE: webImage,
229
+ };
230
+ if (dbConfiguration) {
231
+ environment.MYSQL_DB_CONFIGURATION = dbConfiguration;
232
+ }
233
+ if (dbStorage) {
234
+ environment.MYSQL_DB_STORAGE = dbStorage;
235
+ }
236
+
222
237
  dockerEnvironment = await new DockerComposeEnvironment(
223
238
  composeFileDir,
224
239
  composeFileName,
225
240
  )
226
- .withEnvironment({
227
- MYSQL_IMAGE: databaseImage,
228
- OPENID_IMAGE: openidImage,
229
- SAML_IMAGE: samlImage,
230
- WEB_IMAGE: webImage,
231
- })
241
+ .withEnvironment(environment)
232
242
  .withProfiles(...profiles)
233
243
  .withStartupTimeout(900_000) // 15 minutes
234
244
  .withWaitStrategy(
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": "26.9.0",
4
+ "version": "26.10.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon.git"