@camunda/e2e-test-suite 0.0.820 → 0.0.821
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const test_1 = require("@playwright/test");
|
|
4
|
+
const _8_10_1 = require("../../fixtures/8.10");
|
|
5
|
+
const apiHelpers_1 = require("../../utils/apiHelpers");
|
|
6
|
+
const randomName_1 = require("../../utils/randomName");
|
|
7
|
+
_8_10_1.test.describe.configure({ mode: 'parallel' });
|
|
8
|
+
const DEFINITION_KEY = 'customer_onboarding_en';
|
|
9
|
+
const expectUnauthorizedErrorBody = (body) => {
|
|
10
|
+
if (body === null || body === undefined)
|
|
11
|
+
return;
|
|
12
|
+
if (typeof body === 'string') {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
(0, test_1.expect)(typeof body).toBe('object');
|
|
16
|
+
const errorBody = body;
|
|
17
|
+
const errorMessage = errorBody.message ?? errorBody.error ?? errorBody.title ?? errorBody.detail;
|
|
18
|
+
(0, test_1.expect)(typeof errorMessage).toBe('string');
|
|
19
|
+
(0, test_1.expect)(errorMessage.trim().length).toBeGreaterThan(0);
|
|
20
|
+
};
|
|
21
|
+
const assertUnauthorizedResponseBody = async (response) => {
|
|
22
|
+
(0, test_1.expect)(response.status()).toBe(401);
|
|
23
|
+
const rawBody = await response.text();
|
|
24
|
+
if (rawBody.trim().length === 0)
|
|
25
|
+
return;
|
|
26
|
+
let body = rawBody;
|
|
27
|
+
try {
|
|
28
|
+
body = JSON.parse(rawBody);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
body = rawBody;
|
|
32
|
+
}
|
|
33
|
+
expectUnauthorizedErrorBody(body);
|
|
34
|
+
};
|
|
35
|
+
const createNumberReport = async (request, options) => {
|
|
36
|
+
const response = await request.post(`${options.baseUrl}/api/report/process/single`, {
|
|
37
|
+
headers: {
|
|
38
|
+
Cookie: options.optimizeCookie,
|
|
39
|
+
'Content-Type': 'application/json',
|
|
40
|
+
},
|
|
41
|
+
data: {
|
|
42
|
+
collectionId: options.collectionId,
|
|
43
|
+
name: options.name,
|
|
44
|
+
description: null,
|
|
45
|
+
data: {
|
|
46
|
+
definitions: [
|
|
47
|
+
{
|
|
48
|
+
key: DEFINITION_KEY,
|
|
49
|
+
versions: ['all'],
|
|
50
|
+
tenantIds: ['<default>'],
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
view: { entity: 'processInstance', properties: ['frequency'] },
|
|
54
|
+
groupBy: { type: 'none', value: null },
|
|
55
|
+
distributedBy: { type: 'none', value: null },
|
|
56
|
+
visualization: 'number',
|
|
57
|
+
filter: [],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
await (0, apiHelpers_1.assertResponseStatus)(response, 200);
|
|
62
|
+
const body = await response.json();
|
|
63
|
+
(0, test_1.expect)(body).toHaveProperty('id');
|
|
64
|
+
return body.id;
|
|
65
|
+
};
|
|
66
|
+
const createRawDataReport = async (request, options) => {
|
|
67
|
+
const response = await request.post(`${options.baseUrl}/api/report/process/single`, {
|
|
68
|
+
headers: {
|
|
69
|
+
Cookie: options.optimizeCookie,
|
|
70
|
+
'Content-Type': 'application/json',
|
|
71
|
+
},
|
|
72
|
+
data: {
|
|
73
|
+
collectionId: options.collectionId,
|
|
74
|
+
name: options.name,
|
|
75
|
+
description: null,
|
|
76
|
+
data: {
|
|
77
|
+
definitions: [
|
|
78
|
+
{
|
|
79
|
+
key: DEFINITION_KEY,
|
|
80
|
+
versions: ['all'],
|
|
81
|
+
tenantIds: ['<default>'],
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
view: { entity: null, properties: ['rawData'] },
|
|
85
|
+
groupBy: { type: 'none', value: null },
|
|
86
|
+
distributedBy: { type: 'none', value: null },
|
|
87
|
+
visualization: 'table',
|
|
88
|
+
filter: [],
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
await (0, apiHelpers_1.assertResponseStatus)(response, 200);
|
|
93
|
+
const body = await response.json();
|
|
94
|
+
(0, test_1.expect)(body).toHaveProperty('id');
|
|
95
|
+
return body.id;
|
|
96
|
+
};
|
|
97
|
+
_8_10_1.test.describe('API Optimize Sharing, Alerts & Export Tests @optimize-sharing-alerts-export-api @8.10', () => {
|
|
98
|
+
let optimizeCookie;
|
|
99
|
+
let optimizeBearerToken;
|
|
100
|
+
let baseUrl;
|
|
101
|
+
let collectionId;
|
|
102
|
+
let numberReportId;
|
|
103
|
+
let rawDataReportId;
|
|
104
|
+
let dashboardId;
|
|
105
|
+
_8_10_1.test.beforeAll(async ({ browser, request }) => {
|
|
106
|
+
const page = await browser.newPage();
|
|
107
|
+
optimizeCookie = await (0, apiHelpers_1.getOptimizeCoockie)(page);
|
|
108
|
+
await page.close();
|
|
109
|
+
optimizeBearerToken = await (0, apiHelpers_1.authSaasAPI)(process.env.OPTIMIZE_API_TOKEN_AUDIENCE);
|
|
110
|
+
baseUrl = process.env.CAMUNDA_OPTIMIZE_BASE_URL;
|
|
111
|
+
collectionId = await (0, apiHelpers_1.createCollection)(request, {
|
|
112
|
+
name: await (0, randomName_1.randomNameAgregator)('Sharing Alerts Collection'),
|
|
113
|
+
optimizeCookie,
|
|
114
|
+
});
|
|
115
|
+
await (0, apiHelpers_1.updateCollectionScope)(request, {
|
|
116
|
+
optimizeCookie,
|
|
117
|
+
collectionId,
|
|
118
|
+
data: [
|
|
119
|
+
{
|
|
120
|
+
definitionKey: DEFINITION_KEY,
|
|
121
|
+
definitionType: 'process',
|
|
122
|
+
tenants: ['<default>'],
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
});
|
|
126
|
+
numberReportId = await createNumberReport(request, {
|
|
127
|
+
baseUrl,
|
|
128
|
+
optimizeCookie,
|
|
129
|
+
collectionId,
|
|
130
|
+
name: await (0, randomName_1.randomNameAgregator)('Number Report'),
|
|
131
|
+
});
|
|
132
|
+
rawDataReportId = await createRawDataReport(request, {
|
|
133
|
+
baseUrl,
|
|
134
|
+
optimizeCookie,
|
|
135
|
+
collectionId,
|
|
136
|
+
name: await (0, randomName_1.randomNameAgregator)('Raw Data Report'),
|
|
137
|
+
});
|
|
138
|
+
dashboardId = await (0, apiHelpers_1.createDashboard)(request, {
|
|
139
|
+
name: await (0, randomName_1.randomNameAgregator)('Sharing Dashboard'),
|
|
140
|
+
optimizeCookie,
|
|
141
|
+
collectionId,
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
_8_10_1.test.afterAll(async ({ request }) => {
|
|
145
|
+
if (collectionId) {
|
|
146
|
+
await request.delete(`${baseUrl}/api/public/collection/${collectionId}`, {
|
|
147
|
+
headers: { Authorization: optimizeBearerToken },
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
(0, _8_10_1.test)('Export report result data returns 200 with paginated payload', async ({ request, }) => {
|
|
152
|
+
await _8_10_1.test.step('GET /api/public/export/report/{id}/result/json (200)', async () => {
|
|
153
|
+
const response = await request.get(`${baseUrl}/api/public/export/report/${rawDataReportId}/result/json?paginationTimeout=60&limit=100`, { headers: { Authorization: optimizeBearerToken } });
|
|
154
|
+
await (0, apiHelpers_1.assertResponseStatus)(response, 200);
|
|
155
|
+
const body = await response.json();
|
|
156
|
+
(0, test_1.expect)(body).toHaveProperty('reportId', rawDataReportId);
|
|
157
|
+
(0, test_1.expect)(body).toHaveProperty('totalNumberOfRecords');
|
|
158
|
+
(0, test_1.expect)(typeof body.totalNumberOfRecords).toBe('number');
|
|
159
|
+
(0, test_1.expect)(body).toHaveProperty('data');
|
|
160
|
+
(0, test_1.expect)(Array.isArray(body.data)).toBeTruthy();
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
(0, _8_10_1.test)('Export report result data without pagination params returns 200', async ({ request, }) => {
|
|
164
|
+
await _8_10_1.test.step('GET export result with optional query params omitted (200)', async () => {
|
|
165
|
+
const response = await request.get(`${baseUrl}/api/public/export/report/${numberReportId}/result/json`, { headers: { Authorization: optimizeBearerToken } });
|
|
166
|
+
await (0, apiHelpers_1.assertResponseStatus)(response, 200);
|
|
167
|
+
const body = await response.json();
|
|
168
|
+
(0, test_1.expect)(body).toHaveProperty('reportId', numberReportId);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
(0, _8_10_1.test)('Export report result data without token returns 401', async ({ request, }) => {
|
|
172
|
+
await _8_10_1.test.step('GET export result without Authorization header (401)', async () => {
|
|
173
|
+
const response = await request.get(`${baseUrl}/api/public/export/report/${numberReportId}/result/json?paginationTimeout=60&limit=100`);
|
|
174
|
+
await assertUnauthorizedResponseBody(response);
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
(0, _8_10_1.test)('Export report result data with invalid token returns 401', async ({ request, }) => {
|
|
178
|
+
await _8_10_1.test.step('GET export result with invalid token (401)', async () => {
|
|
179
|
+
const response = await request.get(`${baseUrl}/api/public/export/report/${numberReportId}/result/json?paginationTimeout=60&limit=100`, { headers: { Authorization: 'Bearer invalid_token' } });
|
|
180
|
+
await assertUnauthorizedResponseBody(response);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
(0, _8_10_1.test)('Export result data for non-existent report is rejected (404; SaaS may respond 500)', async ({ request, }) => {
|
|
184
|
+
await _8_10_1.test.step('GET export result for missing report (404 or 500)', async () => {
|
|
185
|
+
const response = await request.get(`${baseUrl}/api/public/export/report/11111111-1111-1111-1111-111111111111/result/json?paginationTimeout=60&limit=100`, { headers: { Authorization: optimizeBearerToken } });
|
|
186
|
+
(0, test_1.expect)([404, 500]).toContain(response.status());
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
(0, _8_10_1.test)('Enable, evaluate and delete a report share', async ({ request }) => {
|
|
190
|
+
let reportShareId = '';
|
|
191
|
+
await _8_10_1.test.step('POST /api/share/report enables sharing (200)', async () => {
|
|
192
|
+
const response = await request.post(`${baseUrl}/api/share/report`, {
|
|
193
|
+
headers: {
|
|
194
|
+
Cookie: optimizeCookie,
|
|
195
|
+
'Content-Type': 'application/json',
|
|
196
|
+
},
|
|
197
|
+
data: { reportId: numberReportId },
|
|
198
|
+
});
|
|
199
|
+
await (0, apiHelpers_1.assertResponseStatus)(response, 200);
|
|
200
|
+
const body = await response.json();
|
|
201
|
+
(0, test_1.expect)(body).toHaveProperty('id');
|
|
202
|
+
reportShareId = body.id;
|
|
203
|
+
(0, test_1.expect)(reportShareId.length).toBeGreaterThan(0);
|
|
204
|
+
});
|
|
205
|
+
await _8_10_1.test.step('Shared report is evaluable without authentication', async () => {
|
|
206
|
+
const response = await request.post(`${baseUrl}/api/external/share/report/${reportShareId}/evaluate`, {
|
|
207
|
+
headers: { 'Content-Type': 'application/json' },
|
|
208
|
+
data: {},
|
|
209
|
+
});
|
|
210
|
+
(0, test_1.expect)([200, 201]).toContain(response.status());
|
|
211
|
+
});
|
|
212
|
+
await _8_10_1.test.step('DELETE /api/share/report/{shareId} removes the share', async () => {
|
|
213
|
+
const response = await request.delete(`${baseUrl}/api/share/report/${reportShareId}`, { headers: { Cookie: optimizeCookie } });
|
|
214
|
+
(0, test_1.expect)([200, 204]).toContain(response.status());
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
(0, _8_10_1.test)('Enable report share without auth cookie returns 401', async ({ request, }) => {
|
|
218
|
+
await _8_10_1.test.step('POST /api/share/report without cookie (401)', async () => {
|
|
219
|
+
const response = await request.post(`${baseUrl}/api/share/report`, {
|
|
220
|
+
headers: { 'Content-Type': 'application/json' },
|
|
221
|
+
data: { reportId: numberReportId },
|
|
222
|
+
});
|
|
223
|
+
await assertUnauthorizedResponseBody(response);
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
(0, _8_10_1.test)('Enable and delete a dashboard share', async ({ request }) => {
|
|
227
|
+
let dashboardShareId = '';
|
|
228
|
+
await _8_10_1.test.step('POST /api/share/dashboard enables sharing (200)', async () => {
|
|
229
|
+
const response = await request.post(`${baseUrl}/api/share/dashboard`, {
|
|
230
|
+
headers: {
|
|
231
|
+
Cookie: optimizeCookie,
|
|
232
|
+
'Content-Type': 'application/json',
|
|
233
|
+
},
|
|
234
|
+
data: { dashboardId },
|
|
235
|
+
});
|
|
236
|
+
await (0, apiHelpers_1.assertResponseStatus)(response, 200);
|
|
237
|
+
const body = await response.json();
|
|
238
|
+
(0, test_1.expect)(body).toHaveProperty('id');
|
|
239
|
+
dashboardShareId = body.id;
|
|
240
|
+
(0, test_1.expect)(dashboardShareId.length).toBeGreaterThan(0);
|
|
241
|
+
});
|
|
242
|
+
await _8_10_1.test.step('DELETE /api/share/dashboard/{shareId} removes the share', async () => {
|
|
243
|
+
const response = await request.delete(`${baseUrl}/api/share/dashboard/${dashboardShareId}`, { headers: { Cookie: optimizeCookie } });
|
|
244
|
+
(0, test_1.expect)([200, 204]).toContain(response.status());
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
(0, _8_10_1.test)('Create, list and delete an alert for a number report', async ({ request, }) => {
|
|
248
|
+
let alertId = '';
|
|
249
|
+
const alertEmail = process.env.C8_USERNAME;
|
|
250
|
+
await _8_10_1.test.step('POST /api/alert creates an alert (200)', async () => {
|
|
251
|
+
const response = await request.post(`${baseUrl}/api/alert`, {
|
|
252
|
+
headers: {
|
|
253
|
+
Cookie: optimizeCookie,
|
|
254
|
+
'Content-Type': 'application/json',
|
|
255
|
+
},
|
|
256
|
+
data: {
|
|
257
|
+
name: await (0, randomName_1.randomNameAgregator)('Number Report Alert'),
|
|
258
|
+
reportId: numberReportId,
|
|
259
|
+
emails: [alertEmail],
|
|
260
|
+
webhook: null,
|
|
261
|
+
threshold: 100,
|
|
262
|
+
thresholdOperator: '>',
|
|
263
|
+
fixNotification: false,
|
|
264
|
+
checkInterval: { value: 10, unit: 'minutes' },
|
|
265
|
+
reminder: null,
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
await (0, apiHelpers_1.assertResponseStatus)(response, 200);
|
|
269
|
+
const body = await response.json();
|
|
270
|
+
(0, test_1.expect)(body).toHaveProperty('id');
|
|
271
|
+
alertId = body.id;
|
|
272
|
+
(0, test_1.expect)(alertId.length).toBeGreaterThan(0);
|
|
273
|
+
});
|
|
274
|
+
await _8_10_1.test.step('GET /api/collection/{id}/alerts includes the created alert', async () => {
|
|
275
|
+
const response = await request.get(`${baseUrl}/api/collection/${collectionId}/alerts`, { headers: { Cookie: optimizeCookie } });
|
|
276
|
+
await (0, apiHelpers_1.assertResponseStatus)(response, 200);
|
|
277
|
+
const body = await response.json();
|
|
278
|
+
(0, test_1.expect)(Array.isArray(body)).toBeTruthy();
|
|
279
|
+
const ids = body.map((alert) => alert.id);
|
|
280
|
+
(0, test_1.expect)(ids).toContain(alertId);
|
|
281
|
+
});
|
|
282
|
+
await _8_10_1.test.step('DELETE /api/alert/{id} removes the alert', async () => {
|
|
283
|
+
const response = await request.delete(`${baseUrl}/api/alert/${alertId}`, {
|
|
284
|
+
headers: { Cookie: optimizeCookie },
|
|
285
|
+
});
|
|
286
|
+
(0, test_1.expect)([200, 204]).toContain(response.status());
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
(0, _8_10_1.test)('Create alert without auth cookie returns 401', async ({ request }) => {
|
|
290
|
+
await _8_10_1.test.step('POST /api/alert without cookie (401)', async () => {
|
|
291
|
+
const response = await request.post(`${baseUrl}/api/alert`, {
|
|
292
|
+
headers: { 'Content-Type': 'application/json' },
|
|
293
|
+
data: {
|
|
294
|
+
name: await (0, randomName_1.randomNameAgregator)('Unauthorized Alert'),
|
|
295
|
+
reportId: numberReportId,
|
|
296
|
+
emails: [process.env.C8_USERNAME],
|
|
297
|
+
threshold: 100,
|
|
298
|
+
thresholdOperator: '>',
|
|
299
|
+
checkInterval: { value: 10, unit: 'minutes' },
|
|
300
|
+
},
|
|
301
|
+
});
|
|
302
|
+
await assertUnauthorizedResponseBody(response);
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
});
|