@centreon/js-config 23.10.1-MON-20421-docker-cache.21 → 23.10.1-MON-20507-dashboard-permissions-e2e-tests.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.
@@ -13,7 +13,7 @@ const enableVisualTesting = (cypressFolder = 'cypress'): void => {
13
13
  capture: 'viewport',
14
14
  customDiffConfig: { threshold: 0.01 },
15
15
  customSnapshotsDir: `${cypressFolder}/visual-testing-snapshots`,
16
- failureThreshold: 0.07,
16
+ failureThreshold: 0.06,
17
17
  failureThresholdType: 'percent'
18
18
  });
19
19
  };
@@ -216,28 +216,10 @@ Cypress.Commands.add(
216
216
  'startContainer',
217
217
  ({ name, image, portBindings }: StartContainerProps): Cypress.Chainable => {
218
218
  return cy
219
- .exec('docker image list --format "{{.Repository}}:{{.Tag}}"')
220
- .then(({ stdout }) => {
221
- if (
222
- stdout.match(
223
- new RegExp(
224
- `^${image.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')}`,
225
- 'm'
226
- )
227
- )
228
- ) {
229
- cy.log(`Local docker image found : ${image}`);
230
-
231
- return cy.wrap(image);
232
- }
233
-
234
- cy.log(`Pulling remote docker image : ${image}`);
235
-
236
- return cy.exec(`docker pull ${image}`).then(() => cy.wrap(image));
219
+ .exec(`docker image inspect ${image} || docker pull ${image}`, {
220
+ timeout: 120000
237
221
  })
238
- .then((imageName) =>
239
- cy.task('startContainer', { image: imageName, name, portBindings })
240
- );
222
+ .task('startContainer', { image, name, portBindings });
241
223
  }
242
224
  );
243
225
 
@@ -391,6 +373,40 @@ Cypress.Commands.add(
391
373
  }
392
374
  );
393
375
 
376
+ interface ShareDashboardToUserProps {
377
+ dashboardName: string;
378
+ role: string;
379
+ userName: string;
380
+ }
381
+
382
+ Cypress.Commands.add(
383
+ 'shareDashboardToUser',
384
+ ({ dashboardName, userName, role }: ShareDashboardToUserProps): void => {
385
+ Promise.all([
386
+ cy.request({
387
+ method: 'GET',
388
+ url: `/centreon/api/latest/configuration/users?search={"name":"${userName}"}`
389
+ }),
390
+ cy.request({
391
+ method: 'GET',
392
+ url: `/centreon/api/latest/configuration/dashboards?search={"name":"${dashboardName}"}`
393
+ })
394
+ ]).then(([retrievedUser, retrievedDashboard]) => {
395
+ const userId = retrievedUser.body.result[0].id;
396
+ const dashboardId = retrievedDashboard.body.result[0].id;
397
+
398
+ cy.request({
399
+ body: {
400
+ id: userId,
401
+ role: `${role}`
402
+ },
403
+ method: 'POST',
404
+ url: `/centreon/api/latest/configuration/dashboards/${dashboardId}/access_rights/contacts`
405
+ });
406
+ });
407
+ }
408
+ );
409
+
394
410
  Cypress.Commands.add('getTimeFromHeader', (): Cypress.Chainable => {
395
411
  return cy.waitUntil(() => {
396
412
  return cy.get('header div[data-cy="clock"]').then(($time) => {
@@ -430,6 +446,11 @@ declare global {
430
446
  rootItemNumber,
431
447
  subMenu
432
448
  }: NavigateToProps) => Cypress.Chainable;
449
+ shareDashboardToUser: ({
450
+ dashboardName,
451
+ userName,
452
+ role
453
+ }: ShareDashboardToUserProps) => Cypress.Chainable;
433
454
  startContainer: ({
434
455
  name,
435
456
  image
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-MON-20421-docker-cache.21",
4
+ "version": "23.10.1-MON-20507-dashboard-permissions-e2e-tests.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon-frontend.git"