@centreon/js-config 24.10.20 → 24.10.21

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
 
@@ -417,6 +417,16 @@ Cypress.Commands.add(
417
417
  }
418
418
  );
419
419
 
420
+ // The token is set once in the feature's before(), so it is missing when a
421
+ // test is retried: get it again only in that case.
422
+ Cypress.Commands.add('ensureUserTokenApiV1', (): Cypress.Chainable => {
423
+ if (window.localStorage.getItem('userTokenApiV1')) {
424
+ return cy.wrap(null);
425
+ }
426
+
427
+ return cy.setUserTokenApiV1();
428
+ });
429
+
420
430
  interface PortBinding {
421
431
  destination: number;
422
432
  source: number;
@@ -911,6 +921,7 @@ declare global {
911
921
  ) => Cypress.Chainable;
912
922
  copyWebContainerLogs: (props: CopyWebContainerLogsProps) => Cypress.Chainable;
913
923
  createDirectory: (directoryPath: string) => Cypress.Chainable;
924
+ ensureUserTokenApiV1: () => Cypress.Chainable;
914
925
  execInContainer: (
915
926
  props: ExecInContainerProps,
916
927
  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": "24.10.20",
4
+ "version": "24.10.21",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon.git"