@centreon/js-config 24.8.2 → 24.9.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.
@@ -21,6 +21,112 @@ const getStatusNumberFromString = (status: string): number => {
21
21
  throw new Error(`Status ${status} does not exist`);
22
22
  };
23
23
 
24
+ interface HostCheck {
25
+ host: string;
26
+ isForced?: boolean;
27
+ }
28
+
29
+ Cypress.Commands.add(
30
+ 'scheduleHostCheck',
31
+ ({
32
+ host,
33
+ isForced = true
34
+ }: ServiceCheck): Cypress.Chainable => {
35
+ let query = `SELECT id FROM resources WHERE name = '${host}' AND type = 1`;
36
+
37
+ return cy
38
+ .requestOnDatabase({
39
+ database: 'centreon_storage',
40
+ query
41
+ })
42
+ .then(([rows]) => {
43
+ if (rows.length === 0) {
44
+ throw new Error(`Cannot find host ${host}`);
45
+ }
46
+
47
+ const hostId = rows[0].id;
48
+
49
+ return cy.request({
50
+ body: {
51
+ check: {
52
+ is_forced: isForced
53
+ },
54
+ resources: [
55
+ {
56
+ id: hostId,
57
+ parent: null,
58
+ type: 'host'
59
+ }
60
+ ]
61
+ },
62
+ method: 'POST',
63
+ timeout: 30000,
64
+ url: '/centreon/api/latest/monitoring/resources/check'
65
+ }).then((response) => {
66
+ expect(response.status).to.eq(204);
67
+
68
+ return cy.wrap(null);
69
+ });
70
+ });
71
+ }
72
+ );
73
+
74
+ interface ServiceCheck {
75
+ host: string;
76
+ isForced?: boolean;
77
+ service: string;
78
+ }
79
+
80
+ Cypress.Commands.add(
81
+ 'scheduleServiceCheck',
82
+ ({
83
+ host,
84
+ isForced = true,
85
+ service
86
+ }: ServiceCheck): Cypress.Chainable => {
87
+ let query = `SELECT parent_id, id FROM resources WHERE parent_name = '${host}' AND name = '${service}'`;
88
+
89
+ return cy
90
+ .requestOnDatabase({
91
+ database: 'centreon_storage',
92
+ query
93
+ })
94
+ .then(([rows]) => {
95
+ if (rows.length === 0) {
96
+ throw new Error(`Cannot find service ${host} / ${service}`);
97
+ }
98
+
99
+ const hostId = rows[0].parent_id;
100
+ const serviceId = rows[0].id;
101
+
102
+ return cy.request({
103
+ body: {
104
+ check: {
105
+ is_forced: isForced
106
+ },
107
+ resources: [
108
+ {
109
+ id: serviceId,
110
+ parent: {
111
+ id: hostId
112
+ },
113
+ type: 'service'
114
+ }
115
+ ]
116
+ },
117
+ method: 'POST',
118
+ timeout: 30000,
119
+ url: '/centreon/api/latest/monitoring/resources/check'
120
+ }).then((response) => {
121
+ expect(response.status).to.eq(204);
122
+
123
+ return cy.wrap(null);
124
+ });
125
+ });
126
+ }
127
+ );
128
+
129
+
24
130
  interface SubmitResult {
25
131
  host: string;
26
132
  output: string;
@@ -108,6 +214,8 @@ Cypress.Commands.add(
108
214
  declare global {
109
215
  namespace Cypress {
110
216
  interface Chainable {
217
+ scheduleHostCheck: (hostCheck) => Cypress.Chainable;
218
+ scheduleServiceCheck: (serviceCheck) => Cypress.Chainable;
111
219
  submitResults: (props: Array<SubmitResult>) => Cypress.Chainable;
112
220
  waitForDowntime: (downtime: Downtime) => Cypress.Chainable;
113
221
  }
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.8.2",
4
+ "version": "24.9.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon-frontend.git"