@camunda/e2e-test-suite 0.0.162 → 0.0.164

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.
@@ -3,31 +3,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createGlobalClusterVariableSaaS = exports.createProcessInstanceSaaS = exports.deployProcessSaaS = exports.updateCollectionScope = exports.createSingleProcessReport = exports.createDashboard = exports.createCollection = exports.getOptimizeCoockie = exports.authSaasAPI = exports.sendRequestAndAssertResponse = exports.assertResponseStatus = exports.authC8runAPI = void 0;
6
+ exports.updateCollectionScope = exports.createSingleProcessReport = exports.createDashboard = exports.createCollection = exports.getOptimizeCoockie = exports.createGlobalClusterVariable = exports.createProcessInstance = exports.deployProcess = exports.authC8runAPI = exports.authSmAPI = exports.authSaasAPI = exports.authAPI = exports.sendRequestAndAssertResponse = exports.assertResponseStatus = void 0;
7
7
  const test_1 = require("@playwright/test");
8
8
  const sleep_1 = require("./sleep");
9
9
  const fs_1 = __importDefault(require("fs"));
10
10
  const path_1 = __importDefault(require("path"));
11
11
  const utils_1 = require("./utils");
12
12
  let apiRequestContext;
13
+ // ---- Internal: API request context ----
13
14
  async function getApiRequestContext() {
14
15
  if (!apiRequestContext) {
15
16
  apiRequestContext = await test_1.request.newContext();
16
17
  }
17
18
  return apiRequestContext;
18
19
  }
19
- async function authC8runAPI(name, password) {
20
- apiRequestContext = await getApiRequestContext();
21
- const minorVersion = process.env.MINOR_VERSION;
22
- const prefix = minorVersion === 'c8Run-8.8' ? '' : '/api';
23
- await apiRequestContext.post(`${prefix}/login?username=${name}&password=${password}`, {
24
- headers: {
25
- 'Content-Type': 'application/json',
26
- },
27
- });
28
- await apiRequestContext.storageState({ path: 'utils/.auth' });
29
- }
30
- exports.authC8runAPI = authC8runAPI;
20
+ // ---- Common HTTP helpers ----
31
21
  async function assertResponseStatus(response, status) {
32
22
  (0, test_1.expect)(response.status()).toBe(status);
33
23
  }
@@ -55,28 +45,198 @@ async function sendRequestAndAssertResponse(request, url, requestBody, maxRetrie
55
45
  }
56
46
  }
57
47
  exports.sendRequestAndAssertResponse = sendRequestAndAssertResponse;
58
- async function authSaasAPI(audience = process.env.ZEEBE_API_TOKEN_AUDIENCE) {
48
+ // ---- Zeebe: URL building (SaaS vs SM) ----
49
+ function inferZeebeEnvironment(override) {
50
+ if (override) {
51
+ return override;
52
+ }
53
+ if (process.env.MINOR_VERSION?.includes('SM')) {
54
+ return 'sm';
55
+ }
56
+ if (process.env.ZEEBE_API_URL) {
57
+ return 'saas';
58
+ }
59
+ return 'sm';
60
+ }
61
+ function normalizeOrigin(value, defaultProtocol = 'https') {
62
+ const trimmed = value.trim().replace(/\/+$/, '');
63
+ if (/^https?:\/\//i.test(trimmed)) {
64
+ return trimmed;
65
+ }
66
+ return `${defaultProtocol}://${trimmed}`;
67
+ }
68
+ function getZeebeApiOrigin(environment) {
69
+ if (environment === 'saas') {
70
+ const saasUrl = process.env.ZEEBE_API_URL?.trim();
71
+ if (!saasUrl) {
72
+ throw new Error('Missing ZEEBE_API_URL (SaaS).');
73
+ }
74
+ return saasUrl.replace(/\/+$/, '');
75
+ }
76
+ const baseUrl = process.env.BASE_URL?.trim();
77
+ if (baseUrl) {
78
+ return normalizeOrigin(baseUrl, 'https');
79
+ }
80
+ throw new Error('Missing BASE_URL (SM).');
81
+ }
82
+ function buildZeebeApiUrl(resourcePath, environmentOverride) {
83
+ const environment = inferZeebeEnvironment(environmentOverride);
84
+ const baseUrl = getZeebeApiOrigin(environment);
85
+ const normalizedPath = resourcePath.startsWith('/')
86
+ ? resourcePath
87
+ : `/${resourcePath}`;
88
+ const pathWithPrefix = environment === 'sm' ? `/orchestration${normalizedPath}` : normalizedPath;
89
+ return `${baseUrl}${pathWithPrefix}`;
90
+ }
91
+ async function authAPI(environment, audience = process.env.ZEEBE_API_TOKEN_AUDIENCE) {
59
92
  apiRequestContext = await getApiRequestContext();
60
- const tokenResponse = await apiRequestContext.post('https://login.cloud.ultrawombat.com/oauth/token', {
93
+ if (environment === 'saas') {
94
+ const tokenResponse = await apiRequestContext.post('https://login.cloud.ultrawombat.com/oauth/token', {
95
+ headers: {
96
+ 'Content-Type': 'application/json',
97
+ },
98
+ data: {
99
+ audience,
100
+ client_id: process.env.ZEEBE_API_CLIENT_ID,
101
+ client_secret: process.env.ZEEBE_API_CLIENT_SECRET,
102
+ grant_type: 'client_credentials',
103
+ },
104
+ });
105
+ if (tokenResponse.status() !== 200) {
106
+ const errorBody = await tokenResponse.text();
107
+ throw new Error(`Failed to fetch access token. Response: ${errorBody}`);
108
+ }
109
+ const tokenJson = await tokenResponse.json();
110
+ const bearerToken = `Bearer ${tokenJson.access_token}`;
111
+ return bearerToken;
112
+ }
113
+ const baseUrlRaw = process.env.BASE_URL?.trim();
114
+ if (!baseUrlRaw) {
115
+ throw new Error('Missing BASE_URL (required for SM auth).');
116
+ }
117
+ const origin = normalizeOrigin(baseUrlRaw, 'https');
118
+ const tokenUrl = `${origin}/auth/realms/camunda-platform/protocol/openid-connect/token`;
119
+ const tokenResponse = await apiRequestContext.post(tokenUrl, {
61
120
  headers: {
62
- 'Content-Type': 'application/json',
121
+ 'Content-Type': 'application/x-www-form-urlencoded',
63
122
  },
64
- data: {
65
- audience: audience,
66
- client_id: process.env.ZEEBE_API_CLIENT_ID,
67
- client_secret: process.env.ZEEBE_API_CLIENT_SECRET,
123
+ form: {
124
+ client_id: process.env.DISTRO_QA_E2E_TESTS_KEYCLOAK_CLIENT_ID ?? 'venom',
125
+ client_secret: process.env.DISTRO_QA_E2E_TESTS_KEYCLOAK_ADMIN_SECRET,
68
126
  grant_type: 'client_credentials',
69
127
  },
70
128
  });
71
129
  if (tokenResponse.status() !== 200) {
72
130
  const errorBody = await tokenResponse.text();
73
- throw new Error(`Failed to fetch access token. Response: ${errorBody}`);
131
+ throw new Error(`Failed to fetch SM access token. Response: ${errorBody}`);
74
132
  }
75
133
  const tokenJson = await tokenResponse.json();
76
134
  const bearerToken = `Bearer ${tokenJson.access_token}`;
77
135
  return bearerToken;
78
136
  }
137
+ exports.authAPI = authAPI;
138
+ async function authSaasAPI(audience = process.env.ZEEBE_API_TOKEN_AUDIENCE) {
139
+ return authAPI('saas', audience);
140
+ }
79
141
  exports.authSaasAPI = authSaasAPI;
142
+ async function authSmAPI() {
143
+ return authAPI('sm');
144
+ }
145
+ exports.authSmAPI = authSmAPI;
146
+ async function authC8runAPI(name, password) {
147
+ apiRequestContext = await getApiRequestContext();
148
+ const minorVersion = process.env.MINOR_VERSION;
149
+ const prefix = minorVersion === 'c8Run-8.8' ? '' : '/api';
150
+ await apiRequestContext.post(`${prefix}/login?username=${name}&password=${password}`, {
151
+ headers: {
152
+ 'Content-Type': 'application/json',
153
+ },
154
+ });
155
+ await apiRequestContext.storageState({ path: 'utils/.auth' });
156
+ }
157
+ exports.authC8runAPI = authC8runAPI;
158
+ // ---- Zeebe: API helpers ----
159
+ async function deployProcess(filePath, authToken, environment) {
160
+ try {
161
+ apiRequestContext = await getApiRequestContext();
162
+ const fileContent = fs_1.default.readFileSync(filePath);
163
+ const fileName = path_1.default.basename(filePath);
164
+ const resources = {
165
+ name: fileName,
166
+ mimeType: 'application/vnd.bpmn+xml',
167
+ buffer: fileContent,
168
+ };
169
+ const url = buildZeebeApiUrl('/v2/deployments', environment);
170
+ const response = await apiRequestContext.post(url, {
171
+ headers: {
172
+ Authorization: authToken ?? '',
173
+ },
174
+ multipart: { resources },
175
+ });
176
+ (0, test_1.expect)(response.status()).toBe(200);
177
+ const responseJson = await response.json();
178
+ if (!responseJson.deployments?.[0]?.processDefinition?.processDefinitionKey) {
179
+ console.warn(`No processDefinitionKey found for ${fileName}; is fine if it's a form`);
180
+ return null;
181
+ }
182
+ await (0, sleep_1.sleep)(10000);
183
+ return responseJson.deployments[0].processDefinition.processDefinitionKey;
184
+ }
185
+ catch (err) {
186
+ console.error(`Error during deployProcess for ${filePath}:`, err);
187
+ return null;
188
+ }
189
+ }
190
+ exports.deployProcess = deployProcess;
191
+ async function createProcessInstance(processDefinitionKey, authToken, environment) {
192
+ apiRequestContext = await getApiRequestContext();
193
+ const url = buildZeebeApiUrl('/v2/process-instances', environment);
194
+ const response = await apiRequestContext.post(url, {
195
+ headers: {
196
+ Authorization: authToken ?? '',
197
+ },
198
+ data: {
199
+ processDefinitionKey: String(processDefinitionKey),
200
+ variables: {},
201
+ },
202
+ });
203
+ (0, test_1.expect)(response.status()).toBe(200);
204
+ const responseBody = await response.json();
205
+ const processInstanceKey = responseBody?.processInstanceKey;
206
+ if (processInstanceKey == null) {
207
+ throw new Error(`Expected processInstanceKey in createProcessInstance response, but got: ${JSON.stringify(responseBody, null, 2)}`);
208
+ }
209
+ return String(processInstanceKey);
210
+ }
211
+ exports.createProcessInstance = createProcessInstance;
212
+ async function createGlobalClusterVariable(authToken, environment) {
213
+ apiRequestContext = await getApiRequestContext();
214
+ const url = buildZeebeApiUrl('/v2/cluster-variables/global', environment);
215
+ const response = await apiRequestContext.post(url, {
216
+ headers: {
217
+ Authorization: authToken ?? '',
218
+ },
219
+ data: {
220
+ name: String(process.env.CLUSTER_VARIABLE_NAME),
221
+ value: JSON.parse(process.env.CLUSTER_VARIABLE_JSON),
222
+ },
223
+ });
224
+ const status = response.status();
225
+ // Accept common successful statuses
226
+ if (status === 200 || status === 201 || status === 204) {
227
+ return;
228
+ }
229
+ // Handle "already exists" as a benign condition
230
+ if (status === 409) {
231
+ console.warn(`Global cluster variable "${process.env
232
+ .CLUSTER_VARIABLE_NAME}" already exists (HTTP 409).`);
233
+ return;
234
+ }
235
+ const bodyText = await response.text();
236
+ throw new Error(`Failed to create global cluster variable "${process.env
237
+ .CLUSTER_VARIABLE_NAME}": HTTP ${status} - ${bodyText}`);
238
+ }
239
+ exports.createGlobalClusterVariable = createGlobalClusterVariable;
80
240
  async function getOptimizeCoockie(page) {
81
241
  await (0, utils_1.loginToApp)(process.env.CAMUNDA_OPTIMIZE_BASE_URL, page);
82
242
  const context = page.context();
@@ -219,81 +379,3 @@ async function updateCollectionScope(request, options) {
219
379
  return responseBody;
220
380
  }
221
381
  exports.updateCollectionScope = updateCollectionScope;
222
- async function deployProcessSaaS(filePath, authToken) {
223
- try {
224
- apiRequestContext = await getApiRequestContext();
225
- const fileContent = fs_1.default.readFileSync(filePath);
226
- const fileName = path_1.default.basename(filePath);
227
- const resources = {
228
- name: fileName,
229
- mimeType: 'application/vnd.bpmn+xml',
230
- buffer: fileContent,
231
- };
232
- const response = await apiRequestContext.post(`${process.env.ZEEBE_API_URL}/v2/deployments`, {
233
- headers: {
234
- Authorization: authToken ?? '',
235
- },
236
- multipart: { resources },
237
- });
238
- (0, test_1.expect)(response.status()).toBe(200);
239
- const responseJson = await response.json();
240
- if (!responseJson.deployments?.[0]?.processDefinition?.processDefinitionKey) {
241
- console.warn(`No processDefinitionKey found for ${fileName}; is fine if it's a form`);
242
- return null;
243
- }
244
- await (0, sleep_1.sleep)(10000);
245
- return responseJson.deployments[0].processDefinition.processDefinitionKey;
246
- }
247
- catch (err) {
248
- console.error(`Error during deployProcessSaaS for ${filePath}:`, err);
249
- return null;
250
- }
251
- }
252
- exports.deployProcessSaaS = deployProcessSaaS;
253
- async function createProcessInstanceSaaS(processDefinitionKey, authToken) {
254
- apiRequestContext = await getApiRequestContext();
255
- const response = await apiRequestContext.post(`${process.env.ZEEBE_API_URL}/v2/process-instances`, {
256
- headers: {
257
- Authorization: authToken ?? '',
258
- },
259
- data: {
260
- processDefinitionKey: String(processDefinitionKey),
261
- variables: {},
262
- },
263
- });
264
- (0, test_1.expect)(response.status()).toBe(200);
265
- const responseBody = await response.json();
266
- const processInstanceKey = responseBody?.processInstanceKey;
267
- if (processInstanceKey == null) {
268
- throw new Error(`Expected processInstanceKey in createProcessInstanceSaaS response, but got: ${JSON.stringify(responseBody, null, 2)}`);
269
- }
270
- return String(processInstanceKey);
271
- }
272
- exports.createProcessInstanceSaaS = createProcessInstanceSaaS;
273
- async function createGlobalClusterVariableSaaS(authToken) {
274
- apiRequestContext = await getApiRequestContext();
275
- const response = await apiRequestContext.post(`${process.env.ZEEBE_API_URL}/v2/cluster-variables/global`, {
276
- headers: {
277
- Authorization: authToken ?? '',
278
- },
279
- data: {
280
- name: String(process.env.CLUSTER_VARIABLE_NAME),
281
- value: JSON.parse(process.env.CLUSTER_VARIABLE_JSON),
282
- },
283
- });
284
- const status = response.status();
285
- // Accept common successful statuses
286
- if (status === 200 || status === 201 || status === 204) {
287
- return;
288
- }
289
- // Handle "already exists" as a benign condition
290
- if (status === 409) {
291
- console.warn(`Global cluster variable "${process.env
292
- .CLUSTER_VARIABLE_NAME}" already exists (HTTP 409).`);
293
- return;
294
- }
295
- const bodyText = await response.text();
296
- throw new Error(`Failed to create global cluster variable "${process.env
297
- .CLUSTER_VARIABLE_NAME}": ` + `HTTP ${status} - ${bodyText}`);
298
- }
299
- exports.createGlobalClusterVariableSaaS = createGlobalClusterVariableSaaS;
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@camunda/e2e-test-suite",
3
- "version": "0.0.162",
3
+ "version": "0.0.164",
4
4
  "description": "End-to-end test helpers for Camunda 8",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/camunda/c8-cross-component-e2e-tests.git"
8
8
  },
9
9
  "main": "dist/index.js",
10
+ "bin": {
11
+ "gremlin": "dist/gremlin/bin/gremlin"
12
+ },
10
13
  "files": [
11
14
  "dist"
12
15
  ],
@@ -20,8 +23,11 @@
20
23
  "lint": "tsc && eslint . --ext .ts",
21
24
  "lint:fix": "eslint . --ext .ts --fix",
22
25
  "build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
26
+ "build:gremlin": "npm run build --prefix tools/gremlin",
27
+ "bundle:gremlin": "node scripts/bundle-gremlin.js",
28
+ "build:release": "npm run build && npm run build:gremlin && npm run bundle:gremlin",
23
29
  "clean": "rimraf dist",
24
- "prepack": "npm run clean && npm run build",
30
+ "prepack": "npm run clean && npm run build:release",
25
31
  "setup": "ts-node setup.ts",
26
32
  "prepare": "node download-vault.js"
27
33
  },