@centreon/js-config 24.4.27 → 24.4.29

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.
@@ -18,15 +18,6 @@ interface MountProps {
18
18
  Component: React.ReactNode;
19
19
  options?: object;
20
20
  }
21
- interface Resolution {
22
- height: number;
23
- width: number;
24
- }
25
-
26
- interface MakeSnapshotWithCustomResolution {
27
- resolution: Resolution;
28
- title: string;
29
- }
30
21
 
31
22
  export enum Method {
32
23
  DELETE = 'DELETE',
@@ -106,32 +97,20 @@ Cypress.Commands.add(
106
97
  }
107
98
  );
108
99
 
109
- interface MoveSortableElementProps {
110
- direction: 'up' | 'down' | 'left' | 'right';
111
- element: Cypress.Chainable<JQuery<HTMLElement>>;
112
- times?: number;
113
- }
114
-
115
- Cypress.Commands.add(
116
- 'moveSortableElement',
117
- ({ element, direction, times = 1 }: MoveSortableElementProps): void => {
118
- const key = `{${direction}arrow}`;
119
-
120
- element.type(' ', {
121
- force: true,
122
- scrollBehavior: false
123
- });
100
+ Cypress.Commands.add('moveSortableElement', ({ element, direction }): void => {
101
+ const key = `{${direction}arrow}`;
124
102
 
125
- Array.from({ length: times }).forEach(() => {
126
- element.eq(-1).type(key, {
127
- scrollBehavior: false
128
- });
129
- });
130
- element.eq(-1).type(' ', {
131
- scrollBehavior: false
132
- });
133
- }
134
- );
103
+ element.type(' ', {
104
+ force: true,
105
+ scrollBehavior: false
106
+ });
107
+ element.eq(-1).type(key, {
108
+ scrollBehavior: false
109
+ });
110
+ element.eq(-1).type(' ', {
111
+ scrollBehavior: false
112
+ });
113
+ });
135
114
 
136
115
  Cypress.Commands.add(
137
116
  'moveSortableElementUsingAriaLabel',
@@ -158,15 +137,6 @@ Cypress.Commands.add('makeSnapshot', (title?: string) => {
158
137
  cy.matchImageSnapshot(title);
159
138
  });
160
139
 
161
- Cypress.Commands.add(
162
- 'makeSnapshotWithCustomResolution',
163
- ({ title, resolution }: MakeSnapshotWithCustomResolution) => {
164
- const { width, height } = resolution;
165
- cy.viewport(width, height);
166
- cy.matchImageSnapshot(title);
167
- }
168
- );
169
-
170
140
  Cypress.Commands.add('cssDisableMotion', (): void => {
171
141
  Cypress.on('window:before:load', (cyWindow) => {
172
142
  disableMotion(cyWindow);
@@ -178,22 +148,13 @@ declare global {
178
148
  interface Chainable {
179
149
  adjustViewport: () => Cypress.Chainable;
180
150
  cssDisableMotion: () => Cypress.Chainable;
181
- getRequestCalls: (alias) => Cypress.Chainable;
182
151
  interceptAPIRequest: <T extends object>(
183
152
  props: InterceptAPIRequestProps<T>
184
153
  ) => Cypress.Chainable;
185
154
  interceptRequest: (method, path, mock, alias) => Cypress.Chainable;
186
155
  makeSnapshot: (title?: string) => void;
187
- makeSnapshotWithCustomResolution: ({
188
- title,
189
- resolution
190
- }: MakeSnapshotWithCustomResolution) => Cypress.Chainable;
191
156
  mount: ({ Component, options }: MountProps) => Cypress.Chainable;
192
- moveSortableElement: ({
193
- element,
194
- direction,
195
- times
196
- }: MoveSortableElementProps) => void;
157
+ moveSortableElement: ({ element, direction }) => void;
197
158
  moveSortableElementUsingAriaLabel: ({ ariaLabel, direction }) => void;
198
159
  waitForRequest: (alias) => Cypress.Chainable;
199
160
  }
@@ -3,7 +3,6 @@ const { defineConfig } = require('cypress');
3
3
  const {
4
4
  addMatchImageSnapshotPlugin
5
5
  } = require('@simonsmith/cypress-image-snapshot/plugin');
6
- const cypressCodeCoverageTask = require('@cypress/code-coverage/task');
7
6
 
8
7
  module.exports = ({
9
8
  webpackConfig,
@@ -26,12 +25,9 @@ module.exports = ({
26
25
  setupNodeEvents: (on, config) => {
27
26
  addMatchImageSnapshotPlugin(on, config);
28
27
 
29
- cypressCodeCoverageTask(on, config);
30
-
31
28
  on('before:browser:launch', (browser, launchOptions) => {
32
29
  if (browser.name === 'chrome' && browser.isHeadless) {
33
30
  launchOptions.args.push('--headless=new');
34
- launchOptions.args.push('--force-color-profile=srgb');
35
31
  }
36
32
 
37
33
  return launchOptions;
@@ -41,17 +37,8 @@ module.exports = ({
41
37
  supportFile: `${mainCypressFolder}/support/component.tsx`
42
38
  },
43
39
  env: {
44
- baseUrl: 'http://localhost:9092',
45
- codeCoverage: {
46
- exclude: [
47
- 'cypress/**/*.*',
48
- 'packages/**',
49
- 'node_modules',
50
- '**/*.js',
51
- '**/*.spec.tsx'
52
- ]
53
- },
54
- ...env
40
+ ...env,
41
+ baseUrl: 'http://localhost:9092'
55
42
  },
56
43
  reporter: 'mochawesome',
57
44
  reporterOptions: {
@@ -1,7 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-namespace */
2
2
 
3
- import { Action } from 'e2e/features/ACLs/commands';
4
-
5
3
  const apiBase = '/centreon/api';
6
4
  const apiActionV1 = `${apiBase}/index.php`;
7
5
 
@@ -140,102 +138,6 @@ Cypress.Commands.add(
140
138
  }
141
139
  );
142
140
 
143
- interface Contact {
144
- admin?: boolean;
145
- alias?: string | null;
146
- authenticationType?: 'local' | 'ldap';
147
- email: string;
148
- enableNotifications?: boolean;
149
- GUIAccess?: boolean;
150
- language?: string;
151
- name: string;
152
- password: string;
153
- }
154
-
155
- Cypress.Commands.add(
156
- 'addContact',
157
- ({
158
- admin = true,
159
- alias = null,
160
- authenticationType = 'local',
161
- email,
162
- enableNotifications = true,
163
- GUIAccess = true,
164
- language = 'en_US',
165
- name,
166
- password
167
- }: Contact): Cypress.Chainable => {
168
- const contactAdmin = admin ? 1 : 0;
169
- const contactAlias = alias === null ? name : alias;
170
- const contactEnableNotifications = enableNotifications ? 1 : 0;
171
- const contactGUIAccess = GUIAccess ? 1 : 0;
172
-
173
- return cy
174
- .executeActionViaClapi({
175
- bodyContent: {
176
- action: 'ADD',
177
- object: 'CONTACT',
178
- values: `${name};${contactAlias};${email};${password};${contactAdmin};${contactGUIAccess};${language};${authenticationType}`
179
- }
180
- })
181
- .then(() => {
182
- const contactParams = {
183
- enable_notifications: contactEnableNotifications
184
- };
185
- Object.entries(contactParams).map(([paramName, paramValue]) => {
186
- if (paramValue === null) {
187
- return null;
188
- }
189
-
190
- return cy.executeActionViaClapi({
191
- bodyContent: {
192
- action: 'SETPARAM',
193
- object: 'CONTACT',
194
- values: `${name};${paramName};${paramValue}`
195
- }
196
- });
197
- });
198
-
199
- return cy.wrap(null);
200
- });
201
- }
202
- );
203
-
204
- interface ContactGroup {
205
- alias?: string | null;
206
- contacts: string[];
207
- name: string;
208
- }
209
-
210
- Cypress.Commands.add(
211
- 'addContactGroup',
212
- ({ alias = null, contacts, name }: ContactGroup): Cypress.Chainable => {
213
- const contactGroupAlias = alias === null ? name : alias;
214
-
215
- return cy
216
- .executeActionViaClapi({
217
- bodyContent: {
218
- action: 'ADD',
219
- object: 'CG',
220
- values: `${name};${contactGroupAlias}`
221
- }
222
- })
223
- .then(() => {
224
- contacts.map((contact) => {
225
- return cy.executeActionViaClapi({
226
- bodyContent: {
227
- action: 'ADDCONTACT',
228
- object: 'CG',
229
- values: `${name};${contact}`
230
- }
231
- });
232
- });
233
-
234
- return cy.wrap(null);
235
- });
236
- }
237
- );
238
-
239
141
  interface Host {
240
142
  activeCheckEnabled?: boolean;
241
143
  address?: string;
@@ -306,26 +208,6 @@ Cypress.Commands.add(
306
208
  }
307
209
  );
308
210
 
309
- interface HostGroup {
310
- alias?: string | null;
311
- name: string;
312
- }
313
-
314
- Cypress.Commands.add(
315
- 'addHostGroup',
316
- ({ alias = null, name }: HostGroup): Cypress.Chainable => {
317
- const hostGroupAlias = alias === null ? name : alias;
318
-
319
- return cy.executeActionViaClapi({
320
- bodyContent: {
321
- action: 'ADD',
322
- object: 'HG',
323
- values: `${name};${hostGroupAlias}`
324
- }
325
- });
326
- }
327
- );
328
-
329
211
  interface ServiceTemplate {
330
212
  activeCheckEnabled?: boolean;
331
213
  checkCommand?: string | null;
@@ -447,45 +329,6 @@ Cypress.Commands.add(
447
329
  }
448
330
  );
449
331
 
450
- interface ServiceGroup {
451
- alias?: string | null;
452
- hostsAndServices: string[][];
453
- name: string;
454
- }
455
-
456
- Cypress.Commands.add(
457
- 'addServiceGroup',
458
- ({
459
- alias = null,
460
- hostsAndServices,
461
- name
462
- }: ServiceGroup): Cypress.Chainable => {
463
- const serviceGroupAlias = alias === null ? name : alias;
464
-
465
- return cy
466
- .executeActionViaClapi({
467
- bodyContent: {
468
- action: 'ADD',
469
- object: 'SG',
470
- values: `${name};${serviceGroupAlias}`
471
- }
472
- })
473
- .then(() => {
474
- hostsAndServices.map((hostAndService) => {
475
- return cy.executeActionViaClapi({
476
- bodyContent: {
477
- action: 'ADDSERVICE',
478
- object: 'SG',
479
- values: `${name};${hostAndService[0]},${hostAndService[1]}`
480
- }
481
- });
482
- });
483
-
484
- return cy.wrap(null);
485
- });
486
- }
487
- );
488
-
489
332
  Cypress.Commands.add(
490
333
  'applyPollerConfiguration',
491
334
  (pollerName = 'Central'): Cypress.Chainable => {
@@ -498,179 +341,12 @@ Cypress.Commands.add(
498
341
  }
499
342
  );
500
343
 
501
- interface ACLGroup {
502
- alias?: string | null;
503
- contacts?: string[];
504
- contactGroups?: string[];
505
- name: string;
506
- }
507
-
508
- Cypress.Commands.add(
509
- 'addACLGroup',
510
- ({
511
- alias = null,
512
- contacts = [],
513
- contactGroups = [],
514
- name
515
- }: ACLGroup): Cypress.Chainable => {
516
- const ACLGroupALias = alias === null ? name : alias;
517
-
518
- return cy
519
- .executeActionViaClapi({
520
- bodyContent: {
521
- action: 'ADD',
522
- object: 'ACLGROUP',
523
- values: `${name};${ACLGroupALias}`
524
- }
525
- })
526
- .then(() => {
527
- if (contacts) {
528
- contacts.map((contact) => {
529
- cy.executeActionViaClapi({
530
- bodyContent: {
531
- action: 'ADDCONTACT',
532
- object: 'ACLGROUP',
533
- values: `${name};${contact}`
534
- }
535
- });
536
- });
537
- }
538
- if (contactGroups) {
539
- contactGroups.map((contactGroup) => {
540
- cy.executeActionViaClapi({
541
- bodyContent: {
542
- action: 'ADDCONTACTGROUP',
543
- object: 'ACLGROUP',
544
- values: `${name};${contactGroup}`
545
- }
546
- });
547
- });
548
- }
549
- });
550
- }
551
- );
552
-
553
- interface ACLMenu {
554
- name: string;
555
- rule?: string[];
556
- alias?: string | null;
557
- includeChildren?: boolean;
558
- readOnly?: boolean;
559
- }
560
-
561
- Cypress.Commands.add(
562
- 'addACLMenu',
563
- ({
564
- name,
565
- rule = [],
566
- alias = null,
567
- includeChildren = true,
568
- readOnly = false
569
- }: ACLMenu): Cypress.Chainable => {
570
- const ACLMenuAlias = alias === null ? name : alias;
571
- const action = readOnly ? 'GRANTRO' : 'GRANTRW';
572
- const children = includeChildren ? '1' : '0';
573
-
574
- return cy
575
- .executeActionViaClapi({
576
- bodyContent: {
577
- action: 'ADD',
578
- object: 'ACLMENU',
579
- values: `${name};${ACLMenuAlias}`
580
- }
581
- })
582
- .then(() => {
583
- if (rule.length == 0) {
584
- return cy.wrap(null);
585
- }
586
-
587
- let ruleCommand = '';
588
- rule.map((rulePage, index) => {
589
- ruleCommand += rulePage + (index == rule.length - 1 ? '' : ';');
590
- });
591
- cy.executeActionViaClapi({
592
- bodyContent: {
593
- action: action,
594
- object: 'ACLMENU',
595
- values: `${name};${children};${ruleCommand}`
596
- }
597
- });
598
- return cy.wrap(null);
599
- });
600
- }
601
- );
602
-
603
- interface ACLAction {
604
- name: string;
605
- description: string;
606
- actions?: Action[];
607
- }
608
-
609
- Cypress.Commands.add(
610
- 'addACLAction',
611
- ({ name, description, actions = [] }: ACLAction): Cypress.Chainable => {
612
- return cy
613
- .executeActionViaClapi({
614
- bodyContent: {
615
- action: 'ADD',
616
- object: 'ACLACTION',
617
- values: `${name};${description}`
618
- }
619
- })
620
- .then(() => {
621
- if (actions.length == 0) {
622
- return cy.wrap(null);
623
- }
624
-
625
- let actionCommand = '';
626
- actions.map((action, index) => {
627
- actionCommand += action + (index == actions.length - 1 ? '' : '|');
628
- });
629
- cy.executeActionViaClapi({
630
- bodyContent: {
631
- action: 'GRANT',
632
- object: 'ACLACTION',
633
- values: `${name};${actionCommand}`
634
- }
635
- });
636
- return cy.wrap(null);
637
- });
638
- }
639
- );
640
-
641
- interface ACLResource {
642
- name: string;
643
- alias?: string | null;
644
- }
645
-
646
- Cypress.Commands.add(
647
- 'addACLResource',
648
- ({ name, alias = null }: ACLResource): Cypress.Chainable => {
649
- const ACLResourcesAlias = alias === null ? name : alias;
650
- return cy.executeActionViaClapi({
651
- bodyContent: {
652
- action: 'ADD',
653
- object: 'ACLRESOURCE',
654
- values: `${name};${ACLResourcesAlias}`
655
- }
656
- });
657
- }
658
- );
659
-
660
344
  declare global {
661
345
  namespace Cypress {
662
346
  interface Chainable {
663
- addACLAction: (props: ACLAction) => Cypress.Chainable;
664
- addACLGroup: (props: ACLGroup) => Cypress.Chainable;
665
- addACLMenu: (props: ACLMenu) => Cypress.Chainable;
666
- addACLResource: (props: ACLResource) => Cypress.Chainable;
667
347
  addCheckCommand: (props: CheckCommand) => Cypress.Chainable;
668
- addContact: (props: Contact) => Cypress.Chainable;
669
- addContactGroup: (props: ContactGroup) => Cypress.Chainable;
670
348
  addHost: (props: Host) => Cypress.Chainable;
671
- addHostGroup: (props: HostGroup) => Cypress.Chainable;
672
349
  addService: (props: Service) => Cypress.Chainable;
673
- addServiceGroup: (props: ServiceGroup) => Cypress.Chainable;
674
350
  addServiceTemplate: (props: ServiceTemplate) => Cypress.Chainable;
675
351
  addTimePeriod: (props: TimePeriod) => Cypress.Chainable;
676
352
  applyPollerConfiguration: (props?: string) => Cypress.Chainable;