@centreon/js-config 25.10.19 → 25.10.20

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.
@@ -22,15 +22,17 @@ Cypress.Commands.add(
22
22
  bodyContent,
23
23
  method = 'POST'
24
24
  }: ExecuteActionViaClapiProps): Cypress.Chainable => {
25
- return cy.request({
26
- body: bodyContent,
27
- headers: {
28
- 'Content-Type': 'application/json',
29
- 'centreon-auth-token': window.localStorage.getItem('userTokenApiV1')
30
- },
31
- method,
32
- url: `${apiActionV1}?action=action&object=centreon_clapi`
33
- });
25
+ return cy.ensureUserTokenApiV1().then(() =>
26
+ cy.request({
27
+ body: bodyContent,
28
+ headers: {
29
+ 'Content-Type': 'application/json',
30
+ 'centreon-auth-token': window.localStorage.getItem('userTokenApiV1')
31
+ },
32
+ method,
33
+ url: `${apiActionV1}?action=action&object=centreon_clapi`
34
+ })
35
+ );
34
36
  }
35
37
  );
36
38
 
@@ -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
 
@@ -418,6 +418,16 @@ Cypress.Commands.add(
418
418
  }
419
419
  );
420
420
 
421
+ // The token is set once in the feature's before(), so it is missing when a
422
+ // test is retried: get it again only in that case.
423
+ Cypress.Commands.add('ensureUserTokenApiV1', (): Cypress.Chainable => {
424
+ if (window.localStorage.getItem('userTokenApiV1')) {
425
+ return cy.wrap(null);
426
+ }
427
+
428
+ return cy.setUserTokenApiV1();
429
+ });
430
+
421
431
  interface PortBinding {
422
432
  destination: number;
423
433
  source: number;
@@ -912,6 +922,7 @@ declare global {
912
922
  ) => Cypress.Chainable;
913
923
  copyWebContainerLogs: (props: CopyWebContainerLogsProps) => Cypress.Chainable;
914
924
  createDirectory: (directoryPath: string) => Cypress.Chainable;
925
+ ensureUserTokenApiV1: () => Cypress.Chainable;
915
926
  execInContainer: (
916
927
  props: ExecInContainerProps,
917
928
  options?: ExecInContainerOptions
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": "25.10.19",
4
+ "version": "25.10.20",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon.git"